From 0f3a11b39ddd612f8b62fba62a2a794cda907e18 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 4 Sep 2023 23:58:06 +0200 Subject: [PATCH 001/135] original approach --- .../schema/dpns-contract-documents.json | 9 +- .../data_contract/document_type/index/mod.rs | 82 +++++++++++++++++++ packages/rs-dpp/src/errors/protocol_error.rs | 3 + 3 files changed, 93 insertions(+), 1 deletion(-) diff --git a/packages/dpns-contract/schema/dpns-contract-documents.json b/packages/dpns-contract/schema/dpns-contract-documents.json index fcf4f511cd..dca8dc8de5 100644 --- a/packages/dpns-contract/schema/dpns-contract-documents.json +++ b/packages/dpns-contract/schema/dpns-contract-documents.json @@ -12,7 +12,14 @@ "normalizedLabel": "asc" } ], - "unique": true + "unique": true, + "contested": { + "name": "normalizedLabelContested", + "fieldMatch": "normalizedLabel", + "regexPattern": "^[a-zA-Z]{3,19}$", + "resolution": 0, + "description": "If the normalized label part of this index is less than 20 characters (all non numeric) then this index is non unique while contest resolution takes place." + } }, { "name": "dashIdentityId", diff --git a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs index 21db11aba4..8d338b4cea 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs @@ -13,18 +13,65 @@ use crate::data_contract::errors::{DataContractError, StructureError}; use crate::ProtocolError; use anyhow::anyhow; +use crate::data_contract::document_type::ContestedIndexFieldMatch::Regex; +use crate::data_contract::document_type::ContestedIndexResolution::MasternodeVote; use platform_value::{Value, ValueMap}; use rand::distributions::{Alphanumeric, DistString}; use std::{collections::BTreeMap, convert::TryFrom}; pub mod random_index; +#[repr(u8)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum ContestedIndexResolution { + MasternodeVote = 0, +} + +impl TryFrom for ContestedIndexResolution { + type Error = ProtocolError; + + fn try_from(value: u8) -> Result { + match value { + 0 => Ok(MasternodeVote), + value => Err(ProtocolError::UnknownStorageKeyRequirements(format!( + "contested index resolution unknown: {}", + value + ))), + } + } +} + +#[repr(u8)] +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum ContestedIndexFieldMatch { + Regex(String), +} + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ContestedIndexInformation { + pub contested_field_name: String, + pub field_match: ContestedIndexFieldMatch, + pub resolution: ContestedIndexResolution, +} + +impl Default for ContestedIndexInformation { + fn default() -> Self { + ContestedIndexInformation { + contested_field_name: "".to_string(), + field_match: Regex(String::new()), + resolution: ContestedIndexResolution::MasternodeVote, + } + } +} + // Indices documentation: https://dashplatform.readme.io/docs/reference-data-contracts#document-indices #[derive(Clone, Debug, PartialEq, Eq)] pub struct Index { pub name: String, pub properties: Vec, pub unique: bool, + /// Contested indexes are useful when a resource is considered valuable + pub contested_index: Option, } impl Index { @@ -185,6 +232,7 @@ impl TryFrom<&[(Value, Value)]> for Index { let mut unique = false; let mut name = None; + let mut contested_index = None; let mut index_properties: Vec = Vec::new(); for (key_value, value_value) in index_type_value_map { @@ -210,6 +258,39 @@ impl TryFrom<&[(Value, Value)]> for Index { unique = value_value.as_bool().expect("confirmed as bool"); } } + "contested" => { + let contested_properties_value_map = value_value.to_map()?; + + let mut contested_index_information = ContestedIndexInformation::default(); + + for (contested_key_value, contested_value) in contested_properties_value_map { + let contested_key = contested_key_value + .to_str() + .map_err(ProtocolError::ValueError)?; + match contested_key { + "regexPattern" => { + let regex = contested_value.to_str()?.to_owned(); + contested_index_information.field_match = Regex(regex); + } + "fieldMatch" => { + let field = contested_value.to_str()?.to_owned(); + contested_index_information.contested_field_name = field; + } + "resolution" => { + let resolution_int = contested_value.to_integer::()?; + contested_index_information.resolution = + resolution_int.try_into()?; + } + "description" => {} + _ => { + return Err(ProtocolError::StructureError( + StructureError::ValueWrongType("unexpected contested key"), + )) + } + } + } + contested_index = Some(contested_index_information); + } "properties" => { let properties = value_value.as_array().ok_or(ProtocolError::StructureError( @@ -244,6 +325,7 @@ impl TryFrom<&[(Value, Value)]> for Index { name, properties: index_properties, unique, + contested_index, }) } } diff --git a/packages/rs-dpp/src/errors/protocol_error.rs b/packages/rs-dpp/src/errors/protocol_error.rs index a439bb5352..57ee6eb63b 100644 --- a/packages/rs-dpp/src/errors/protocol_error.rs +++ b/packages/rs-dpp/src/errors/protocol_error.rs @@ -93,6 +93,9 @@ pub enum ProtocolError { #[error("unknown storage key requirements {0}")] UnknownStorageKeyRequirements(String), + #[error("unknown contested index resolution {0}")] + UnknownContestedIndexResolution(String), + #[error(transparent)] DataContractError(#[from] DataContractError), From b2319b171c1a28c24df4d2548b4716cf7378b340 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 6 Sep 2023 05:27:29 +0200 Subject: [PATCH 002/135] added a masternode vote state transition --- .../document/v0/document-meta.json | 27 ++++ .../data_contract/document_type/index/mod.rs | 7 ++ .../document_type/index/random_index.rs | 1 + .../document_type/index_level/mod.rs | 44 +++++++ packages/rs-dpp/src/lib.rs | 1 + packages/rs-dpp/src/state_transition/mod.rs | 16 +++ .../state_transition_types.rs | 1 + .../accessors/mod.rs | 36 ++++++ .../accessors/v0/mod.rs | 9 ++ .../masternode_vote_transition/fields.rs | 15 +++ .../identity_signed.rs | 25 ++++ .../json_conversion.rs | 27 ++++ .../masternode_vote_transition/methods/mod.rs | 7 ++ .../methods/v0/mod.rs | 8 ++ .../masternode_vote_transition/mod.rs | 86 +++++++++++++ .../state_transition_like.rs | 49 ++++++++ .../v0/identity_signed.rs | 18 +++ .../v0/json_conversion.rs | 4 + .../masternode_vote_transition/v0/mod.rs | 85 +++++++++++++ .../v0/state_transition_like.rs | 52 ++++++++ .../masternode_vote_transition/v0/types.rs | 18 +++ .../v0/v0_methods.rs | 4 + .../v0/value_conversion.rs | 60 +++++++++ .../masternode_vote_transition/v0/version.rs | 9 ++ .../value_conversion.rs | 119 ++++++++++++++++++ .../masternode_vote_transition/version.rs | 11 ++ .../state_transitions/identity/mod.rs | 1 + packages/rs-dpp/src/voting/mod.rs | 2 + .../rs-dpp/src/voting/resource_vote/mod.rs | 25 ++++ packages/rs-dpp/src/voting/vote/mod.rs | 5 + .../src/version/dpp_versions.rs | 1 + .../src/version/mocks/v2_test.rs | 5 + .../src/version/mocks/v3_test.rs | 5 + .../rs-platform-version/src/version/v1.rs | 5 + 34 files changed, 788 insertions(+) create mode 100644 packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/mod.rs create mode 100644 packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/v0/mod.rs create mode 100644 packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/fields.rs create mode 100644 packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/identity_signed.rs create mode 100644 packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/json_conversion.rs create mode 100644 packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/mod.rs create mode 100644 packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/v0/mod.rs create mode 100644 packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs create mode 100644 packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/state_transition_like.rs create mode 100644 packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/identity_signed.rs create mode 100644 packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/json_conversion.rs create mode 100644 packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs create mode 100644 packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/state_transition_like.rs create mode 100644 packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/types.rs create mode 100644 packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/v0_methods.rs create mode 100644 packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/value_conversion.rs create mode 100644 packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/version.rs create mode 100644 packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/value_conversion.rs create mode 100644 packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/version.rs create mode 100644 packages/rs-dpp/src/voting/mod.rs create mode 100644 packages/rs-dpp/src/voting/resource_vote/mod.rs create mode 100644 packages/rs-dpp/src/voting/vote/mod.rs diff --git a/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json b/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json index 35d20a33c4..c8e6cb132b 100644 --- a/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json +++ b/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json @@ -408,6 +408,33 @@ }, "unique": { "type": "boolean" + }, + "contested": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1, + "maxLength": 256 + }, + "fieldMatch": { + "type": "string", + "minLength": 1, + "maxLength": 256 + }, + "regexPattern": { + "type": "string", + "minLength": 1, + "maxLength": 256 + }, + "resolution": { + "type": "integer", + "enum": [ + 0 + ], + "description": "Resolution. 0 - Masternode Vote" + } + } } }, "required": [ diff --git a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs index 8d338b4cea..6aab72aaa3 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs @@ -49,6 +49,7 @@ pub enum ContestedIndexFieldMatch { #[derive(Clone, Debug, PartialEq, Eq)] pub struct ContestedIndexInformation { + pub contested_field_temp_replacement_name: String, pub contested_field_name: String, pub field_match: ContestedIndexFieldMatch, pub resolution: ContestedIndexResolution, @@ -57,6 +58,7 @@ pub struct ContestedIndexInformation { impl Default for ContestedIndexInformation { fn default() -> Self { ContestedIndexInformation { + contested_field_temp_replacement_name: "".to_string(), contested_field_name: "".to_string(), field_match: Regex(String::new()), resolution: ContestedIndexResolution::MasternodeVote, @@ -272,6 +274,11 @@ impl TryFrom<&[(Value, Value)]> for Index { let regex = contested_value.to_str()?.to_owned(); contested_index_information.field_match = Regex(regex); } + "name" => { + let field = contested_value.to_str()?.to_owned(); + contested_index_information.contested_field_temp_replacement_name = + field; + } "fieldMatch" => { let field = contested_value.to_str()?.to_owned(); contested_index_information.contested_field_name = field; diff --git a/packages/rs-dpp/src/data_contract/document_type/index/random_index.rs b/packages/rs-dpp/src/data_contract/document_type/index/random_index.rs index 269fa14ac2..636cc9f501 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index/random_index.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index/random_index.rs @@ -52,6 +52,7 @@ impl Index { name: index_name, properties, unique, + contested_index: None, }) } } diff --git a/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs b/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs index 036eb13fab..79d0ca2e4f 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs @@ -154,6 +154,50 @@ impl IndexLevel { current_level.has_index_with_uniqueness = Some(index.unique); } } + + if let Some(contested_index) = &index.contested_index { + let mut current_level = &mut index_level; + let mut properties_iter = index.properties.iter().peekable(); + + while let Some(index_part) = properties_iter.next() { + let level_name = if contested_index.contested_field_name == index_part.name { + &contested_index.contested_field_temp_replacement_name + } else { + &index_part.name + }; + current_level = current_level + .sub_index_levels + .entry(level_name.clone()) + .or_insert_with(|| { + counter += 1; + IndexLevel { + level_identifier: counter, + sub_index_levels: Default::default(), + has_index_with_uniqueness: None, + } + }); + + // The last property + if properties_iter.peek().is_none() { + // This level already has been initialized. + // It means there are two indices with the same combination of properties. + + // We might need to take into account the sorting order when we have it + if current_level.has_index_with_uniqueness.is_some() { + // an index already exists return error + return Err(ConsensusError::BasicError( + BasicError::DuplicateIndexError(DuplicateIndexError::new( + document_type_name.to_owned(), + level_name.clone(), + )), + ) + .into()); + } + + current_level.has_index_with_uniqueness = Some(false); + } + } + } } Ok(index_level) diff --git a/packages/rs-dpp/src/lib.rs b/packages/rs-dpp/src/lib.rs index 9a648df706..9455fa0db9 100644 --- a/packages/rs-dpp/src/lib.rs +++ b/packages/rs-dpp/src/lib.rs @@ -43,6 +43,7 @@ pub mod serialization; pub mod signing; #[cfg(feature = "system_contracts")] pub mod system_data_contracts; +pub mod voting; pub mod withdrawal; pub use async_trait; diff --git a/packages/rs-dpp/src/state_transition/mod.rs b/packages/rs-dpp/src/state_transition/mod.rs index 7979407b19..7097fcded0 100644 --- a/packages/rs-dpp/src/state_transition/mod.rs +++ b/packages/rs-dpp/src/state_transition/mod.rs @@ -37,6 +37,7 @@ use crate::consensus::ConsensusError; use crate::identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV0; use crate::identity::signer::Signer; use crate::identity::{IdentityPublicKey, KeyID, KeyType, Purpose, SecurityLevel}; +use crate::state_transition::masternode_vote_transition::MasternodeVoteTransitionSignable; pub use state_transitions::*; use crate::serialization::Signable; @@ -74,6 +75,7 @@ use crate::state_transition::identity_topup_transition::{ use crate::state_transition::identity_update_transition::{ IdentityUpdateTransition, IdentityUpdateTransitionSignable, }; +use crate::state_transition::masternode_vote_transition::MasternodeVoteTransition; use crate::state_transition::state_transitions::document::documents_batch_transition::methods::v0::DocumentsBatchTransitionMethodsV0; pub type GetDataContractSecurityLevelRequirementFn = @@ -90,6 +92,7 @@ macro_rules! call_method { StateTransition::IdentityCreditWithdrawal(st) => st.$method($args), StateTransition::IdentityUpdate(st) => st.$method($args), StateTransition::IdentityCreditTransfer(st) => st.$method($args), + StateTransition::MasternodeVote(st) => st.$method($args), } }; ($state_transition:expr, $method:ident ) => { @@ -102,6 +105,7 @@ macro_rules! call_method { StateTransition::IdentityCreditWithdrawal(st) => st.$method(), StateTransition::IdentityUpdate(st) => st.$method(), StateTransition::IdentityCreditTransfer(st) => st.$method(), + StateTransition::MasternodeVote(st) => st.$method(), } }; } @@ -117,6 +121,7 @@ macro_rules! call_getter_method_identity_signed { StateTransition::IdentityCreditWithdrawal(st) => Some(st.$method($args)), StateTransition::IdentityUpdate(st) => Some(st.$method($args)), StateTransition::IdentityCreditTransfer(st) => Some(st.$method($args)), + StateTransition::MasternodeVote(st) => Some(st.$method($args)), } }; ($state_transition:expr, $method:ident ) => { @@ -129,6 +134,7 @@ macro_rules! call_getter_method_identity_signed { StateTransition::IdentityCreditWithdrawal(st) => Some(st.$method()), StateTransition::IdentityUpdate(st) => Some(st.$method()), StateTransition::IdentityCreditTransfer(st) => Some(st.$method()), + StateTransition::MasternodeVote(st) => Some(st.$method()), } }; } @@ -144,6 +150,7 @@ macro_rules! call_method_identity_signed { StateTransition::IdentityCreditWithdrawal(st) => st.$method($args), StateTransition::IdentityUpdate(st) => st.$method($args), StateTransition::IdentityCreditTransfer(st) => st.$method($args), + StateTransition::MasternodeVote(st) => st.$method($args), } }; ($state_transition:expr, $method:ident ) => { @@ -156,6 +163,7 @@ macro_rules! call_method_identity_signed { StateTransition::IdentityCreditWithdrawal(st) => st.$method(), StateTransition::IdentityUpdate(st) => st.$method(), StateTransition::IdentityCreditTransfer(st) => st.$method(), + StateTransition::MasternodeVote(st) => st.$method(), } }; } @@ -175,6 +183,7 @@ macro_rules! call_errorable_method_identity_signed { StateTransition::IdentityCreditWithdrawal(st) => st.$method($args), StateTransition::IdentityUpdate(st) => st.$method($args), StateTransition::IdentityCreditTransfer(st) => st.$method($args), + StateTransition::MasternodeVote(st) => st.$method($args), } }; ($state_transition:expr, $method:ident ) => { @@ -191,6 +200,7 @@ macro_rules! call_errorable_method_identity_signed { StateTransition::IdentityCreditWithdrawal(st) => st.$method(), StateTransition::IdentityUpdate(st) => st.$method(), StateTransition::IdentityCreditTransfer(st) => st.$method(), + StateTransition::MasternodeVote(st) => st.$method(), } }; } @@ -210,6 +220,7 @@ macro_rules! call_static_method { StateTransition::IdentityCreditTransfer(_) => { IdentityCreditTransferTransition::$method() } + StateTransition::MasternodeVote(_) => MasternodeVote::$method(), } }; } @@ -241,6 +252,7 @@ pub enum StateTransition { IdentityCreditWithdrawal(IdentityCreditWithdrawalTransition), IdentityUpdate(IdentityUpdateTransition), IdentityCreditTransfer(IdentityCreditTransferTransition), + MasternodeVote(MasternodeVoteTransition), } impl StateTransition { @@ -368,6 +380,10 @@ impl StateTransition { "identity top up can not be called for identity signing".to_string(), )) } + StateTransition::MasternodeVote(st) => { + st.verify_public_key_level_and_purpose(identity_public_key)?; + st.verify_public_key_is_enabled(identity_public_key)?; + } } let data = self.signable_bytes()?; self.set_signature(signer.sign(identity_public_key, data.as_slice())?); diff --git a/packages/rs-dpp/src/state_transition/state_transition_types.rs b/packages/rs-dpp/src/state_transition/state_transition_types.rs index 1b747d3135..246f462063 100644 --- a/packages/rs-dpp/src/state_transition/state_transition_types.rs +++ b/packages/rs-dpp/src/state_transition/state_transition_types.rs @@ -28,6 +28,7 @@ pub enum StateTransitionType { IdentityUpdate = 5, IdentityCreditWithdrawal = 6, IdentityCreditTransfer = 7, + MasternodeVote = 8, } impl std::fmt::Display for StateTransitionType { diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/mod.rs new file mode 100644 index 0000000000..17c10db765 --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/mod.rs @@ -0,0 +1,36 @@ +mod v0; + +use crate::state_transition::masternode_vote_transition::MasternodeVoteTransition; +use crate::voting::resource_vote::ResourceVote; +use platform_value::Identifier; +pub use v0::*; + +impl MasternodeVoteTransitionAccessorsV0 for MasternodeVoteTransition { + fn pro_tx_hash(&self) -> Identifier { + match self { + MasternodeVoteTransition::V0(transition) => transition.pro_tx_hash, + } + } + + fn set_pro_tx_hash(&mut self, pro_tx_hash: Identifier) { + match self { + MasternodeVoteTransition::V0(transition) => { + transition.pro_tx_hash = pro_tx_hash; + } + } + } + + fn resource_vote(&self) -> ResourceVote { + match self { + MasternodeVoteTransition::V0(transition) => transition.resource_vote, + } + } + + fn set_resource_vote(&mut self, resource_vote: ResourceVote) { + match self { + MasternodeVoteTransition::V0(transition) => { + transition.resource_vote = resource_vote; + } + } + } +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/v0/mod.rs new file mode 100644 index 0000000000..c35e08b810 --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/v0/mod.rs @@ -0,0 +1,9 @@ +use crate::voting::resource_vote::ResourceVote; +use platform_value::Identifier; + +pub trait MasternodeVoteTransitionAccessorsV0 { + fn pro_tx_hash(&self) -> Identifier; + fn set_pro_tx_hash(&mut self, pro_tx_hash: Identifier); + fn resource_vote(&self) -> ResourceVote; + fn set_resource_vote(&mut self, resource_vote: ResourceVote); +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/fields.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/fields.rs new file mode 100644 index 0000000000..95e00a9c8f --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/fields.rs @@ -0,0 +1,15 @@ +use crate::state_transition::state_transitions; + +use crate::state_transition::masternode_vote_transition::fields::property_names::RECIPIENT_ID; +pub use state_transitions::common_fields::property_names::{ + ENTROPY, SIGNATURE, SIGNATURE_PUBLIC_KEY_ID, STATE_TRANSITION_PROTOCOL_VERSION, TRANSITION_TYPE, +}; +pub use state_transitions::identity::common_fields::property_names::IDENTITY_ID; + +pub(crate) mod property_names { + pub const RECIPIENT_ID: &str = "recipientId"; +} + +pub const IDENTIFIER_FIELDS: [&str; 2] = [IDENTITY_ID, RECIPIENT_ID]; +pub const BINARY_FIELDS: [&str; 1] = [SIGNATURE]; +pub const U32_FIELDS: [&str; 1] = [STATE_TRANSITION_PROTOCOL_VERSION]; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/identity_signed.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/identity_signed.rs new file mode 100644 index 0000000000..8c79f2bfb3 --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/identity_signed.rs @@ -0,0 +1,25 @@ +use crate::identity::{KeyID, SecurityLevel}; +use crate::state_transition::masternode_vote_transition::MasternodeVoteTransition; +use crate::state_transition::StateTransitionIdentitySigned; + +impl StateTransitionIdentitySigned for MasternodeVoteTransition { + fn signature_public_key_id(&self) -> KeyID { + match self { + MasternodeVoteTransition::V0(transition) => transition.signature_public_key_id(), + } + } + + fn set_signature_public_key_id(&mut self, key_id: KeyID) { + match self { + MasternodeVoteTransition::V0(transition) => { + transition.set_signature_public_key_id(key_id) + } + } + } + + fn security_level_requirement(&self) -> Vec { + match self { + MasternodeVoteTransition::V0(transition) => transition.security_level_requirement(), + } + } +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/json_conversion.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/json_conversion.rs new file mode 100644 index 0000000000..5eda4c90f1 --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/json_conversion.rs @@ -0,0 +1,27 @@ +use crate::state_transition::masternode_vote_transition::MasternodeVoteTransition; +use crate::state_transition::state_transitions::masternode_vote_transition::fields::*; +use crate::state_transition::{ + JsonStateTransitionSerializationOptions, StateTransitionJsonConvert, +}; +use crate::ProtocolError; +use serde_json::Number; +use serde_json::Value as JsonValue; + +impl<'a> StateTransitionJsonConvert<'a> for MasternodeVoteTransition { + fn to_json( + &self, + options: JsonStateTransitionSerializationOptions, + ) -> Result { + match self { + MasternodeVoteTransition::V0(transition) => { + let mut value = transition.to_json(options)?; + let map_value = value.as_object_mut().expect("expected an object"); + map_value.insert( + STATE_TRANSITION_PROTOCOL_VERSION.to_string(), + JsonValue::Number(Number::from(0)), + ); + Ok(value) + } + } + } +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/mod.rs new file mode 100644 index 0000000000..a2e8c936f1 --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/mod.rs @@ -0,0 +1,7 @@ +mod v0; + +pub use v0::*; + +use crate::state_transition::masternode_vote_transition::MasternodeVoteTransition; + +impl MasternodeVoteTransitionMethodsV0 for MasternodeVoteTransition {} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/v0/mod.rs new file mode 100644 index 0000000000..ae9aac7ea9 --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/v0/mod.rs @@ -0,0 +1,8 @@ +use crate::state_transition::StateTransitionType; + +pub trait MasternodeVoteTransitionMethodsV0 { + /// Get State Transition Type + fn get_type() -> StateTransitionType { + StateTransitionType::MasternodeVote + } +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs new file mode 100644 index 0000000000..644714af10 --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs @@ -0,0 +1,86 @@ +pub mod accessors; +pub mod fields; +mod identity_signed; +#[cfg(feature = "state-transition-json-conversion")] +mod json_conversion; +pub mod methods; +mod state_transition_like; +pub mod v0; +#[cfg(feature = "state-transition-value-conversion")] +mod value_conversion; +mod version; + +use crate::state_transition::masternode_vote_transition::fields::property_names::RECIPIENT_ID; +use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; +use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0Signable; +use crate::state_transition::StateTransitionFieldTypes; + +use crate::ProtocolError; +use bincode::{Decode, Encode}; +use derive_more::From; +use fields::*; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize, PlatformSignable}; +use platform_version::version::PlatformVersion; +use platform_versioning::PlatformVersioned; +use serde::{Deserialize, Serialize}; + +pub type MasternodeVoteTransitionLatest = MasternodeVoteTransitionV0; + +#[derive( + Debug, + Clone, + Encode, + Decode, + PlatformDeserialize, + PlatformSerialize, + PlatformSignable, + PlatformVersioned, + From, + PartialEq, +)] +#[cfg_attr( + feature = "state-transition-serde-conversion", + derive(Serialize, Deserialize), + serde(tag = "$version") +)] +#[platform_serialize(unversioned)] //versioned directly, no need to use platform_version +#[platform_version_path_bounds( + "dpp.state_transition_serialization_versions.masternode_vote_state_transition" +)] +pub enum MasternodeVoteTransition { + #[cfg_attr(feature = "state-transition-serde-conversion", serde(rename = "0"))] + V0(MasternodeVoteTransitionV0), +} + +impl MasternodeVoteTransition { + pub fn default_versioned(platform_version: &PlatformVersion) -> Result { + match platform_version + .dpp + .identity_versions + .identity_structure_version + { + 0 => Ok(MasternodeVoteTransition::V0( + MasternodeVoteTransitionV0::default(), + )), + version => Err(ProtocolError::UnknownVersionMismatch { + method: "MasternodeVoteTransitionV0::default_versioned".to_string(), + known_versions: vec![0], + received: version, + }), + } + } +} + +impl StateTransitionFieldTypes for MasternodeVoteTransition { + fn signature_property_paths() -> Vec<&'static str> { + vec![SIGNATURE] + } + + fn identifiers_property_paths() -> Vec<&'static str> { + vec![IDENTITY_ID, RECIPIENT_ID] + } + + fn binary_property_paths() -> Vec<&'static str> { + vec![] + } +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/state_transition_like.rs new file mode 100644 index 0000000000..d54d4bb383 --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/state_transition_like.rs @@ -0,0 +1,49 @@ +use crate::state_transition::masternode_vote_transition::MasternodeVoteTransition; +use crate::state_transition::{StateTransitionLike, StateTransitionType}; +use crate::version::FeatureVersion; +use platform_value::{BinaryData, Identifier}; + +impl StateTransitionLike for MasternodeVoteTransition { + /// Returns ID of the credit_transferred contract + fn modified_data_ids(&self) -> Vec { + match self { + MasternodeVoteTransition::V0(transition) => transition.modified_data_ids(), + } + } + + fn state_transition_protocol_version(&self) -> FeatureVersion { + match self { + MasternodeVoteTransition::V0(_) => 0, + } + } + /// returns the type of State Transition + fn state_transition_type(&self) -> StateTransitionType { + match self { + MasternodeVoteTransition::V0(transition) => transition.state_transition_type(), + } + } + /// returns the signature as a byte-array + fn signature(&self) -> &BinaryData { + match self { + MasternodeVoteTransition::V0(transition) => transition.signature(), + } + } + /// set a new signature + fn set_signature(&mut self, signature: BinaryData) { + match self { + MasternodeVoteTransition::V0(transition) => transition.set_signature(signature), + } + } + + fn set_signature_bytes(&mut self, signature: Vec) { + match self { + MasternodeVoteTransition::V0(transition) => transition.set_signature_bytes(signature), + } + } + + fn owner_id(&self) -> Identifier { + match self { + MasternodeVoteTransition::V0(transition) => transition.owner_id(), + } + } +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/identity_signed.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/identity_signed.rs new file mode 100644 index 0000000000..52ca167dca --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/identity_signed.rs @@ -0,0 +1,18 @@ +use crate::identity::SecurityLevel::CRITICAL; +use crate::identity::{KeyID, SecurityLevel}; +use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; +use crate::state_transition::StateTransitionIdentitySigned; + +impl StateTransitionIdentitySigned for MasternodeVoteTransitionV0 { + fn signature_public_key_id(&self) -> KeyID { + self.signature_public_key_id + } + + fn set_signature_public_key_id(&mut self, key_id: KeyID) { + self.signature_public_key_id = key_id + } + + fn security_level_requirement(&self) -> Vec { + vec![CRITICAL] + } +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/json_conversion.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/json_conversion.rs new file mode 100644 index 0000000000..8bbca6c8ad --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/json_conversion.rs @@ -0,0 +1,4 @@ +use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; +use crate::state_transition::StateTransitionJsonConvert; + +impl<'a> StateTransitionJsonConvert<'a> for MasternodeVoteTransitionV0 {} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs new file mode 100644 index 0000000000..a7f9ff318b --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs @@ -0,0 +1,85 @@ +mod identity_signed; +#[cfg(feature = "state-transition-json-conversion")] +mod json_conversion; +mod state_transition_like; +mod types; +pub(super) mod v0_methods; +#[cfg(feature = "state-transition-value-conversion")] +mod value_conversion; +mod version; + +use crate::identity::KeyID; + +use crate::prelude::Identifier; + +use crate::protocol_error::ProtocolError; +use crate::voting::resource_vote::ResourceVote; +use bincode::{Decode, Encode}; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize, PlatformSignable}; +use platform_value::BinaryData; +use serde::{Deserialize, Serialize}; + +#[derive( + Debug, + Clone, + Encode, + Decode, + PlatformSerialize, + PlatformDeserialize, + PlatformSignable, + PartialEq, +)] +#[cfg_attr( + feature = "state-transition-serde-conversion", + derive(Serialize, Deserialize), + serde(rename_all = "camelCase") +)] +#[platform_serialize(unversioned)] +#[derive(Default)] +pub struct MasternodeVoteTransitionV0 { + // Own ST fields + pub pro_tx_hash: Identifier, + pub resource_vote: ResourceVote, + #[platform_signable(exclude_from_sig_hash)] + pub signature_public_key_id: KeyID, + #[platform_signable(exclude_from_sig_hash)] + pub signature: BinaryData, +} + +#[cfg(test)] +mod test { + + use crate::serialization::{PlatformDeserializable, PlatformSerializable}; + + use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; + use crate::voting::resource_vote::ResourceVote; + use platform_value::Identifier; + use rand::Rng; + use std::fmt::Debug; + + fn test_masternode_vote_transition< + T: PlatformSerializable + PlatformDeserializable + Debug + PartialEq, + >( + transition: T, + ) where + ::Error: std::fmt::Debug, + { + let serialized = T::serialize_to_bytes(&transition).expect("expected to serialize"); + let deserialized = + T::deserialize_from_bytes(serialized.as_slice()).expect("expected to deserialize"); + assert_eq!(transition, deserialized); + } + + #[test] + fn test_masternode_vote_transition1() { + let mut rng = rand::thread_rng(); + let transition = MasternodeVoteTransitionV0 { + pro_tx_hash: Identifier::random(), + resource_vote: ResourceVote::TowardsIdentity(Identifier::random()), + signature_public_key_id: rng.gen(), + signature: [0; 65].to_vec().into(), + }; + + test_masternode_vote_transition(transition); + } +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/state_transition_like.rs new file mode 100644 index 0000000000..ec57938247 --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/state_transition_like.rs @@ -0,0 +1,52 @@ +use platform_value::BinaryData; + +use crate::{ + prelude::Identifier, + state_transition::{StateTransitionLike, StateTransitionType}, +}; + +use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; +use crate::state_transition::masternode_vote_transition::MasternodeVoteTransition; + +use crate::state_transition::StateTransition; +use crate::state_transition::StateTransitionType::MasternodeVote; +use crate::version::FeatureVersion; + +impl From for StateTransition { + fn from(value: MasternodeVoteTransitionV0) -> Self { + let masternode_vote_transition: MasternodeVoteTransition = value.into(); + masternode_vote_transition.into() + } +} + +impl StateTransitionLike for MasternodeVoteTransitionV0 { + fn state_transition_protocol_version(&self) -> FeatureVersion { + 0 + } + + /// returns the type of State Transition + fn state_transition_type(&self) -> StateTransitionType { + MasternodeVote + } + /// returns the signature as a byte-array + fn signature(&self) -> &BinaryData { + &self.signature + } + /// set a new signature + fn set_signature(&mut self, signature: BinaryData) { + self.signature = signature + } + /// Returns ID of the created contract + fn modified_data_ids(&self) -> Vec { + vec![self.pro_tx_hash] + } + + fn set_signature_bytes(&mut self, signature: Vec) { + self.signature = BinaryData::new(signature) + } + + /// Get owner ID + fn owner_id(&self) -> Identifier { + self.pro_tx_hash + } +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/types.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/types.rs new file mode 100644 index 0000000000..b0ec8019b9 --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/types.rs @@ -0,0 +1,18 @@ +use crate::state_transition::masternode_vote_transition::fields::property_names::*; +use crate::state_transition::masternode_vote_transition::fields::*; +use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; +use crate::state_transition::StateTransitionFieldTypes; + +impl StateTransitionFieldTypes for MasternodeVoteTransitionV0 { + fn signature_property_paths() -> Vec<&'static str> { + vec![SIGNATURE] + } + + fn identifiers_property_paths() -> Vec<&'static str> { + vec![IDENTITY_ID, RECIPIENT_ID] + } + + fn binary_property_paths() -> Vec<&'static str> { + vec![] + } +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/v0_methods.rs new file mode 100644 index 0000000000..1ac5dbebc0 --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/v0_methods.rs @@ -0,0 +1,4 @@ +use crate::state_transition::masternode_vote_transition::methods::MasternodeVoteTransitionMethodsV0; +use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; + +impl MasternodeVoteTransitionMethodsV0 for MasternodeVoteTransitionV0 {} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/value_conversion.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/value_conversion.rs new file mode 100644 index 0000000000..e17390a562 --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/value_conversion.rs @@ -0,0 +1,60 @@ +use std::collections::BTreeMap; + +use platform_value::{IntegerReplacementType, ReplacementType, Value}; + +use crate::{state_transition::StateTransitionFieldTypes, ProtocolError}; + +use crate::state_transition::masternode_vote_transition::fields::*; +use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; +use crate::state_transition::StateTransitionValueConvert; + +use platform_version::version::PlatformVersion; + +impl<'a> StateTransitionValueConvert<'a> for MasternodeVoteTransitionV0 { + fn from_object( + raw_object: Value, + _platform_version: &PlatformVersion, + ) -> Result { + platform_value::from_value(raw_object).map_err(ProtocolError::ValueError) + } + + fn clean_value(value: &mut Value) -> Result<(), ProtocolError> { + value.replace_at_paths(IDENTIFIER_FIELDS, ReplacementType::Identifier)?; + value.replace_at_paths(BINARY_FIELDS, ReplacementType::BinaryBytes)?; + value.replace_integer_type_at_paths(U32_FIELDS, IntegerReplacementType::U32)?; + Ok(()) + } + + fn from_value_map( + raw_value_map: BTreeMap, + platform_version: &PlatformVersion, + ) -> Result { + let value: Value = raw_value_map.into(); + Self::from_object(value, platform_version) + } + + fn to_object(&self, skip_signature: bool) -> Result { + let mut value = platform_value::to_value(self)?; + if skip_signature { + value + .remove_values_matching_paths(Self::signature_property_paths()) + .map_err(ProtocolError::ValueError)?; + } + Ok(value) + } + + fn to_cleaned_object(&self, skip_signature: bool) -> Result { + let mut value = platform_value::to_value(self)?; + if skip_signature { + value + .remove_values_matching_paths(Self::signature_property_paths()) + .map_err(ProtocolError::ValueError)?; + } + Ok(value) + } + + // Override to_canonical_cleaned_object to manage add_public_keys individually + fn to_canonical_cleaned_object(&self, skip_signature: bool) -> Result { + self.to_cleaned_object(skip_signature) + } +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/version.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/version.rs new file mode 100644 index 0000000000..35b2683ca2 --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/version.rs @@ -0,0 +1,9 @@ +use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; +use crate::state_transition::FeatureVersioned; +use crate::version::FeatureVersion; + +impl FeatureVersioned for MasternodeVoteTransitionV0 { + fn feature_version(&self) -> FeatureVersion { + 0 + } +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/value_conversion.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/value_conversion.rs new file mode 100644 index 0000000000..f38aa07913 --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/value_conversion.rs @@ -0,0 +1,119 @@ +use std::collections::BTreeMap; + +use platform_value::Value; + +use crate::ProtocolError; + +use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; +use crate::state_transition::masternode_vote_transition::MasternodeVoteTransition; +use crate::state_transition::state_transitions::masternode_vote_transition::fields::*; +use crate::state_transition::StateTransitionValueConvert; + +use crate::serialization::ValueConvertible; +use platform_value::btreemap_extensions::BTreeValueRemoveFromMapHelper; +use platform_version::version::{FeatureVersion, PlatformVersion}; + +impl<'a> ValueConvertible<'a> for MasternodeVoteTransition {} + +impl<'a> StateTransitionValueConvert<'a> for MasternodeVoteTransition { + fn to_object(&self, skip_signature: bool) -> Result { + match self { + MasternodeVoteTransition::V0(transition) => { + let mut value = transition.to_object(skip_signature)?; + value.insert(STATE_TRANSITION_PROTOCOL_VERSION.to_string(), Value::U16(0))?; + Ok(value) + } + } + } + + fn to_canonical_object(&self, skip_signature: bool) -> Result { + match self { + MasternodeVoteTransition::V0(transition) => { + let mut value = transition.to_canonical_object(skip_signature)?; + value.insert(STATE_TRANSITION_PROTOCOL_VERSION.to_string(), Value::U16(0))?; + Ok(value) + } + } + } + + fn to_canonical_cleaned_object(&self, skip_signature: bool) -> Result { + match self { + MasternodeVoteTransition::V0(transition) => { + let mut value = transition.to_canonical_cleaned_object(skip_signature)?; + value.insert(STATE_TRANSITION_PROTOCOL_VERSION.to_string(), Value::U16(0))?; + Ok(value) + } + } + } + + fn to_cleaned_object(&self, skip_signature: bool) -> Result { + match self { + MasternodeVoteTransition::V0(transition) => { + let mut value = transition.to_cleaned_object(skip_signature)?; + value.insert(STATE_TRANSITION_PROTOCOL_VERSION.to_string(), Value::U16(0))?; + Ok(value) + } + } + } + + fn from_object( + mut raw_object: Value, + platform_version: &PlatformVersion, + ) -> Result { + let version: FeatureVersion = raw_object + .remove_optional_integer(STATE_TRANSITION_PROTOCOL_VERSION) + .map_err(ProtocolError::ValueError)? + .unwrap_or({ + platform_version + .dpp + .state_transition_serialization_versions + .contract_create_state_transition + .default_current_version + }); + + match version { + 0 => Ok(MasternodeVoteTransitionV0::from_object(raw_object, platform_version)?.into()), + n => Err(ProtocolError::UnknownVersionError(format!( + "Unknown MasternodeVoteTransition version {n}" + ))), + } + } + + fn from_value_map( + mut raw_value_map: BTreeMap, + platform_version: &PlatformVersion, + ) -> Result { + let version: FeatureVersion = raw_value_map + .remove_optional_integer(STATE_TRANSITION_PROTOCOL_VERSION) + .map_err(ProtocolError::ValueError)? + .unwrap_or({ + platform_version + .dpp + .state_transition_serialization_versions + .contract_create_state_transition + .default_current_version + }); + + match version { + 0 => Ok( + MasternodeVoteTransitionV0::from_value_map(raw_value_map, platform_version)?.into(), + ), + n => Err(ProtocolError::UnknownVersionError(format!( + "Unknown MasternodeVoteTransition version {n}" + ))), + } + } + + fn clean_value(value: &mut Value) -> Result<(), ProtocolError> { + let version: u8 = value + .get_integer(STATE_TRANSITION_PROTOCOL_VERSION) + .map_err(ProtocolError::ValueError)?; + + match version { + 0 => MasternodeVoteTransitionV0::clean_value(value), + n => Err(ProtocolError::UnknownVersionError(format!( + "Unknown MasternodeVoteTransition version {n}" + ))), + } + } +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/version.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/version.rs new file mode 100644 index 0000000000..40a720b5a7 --- /dev/null +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/version.rs @@ -0,0 +1,11 @@ +use crate::state_transition::masternode_vote_transition::MasternodeVoteTransition; +use crate::state_transition::FeatureVersioned; +use crate::version::FeatureVersion; + +impl FeatureVersioned for MasternodeVoteTransition { + fn feature_version(&self) -> FeatureVersion { + match self { + MasternodeVoteTransition::V0(v0) => v0.feature_version(), + } + } +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/mod.rs index 97956e466d..bccd076609 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/mod.rs @@ -4,4 +4,5 @@ pub mod identity_credit_transfer_transition; pub mod identity_credit_withdrawal_transition; pub mod identity_topup_transition; pub mod identity_update_transition; +pub mod masternode_vote_transition; pub mod public_key_in_creation; diff --git a/packages/rs-dpp/src/voting/mod.rs b/packages/rs-dpp/src/voting/mod.rs new file mode 100644 index 0000000000..115b2c2f24 --- /dev/null +++ b/packages/rs-dpp/src/voting/mod.rs @@ -0,0 +1,2 @@ +pub mod resource_vote; +pub mod vote; diff --git a/packages/rs-dpp/src/voting/resource_vote/mod.rs b/packages/rs-dpp/src/voting/resource_vote/mod.rs new file mode 100644 index 0000000000..cfa9716416 --- /dev/null +++ b/packages/rs-dpp/src/voting/resource_vote/mod.rs @@ -0,0 +1,25 @@ +use bincode::{Decode, Encode}; +use platform_value::Identifier; +use serde::{Deserialize, Serialize}; + +/// A resource vote is a vote determining what we should do with a contested resource. +/// For example Alice and Bob both want the username "Malaka" +/// Some would vote for Alice to get it by putting in her Identifier. +/// Some would vote for Bob to get it by putting in Bob's Identifier. +/// Let's say someone voted, but is now not quite sure of their vote, they can abstain. +/// Lock is there to signal that the shared resource should be given to no one. +/// In this case Malaka might have a bad connotation in Greek, hence some might vote to Lock +/// the name. +/// +#[derive(Debug, Clone, Copy, Encode, Decode, PartialEq, Default)] +#[cfg_attr( + feature = "state-transition-serde-conversion", + derive(Serialize, Deserialize), + serde(rename_all = "camelCase") +)] +pub enum ResourceVote { + TowardsIdentity(Identifier), + #[default] + Abstain, + Lock, +} diff --git a/packages/rs-dpp/src/voting/vote/mod.rs b/packages/rs-dpp/src/voting/vote/mod.rs new file mode 100644 index 0000000000..41d0b1abc2 --- /dev/null +++ b/packages/rs-dpp/src/voting/vote/mod.rs @@ -0,0 +1,5 @@ +pub enum Vote { + YES, + NO, + ABSTAIN, +} diff --git a/packages/rs-platform-version/src/version/dpp_versions.rs b/packages/rs-platform-version/src/version/dpp_versions.rs index 4bb8a18abd..18ed053d7a 100644 --- a/packages/rs-platform-version/src/version/dpp_versions.rs +++ b/packages/rs-platform-version/src/version/dpp_versions.rs @@ -93,6 +93,7 @@ pub struct StateTransitionSerializationVersions { pub identity_top_up_state_transition: FeatureVersionBounds, pub identity_credit_withdrawal_state_transition: FeatureVersionBounds, pub identity_credit_transfer_state_transition: FeatureVersionBounds, + pub masternode_vote_state_transition: FeatureVersionBounds, pub contract_create_state_transition: FeatureVersionBounds, pub contract_update_state_transition: FeatureVersionBounds, pub documents_batch_state_transition: FeatureVersionBounds, diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index e913d65a7d..8795e0a151 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -640,6 +640,11 @@ pub(crate) const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { max_version: 0, default_current_version: 0, }, + masternode_vote_state_transition: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, contract_create_state_transition: FeatureVersionBounds { min_version: 0, max_version: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index b9d8d7cb14..fe3d063551 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -640,6 +640,11 @@ pub(crate) const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { max_version: 0, default_current_version: 0, }, + masternode_vote_state_transition: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, contract_create_state_transition: FeatureVersionBounds { min_version: 0, max_version: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index f80998dcc1..74a7c237ca 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -637,6 +637,11 @@ pub(super) const PLATFORM_V1: PlatformVersion = PlatformVersion { max_version: 0, default_current_version: 0, }, + masternode_vote_state_transition: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, contract_create_state_transition: FeatureVersionBounds { min_version: 0, max_version: 0, From e0f7a4f2428fca0b0cf1d8c3a8157ce759d32458 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 6 Sep 2023 06:34:31 +0200 Subject: [PATCH 003/135] started working on drive structure --- .../state_transitions/masternode_vote/mod.rs | 99 +++++++++++++++++++ .../masternode_vote/state/mod.rs | 1 + .../masternode_vote/state/v0/mod.rs | 84 ++++++++++++++++ .../masternode_vote/structure/mod.rs | 1 + .../masternode_vote/structure/v0/mod.rs | 20 ++++ .../state_transition/state_transitions/mod.rs | 3 + .../drive/batch/drive_op_batch/identity.rs | 13 +++ .../identity/masternode_vote/mod.rs | 32 ++++++ .../identity/masternode_vote/transformer.rs | 19 ++++ .../identity/masternode_vote/v0/mod.rs | 15 +++ .../masternode_vote/v0/transformer.rs | 30 ++++++ .../state_transition_action/identity/mod.rs | 2 + .../src/version/drive_abci_versions.rs | 1 + .../rs-platform-version/src/version/v1.rs | 6 ++ 14 files changed, 326 insertions(+) create mode 100644 packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/structure/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/structure/v0/mod.rs create mode 100644 packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs create mode 100644 packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs create mode 100644 packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs create mode 100644 packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs new file mode 100644 index 0000000000..af4801efd2 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -0,0 +1,99 @@ +mod state; +mod structure; + +use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; +use dpp::validation::{ConsensusValidationResult, SimpleConsensusValidationResult}; +use dpp::version::PlatformVersion; +use drive::state_transition_action::StateTransitionAction; + +use drive::grovedb::TransactionArg; + +use crate::error::execution::ExecutionError; +use crate::error::Error; +use crate::platform_types::platform::{PlatformRef, PlatformStateRef}; +use crate::rpc::core::CoreRPCLike; + +use crate::execution::validation::state_transition::masternode_vote::state::v0::MasternodeVoteStateTransitionStateValidationV0; +use crate::execution::validation::state_transition::masternode_vote::structure::v0::MasternodeVoteStateTransitionStructureValidationV0; +use crate::execution::validation::state_transition::processor::v0::{ + StateTransitionStateValidationV0, StateTransitionStructureValidationV0, +}; +use crate::execution::validation::state_transition::transformer::StateTransitionActionTransformerV0; +use crate::platform_types::platform_state::v0::PlatformStateV0Methods; + +impl StateTransitionActionTransformerV0 for MasternodeVoteTransition { + fn transform_into_action( + &self, + platform: &PlatformRef, + _validate: bool, + _tx: TransactionArg, + ) -> Result, Error> { + let platform_version = + PlatformVersion::get(platform.state.current_protocol_version_in_consensus())?; + match platform_version + .drive_abci + .validation_and_processing + .state_transitions + .masternode_vote_state_transition + .transform_into_action + { + 0 => self.transform_into_action_v0(), + version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { + method: "masternode vote state transition: transform_into_action".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} + +impl StateTransitionStructureValidationV0 for MasternodeVoteTransition { + fn validate_structure( + &self, + _platform: &PlatformStateRef, + _action: Option<&StateTransitionAction>, + protocol_version: u32, + ) -> Result { + let platform_version = PlatformVersion::get(protocol_version)?; + match platform_version + .drive_abci + .validation_and_processing + .state_transitions + .masternode_vote_state_transition + .structure + { + 0 => self.validate_base_structure_v0(), + version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { + method: "masternode vote state transition: validate_structure".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} + +impl StateTransitionStateValidationV0 for MasternodeVoteTransition { + fn validate_state( + &self, + _action: Option, + platform: &PlatformRef, + tx: TransactionArg, + ) -> Result, Error> { + let platform_version = + PlatformVersion::get(platform.state.current_protocol_version_in_consensus())?; + match platform_version + .drive_abci + .validation_and_processing + .state_transitions + .masternode_vote_state_transition + .state + { + 0 => self.validate_state_v0(platform, tx, platform_version), + version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { + method: "masternode vote state transition: validate_state".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/mod.rs new file mode 100644 index 0000000000..9a1925de7f --- /dev/null +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/mod.rs @@ -0,0 +1 @@ +pub(crate) mod v0; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs new file mode 100644 index 0000000000..9e87172f94 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs @@ -0,0 +1,84 @@ +use crate::error::Error; +use crate::platform_types::platform::PlatformRef; +use crate::rpc::core::CoreRPCLike; + +use dpp::consensus::signature::IdentityNotFoundError; + +use dpp::consensus::state::identity::IdentityInsufficientBalanceError; + +use dpp::prelude::ConsensusValidationResult; +use dpp::state_transition::masternode_vote_transition::accessors::MasternodeVoteTransitionAccessorsV0; +use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; +use drive::state_transition_action::identity::masternode_vote::MasternodeVoteTransitionAction; + +use dpp::version::PlatformVersion; +use drive::grovedb::TransactionArg; +use drive::state_transition_action::StateTransitionAction; + +pub(in crate::execution::validation::state_transition::state_transitions::masternode_vote) trait MasternodeVoteStateTransitionStateValidationV0 +{ + fn validate_state_v0( + &self, + platform: &PlatformRef, + tx: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error>; + + fn transform_into_action_v0( + &self, + ) -> Result, Error>; +} + +impl MasternodeVoteStateTransitionStateValidationV0 for MasternodeVoteTransition { + fn validate_state_v0( + &self, + platform: &PlatformRef, + tx: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let maybe_existing_identity_balance = platform.drive.fetch_identity_balance( + self.identity_id().to_buffer(), + tx, + platform_version, + )?; + + let Some(existing_identity_balance) = maybe_existing_identity_balance else { + return Ok(ConsensusValidationResult::new_with_error( + IdentityNotFoundError::new(self.identity_id()).into(), + )); + }; + + if existing_identity_balance < self.amount() { + return Ok(ConsensusValidationResult::new_with_error( + IdentityInsufficientBalanceError::new( + self.identity_id(), + existing_identity_balance, + self.amount(), + ) + .into(), + )); + } + + let maybe_existing_recipient = platform.drive.fetch_identity_balance( + self.recipient_id().to_buffer(), + tx, + platform_version, + )?; + + if maybe_existing_recipient.is_none() { + return Ok(ConsensusValidationResult::new_with_error( + IdentityNotFoundError::new(self.recipient_id()).into(), + )); + } + + self.transform_into_action_v0() + } + + fn transform_into_action_v0( + &self, + ) -> Result, Error> { + Ok(ConsensusValidationResult::new_with_data( + MasternodeVoteTransitionAction::from(self).into(), + )) + } +} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/structure/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/structure/mod.rs new file mode 100644 index 0000000000..9a1925de7f --- /dev/null +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/structure/mod.rs @@ -0,0 +1 @@ +pub(crate) mod v0; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/structure/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/structure/v0/mod.rs new file mode 100644 index 0000000000..8eeae9535c --- /dev/null +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/structure/v0/mod.rs @@ -0,0 +1,20 @@ +// use dpp::platform_value:: +use crate::error::Error; +use dpp::state_transition::masternode_vote_transition::accessors::MasternodeVoteTransitionAccessorsV0; +use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; +use dpp::validation::SimpleConsensusValidationResult; + +const MIN_TRANSFER_AMOUNT: u64 = 1000; + +pub(in crate::execution::validation::state_transition::state_transitions::masternode_vote) trait MasternodeVoteStateTransitionStructureValidationV0 +{ + fn validate_base_structure_v0(&self) -> Result; +} + +impl MasternodeVoteStateTransitionStructureValidationV0 for MasternodeVoteTransition { + fn validate_base_structure_v0(&self) -> Result { + let result = SimpleConsensusValidationResult::new(); + + Ok(result) + } +} 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 39b3dee515..5eda834af9 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 @@ -21,3 +21,6 @@ pub mod data_contract_create; /// Module for updating an existing data contract entity. pub mod data_contract_update; + +/// Module for voting from a masternode. +pub mod masternode_vote; diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs index d9c04521c6..5ca1ce0646 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs @@ -7,6 +7,7 @@ use dpp::identity::{Identity, IdentityPublicKey, KeyID, TimestampMillis}; use dpp::prelude::Revision; use dpp::version::PlatformVersion; +use dpp::voting::resource_vote::ResourceVote; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; @@ -69,6 +70,14 @@ pub enum IdentityOperationType { /// The revision we are updating to revision: Revision, }, + + /// Updates an identities revision. + MasternodeResourceVote { + /// The pro tx hash of the masternode + pro_tx_hash: [u8; 32], + /// The resource vote + resource_vote: ResourceVote, + }, } impl DriveLowLevelOperationConverter for IdentityOperationType { @@ -158,6 +167,10 @@ impl DriveLowLevelOperationConverter for IdentityOperationType { estimated_costs_only_with_layer_info, platform_version, )?]), + IdentityOperationType::MasternodeResourceVote { + identity_id, + resource_vote, + } => {} } } } diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs new file mode 100644 index 0000000000..a4b5c18cb2 --- /dev/null +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs @@ -0,0 +1,32 @@ +/// transformer +pub mod transformer; +/// v0 +pub mod v0; + +use crate::state_transition_action::identity::masternode_vote::v0::MasternodeVoteTransitionActionV0; +use derive_more::From; +use dpp::platform_value::Identifier; +use dpp::voting::resource_vote::ResourceVote; + +/// action +#[derive(Debug, Clone, From)] +pub enum MasternodeVoteTransitionAction { + /// v0 + V0(MasternodeVoteTransitionActionV0), +} + +impl MasternodeVoteTransitionAction { + /// the pro tx hash identifier of the masternode + pub fn pro_tx_hash(&self) -> Identifier { + match self { + MasternodeVoteTransitionAction::V0(transition) => transition.pro_tx_hash, + } + } + + /// Resource vote + pub fn resource_vote(&self) -> ResourceVote { + match self { + MasternodeVoteTransitionAction::V0(transition) => transition.resource_vote, + } + } +} diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs new file mode 100644 index 0000000000..f7fd9ea9d2 --- /dev/null +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs @@ -0,0 +1,19 @@ +use crate::state_transition_action::identity::masternode_vote::v0::MasternodeVoteTransitionActionV0; +use crate::state_transition_action::identity::masternode_vote::MasternodeVoteTransitionAction; +use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; + +impl From for MasternodeVoteTransitionAction { + fn from(value: MasternodeVoteTransition) -> Self { + match value { + MasternodeVoteTransition::V0(v0) => MasternodeVoteTransitionActionV0::from(v0).into(), + } + } +} + +impl From<&MasternodeVoteTransition> for MasternodeVoteTransitionAction { + fn from(value: &MasternodeVoteTransition) -> Self { + match value { + MasternodeVoteTransition::V0(v0) => MasternodeVoteTransitionActionV0::from(v0).into(), + } + } +} diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs new file mode 100644 index 0000000000..07f15ffb81 --- /dev/null +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs @@ -0,0 +1,15 @@ +mod transformer; + +use dpp::platform_value::Identifier; +use dpp::voting::resource_vote::ResourceVote; +use serde::{Deserialize, Serialize}; + +/// action v0 +#[derive(Default, Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct MasternodeVoteTransitionActionV0 { + /// the pro tx hash identifier of the masternode + pub pro_tx_hash: Identifier, + /// the resource vote + pub resource_vote: ResourceVote, +} diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs new file mode 100644 index 0000000000..08d6fd8e6c --- /dev/null +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs @@ -0,0 +1,30 @@ +use crate::state_transition_action::identity::masternode_vote::v0::MasternodeVoteTransitionActionV0; +use dpp::state_transition::state_transitions::identity::masternode_vote_transition::v0::MasternodeVoteTransitionV0; + +impl From for MasternodeVoteTransitionActionV0 { + fn from(value: MasternodeVoteTransitionV0) -> Self { + let MasternodeVoteTransitionV0 { + pro_tx_hash, + resource_vote, + .. + } = value; + MasternodeVoteTransitionActionV0 { + pro_tx_hash, + resource_vote, + } + } +} + +impl From<&MasternodeVoteTransitionV0> for MasternodeVoteTransitionActionV0 { + fn from(value: &MasternodeVoteTransitionV0) -> Self { + let MasternodeVoteTransitionV0 { + pro_tx_hash, + resource_vote, + .. + } = value; + MasternodeVoteTransitionActionV0 { + pro_tx_hash: *pro_tx_hash, + resource_vote: *resource_vote, + } + } +} diff --git a/packages/rs-drive/src/state_transition_action/identity/mod.rs b/packages/rs-drive/src/state_transition_action/identity/mod.rs index 5c7150542e..5c03b202ad 100644 --- a/packages/rs-drive/src/state_transition_action/identity/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/mod.rs @@ -8,3 +8,5 @@ pub mod identity_credit_withdrawal; pub mod identity_topup; /// identity update pub mod identity_update; +/// masternode vote +pub mod masternode_vote; diff --git a/packages/rs-platform-version/src/version/drive_abci_versions.rs b/packages/rs-platform-version/src/version/drive_abci_versions.rs index 1190b35f12..949c377b40 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions.rs @@ -86,6 +86,7 @@ pub struct DriveAbciStateTransitionValidationVersions { pub identity_top_up_state_transition: DriveAbciStateTransitionValidationVersion, pub identity_credit_withdrawal_state_transition: DriveAbciStateTransitionValidationVersion, pub identity_credit_transfer_state_transition: DriveAbciStateTransitionValidationVersion, + pub masternode_vote_state_transition: DriveAbciStateTransitionValidationVersion, pub contract_create_state_transition: DriveAbciStateTransitionValidationVersion, pub contract_update_state_transition: DriveAbciStateTransitionValidationVersion, pub documents_batch_state_transition: DriveAbciDocumentsStateTransitionValidationVersions, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 74a7c237ca..e9f4256268 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -546,6 +546,12 @@ pub(super) const PLATFORM_V1: PlatformVersion = PlatformVersion { state: 0, transform_into_action: 0, }, + masternode_vote_state_transition: DriveAbciStateTransitionValidationVersion { + structure: 0, + identity_signatures: None, + state: 0, + transform_into_action: 0, + }, contract_create_state_transition: DriveAbciStateTransitionValidationVersion { structure: 0, identity_signatures: None, From 52dcb74669891faa7163848f60d36da4b94a5e52 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sat, 9 Sep 2023 04:09:03 +0200 Subject: [PATCH 004/135] temp work --- .../document_type/index_level/mod.rs | 42 +++- .../src/data_contract/document_type/mod.rs | 1 + .../masternode_vote_transition/v0/mod.rs | 7 +- packages/rs-dpp/src/voting/common_vote/mod.rs | 14 ++ packages/rs-dpp/src/voting/mod.rs | 31 ++- packages/rs-dpp/src/voting/vote/mod.rs | 5 - .../masternode_vote/state/v0/mod.rs | 2 +- .../v0/mod.rs | 4 +- .../mod.rs | 5 +- .../v0/mod.rs | 3 +- .../v0/mod.rs | 4 +- .../mod.rs | 5 +- .../v0/mod.rs | 189 +++++++++++++----- .../identity/masternode_vote/v0/mod.rs | 4 +- .../masternode_vote/v0/transformer.rs | 8 +- 15 files changed, 234 insertions(+), 90 deletions(-) create mode 100644 packages/rs-dpp/src/voting/common_vote/mod.rs delete mode 100644 packages/rs-dpp/src/voting/vote/mod.rs diff --git a/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs b/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs index 79d0ca2e4f..072aad87fb 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs @@ -5,13 +5,29 @@ use crate::data_contract::document_type::Index; use crate::version::PlatformVersion; use crate::ProtocolError; use std::collections::BTreeMap; +use crate::data_contract::document_type::index_level::IndexType::{ContestedResourceIndex, NonUniqueIndex, UniqueIndex}; + +#[derive(Debug, PartialEq, Copy, Clone)] +pub enum IndexType { + /// A normal non unique index + NonUniqueIndex, + /// A unique index, that means that the values for this index are unique + /// As long as one of the values is not nil + UniqueIndex, + /// A contested resource: This is a unique index but that can be contested through a resolution + /// The simplest to understand resolution is a masternode vote, but could also be something + /// like a bidding war. + /// For example the path/name in the dpns contract must be unique but it is a contested potentially + /// valuable resource. + ContestedResourceIndex, +} #[derive(Debug, PartialEq, Clone)] pub struct IndexLevel { /// the lower index levels from this level sub_index_levels: BTreeMap, /// did an index terminate at this level - has_index_with_uniqueness: Option, + has_index_with_type: Option, /// unique level identifier level_identifier: u64, } @@ -25,8 +41,8 @@ impl IndexLevel { &self.sub_index_levels } - pub fn has_index_with_uniqueness(&self) -> Option { - self.has_index_with_uniqueness + pub fn has_index_with_type(&self) -> Option { + self.has_index_with_type } /// Checks whether the given `rhs` IndexLevel is a subset of the current IndexLevel (`self`). @@ -111,7 +127,7 @@ impl IndexLevel { ) -> Result { let mut index_level = IndexLevel { sub_index_levels: Default::default(), - has_index_with_uniqueness: None, + has_index_with_type: None, level_identifier: 0, }; @@ -130,7 +146,7 @@ impl IndexLevel { IndexLevel { level_identifier: counter, sub_index_levels: Default::default(), - has_index_with_uniqueness: None, + has_index_with_type: None, } }); @@ -140,7 +156,7 @@ impl IndexLevel { // It means there are two indices with the same combination of properties. // We might need to take into account the sorting order when we have it - if current_level.has_index_with_uniqueness.is_some() { + if current_level.has_index_with_type.is_some() { // an index already exists return error return Err(ConsensusError::BasicError(BasicError::DuplicateIndexError( DuplicateIndexError::new( @@ -151,7 +167,13 @@ impl IndexLevel { .into()); } - current_level.has_index_with_uniqueness = Some(index.unique); + let index_type = if index.unique { + UniqueIndex + } else { + NonUniqueIndex + }; + + current_level.has_index_with_type = Some(index_type); } } @@ -173,7 +195,7 @@ impl IndexLevel { IndexLevel { level_identifier: counter, sub_index_levels: Default::default(), - has_index_with_uniqueness: None, + has_index_with_type: None, } }); @@ -183,7 +205,7 @@ impl IndexLevel { // It means there are two indices with the same combination of properties. // We might need to take into account the sorting order when we have it - if current_level.has_index_with_uniqueness.is_some() { + if current_level.has_index_with_type.is_some() { // an index already exists return error return Err(ConsensusError::BasicError( BasicError::DuplicateIndexError(DuplicateIndexError::new( @@ -194,7 +216,7 @@ impl IndexLevel { .into()); } - current_level.has_index_with_uniqueness = Some(false); + current_level.has_index_with_type = Some(ContestedResourceIndex); } } } diff --git a/packages/rs-dpp/src/data_contract/document_type/mod.rs b/packages/rs-dpp/src/data_contract/document_type/mod.rs index 84d5fbfbce..423d2442b4 100644 --- a/packages/rs-dpp/src/data_contract/document_type/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/mod.rs @@ -6,6 +6,7 @@ mod index; pub mod methods; pub use index::*; mod index_level; +pub use index_level::IndexType; pub use index_level::IndexLevel; #[cfg(feature = "random-documents")] diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs index a7f9ff318b..83b0b071ee 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs @@ -13,11 +13,11 @@ use crate::identity::KeyID; use crate::prelude::Identifier; use crate::protocol_error::ProtocolError; -use crate::voting::resource_vote::ResourceVote; use bincode::{Decode, Encode}; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize, PlatformSignable}; use platform_value::BinaryData; use serde::{Deserialize, Serialize}; +use crate::voting::Vote; #[derive( Debug, @@ -39,7 +39,7 @@ use serde::{Deserialize, Serialize}; pub struct MasternodeVoteTransitionV0 { // Own ST fields pub pro_tx_hash: Identifier, - pub resource_vote: ResourceVote, + pub vote: Vote, #[platform_signable(exclude_from_sig_hash)] pub signature_public_key_id: KeyID, #[platform_signable(exclude_from_sig_hash)] @@ -56,6 +56,7 @@ mod test { use platform_value::Identifier; use rand::Rng; use std::fmt::Debug; + use crate::voting::Vote; fn test_masternode_vote_transition< T: PlatformSerializable + PlatformDeserializable + Debug + PartialEq, @@ -75,7 +76,7 @@ mod test { let mut rng = rand::thread_rng(); let transition = MasternodeVoteTransitionV0 { pro_tx_hash: Identifier::random(), - resource_vote: ResourceVote::TowardsIdentity(Identifier::random()), + vote: Vote::ContestedDocumentResourceVote(Identifier::random(), "hello".to_string(), "index_1".to_string(), vec![], ResourceVote::TowardsIdentity(Identifier::random())), signature_public_key_id: rng.gen(), signature: [0; 65].to_vec().into(), }; diff --git a/packages/rs-dpp/src/voting/common_vote/mod.rs b/packages/rs-dpp/src/voting/common_vote/mod.rs new file mode 100644 index 0000000000..0470b1e88c --- /dev/null +++ b/packages/rs-dpp/src/voting/common_vote/mod.rs @@ -0,0 +1,14 @@ +use bincode::{Decode, Encode}; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, Encode, Decode, PartialEq, Default)] +#[cfg_attr( +feature = "state-transition-serde-conversion", +derive(Serialize, Deserialize), +serde(rename_all = "camelCase") +)] +pub enum CommonVote { + YES, + NO, + ABSTAIN, +} diff --git a/packages/rs-dpp/src/voting/mod.rs b/packages/rs-dpp/src/voting/mod.rs index 115b2c2f24..a45157d226 100644 --- a/packages/rs-dpp/src/voting/mod.rs +++ b/packages/rs-dpp/src/voting/mod.rs @@ -1,2 +1,31 @@ +use bincode::{Decode, Encode}; +use serde::{Deserialize, Serialize}; +use platform_value::{Identifier, Value}; +use crate::voting::resource_vote::ResourceVote; +use crate::voting::Vote::ContestedDocumentResourceVote; + pub mod resource_vote; -pub mod vote; +pub mod common_vote; + +type ContractId = Identifier; +type DocumentTypeName = String; + +type IndexName = String; + +type IndexValues = Vec; + +#[derive(Debug, Clone, Encode, Decode, PartialEq)] +#[cfg_attr( +feature = "state-transition-serde-conversion", +derive(Serialize, Deserialize), +serde(rename_all = "camelCase") +)] +pub enum Vote { + ContestedDocumentResourceVote(ContractId, DocumentTypeName, IndexName, IndexValues, ResourceVote), +} + +impl Default for Vote { + fn default() -> Self { + ContestedDocumentResourceVote(Identifier::default(), String::default(), String::default(), Vec::default(), ResourceVote::Abstain) + } +} diff --git a/packages/rs-dpp/src/voting/vote/mod.rs b/packages/rs-dpp/src/voting/vote/mod.rs deleted file mode 100644 index 41d0b1abc2..0000000000 --- a/packages/rs-dpp/src/voting/vote/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub enum Vote { - YES, - NO, - ABSTAIN, -} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs index 9e87172f94..e999a0ff9c 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs @@ -37,7 +37,7 @@ impl MasternodeVoteStateTransitionStateValidationV0 for MasternodeVoteTransition platform_version: &PlatformVersion, ) -> Result, Error> { let maybe_existing_identity_balance = platform.drive.fetch_identity_balance( - self.identity_id().to_buffer(), + self.pro_tx_hash().to_buffer(), tx, platform_version, )?; diff --git a/packages/rs-drive/src/drive/document/delete/remove_indices_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/delete/remove_indices_for_index_level_for_contract_operations/v0/mod.rs index 2ddce191d5..bd9426731c 100644 --- a/packages/rs-drive/src/drive/document/delete/remove_indices_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/remove_indices_for_index_level_for_contract_operations/v0/mod.rs @@ -60,11 +60,11 @@ impl Drive { ); } - if let Some(unique) = index_level.has_index_with_uniqueness() { + if let Some(index_type) = index_level.has_index_with_type() { self.remove_reference_for_index_level_for_contract_operations( document_and_contract_info, index_path_info.clone(), - unique, + index_type, any_fields_null, storage_flags, previous_batch_operations, diff --git a/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/mod.rs index c8fc6e335f..4de85c6055 100644 --- a/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/mod.rs @@ -13,6 +13,7 @@ use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; +use dpp::data_contract::document_type::IndexType; impl Drive { /// Removes the terminal reference. @@ -37,7 +38,7 @@ impl Drive { &self, document_and_contract_info: &DocumentAndContractInfo, index_path_info: PathInfo<0>, - unique: bool, + index_type: IndexType, any_fields_null: bool, storage_flags: &Option<&StorageFlags>, previous_batch_operations: &Option<&mut Vec>, @@ -59,7 +60,7 @@ impl Drive { 0 => self.remove_reference_for_index_level_for_contract_operations_v0( document_and_contract_info, index_path_info, - unique, + index_type, any_fields_null, storage_flags, previous_batch_operations, diff --git a/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/v0/mod.rs index ea6ce25248..08f6153856 100644 --- a/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -7,6 +7,7 @@ use grovedb::{EstimatedLayerInformation, TransactionArg}; use grovedb::EstimatedSumTrees::NoSumTrees; use std::collections::HashMap; +use dpp::data_contract::document_type::IndexType; use crate::drive::defaults::{CONTRACT_DOCUMENTS_PATH_HEIGHT, DEFAULT_HASH_SIZE_U8}; use crate::drive::document::document_reference_size; @@ -26,7 +27,7 @@ impl Drive { &self, document_and_contract_info: &DocumentAndContractInfo, index_path_info: PathInfo<0>, - unique: bool, + index_type: IndexType, any_fields_null: bool, storage_flags: &Option<&StorageFlags>, previous_batch_operations: &Option<&mut Vec>, diff --git a/packages/rs-drive/src/drive/document/insert/add_indices_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_indices_for_index_level_for_contract_operations/v0/mod.rs index 8a0f4f3a10..ffc85440b9 100644 --- a/packages/rs-drive/src/drive/document/insert/add_indices_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_indices_for_index_level_for_contract_operations/v0/mod.rs @@ -35,11 +35,11 @@ impl Drive { batch_operations: &mut Vec, platform_version: &PlatformVersion, ) -> Result<(), Error> { - if let Some(unique) = index_level.has_index_with_uniqueness() { + if let Some(index_type) = index_level.has_index_with_type() { self.add_reference_for_index_level_for_contract_operations( document_and_contract_info, index_path_info.clone(), - unique, + index_type, any_fields_null, previous_batch_operations, storage_flags, diff --git a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/mod.rs index e47b4c5863..f77f4dd8ba 100644 --- a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/mod.rs @@ -13,6 +13,7 @@ use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; +use dpp::data_contract::document_type::IndexType; impl Drive { /// Adds the terminal reference. @@ -20,7 +21,7 @@ impl Drive { &self, document_and_contract_info: &DocumentAndContractInfo, index_path_info: PathInfo<0>, - unique: bool, + index_type: IndexType, any_fields_null: bool, previous_batch_operations: &mut Option<&mut Vec>, storage_flags: &Option<&StorageFlags>, @@ -40,7 +41,7 @@ impl Drive { 0 => self.add_reference_for_index_level_for_contract_operations_v0( document_and_contract_info, index_path_info, - unique, + index_type, any_fields_null, previous_batch_operations, storage_flags, diff --git a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs index c46e791faa..f44fc05cbc 100644 --- a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -20,10 +20,13 @@ use dpp::version::drive_versions::DriveVersion; use grovedb::batch::key_info::KeyInfo; use grovedb::batch::KeyInfoPath; use grovedb::EstimatedLayerCount::PotentiallyAtMaxElements; -use grovedb::EstimatedLayerSizes::AllSubtrees; +use grovedb::EstimatedLayerSizes::{AllReference, AllSubtrees}; use grovedb::EstimatedSumTrees::NoSumTrees; use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; +use dpp::data_contract::document_type::IndexType; +use dpp::data_contract::document_type::IndexType::{ContestedResourceIndex, NonUniqueIndex}; +use crate::drive::object_size_info::PathKeyElementInfo::PathKeyElement; impl Drive { /// Adds the terminal reference. @@ -31,7 +34,7 @@ impl Drive { &self, document_and_contract_info: &DocumentAndContractInfo, mut index_path_info: PathInfo<0>, - unique: bool, + index_type: IndexType, any_fields_null: bool, previous_batch_operations: &mut Option<&mut Vec>, storage_flags: &Option<&StorageFlags>, @@ -44,7 +47,10 @@ impl Drive { ) -> Result<(), Error> { // unique indexes will be stored under key "0" // non unique indices should have a tree at key "0" that has all elements based off of primary key - if !unique || any_fields_null { + if index_type == NonUniqueIndex || index_type == ContestedResourceIndex || any_fields_null { + + // Tree generation, this happens for both non unique indexes, unique indexes with a null inside + // a member of the path and for contested resource indexes let key_path_info = KeyRef(&[0]); let path_key_info = key_path_info.add_path_info(index_path_info.clone()); @@ -74,62 +80,135 @@ impl Drive { index_path_info.push(Key(vec![0]))?; - if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info - { - // On this level we will have a 0 and all the top index paths - estimated_costs_only_with_layer_info.insert( - index_path_info.clone().convert_to_key_info_path(), - EstimatedLayerInformation { - is_sum_tree: false, - estimated_layer_count: PotentiallyAtMaxElements, - estimated_layer_sizes: AllSubtrees( - DEFAULT_HASH_SIZE_U8, - NoSumTrees, - storage_flags.map(|s| s.serialized_size()), - ), - }, - ); - } + if index_type != ContestedResourceIndex { - let key_element_info = - match &document_and_contract_info.owned_document_info.document_info { - DocumentRefAndSerialization((document, _, storage_flags)) - | DocumentRefInfo((document, storage_flags)) => { - let document_reference = make_document_reference( - document, - document_and_contract_info.document_type, - storage_flags.as_ref().map(|flags| flags.as_ref()), - ); - KeyElement((document.id_ref().as_slice(), document_reference)) - } - DocumentOwnedInfo((document, storage_flags)) - | DocumentAndSerialization((document, _, storage_flags)) => { - let document_reference = make_document_reference( - document, - document_and_contract_info.document_type, - storage_flags.as_ref().map(|flags| flags.as_ref()), - ); - KeyElement((document.id_ref().as_slice(), document_reference)) - } - DocumentEstimatedAverageSize(max_size) => KeyUnknownElementSize(( - KeyInfo::MaxKeySize { - unique_id: document_and_contract_info - .document_type - .unique_id_for_storage() - .to_vec(), - max_size: DEFAULT_HASH_SIZE_U8, + // This is the simpler situation + // Under each tree we have all the references + + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info + { + // On this level we will have a 0 and all the top index paths + estimated_costs_only_with_layer_info.insert( + index_path_info.clone().convert_to_key_info_path(), + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: PotentiallyAtMaxElements, + estimated_layer_sizes: AllReference( + DEFAULT_HASH_SIZE_U8, + document_reference_size(document_and_contract_info.document_type), + storage_flags.map(|s| s.serialized_size()), + ), }, - Element::required_item_space(*max_size, STORAGE_FLAGS_SIZE), - )), - }; + ); + } - let path_key_element_info = PathKeyElementInfo::from_path_info_and_key_element( - index_path_info, - key_element_info, - )?; + let key_element_info = + match &document_and_contract_info.owned_document_info.document_info { + DocumentRefAndSerialization((document, _, storage_flags)) + | DocumentRefInfo((document, storage_flags)) => { + let document_reference = make_document_reference( + document, + document_and_contract_info.document_type, + storage_flags.as_ref().map(|flags| flags.as_ref()), + ); + KeyElement((document.id_ref().as_slice(), document_reference)) + } + DocumentOwnedInfo((document, storage_flags)) + | DocumentAndSerialization((document, _, storage_flags)) => { + let document_reference = make_document_reference( + document, + document_and_contract_info.document_type, + storage_flags.as_ref().map(|flags| flags.as_ref()), + ); + KeyElement((document.id_ref().as_slice(), document_reference)) + } + DocumentEstimatedAverageSize(max_size) => KeyUnknownElementSize(( + KeyInfo::MaxKeySize { + unique_id: document_and_contract_info + .document_type + .unique_id_for_storage() + .to_vec(), + max_size: DEFAULT_HASH_SIZE_U8, + }, + Element::required_item_space(*max_size, STORAGE_FLAGS_SIZE), + )), + }; - // here we should return an error if the element already exists - self.batch_insert(path_key_element_info, batch_operations, drive_version)?; + let path_key_element_info = PathKeyElementInfo::from_path_info_and_key_element( + index_path_info, + key_element_info, + )?; + + // here we should return an error if the element already exists + self.batch_insert(path_key_element_info, batch_operations, drive_version)?; + } else { + // Contested Resource index + // Under each tree we have all identifiers of identities that want the contested resource + // We get something like + // item name contested (there will be another path with item_name) + // | + // Goblet of Fire + // | + // 0 (for the termination of the index) + // / \ + // Sam's Id Ivan's Id + // / \ / \ + // 0 (ref) 1 (sum tree) 0 (ref) 1 (sum tree) + // + + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info + { + // On this level we will have a 0 and all the top index paths + estimated_costs_only_with_layer_info.insert( + index_path_info.clone().convert_to_key_info_path(), + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: PotentiallyAtMaxElements, + estimated_layer_sizes: AllSubtrees( + DEFAULT_HASH_SIZE_U8, + NoSumTrees, + storage_flags.map(|s| s.serialized_size()), + ), + }, + ); + } + + let key_element_info = + match &document_and_contract_info.owned_document_info.document_info { + DocumentRefAndSerialization((document, _, storage_flags)) + | DocumentRefInfo((document, storage_flags)) => { + + KeyElement((document.id_ref().as_slice(), document_reference)) + } + DocumentOwnedInfo((document, storage_flags)) + | DocumentAndSerialization((document, _, storage_flags)) => { + let document_reference = make_document_reference( + document, + document_and_contract_info.document_type, + storage_flags.as_ref().map(|flags| flags.as_ref()), + ); + KeyElement((document.id_ref().as_slice(), document_reference)) + } + DocumentEstimatedAverageSize(max_size) => KeyUnknownElementSize(( + KeyInfo::MaxKeySize { + unique_id: document_and_contract_info + .document_type + .unique_id_for_storage() + .to_vec(), + max_size: DEFAULT_HASH_SIZE_U8, + }, + Element::required_item_space(*max_size, STORAGE_FLAGS_SIZE), + )), + }; + + let path_key_element_info = PathKeyElementInfo::from_path_info_and_key_element( + index_path_info, + key_element_info, + )?; + + // here we should return an error if the element already exists + self.batch_insert_empty_tree_if_not_exists(path_key_element_info, batch_operations, drive_version)?; + } } else { let key_element_info = match &document_and_contract_info.owned_document_info.document_info { diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs index 07f15ffb81..aa29726725 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs @@ -1,8 +1,8 @@ mod transformer; use dpp::platform_value::Identifier; -use dpp::voting::resource_vote::ResourceVote; use serde::{Deserialize, Serialize}; +use dpp::voting::Vote; /// action v0 #[derive(Default, Debug, Clone, Serialize, Deserialize)] @@ -11,5 +11,5 @@ pub struct MasternodeVoteTransitionActionV0 { /// the pro tx hash identifier of the masternode pub pro_tx_hash: Identifier, /// the resource vote - pub resource_vote: ResourceVote, + pub vote: Vote, } diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs index 08d6fd8e6c..de10273cae 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs @@ -5,12 +5,12 @@ impl From for MasternodeVoteTransitionActionV0 { fn from(value: MasternodeVoteTransitionV0) -> Self { let MasternodeVoteTransitionV0 { pro_tx_hash, - resource_vote, + vote, .. } = value; MasternodeVoteTransitionActionV0 { pro_tx_hash, - resource_vote, + vote, } } } @@ -19,12 +19,12 @@ impl From<&MasternodeVoteTransitionV0> for MasternodeVoteTransitionActionV0 { fn from(value: &MasternodeVoteTransitionV0) -> Self { let MasternodeVoteTransitionV0 { pro_tx_hash, - resource_vote, + vote, .. } = value; MasternodeVoteTransitionActionV0 { pro_tx_hash: *pro_tx_hash, - resource_vote: *resource_vote, + vote: vote.clone(), } } } From 55c7ec49f5d3e7fbba1d2b4f9ae543585eab4970 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 11 Sep 2023 20:04:02 +0200 Subject: [PATCH 005/135] more work and formatting --- .../document_type/index_level/mod.rs | 4 +- .../src/data_contract/document_type/mod.rs | 2 +- .../masternode_vote_transition/v0/mod.rs | 12 +- packages/rs-dpp/src/voting/common_vote/mod.rs | 6 +- packages/rs-dpp/src/voting/mod.rs | 30 +++-- .../mod.rs | 2 +- .../v0/mod.rs | 2 +- .../mod.rs | 2 +- .../v0/mod.rs | 112 ++++++++++++------ .../identity/masternode_vote/v0/mod.rs | 2 +- .../masternode_vote/v0/transformer.rs | 13 +- 11 files changed, 120 insertions(+), 67 deletions(-) diff --git a/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs b/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs index 072aad87fb..67a3525cd8 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs @@ -1,11 +1,13 @@ use crate::consensus::basic::data_contract::DuplicateIndexError; use crate::consensus::basic::BasicError; use crate::consensus::ConsensusError; +use crate::data_contract::document_type::index_level::IndexType::{ + ContestedResourceIndex, NonUniqueIndex, UniqueIndex, +}; use crate::data_contract::document_type::Index; use crate::version::PlatformVersion; use crate::ProtocolError; use std::collections::BTreeMap; -use crate::data_contract::document_type::index_level::IndexType::{ContestedResourceIndex, NonUniqueIndex, UniqueIndex}; #[derive(Debug, PartialEq, Copy, Clone)] pub enum IndexType { diff --git a/packages/rs-dpp/src/data_contract/document_type/mod.rs b/packages/rs-dpp/src/data_contract/document_type/mod.rs index 423d2442b4..e91e483f20 100644 --- a/packages/rs-dpp/src/data_contract/document_type/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/mod.rs @@ -6,8 +6,8 @@ mod index; pub mod methods; pub use index::*; mod index_level; -pub use index_level::IndexType; pub use index_level::IndexLevel; +pub use index_level::IndexType; #[cfg(feature = "random-documents")] pub mod random_document; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs index 83b0b071ee..c80bf43f9a 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs @@ -13,11 +13,11 @@ use crate::identity::KeyID; use crate::prelude::Identifier; use crate::protocol_error::ProtocolError; +use crate::voting::Vote; use bincode::{Decode, Encode}; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize, PlatformSignable}; use platform_value::BinaryData; use serde::{Deserialize, Serialize}; -use crate::voting::Vote; #[derive( Debug, @@ -53,10 +53,10 @@ mod test { use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; use crate::voting::resource_vote::ResourceVote; + use crate::voting::Vote; use platform_value::Identifier; use rand::Rng; use std::fmt::Debug; - use crate::voting::Vote; fn test_masternode_vote_transition< T: PlatformSerializable + PlatformDeserializable + Debug + PartialEq, @@ -76,7 +76,13 @@ mod test { let mut rng = rand::thread_rng(); let transition = MasternodeVoteTransitionV0 { pro_tx_hash: Identifier::random(), - vote: Vote::ContestedDocumentResourceVote(Identifier::random(), "hello".to_string(), "index_1".to_string(), vec![], ResourceVote::TowardsIdentity(Identifier::random())), + vote: Vote::ContestedDocumentResourceVote( + Identifier::random(), + "hello".to_string(), + "index_1".to_string(), + vec![], + ResourceVote::TowardsIdentity(Identifier::random()), + ), signature_public_key_id: rng.gen(), signature: [0; 65].to_vec().into(), }; diff --git a/packages/rs-dpp/src/voting/common_vote/mod.rs b/packages/rs-dpp/src/voting/common_vote/mod.rs index 0470b1e88c..e831d5a47f 100644 --- a/packages/rs-dpp/src/voting/common_vote/mod.rs +++ b/packages/rs-dpp/src/voting/common_vote/mod.rs @@ -3,9 +3,9 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, Encode, Decode, PartialEq, Default)] #[cfg_attr( -feature = "state-transition-serde-conversion", -derive(Serialize, Deserialize), -serde(rename_all = "camelCase") + feature = "state-transition-serde-conversion", + derive(Serialize, Deserialize), + serde(rename_all = "camelCase") )] pub enum CommonVote { YES, diff --git a/packages/rs-dpp/src/voting/mod.rs b/packages/rs-dpp/src/voting/mod.rs index a45157d226..2c11210b08 100644 --- a/packages/rs-dpp/src/voting/mod.rs +++ b/packages/rs-dpp/src/voting/mod.rs @@ -1,11 +1,11 @@ -use bincode::{Decode, Encode}; -use serde::{Deserialize, Serialize}; -use platform_value::{Identifier, Value}; use crate::voting::resource_vote::ResourceVote; use crate::voting::Vote::ContestedDocumentResourceVote; +use bincode::{Decode, Encode}; +use platform_value::{Identifier, Value}; +use serde::{Deserialize, Serialize}; -pub mod resource_vote; pub mod common_vote; +pub mod resource_vote; type ContractId = Identifier; type DocumentTypeName = String; @@ -16,16 +16,28 @@ type IndexValues = Vec; #[derive(Debug, Clone, Encode, Decode, PartialEq)] #[cfg_attr( -feature = "state-transition-serde-conversion", -derive(Serialize, Deserialize), -serde(rename_all = "camelCase") + feature = "state-transition-serde-conversion", + derive(Serialize, Deserialize), + serde(rename_all = "camelCase") )] pub enum Vote { - ContestedDocumentResourceVote(ContractId, DocumentTypeName, IndexName, IndexValues, ResourceVote), + ContestedDocumentResourceVote( + ContractId, + DocumentTypeName, + IndexName, + IndexValues, + ResourceVote, + ), } impl Default for Vote { fn default() -> Self { - ContestedDocumentResourceVote(Identifier::default(), String::default(), String::default(), Vec::default(), ResourceVote::Abstain) + ContestedDocumentResourceVote( + Identifier::default(), + String::default(), + String::default(), + Vec::default(), + ResourceVote::Abstain, + ) } } diff --git a/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/mod.rs index 4de85c6055..068933bdd9 100644 --- a/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/mod.rs @@ -11,9 +11,9 @@ use dpp::version::PlatformVersion; use grovedb::batch::KeyInfoPath; +use dpp::data_contract::document_type::IndexType; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; -use dpp::data_contract::document_type::IndexType; impl Drive { /// Removes the terminal reference. diff --git a/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/v0/mod.rs index 08f6153856..bad3f5914a 100644 --- a/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -5,9 +5,9 @@ use grovedb::EstimatedLayerCount::PotentiallyAtMaxElements; use grovedb::EstimatedLayerSizes::{AllReference, AllSubtrees}; use grovedb::{EstimatedLayerInformation, TransactionArg}; +use dpp::data_contract::document_type::IndexType; use grovedb::EstimatedSumTrees::NoSumTrees; use std::collections::HashMap; -use dpp::data_contract::document_type::IndexType; use crate::drive::defaults::{CONTRACT_DOCUMENTS_PATH_HEIGHT, DEFAULT_HASH_SIZE_U8}; use crate::drive::document::document_reference_size; diff --git a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/mod.rs index f77f4dd8ba..88089afa49 100644 --- a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/mod.rs @@ -11,9 +11,9 @@ use dpp::version::drive_versions::DriveVersion; use grovedb::batch::KeyInfoPath; +use dpp::data_contract::document_type::IndexType; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; -use dpp::data_contract::document_type::IndexType; impl Drive { /// Adds the terminal reference. diff --git a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs index f44fc05cbc..7115eac175 100644 --- a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -9,13 +9,17 @@ use crate::drive::object_size_info::DocumentInfo::{ }; use crate::drive::object_size_info::DriveKeyInfo::{Key, KeyRef}; use crate::drive::object_size_info::KeyElementInfo::{KeyElement, KeyUnknownElementSize}; +use crate::drive::object_size_info::PathKeyElementInfo::PathKeyElement; use crate::drive::object_size_info::{DocumentAndContractInfo, PathInfo, PathKeyElementInfo}; use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; +use dpp::data_contract::document_type::IndexType; +use dpp::data_contract::document_type::IndexType::{ContestedResourceIndex, NonUniqueIndex}; use dpp::document::DocumentV0Getters; +use dpp::platform_value::Value::Identifier; use dpp::version::drive_versions::DriveVersion; use grovedb::batch::key_info::KeyInfo; use grovedb::batch::KeyInfoPath; @@ -24,9 +28,6 @@ use grovedb::EstimatedLayerSizes::{AllReference, AllSubtrees}; use grovedb::EstimatedSumTrees::NoSumTrees; use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; -use dpp::data_contract::document_type::IndexType; -use dpp::data_contract::document_type::IndexType::{ContestedResourceIndex, NonUniqueIndex}; -use crate::drive::object_size_info::PathKeyElementInfo::PathKeyElement; impl Drive { /// Adds the terminal reference. @@ -48,7 +49,6 @@ impl Drive { // unique indexes will be stored under key "0" // non unique indices should have a tree at key "0" that has all elements based off of primary key if index_type == NonUniqueIndex || index_type == ContestedResourceIndex || any_fields_null { - // Tree generation, this happens for both non unique indexes, unique indexes with a null inside // a member of the path and for contested resource indexes let key_path_info = KeyRef(&[0]); @@ -81,11 +81,11 @@ impl Drive { index_path_info.push(Key(vec![0]))?; if index_type != ContestedResourceIndex { - // This is the simpler situation // Under each tree we have all the references - if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info + if let Some(estimated_costs_only_with_layer_info) = + estimated_costs_only_with_layer_info { // On this level we will have a 0 and all the top index paths estimated_costs_only_with_layer_info.insert( @@ -156,7 +156,57 @@ impl Drive { // 0 (ref) 1 (sum tree) 0 (ref) 1 (sum tree) // - if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info + let (document_id, ref_key_element_info) = + match &document_and_contract_info.owned_document_info.document_info { + DocumentRefAndSerialization((document, _, storage_flags)) + | DocumentRefInfo((document, storage_flags)) => { + let document_reference = make_document_reference( + document, + document_and_contract_info.document_type, + storage_flags.as_ref().map(|flags| flags.as_ref()), + ); + (document.id(), KeyElement((&[0], document_reference))) + } + DocumentOwnedInfo((document, storage_flags)) + | DocumentAndSerialization((document, _, storage_flags)) => { + let document_reference = make_document_reference( + document, + document_and_contract_info.document_type, + storage_flags.as_ref().map(|flags| flags.as_ref()), + ); + (document.id(), KeyElement((&[0], document_reference))) + } + DocumentEstimatedAverageSize(max_size) => { + let unique_id = document_and_contract_info + .document_type + .unique_id_for_storage(); + let unique_id_vec = unique_id.to_vec(); + ( + unique_id.into(), + KeyUnknownElementSize(( + KeyInfo::MaxKeySize { + unique_id: unique_id_vec, + max_size: DEFAULT_HASH_SIZE_U8, + }, + Element::required_item_space(*max_size, STORAGE_FLAGS_SIZE), + )), + ) + } + }; + + let document_key_path_info = document.id_ref().as_slice(); + + let ref_key_path_info = KeyRef(&[0]); + + let votes_key_path_info = KeyRef(&[1]); + + let ref_path_key_info = ref_key_path_info.add_path_info(index_path_info.clone()); + + let votes_path_key_info = + votes_key_path_info.add_path_info(index_path_info.clone()); + + if let Some(estimated_costs_only_with_layer_info) = + estimated_costs_only_with_layer_info { // On this level we will have a 0 and all the top index paths estimated_costs_only_with_layer_info.insert( @@ -171,35 +221,21 @@ impl Drive { ), }, ); - } - - let key_element_info = - match &document_and_contract_info.owned_document_info.document_info { - DocumentRefAndSerialization((document, _, storage_flags)) - | DocumentRefInfo((document, storage_flags)) => { - KeyElement((document.id_ref().as_slice(), document_reference)) - } - DocumentOwnedInfo((document, storage_flags)) - | DocumentAndSerialization((document, _, storage_flags)) => { - let document_reference = make_document_reference( - document, - document_and_contract_info.document_type, - storage_flags.as_ref().map(|flags| flags.as_ref()), - ); - KeyElement((document.id_ref().as_slice(), document_reference)) - } - DocumentEstimatedAverageSize(max_size) => KeyUnknownElementSize(( - KeyInfo::MaxKeySize { - unique_id: document_and_contract_info - .document_type - .unique_id_for_storage() - .to_vec(), - max_size: DEFAULT_HASH_SIZE_U8, - }, - Element::required_item_space(*max_size, STORAGE_FLAGS_SIZE), - )), - }; + // On this level we will have a 0 and all the top index paths + estimated_costs_only_with_layer_info.insert( + votes_path_key_info.clone().convert_to_key_info_path()?, + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: PotentiallyAtMaxElements, + estimated_layer_sizes: AllSubtrees( + DEFAULT_HASH_SIZE_U8, + NoSumTrees, + storage_flags.map(|s| s.serialized_size()), + ), + }, + ); + } let path_key_element_info = PathKeyElementInfo::from_path_info_and_key_element( index_path_info, @@ -207,7 +243,11 @@ impl Drive { )?; // here we should return an error if the element already exists - self.batch_insert_empty_tree_if_not_exists(path_key_element_info, batch_operations, drive_version)?; + self.batch_insert_empty_tree_if_not_exists( + path_key_element_info, + batch_operations, + drive_version, + )?; } } else { let key_element_info = diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs index aa29726725..02eb8ebd9c 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs @@ -1,8 +1,8 @@ mod transformer; use dpp::platform_value::Identifier; -use serde::{Deserialize, Serialize}; use dpp::voting::Vote; +use serde::{Deserialize, Serialize}; /// action v0 #[derive(Default, Debug, Clone, Serialize, Deserialize)] diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs index de10273cae..663b99d8f4 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs @@ -4,23 +4,16 @@ use dpp::state_transition::state_transitions::identity::masternode_vote_transiti impl From for MasternodeVoteTransitionActionV0 { fn from(value: MasternodeVoteTransitionV0) -> Self { let MasternodeVoteTransitionV0 { - pro_tx_hash, - vote, - .. + pro_tx_hash, vote, .. } = value; - MasternodeVoteTransitionActionV0 { - pro_tx_hash, - vote, - } + MasternodeVoteTransitionActionV0 { pro_tx_hash, vote } } } impl From<&MasternodeVoteTransitionV0> for MasternodeVoteTransitionActionV0 { fn from(value: &MasternodeVoteTransitionV0) -> Self { let MasternodeVoteTransitionV0 { - pro_tx_hash, - vote, - .. + pro_tx_hash, vote, .. } = value; MasternodeVoteTransitionActionV0 { pro_tx_hash: *pro_tx_hash, From 3d5fb76618c60ec957754d95c4fbb75a1db83299 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 17 Sep 2023 14:07:05 +0700 Subject: [PATCH 006/135] more work --- .../v0/mod.rs | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs index 7115eac175..f9e89bc119 100644 --- a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -151,7 +151,7 @@ impl Drive { // | // 0 (for the termination of the index) // / \ - // Sam's Id Ivan's Id + // Sam's Document Id Ivan's Document Id // / \ / \ // 0 (ref) 1 (sum tree) 0 (ref) 1 (sum tree) // @@ -194,16 +194,20 @@ impl Drive { } }; - let document_key_path_info = document.id_ref().as_slice(); + let document_key_path_info = KeyRef(document_id.as_slice()); + + let mut document_path_info = index_path_info.clone(); + + document_path_info.push(document_key_path_info)?; let ref_key_path_info = KeyRef(&[0]); let votes_key_path_info = KeyRef(&[1]); - let ref_path_key_info = ref_key_path_info.add_path_info(index_path_info.clone()); + let ref_path_key_info = ref_key_path_info.add_path_info(document_path_info.clone()); let votes_path_key_info = - votes_key_path_info.add_path_info(index_path_info.clone()); + votes_key_path_info.add_path_info(document_path_info.clone()); if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info @@ -242,9 +246,20 @@ impl Drive { key_element_info, )?; - // here we should return an error if the element already exists - self.batch_insert_empty_tree_if_not_exists( - path_key_element_info, + // here we are the tree that will contain the ref and the voting tree + self.batch_insert_empty_tree( + document_path_info, + *storage_flags, + previous_batch_operations, + batch_operations, + drive_version, + )?; + + // here we are the tree that will contain the ref and the voting tree + self.batch_insert_empty_tree( + document_path_info, + *storage_flags, + previous_batch_operations, batch_operations, drive_version, )?; From 6eaff5ba7c6cacdb2cc1fae0d7f2e75359f9d967 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 18 Sep 2023 05:43:29 +0700 Subject: [PATCH 007/135] more work --- .../accessors/mod.rs | 10 +-- .../accessors/v0/mod.rs | 7 ++- packages/rs-dpp/src/voting/common_vote/mod.rs | 1 + .../v0/mod.rs | 4 +- .../src/drive/initialization/v0/mod.rs | 13 +++- packages/rs-drive/src/drive/mod.rs | 14 +++-- .../add_new_masternode_vote_type/mod.rs | 61 +++++++++++++++++++ .../add_new_masternode_vote_type/v0/mod.rs | 0 .../rs-drive/src/drive/votes/insert/mod.rs | 1 + packages/rs-drive/src/drive/votes/mod.rs | 1 + .../src/version/drive_versions.rs | 11 ++++ .../src/version/mocks/v2_test.rs | 6 ++ .../src/version/mocks/v3_test.rs | 6 ++ 13 files changed, 117 insertions(+), 18 deletions(-) create mode 100644 packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/insert/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/mod.rs diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/mod.rs index 17c10db765..c5f4ccf461 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/mod.rs @@ -1,9 +1,9 @@ mod v0; use crate::state_transition::masternode_vote_transition::MasternodeVoteTransition; -use crate::voting::resource_vote::ResourceVote; use platform_value::Identifier; pub use v0::*; +use crate::voting::Vote; impl MasternodeVoteTransitionAccessorsV0 for MasternodeVoteTransition { fn pro_tx_hash(&self) -> Identifier { @@ -20,16 +20,16 @@ impl MasternodeVoteTransitionAccessorsV0 for MasternodeVoteTransition { } } - fn resource_vote(&self) -> ResourceVote { + fn vote(&self) -> &Vote { match self { - MasternodeVoteTransition::V0(transition) => transition.resource_vote, + MasternodeVoteTransition::V0(transition) => &transition.vote, } } - fn set_resource_vote(&mut self, resource_vote: ResourceVote) { + fn set_vote(&mut self, vote: Vote) { match self { MasternodeVoteTransition::V0(transition) => { - transition.resource_vote = resource_vote; + transition.vote = vote; } } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/v0/mod.rs index c35e08b810..cb41fa3e9b 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/v0/mod.rs @@ -1,9 +1,10 @@ -use crate::voting::resource_vote::ResourceVote; + use platform_value::Identifier; +use crate::voting::Vote; pub trait MasternodeVoteTransitionAccessorsV0 { fn pro_tx_hash(&self) -> Identifier; fn set_pro_tx_hash(&mut self, pro_tx_hash: Identifier); - fn resource_vote(&self) -> ResourceVote; - fn set_resource_vote(&mut self, resource_vote: ResourceVote); + fn vote(&self) -> &Vote; + fn set_vote(&mut self, vote: Vote); } diff --git a/packages/rs-dpp/src/voting/common_vote/mod.rs b/packages/rs-dpp/src/voting/common_vote/mod.rs index e831d5a47f..89336f16aa 100644 --- a/packages/rs-dpp/src/voting/common_vote/mod.rs +++ b/packages/rs-dpp/src/voting/common_vote/mod.rs @@ -10,5 +10,6 @@ use serde::{Deserialize, Serialize}; pub enum CommonVote { YES, NO, + #[default] ABSTAIN, } diff --git a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs index f9e89bc119..41719759d6 100644 --- a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -9,7 +9,6 @@ use crate::drive::object_size_info::DocumentInfo::{ }; use crate::drive::object_size_info::DriveKeyInfo::{Key, KeyRef}; use crate::drive::object_size_info::KeyElementInfo::{KeyElement, KeyUnknownElementSize}; -use crate::drive::object_size_info::PathKeyElementInfo::PathKeyElement; use crate::drive::object_size_info::{DocumentAndContractInfo, PathInfo, PathKeyElementInfo}; use crate::drive::Drive; use crate::error::drive::DriveError; @@ -19,7 +18,6 @@ use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; use dpp::data_contract::document_type::IndexType; use dpp::data_contract::document_type::IndexType::{ContestedResourceIndex, NonUniqueIndex}; use dpp::document::DocumentV0Getters; -use dpp::platform_value::Value::Identifier; use dpp::version::drive_versions::DriveVersion; use grovedb::batch::key_info::KeyInfo; use grovedb::batch::KeyInfoPath; @@ -142,7 +140,7 @@ impl Drive { // here we should return an error if the element already exists self.batch_insert(path_key_element_info, batch_operations, drive_version)?; } else { - // Contested Resource index + // Contested Resource Index // Under each tree we have all identifiers of identities that want the contested resource // We get something like // item name contested (there will be another path with item_name) diff --git a/packages/rs-drive/src/drive/initialization/v0/mod.rs b/packages/rs-drive/src/drive/initialization/v0/mod.rs index 5bbed275f8..8559cffcf5 100644 --- a/packages/rs-drive/src/drive/initialization/v0/mod.rs +++ b/packages/rs-drive/src/drive/initialization/v0/mod.rs @@ -120,14 +120,14 @@ impl Drive { self.grove_insert_empty_tree( SubtreePath::empty(), - &[RootTree::Misc as u8], + &[RootTree::Votes as u8], transaction, None, &mut drive_operations, drive_version, )?; - //Row 3 (3/8 taken) + //Row 3 (5/8 taken) self.grove_insert_empty_tree( SubtreePath::empty(), @@ -156,6 +156,15 @@ impl Drive { drive_version, )?; + self.grove_insert_empty_tree( + SubtreePath::empty(), + &[RootTree::Misc as u8], + transaction, + None, + &mut drive_operations, + drive_version, + )?; + self.grove_insert_empty_tree( SubtreePath::empty(), &[RootTree::Versions as u8], diff --git a/packages/rs-drive/src/drive/mod.rs b/packages/rs-drive/src/drive/mod.rs index e1fa273b4a..d2dc2609ac 100644 --- a/packages/rs-drive/src/drive/mod.rs +++ b/packages/rs-drive/src/drive/mod.rs @@ -93,6 +93,7 @@ mod system_contracts_cache; /// Contains a set of useful grovedb proof verification functions #[cfg(any(feature = "full", feature = "verify"))] pub mod verify; +mod votes; #[cfg(feature = "full")] use crate::drive::cache::DriveCache; @@ -124,9 +125,9 @@ pub struct Drive { // / \ // Identities 32 Balances 96 // / \ / \ -// Token_Balances 16 Pools 48 WithdrawalTransactions 80 Misc 112 -// / \ / \ -// NUPKH->I 8 UPKH->I 24 SpentAssetLockTransactions 72 Versions 120 +// Token_Balances 16 Pools 48 WithdrawalTransactions 80 Votes 112 +// / \ / / \ +// NUPKH->I 8 UPKH->I 24 SpentAssetLockTransactions 72 Misc 104 Versions 120 /// Keys for the root tree. #[cfg(any(feature = "full", feature = "verify"))] @@ -146,7 +147,7 @@ pub enum RootTree { /// Spent Asset Lock Transactions SpentAssetLockTransactions = 72, /// Misc - Misc = 112, + Misc = 104, /// Asset Unlock Transactions WithdrawalTransactions = 80, /// Balances @@ -155,6 +156,8 @@ pub enum RootTree { TokenBalances = 16, /// Versions desired by proposers Versions = 120, + /// Registered votes + Votes = 112 } /// Storage cost @@ -184,12 +187,13 @@ impl From for &'static [u8; 1] { RootTree::UniquePublicKeyHashesToIdentities => &[24], RootTree::SpentAssetLockTransactions => &[72], RootTree::Pools => &[48], - RootTree::Misc => &[112], + RootTree::Misc => &[104], RootTree::WithdrawalTransactions => &[80], RootTree::Balances => &[96], RootTree::TokenBalances => &[16], RootTree::NonUniquePublicKeyKeyHashesToIdentities => &[8], RootTree::Versions => &[120], + RootTree::Votes => &[112], } } } diff --git a/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/mod.rs b/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/mod.rs new file mode 100644 index 0000000000..cf81b63c8d --- /dev/null +++ b/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/mod.rs @@ -0,0 +1,61 @@ +mod v0; + +use crate::drive::object_size_info::OwnedDocumentInfo; +use crate::drive::Drive; + +use crate::error::drive::DriveError; +use crate::error::Error; + +use dpp::block::block_info::BlockInfo; +use dpp::fee::fee_result::FeeResult; +use dpp::identifier::Identifier; + +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +impl Drive { + /// Adds a document using bincode serialization + /// + /// # Parameters + /// * `owned_document_info`: The document info to be added. + /// * `data_contract_id`: The identifier for the data contract. + /// * `document_type_name`: The document type name. + /// * `override_document`: Whether to override the document. + /// * `block_info`: The block info. + /// * `apply`: Whether to apply the operation. + /// * `transaction`: The transaction argument. + /// * `platform_version`: The platform version to select the correct function version to run. + /// + /// # Returns + /// * `Ok(FeeResult)` if the operation was successful. + /// * `Err(DriveError::UnknownVersionMismatch)` if the drive version does not match known versions. + pub fn add_new_masternode_vote_type( + &self, + owned_document_info: OwnedDocumentInfo, + data_contract_id: Identifier, + document_type_name: &str, + override_document: bool, + block_info: &BlockInfo, + apply: bool, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + match platform_version.drive.methods.document.insert.add_document { + 0 => self.add_document_v0( + owned_document_info, + data_contract_id, + document_type_name, + override_document, + block_info, + apply, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "add_document".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/rs-drive/src/drive/votes/insert/mod.rs b/packages/rs-drive/src/drive/votes/insert/mod.rs new file mode 100644 index 0000000000..da7f9477b8 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/insert/mod.rs @@ -0,0 +1 @@ +mod add_new_masternode_vote_type; \ No newline at end of file diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs new file mode 100644 index 0000000000..5ca93d23b2 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -0,0 +1 @@ +mod insert; \ No newline at end of file diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index d544d36320..ef3b2234e8 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -20,6 +20,7 @@ pub struct DriveMethodVersions { pub protocol_upgrade: DriveProtocolUpgradeVersions, pub balances: DriveBalancesMethodVersions, pub document: DriveDocumentMethodVersions, + pub vote: DriveVoteMethodVersions, pub contract: DriveContractMethodVersions, pub fees: DriveFeesMethodVersions, pub estimated_costs: DriveEstimatedCostsMethodVersions, @@ -197,6 +198,16 @@ pub struct DriveSystemEstimationCostsMethodVersions { pub for_total_system_credits_update: FeatureVersion, } +#[derive(Clone, Debug, Default)] +pub struct DriveVoteMethodVersions { + pub insert: DriveVoteInsertMethodVersions, +} + +#[derive(Clone, Debug, Default)] +pub struct DriveVoteInsertMethodVersions { + pub add_new_masternode_vote_type: FeatureVersion, +} + #[derive(Clone, Debug, Default)] pub struct DriveDocumentMethodVersions { pub query: DriveDocumentQueryMethodVersions, diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 8795e0a151..d69f4ca4ed 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -549,6 +549,12 @@ pub(crate) const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { state: 0, transform_into_action: 0, }, + masternode_vote_state_transition: DriveAbciStateTransitionValidationVersion { + structure: 0, + identity_signatures: None, + state: 0, + transform_into_action: 0, + }, contract_create_state_transition: DriveAbciStateTransitionValidationVersion { structure: 0, identity_signatures: None, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index fe3d063551..fef4ec040c 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -549,6 +549,12 @@ pub(crate) const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { state: 0, transform_into_action: 0, }, + masternode_vote_state_transition: DriveAbciStateTransitionValidationVersion { + structure: 0, + identity_signatures: None, + state: 0, + transform_into_action: 0, + }, contract_create_state_transition: DriveAbciStateTransitionValidationVersion { structure: 0, identity_signatures: None, From fba087b6e75f55fc35619b0bdfab464d31e203aa Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 3 Oct 2023 08:45:54 +0700 Subject: [PATCH 008/135] more work --- .../accessors/mod.rs | 2 +- .../accessors/v0/mod.rs | 3 +- .../tests/strategy_tests/core_update_tests.rs | 14 ++- .../tests/strategy_tests/failures.rs | 2 + .../tests/strategy_tests/frequency.rs | 1 + .../tests/strategy_tests/main.rs | 80 ++++++++++++++++ .../tests/strategy_tests/masternodes.rs | 20 ++++ .../strategy_tests/upgrade_fork_tests.rs | 12 +++ .../tests/strategy_tests/voting_tests.rs | 91 +++++++++++++++++++ packages/rs-drive/src/drive/mod.rs | 2 +- .../add_new_masternode_vote_type/v0/mod.rs | 1 + .../rs-drive/src/drive/votes/insert/mod.rs | 2 +- packages/rs-drive/src/drive/votes/mod.rs | 2 +- .../src/version/mocks/v2_test.rs | 6 ++ .../src/version/mocks/v3_test.rs | 6 ++ .../rs-platform-version/src/version/v1.rs | 6 ++ 16 files changed, 242 insertions(+), 8 deletions(-) create mode 100644 packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/mod.rs index c5f4ccf461..acdf95c6f2 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/mod.rs @@ -1,9 +1,9 @@ mod v0; use crate::state_transition::masternode_vote_transition::MasternodeVoteTransition; +use crate::voting::Vote; use platform_value::Identifier; pub use v0::*; -use crate::voting::Vote; impl MasternodeVoteTransitionAccessorsV0 for MasternodeVoteTransition { fn pro_tx_hash(&self) -> Identifier { diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/v0/mod.rs index cb41fa3e9b..319cc487cc 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/v0/mod.rs @@ -1,6 +1,5 @@ - -use platform_value::Identifier; use crate::voting::Vote; +use platform_value::Identifier; pub trait MasternodeVoteTransitionAccessorsV0 { fn pro_tx_hash(&self) -> Identifier; diff --git a/packages/rs-drive-abci/tests/strategy_tests/core_update_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/core_update_tests.rs index cab5e2bf51..9471bda131 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/core_update_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/core_update_tests.rs @@ -18,6 +18,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -26,6 +27,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, proposer_strategy: MasternodeListChangesStrategy { new_hpmns: Default::default(), @@ -34,6 +36,7 @@ mod tests { banned_hpmns: Frequency { times_per_block_range: 1..2, chance_per_block: Some(0.1), + only_once: false, }, unbanned_hpmns: Default::default(), changed_ip_hpmns: Default::default(), @@ -116,6 +119,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -124,12 +128,14 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, proposer_strategy: MasternodeListChangesStrategy { new_hpmns: Default::default(), removed_hpmns: Frequency { times_per_block_range: 1..2, chance_per_block: Some(0.1), + only_once: false, }, updated_hpmns: Default::default(), banned_hpmns: Default::default(), @@ -200,6 +206,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -208,6 +215,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, proposer_strategy: MasternodeListChangesStrategy { new_hpmns: Default::default(), @@ -215,11 +223,13 @@ mod tests { updated_hpmns: Default::default(), banned_hpmns: Frequency { times_per_block_range: 1..2, - chance_per_block: Some(0.1), //lower chance of banning + chance_per_block: Some(0.1), + only_once: false, //lower chance of banning }, unbanned_hpmns: Frequency { times_per_block_range: 1..2, - chance_per_block: Some(0.3), //higher chance of unbanning + chance_per_block: Some(0.3), + only_once: false, //higher chance of unbanning }, changed_ip_hpmns: Default::default(), changed_p2p_port_hpmns: Default::default(), diff --git a/packages/rs-drive-abci/tests/strategy_tests/failures.rs b/packages/rs-drive-abci/tests/strategy_tests/failures.rs index 75b177abcb..8820259e8f 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/failures.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/failures.rs @@ -19,6 +19,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -27,6 +28,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), diff --git a/packages/rs-drive-abci/tests/strategy_tests/frequency.rs b/packages/rs-drive-abci/tests/strategy_tests/frequency.rs index 86a7b7ddc2..59f1e74f19 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/frequency.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/frequency.rs @@ -8,6 +8,7 @@ use std::ops::Range; pub struct Frequency { pub times_per_block_range: Range, //insertion count when block is chosen pub chance_per_block: Option, //chance of insertion if set + pub only_once: bool, //if set to true, only do this operation once } impl Frequency { diff --git a/packages/rs-drive-abci/tests/strategy_tests/main.rs b/packages/rs-drive-abci/tests/strategy_tests/main.rs index 84927ce534..815013043b 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/main.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/main.rs @@ -56,6 +56,7 @@ mod strategy; mod transitions; mod upgrade_fork_tests; mod verify_state_transitions; +mod voting_tests; pub type BlockHeight = u64; @@ -119,6 +120,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -127,6 +129,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -167,6 +170,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -175,6 +179,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -215,6 +220,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -223,6 +229,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -343,6 +350,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -351,6 +359,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -404,6 +413,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -452,6 +462,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -460,6 +471,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..3, chance_per_block: Some(0.5), + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -508,6 +520,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, total_hpmns: 500, extra_normal_mns: 0, @@ -516,6 +529,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 5..6, chance_per_block: Some(0.5), + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: true, @@ -587,6 +601,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -595,11 +610,13 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: Some(0.2), + only_once: false, }, proposer_strategy: MasternodeListChangesStrategy { new_hpmns: Frequency { times_per_block_range: 1..3, chance_per_block: Some(0.5), + only_once: false, }, ..Default::default() }, @@ -650,6 +667,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -658,15 +676,18 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: Some(0.2), + only_once: false, }, proposer_strategy: MasternodeListChangesStrategy { new_hpmns: Frequency { times_per_block_range: 1..3, chance_per_block: Some(0.5), + only_once: false, }, removed_hpmns: Frequency { times_per_block_range: 1..3, chance_per_block: Some(0.5), + only_once: false, }, ..Default::default() }, @@ -716,6 +737,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -724,11 +746,13 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: Some(0.2), + only_once: false, }, proposer_strategy: MasternodeListChangesStrategy { updated_hpmns: Frequency { times_per_block_range: 1..3, chance_per_block: Some(0.5), + only_once: false, }, ..Default::default() }, @@ -809,6 +833,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -817,6 +842,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -825,6 +851,7 @@ mod tests { query_identities_by_public_key_hashes: Frequency { times_per_block_range: 1..5, chance_per_block: None, + only_once: false, }, }), verify_state_transition_results: true, @@ -863,6 +890,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -871,6 +899,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -940,6 +969,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -948,6 +978,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1043,6 +1074,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -1051,6 +1083,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1133,11 +1166,13 @@ mod tests { frequency: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, }], identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -1146,6 +1181,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1205,11 +1241,13 @@ mod tests { frequency: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, }], identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -1218,6 +1256,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1297,6 +1336,7 @@ mod tests { frequency: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, }, Operation { @@ -1304,12 +1344,14 @@ mod tests { frequency: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, }, ], identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -1318,6 +1360,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1397,6 +1440,7 @@ mod tests { frequency: Frequency { times_per_block_range: 1..10, chance_per_block: None, + only_once: false, }, }, Operation { @@ -1404,12 +1448,14 @@ mod tests { frequency: Frequency { times_per_block_range: 1..10, chance_per_block: None, + only_once: false, }, }, ], identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -1418,6 +1464,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1511,6 +1558,7 @@ mod tests { frequency: Frequency { times_per_block_range: 1..40, chance_per_block: None, + only_once: false, }, }, Operation { @@ -1518,12 +1566,14 @@ mod tests { frequency: Frequency { times_per_block_range: 1..15, chance_per_block: None, + only_once: false, }, }, ], identities_inserts: Frequency { times_per_block_range: 1..30, chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -1532,6 +1582,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1623,6 +1674,7 @@ mod tests { frequency: Frequency { times_per_block_range: 1..40, chance_per_block: None, + only_once: false, }, }, Operation { @@ -1630,6 +1682,7 @@ mod tests { frequency: Frequency { times_per_block_range: 1..5, chance_per_block: None, + only_once: false, }, }, Operation { @@ -1637,12 +1690,14 @@ mod tests { frequency: Frequency { times_per_block_range: 1..5, chance_per_block: None, + only_once: false, }, }, ], identities_inserts: Frequency { times_per_block_range: 1..6, chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -1651,6 +1706,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1705,11 +1761,13 @@ mod tests { frequency: Frequency { times_per_block_range: 1..3, chance_per_block: None, + only_once: false, }, }], identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -1718,6 +1776,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1777,11 +1836,13 @@ mod tests { frequency: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, }], identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -1790,6 +1851,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1858,11 +1920,13 @@ mod tests { frequency: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, }], identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -1871,6 +1935,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1938,6 +2003,7 @@ mod tests { frequency: Frequency { times_per_block_range: 1..4, chance_per_block: None, + only_once: false, }, }, Operation { @@ -1945,12 +2011,14 @@ mod tests { frequency: Frequency { times_per_block_range: 1..4, chance_per_block: None, + only_once: false, }, }, ], identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -1959,6 +2027,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -2004,6 +2073,7 @@ mod tests { //we do this to create some paying transactions times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, total_hpmns: 50, extra_normal_mns: 0, @@ -2012,6 +2082,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: true, @@ -2153,6 +2224,7 @@ mod tests { //we do this to create some paying transactions times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, total_hpmns: 500, extra_normal_mns: 0, @@ -2161,6 +2233,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: true, @@ -2272,6 +2345,7 @@ mod tests { //we do this to create some paying transactions times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, total_hpmns: 500, extra_normal_mns: 0, @@ -2280,6 +2354,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: true, @@ -2391,6 +2466,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, total_hpmns: 500, extra_normal_mns: 0, @@ -2399,6 +2475,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -2518,11 +2595,13 @@ mod tests { frequency: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, }], identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, + only_once: false, }, total_hpmns: 100, extra_normal_mns: 0, @@ -2531,6 +2610,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, diff --git a/packages/rs-drive-abci/tests/strategy_tests/masternodes.rs b/packages/rs-drive-abci/tests/strategy_tests/masternodes.rs index cfda8105e1..d7c712a8b8 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/masternodes.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/masternodes.rs @@ -603,42 +603,52 @@ mod tests { update_masternode_keys_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), + only_once: false, }, update_hpmn_keys_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), + only_once: false, }, ban_masternode_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), + only_once: false, }, ban_hpmn_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), + only_once: false, }, unban_masternode_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), + only_once: false, }, unban_hpmn_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), + only_once: false, }, change_masternode_ip_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), + only_once: false, }, change_hpmn_ip_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), + only_once: false, }, change_hpmn_p2p_port_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), + only_once: false, }, change_hpmn_http_port_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), + only_once: false, }, }); let mut rng1 = StdRng::seed_from_u64(12345); @@ -701,42 +711,52 @@ mod tests { update_masternode_keys_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), + only_once: false, }, update_hpmn_keys_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), + only_once: false, }, ban_masternode_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), + only_once: false, }, ban_hpmn_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), + only_once: false, }, unban_masternode_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), + only_once: false, }, unban_hpmn_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), + only_once: false, }, change_masternode_ip_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), + only_once: false, }, change_hpmn_ip_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), + only_once: false, }, change_hpmn_p2p_port_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), + only_once: false, }, change_hpmn_http_port_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), + only_once: false, }, }); diff --git a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs index dacb9afd36..92aaa9301c 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs @@ -34,6 +34,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, total_hpmns: 460, extra_normal_mns: 0, @@ -46,6 +47,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -296,6 +298,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, total_hpmns: 120, extra_normal_mns: 0, @@ -308,6 +311,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -551,6 +555,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, total_hpmns: 200, extra_normal_mns: 0, @@ -563,6 +568,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -721,6 +727,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, total_hpmns: 200, extra_normal_mns: 0, @@ -736,6 +743,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -904,6 +912,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, total_hpmns: 200, extra_normal_mns: 0, @@ -920,6 +929,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1007,6 +1017,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, total_hpmns: 200, extra_normal_mns: 0, @@ -1022,6 +1033,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, + only_once: false, }, proposer_strategy: Default::default(), rotate_quorums: false, diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs new file mode 100644 index 0000000000..0cf3a789a0 --- /dev/null +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -0,0 +1,91 @@ +use crate::execution::run_chain_for_strategy; +use crate::frequency::Frequency; +use crate::operations::{DocumentAction, DocumentOp, Operation, OperationType}; +use crate::query::QueryStrategy; +use crate::strategy::Strategy; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::tests::fixtures::get_dpns_data_contract_fixture; +use drive_abci::config::{PlatformConfig, PlatformTestConfig}; +use drive_abci::test::helpers::setup::TestPlatformBuilder; +use tenderdash_abci::proto::types::CoreChainLock; + +#[test] +fn run_chain_one_username_voting() { + let dpns_contract = get_dpns_data_contract_fixture(None, 1); + + let contract = dpns_contract.data_contract(); + + let document_insertion_op = DocumentOp { + contract: contract.clone(), + action: DocumentAction::DocumentActionInsert, + document_type: contract + .document_type_for_name("contactRequest") + .expect("expected a profile document type") + .to_owned_document_type(), + }; + + let strategy = Strategy { + contracts_with_updates: vec![(dpns_contract, None)], + operations: vec![Operation { + op_type: OperationType::Document(document_insertion_op), + frequency: Frequency { + times_per_block_range: 1..2, + chance_per_block: None, + only_once: true, + }, + }], + identities_inserts: Frequency { + times_per_block_range: 1..2, + chance_per_block: None, + only_once: false, + }, + total_hpmns: 100, + extra_normal_mns: 200, + quorum_count: 24, + upgrading_info: None, + core_height_increase: Frequency { + times_per_block_range: Default::default(), + chance_per_block: None, + only_once: false, + }, + proposer_strategy: Default::default(), + rotate_quorums: false, + failure_testing: None, + query_testing: Some(QueryStrategy { + query_identities_by_public_key_hashes: Frequency { + times_per_block_range: 1..5, + chance_per_block: None, + only_once: false, + }, + }), + verify_state_transition_results: true, + }; + + let config = PlatformConfig { + verify_sum_trees: true, + quorum_size: 100, + validator_set_quorum_rotation_block_count: 25, + block_spacing_ms: 3000, + testing_configs: PlatformTestConfig::default(), + ..Default::default() + }; + + let mut platform = TestPlatformBuilder::new() + .with_config(config.clone()) + .build_with_mock_rpc(); + + platform + .core_rpc + .expect_get_best_chain_lock() + .returning(move || { + Ok(CoreChainLock { + core_block_height: 10, + core_block_hash: [1; 32].to_vec(), + signature: [2; 96].to_vec(), + }) + }); + + let outcome = run_chain_for_strategy(&mut platform, 100, strategy, config, 15); + + assert_eq!(outcome.identities.len(), 100); +} diff --git a/packages/rs-drive/src/drive/mod.rs b/packages/rs-drive/src/drive/mod.rs index d2dc2609ac..7bab43ffee 100644 --- a/packages/rs-drive/src/drive/mod.rs +++ b/packages/rs-drive/src/drive/mod.rs @@ -157,7 +157,7 @@ pub enum RootTree { /// Versions desired by proposers Versions = 120, /// Registered votes - Votes = 112 + Votes = 112, } /// Storage cost diff --git a/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs index e69de29bb2..8b13789179 100644 --- a/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs @@ -0,0 +1 @@ + diff --git a/packages/rs-drive/src/drive/votes/insert/mod.rs b/packages/rs-drive/src/drive/votes/insert/mod.rs index da7f9477b8..9e070614cd 100644 --- a/packages/rs-drive/src/drive/votes/insert/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/mod.rs @@ -1 +1 @@ -mod add_new_masternode_vote_type; \ No newline at end of file +mod add_new_masternode_vote_type; diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 5ca93d23b2..b8e5d32bb8 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -1 +1 @@ -mod insert; \ No newline at end of file +mod insert; diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 6a79b830a5..0fdd8b5e9e 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -51,6 +51,7 @@ use crate::version::drive_versions::{ DriveSystemProtocolVersionMethodVersions, DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVersion, + DriveVoteInsertMethodVersions, DriveVoteMethodVersions, }; use crate::version::mocks::TEST_BYTES; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; @@ -179,6 +180,11 @@ pub(crate) const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { validate_uniqueness_of_data: 0, }, }, + vote: DriveVoteMethodVersions { + insert: DriveVoteInsertMethodVersions { + add_new_masternode_vote_type: 0, + }, + }, contract: DriveContractMethodVersions { prove: DriveContractProveMethodVersions { prove_contract: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 5839e10798..b3446dfdd0 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -51,6 +51,7 @@ use crate::version::drive_versions::{ DriveSystemProtocolVersionMethodVersions, DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVersion, + DriveVoteInsertMethodVersions, DriveVoteMethodVersions, }; use crate::version::mocks::TEST_BYTES; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; @@ -179,6 +180,11 @@ pub(crate) const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { validate_uniqueness_of_data: 0, }, }, + vote: DriveVoteMethodVersions { + insert: DriveVoteInsertMethodVersions { + add_new_masternode_vote_type: 0, + }, + }, contract: DriveContractMethodVersions { prove: DriveContractProveMethodVersions { prove_contract: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 44a42a2942..df4a8462a5 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -51,6 +51,7 @@ use crate::version::drive_versions::{ DriveSystemProtocolVersionMethodVersions, DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVersion, + DriveVoteInsertMethodVersions, DriveVoteMethodVersions, }; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; use crate::version::{AbciStructureVersion, PlatformArchitectureVersion}; @@ -176,6 +177,11 @@ pub(super) const PLATFORM_V1: PlatformVersion = PlatformVersion { validate_uniqueness_of_data: 0, }, }, + vote: DriveVoteMethodVersions { + insert: DriveVoteInsertMethodVersions { + add_new_masternode_vote_type: 0, + }, + }, contract: DriveContractMethodVersions { prove: DriveContractProveMethodVersions { prove_contract: 0, From 9799f743d0b0511700bf27340c1888dfb5d61f9c Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 6 Oct 2023 14:05:41 +0700 Subject: [PATCH 009/135] more work on masternode voting --- packages/rs-dpp/src/errors/protocol_error.rs | 3 + packages/rs-dpp/src/voting/mod.rs | 63 ++++++-- .../src/drive/initialization/v0/mod.rs | 4 + .../rs-drive/src/drive/votes/cleanup/mod.rs | 2 + .../cleanup/remove_votes_for_identity/mod.rs | 37 +++++ .../remove_votes_for_identity/v0/mod.rs | 56 +++++++ .../contested_resource/individual_vote/mod.rs | 2 + .../mod.rs | 39 +++++ .../v0/mod.rs | 34 +++++ .../mod.rs | 38 +++++ .../v0/mod.rs | 0 .../votes/insert/contested_resource/mod.rs | 3 + .../add_vote_poll_end_date_query/mod.rs | 37 +++++ .../add_vote_poll_end_date_query/v0/mod.rs | 0 .../contested_resource/vote_poll/mod.rs | 1 + .../rs-drive/src/drive/votes/insert/mod.rs | 2 + .../insert/register_identity_vote/mod.rs | 36 +++++ .../insert/register_identity_vote/v0/mod.rs | 23 +++ packages/rs-drive/src/drive/votes/mod.rs | 138 ++++++++++++++++++ .../rs-drive/src/drive/votes/setup/mod.rs | 1 + .../mod.rs | 26 ++++ .../v0/mod.rs | 72 +++++++++ .../src/version/drive_versions.rs | 21 ++- .../src/version/mocks/v2_test.rs | 4 +- .../src/version/mocks/v3_test.rs | 4 +- .../rs-platform-version/src/version/v1.rs | 4 +- 26 files changed, 629 insertions(+), 21 deletions(-) create mode 100644 packages/rs-drive/src/drive/votes/cleanup/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/insert/contested_resource/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/setup/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs diff --git a/packages/rs-dpp/src/errors/protocol_error.rs b/packages/rs-dpp/src/errors/protocol_error.rs index 57ee6eb63b..97977684f7 100644 --- a/packages/rs-dpp/src/errors/protocol_error.rs +++ b/packages/rs-dpp/src/errors/protocol_error.rs @@ -199,6 +199,9 @@ pub enum ProtocolError { raw_identity: Value, }, + #[error("vote error {0}")] + VoteError(String), + #[error("Public key generation error {0}")] PublicKeyGenerationError(String), diff --git a/packages/rs-dpp/src/voting/mod.rs b/packages/rs-dpp/src/voting/mod.rs index 2c11210b08..4b722ea219 100644 --- a/packages/rs-dpp/src/voting/mod.rs +++ b/packages/rs-dpp/src/voting/mod.rs @@ -3,16 +3,59 @@ use crate::voting::Vote::ContestedDocumentResourceVote; use bincode::{Decode, Encode}; use platform_value::{Identifier, Value}; use serde::{Deserialize, Serialize}; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +use crate::data_contract::accessors::v0::DataContractV0Getters; +use crate::data_contract::document_type::accessors::DocumentTypeV0Getters; +use crate::prelude::DataContract; +use crate::ProtocolError; pub mod common_vote; pub mod resource_vote; -type ContractId = Identifier; -type DocumentTypeName = String; +#[derive(Debug, Clone, Encode, Decode, PartialEq)] +#[cfg_attr( +feature = "state-transition-serde-conversion", +derive(Serialize, Deserialize), +serde(rename_all = "camelCase") +)] +pub struct ContestedDocumentResourceVotePoll { + pub contract_id: Identifier, + pub document_type_name: String, + pub index_name: String, + pub index_values: Vec, +} + +impl Default for ContestedDocumentResourceVotePoll { + fn default() -> Self { + ContestedDocumentResourceVotePoll { + contract_id: Default::default(), + document_type_name: "".to_string(), + index_name: "".to_string(), + index_values: vec![], + } + } +} -type IndexName = String; +#[derive(Debug, Clone, Encode, Decode, PlatformDeserialize, PlatformSerialize, PartialEq)] +#[cfg_attr( +feature = "state-transition-serde-conversion", +derive(Serialize, Deserialize), +serde(rename_all = "camelCase") +)] +#[platform_serialize(unversioned)] +pub struct ContestedDocumentResourceVoteType { + pub vote_poll: ContestedDocumentResourceVotePoll, + pub resource_vote: ResourceVote, +} -type IndexValues = Vec; +impl Default for ContestedDocumentResourceVoteType { + fn default() -> Self { + ContestedDocumentResourceVoteType { + vote_poll: ContestedDocumentResourceVotePoll::default(), + resource_vote: ResourceVote::Abstain, + } + } +} #[derive(Debug, Clone, Encode, Decode, PartialEq)] #[cfg_attr( @@ -22,22 +65,14 @@ type IndexValues = Vec; )] pub enum Vote { ContestedDocumentResourceVote( - ContractId, - DocumentTypeName, - IndexName, - IndexValues, - ResourceVote, + ContestedDocumentResourceVoteType, ), } impl Default for Vote { fn default() -> Self { ContestedDocumentResourceVote( - Identifier::default(), - String::default(), - String::default(), - Vec::default(), - ResourceVote::Abstain, + ContestedDocumentResourceVoteType::default() ) } } diff --git a/packages/rs-drive/src/drive/initialization/v0/mod.rs b/packages/rs-drive/src/drive/initialization/v0/mod.rs index 8559cffcf5..9461ac97ee 100644 --- a/packages/rs-drive/src/drive/initialization/v0/mod.rs +++ b/packages/rs-drive/src/drive/initialization/v0/mod.rs @@ -196,6 +196,10 @@ impl Drive { self.grove_apply_batch(batch, false, transaction, drive_version)?; + // We can then setup the initial vote tree main structure + + self.setup_initial_vote_tree_main_structure(transaction, platform_version)?; + Ok(()) } } diff --git a/packages/rs-drive/src/drive/votes/cleanup/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/mod.rs new file mode 100644 index 0000000000..1c1f9dbd0a --- /dev/null +++ b/packages/rs-drive/src/drive/votes/cleanup/mod.rs @@ -0,0 +1,2 @@ + +mod remove_votes_for_identity; diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs new file mode 100644 index 0000000000..fe63d862a6 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs @@ -0,0 +1,37 @@ +mod v0; + +use crate::drive::Drive; + +use crate::error::drive::DriveError; +use crate::error::Error; + +use dpp::fee::fee_result::FeeResult; + +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; +use dpp::prelude::Identifier; + +impl Drive { + + /// We remove votes for an identity when that identity is somehow disabled. Currently there is + /// no way to "disable" identities except for masternodes being removed from the list + pub fn remove_votes_for_identity( + &self, + identity_id: Identifier, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version.drive.methods.vote.cleanup.remove_votes_for_identity { + 0 => self.remove_votes_for_identity_v0( + identity_id + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "remove_votes_for_identity".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} \ No newline at end of file diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs new file mode 100644 index 0000000000..b66cfa256c --- /dev/null +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs @@ -0,0 +1,56 @@ +use std::ops::RangeFull; +use crate::drive::Drive; + +use crate::error::drive::DriveError; +use crate::error::Error; + +use dpp::version::PlatformVersion; +use grovedb::{Element, PathQuery, Query, SizedQuery, TransactionArg}; +use grovedb::query_result_type::QueryResultType::QueryElementResultType; +use dpp::prelude::Identifier; +use dpp::serialization::PlatformDeserializable; +use dpp::voting::ContestedDocumentResourceVoteType; +use crate::drive::grove_operations::BatchDeleteApplyType; +use crate::drive::votes::{vote_contested_resource_identity_votes_tree_path_for_identity_vec}; +use crate::query::QueryItem; + +impl Drive { + + /// We remove votes for an identity when that identity is somehow disabled. Currently there is + /// no way to "disable" identities except for masternodes being removed from the list + pub(super) fn remove_votes_for_identity_v0( + &self, + identity_id: Identifier, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + // We first query for all votes that the identity has + + let vote_path = vote_contested_resource_identity_votes_tree_path_for_identity_vec(identity_id.as_bytes()); + + let path_query = PathQuery::new(vote_path, SizedQuery::new(Query::new_single_query_item(QueryItem::RangeFull(RangeFull)), Some(512), None)); + + let votes_to_remove_elements = self.grove_get_path_query(&path_query, transaction, QueryElementResultType, &mut vec![], &platform_version.drive)?.0.to_elements(); + + // Then we take each vote and go looking for it (to remove it) + + let mut deletion_batch = vec![]; + + for vote_to_remove in votes_to_remove_elements { + let Element::Item(vote, ..) = vote_to_remove else { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!("vote {:?} for identity {} is not an item", vote_to_remove, identity_id)))); + }; + + let vote = ContestedDocumentResourceVoteType::deserialize_from_bytes(vote.as_slice())?; + + // we then need to add to the batch the deletion + + self.batch_delete(vote.tree_path(), vote.tree_key(), BatchDeleteApplyType::StatefulBatchDelete { is_known_to_be_subtree_with_sum: Some((false, false)) }, transaction, &mut deletion_batch, &platform_version.drive)?; + } + + + self. + + Ok(()) + } +} \ No newline at end of file diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/mod.rs new file mode 100644 index 0000000000..7c11c116cf --- /dev/null +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/mod.rs @@ -0,0 +1,2 @@ +mod register_contested_resource_identity_vote; +mod register_identity_vote_for_identity_queries; diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs new file mode 100644 index 0000000000..fc88d03aac --- /dev/null +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs @@ -0,0 +1,39 @@ +mod v0; + +use crate::drive::Drive; + +use crate::error::drive::DriveError; +use crate::error::Error; + +use dpp::fee::fee_result::FeeResult; + +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; +use dpp::block::block_info::BlockInfo; +use dpp::voting::{ContestedDocumentResourceVoteType, Vote}; + +impl Drive { + pub fn register_contested_resource_identity_vote( + &self, + vote: ContestedDocumentResourceVoteType, + block_info: &BlockInfo, + apply: bool, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + match platform_version.drive.methods.vote.contested_resource_insert.register_identity_vote { + 0 => self.register_contested_resource_identity_vote_v0( + vote, + block_info, + apply, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "register_identity_vote".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs new file mode 100644 index 0000000000..4826c7d8ba --- /dev/null +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -0,0 +1,34 @@ +use grovedb::TransactionArg; +use dpp::block::block_info::BlockInfo; +use dpp::fee::fee_result::FeeResult; +use dpp::voting::{ContestedDocumentResourceVoteType, Vote}; +use platform_version::version::PlatformVersion; +use crate::drive::Drive; +use crate::error::document::DocumentError; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; + +impl Drive { + pub fn register_contested_resource_identity_vote_v0( + &self, + vote: ContestedDocumentResourceVoteType, + block_info: &BlockInfo, + apply: bool, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + // let's start by creating a batch of operations + let mut drive_operations: Vec = vec![]; + + let contract_fetch_info = self + .get_contract_with_fetch_info_and_add_to_operations( + vote.contract_id.to_buffer(), + Some(&block_info.epoch), + true, + transaction, + &mut drive_operations, + platform_version, + )? + .ok_or(Error::Document(DocumentError::DataContractNotFound))?; + } +} diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/mod.rs new file mode 100644 index 0000000000..32b8645aa7 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/mod.rs @@ -0,0 +1,38 @@ +mod v0; + +use crate::drive::Drive; + +use crate::error::drive::DriveError; +use crate::error::Error; + +use dpp::fee::fee_result::FeeResult; + +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; +use dpp::prelude::Identifier; + +impl Drive { + + /// We register the identity vote to be able to query the current votes of an identity, or to + /// be able to remove votes from a "disabled" identity (ie a masternode that was removed from + /// the list). + pub fn register_identity_vote_for_identity_queries( + &self, + identity_id: Identifier, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + match platform_version.drive.methods.vote.contested_resource_insert.register_identity_vote_for_identity_queries { + 0 => self.register_identity_vote_for_identity_queries_v0( + identity_id, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "register_identity_vote_for_identity_queries".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} \ No newline at end of file diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/v0/mod.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/mod.rs new file mode 100644 index 0000000000..cd377f2ee7 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/mod.rs @@ -0,0 +1,3 @@ +mod individual_vote; + +mod vote_poll; diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/mod.rs new file mode 100644 index 0000000000..2af3c3018e --- /dev/null +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/mod.rs @@ -0,0 +1,37 @@ +mod v0; + +use crate::drive::Drive; + +use crate::error::drive::DriveError; +use crate::error::Error; + +use dpp::fee::fee_result::FeeResult; + +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; +use dpp::prelude::Identifier; + +impl Drive { + + /// We add vote poll references by end date in order to be able to check on every new block if + /// any vote poll should be closed. + pub fn add_vote_poll_end_date_query( + &self, + identity_id: Identifier, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + match platform_version.drive.methods.vote.contested_resource_insert.register_identity_vote_for_identity_queries { + 0 => self.add_vote_poll_end_date_query_v0( + identity_id, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "register_identity_vote_for_identity_queries".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} \ No newline at end of file diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/mod.rs new file mode 100644 index 0000000000..601f917296 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/mod.rs @@ -0,0 +1 @@ +mod add_vote_poll_end_date_query; diff --git a/packages/rs-drive/src/drive/votes/insert/mod.rs b/packages/rs-drive/src/drive/votes/insert/mod.rs index 9e070614cd..128f3014fe 100644 --- a/packages/rs-drive/src/drive/votes/insert/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/mod.rs @@ -1 +1,3 @@ mod add_new_masternode_vote_type; +mod register_identity_vote; +mod contested_resource; diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs new file mode 100644 index 0000000000..3725d55ab4 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs @@ -0,0 +1,36 @@ +mod v0; + +use crate::drive::Drive; + +use crate::error::drive::DriveError; +use crate::error::Error; + +use dpp::fee::fee_result::FeeResult; + +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; +use dpp::voting::Vote; + +impl Drive { + pub fn register_identity_vote( + &self, + vote: Vote, + apply: bool, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + match platform_version.drive.methods.vote.contested_resource_insert.register_identity_vote { + 0 => self.register_identity_vote_v0( + vote, + apply, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "register_identity_vote".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs new file mode 100644 index 0000000000..d169bb589a --- /dev/null +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs @@ -0,0 +1,23 @@ +use grovedb::TransactionArg; +use dpp::fee::fee_result::FeeResult; +use dpp::voting::Vote; +use platform_version::version::PlatformVersion; +use crate::drive::Drive; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; + +impl Drive { + pub fn register_identity_vote( + &self, + vote: Vote, + apply: bool, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + match vote { + Vote::ContestedDocumentResourceVote(contested_document_resource_vote_type) => { + self.register_contested_resource_identity_vote(contested_document_resource_vote_type, apply, transaction, platform_version) + } + } + } +} diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index b8e5d32bb8..1152be443d 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -1 +1,139 @@ +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::DataContract; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::ProtocolError; +use dpp::util::vec; +use dpp::voting::ContestedDocumentResourceVoteType; +use crate::drive::document::{contract_document_type_path, contract_document_type_path_vec}; +use crate::drive::RootTree; + mod insert; +mod setup; +mod cleanup; + + +/// The vote tree structure looks likes this +/// +/// Votes +/// +/// |- Decisions [key: "d"] +/// |- Contested Resource [key: "c"] +/// |- End date Queries [key: "e"] +/// |- Identifier Votes Query [key: "i"] +/// +/// + +pub const VOTE_DECISIONS_TREE_KEY: char = 'd'; + +pub const CONTESTED_RESOURCE_TREE_KEY: char = 'c'; + +pub const END_DATE_QUERIES_TREE_KEY: char = 'e'; + +pub const IDENTITY_VOTES_TREE_KEY: char = 'i'; + + +pub(in crate::drive::votes) fn vote_root_path<'a>() -> [&'a [u8]; 1] { + [ + Into::<&[u8; 1]>::into(RootTree::Votes), + ] +} + +pub(in crate::drive::votes) fn vote_decisions_tree_path<'a>() -> [&'a [u8]; 2] { + [ + Into::<&[u8; 1]>::into(RootTree::Votes), + Into::<&[u8; 1]>::into(VOTE_DECISIONS_TREE_KEY), + ] +} + +pub(in crate::drive::votes) fn vote_contested_resource_tree_path<'a>() -> [&'a [u8]; 2] { + [ + Into::<&[u8; 1]>::into(RootTree::Votes), + Into::<&[u8; 1]>::into(CONTESTED_RESOURCE_TREE_KEY), + ] +} + +pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_tree_path<'a>() -> [&'a [u8]; 3] { + [ + Into::<&[u8; 1]>::into(RootTree::Votes), + Into::<&[u8; 1]>::into(CONTESTED_RESOURCE_TREE_KEY), + Into::<&[u8; 1]>::into(END_DATE_QUERIES_TREE_KEY), + ] +} + +pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path<'a>() -> [&'a [u8]; 3] { + [ + Into::<&[u8; 1]>::into(RootTree::Votes), + Into::<&[u8; 1]>::into(CONTESTED_RESOURCE_TREE_KEY), + Into::<&[u8; 1]>::into(IDENTITY_VOTES_TREE_KEY), + ] +} + +pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_for_identity<'a>(identity_id: &[u8; 32]) -> [&'a [u8]; 4] { + [ + Into::<&[u8; 1]>::into(RootTree::Votes), + Into::<&[u8; 1]>::into(CONTESTED_RESOURCE_TREE_KEY), + Into::<&[u8; 1]>::into(IDENTITY_VOTES_TREE_KEY), + identity_id, + ] +} + +pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_for_identity_vec(identity_id: &[u8; 32]) -> Vec> { + vec![ + vec![RootTree::Votes as u8], + vec![CONTESTED_RESOURCE_TREE_KEY as u8], + vec![IDENTITY_VOTES_TREE_KEY as u8], + identity_id.to_vec(), + ] +} + +pub trait TreePath { + fn tree_path(&self, contract: &DataContract) -> Result, ProtocolError>; +} + + +impl TreePath for ContestedDocumentResourceVoteType { + fn tree_path(&self, contract: &DataContract) -> Result, ProtocolError> { + if contract.id() != self.vote_poll.contract_id { + return Err(ProtocolError::VoteError(format!("contract id of vote {} does not match supplied contract {}", self.vote_poll.contract_id, contract.id()))); + } + let document_type = contract.document_type_for_name(&self.vote_poll.document_type_name)?; + let index = document_type.indices().iter().find(|index| &index.name == &self.vote_poll.index_name).ok_or(ProtocolError::VoteError(format!("vote index name {} not found", &self.vote_poll.index_name)))?; + let mut path = contract_document_type_path(&self.vote_poll.contract_id.as_bytes(), &self.vote_poll.document_type_name).to_vec(); + + // at this point the path only contains the parts before the index + + let Some(contested_index) = &index.contested_index else { + return Err(ProtocolError::VoteError("we expect the index in a contested document resource vote type to be contested".to_string())); + }; + let mut properties_iter = index.properties.iter().peekable(); + + while let Some(index_part) = properties_iter.next() { + let level_name = if contested_index.contested_field_name == index_part.name { + &contested_index.contested_field_temp_replacement_name + } else { + &index_part.name + }; + + // The last property + if properties_iter.peek().is_none() { + // This level already has been initialized. + // It means there are two indices with the same combination of properties. + + // We might need to take into account the sorting order when we have it + if current_level.has_index_with_type.is_some() { + // an index already exists return error + return Err(ConsensusError::BasicError( + BasicError::DuplicateIndexError(DuplicateIndexError::new( + document_type_name.to_owned(), + level_name.clone(), + )), + ) + .into()); + } + + current_level.has_index_with_type = Some(ContestedResourceIndex); + } + } + } + } +} diff --git a/packages/rs-drive/src/drive/votes/setup/mod.rs b/packages/rs-drive/src/drive/votes/setup/mod.rs new file mode 100644 index 0000000000..e2189c9af4 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/setup/mod.rs @@ -0,0 +1 @@ +mod setup_initial_vote_tree_main_structure; \ No newline at end of file diff --git a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs new file mode 100644 index 0000000000..d955d3cdfb --- /dev/null +++ b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs @@ -0,0 +1,26 @@ +mod v0; + +use crate::drive::Drive; + +use crate::error::drive::DriveError; +use crate::error::Error; + +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +impl Drive { + pub fn setup_initial_vote_tree_main_structure( + &self, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version.drive.methods.vote.setup_initial_vote_tree_main_structure { + 0 => self.setup_initial_vote_tree_main_structure_v0(transaction, platform_version), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "setup_initial_vote_tree_main_structure".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs new file mode 100644 index 0000000000..dabb30318a --- /dev/null +++ b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs @@ -0,0 +1,72 @@ +use grovedb::operations::insert::InsertOptions; +use crate::drive::{Drive, RootTree}; +use crate::error::Error; +use grovedb::TransactionArg; +use grovedb_path::SubtreePath; +use platform_version::version::PlatformVersion; +use crate::drive::votes::{CONTESTED_RESOURCE_TREE_KEY, vote_contested_resource_end_date_queries_tree_path, vote_contested_resource_identity_votes_tree_path, VOTE_DECISIONS_TREE_KEY, vote_root_path}; + +impl Drive { + pub fn setup_initial_vote_tree_main_structure_v0( + &self, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + let drive_version = &platform_version.drive; + + let mut drive_operations = vec![]; + + self.grove_insert_empty_tree( + SubtreePath::from(vote_root_path()), + &[VOTE_DECISIONS_TREE_KEY.into()], + transaction, + Some(InsertOptions { + validate_insertion_does_not_override: true, + validate_insertion_does_not_override_tree: true, + base_root_storage_is_free: true, + }), + &mut drive_operations, + drive_version, + )?; + + self.grove_insert_empty_tree( + SubtreePath::from(vote_root_path()), + &[CONTESTED_RESOURCE_TREE_KEY.into()], + transaction, + Some(InsertOptions { + validate_insertion_does_not_override: true, + validate_insertion_does_not_override_tree: true, + base_root_storage_is_free: true, + }), + &mut drive_operations, + drive_version, + )?; + + + self.grove_insert_empty_tree( + SubtreePath::from(vote_contested_resource_end_date_queries_tree_path()), + &[CONTESTED_RESOURCE_TREE_KEY.into()], + transaction, + Some(InsertOptions { + validate_insertion_does_not_override: true, + validate_insertion_does_not_override_tree: true, + base_root_storage_is_free: true, + }), + &mut drive_operations, + drive_version, + )?; + + self.grove_insert_empty_tree( + SubtreePath::from(vote_contested_resource_identity_votes_tree_path()), + &[CONTESTED_RESOURCE_TREE_KEY.into()], + transaction, + Some(InsertOptions { + validate_insertion_does_not_override: true, + validate_insertion_does_not_override_tree: true, + base_root_storage_is_free: true, + }), + &mut drive_operations, + drive_version, + ) + } +} diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 37aa31c86f..5810d6d5cc 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -201,11 +201,30 @@ pub struct DriveSystemEstimationCostsMethodVersions { #[derive(Clone, Debug, Default)] pub struct DriveVoteMethodVersions { pub insert: DriveVoteInsertMethodVersions, + pub contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions, + pub cleanup: DriveVoteCleanupMethodVersions, + pub setup: DriveVoteSetupMethodVersions, +} + +#[derive(Clone, Debug, Default)] +pub struct DriveVoteSetupMethodVersions { + pub setup_initial_vote_tree_main_structure: FeatureVersion, +} + +#[derive(Clone, Debug, Default)] +pub struct DriveVoteCleanupMethodVersions { + pub remove_votes_for_identity: FeatureVersion, } #[derive(Clone, Debug, Default)] pub struct DriveVoteInsertMethodVersions { - pub add_new_masternode_vote_type: FeatureVersion, + pub register_identity_vote: FeatureVersion, +} + +#[derive(Clone, Debug, Default)] +pub struct DriveVoteContestedResourceInsertMethodVersions { + pub register_contested_resource_identity_vote: FeatureVersion, + pub register_identity_vote_for_identity_queries: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 0fdd8b5e9e..90ca3b3aa5 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -51,7 +51,7 @@ use crate::version::drive_versions::{ DriveSystemProtocolVersionMethodVersions, DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVersion, - DriveVoteInsertMethodVersions, DriveVoteMethodVersions, + DriveVoteContestedResourceInsertMethodVersions, DriveVoteMethodVersions, }; use crate::version::mocks::TEST_BYTES; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; @@ -181,7 +181,7 @@ pub(crate) const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { }, }, vote: DriveVoteMethodVersions { - insert: DriveVoteInsertMethodVersions { + contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { add_new_masternode_vote_type: 0, }, }, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index b3446dfdd0..777e05925c 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -51,7 +51,7 @@ use crate::version::drive_versions::{ DriveSystemProtocolVersionMethodVersions, DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVersion, - DriveVoteInsertMethodVersions, DriveVoteMethodVersions, + DriveVoteContestedResourceInsertMethodVersions, DriveVoteMethodVersions, }; use crate::version::mocks::TEST_BYTES; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; @@ -181,7 +181,7 @@ pub(crate) const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { }, }, vote: DriveVoteMethodVersions { - insert: DriveVoteInsertMethodVersions { + contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { add_new_masternode_vote_type: 0, }, }, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index df4a8462a5..9d3d4a1db2 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -51,7 +51,7 @@ use crate::version::drive_versions::{ DriveSystemProtocolVersionMethodVersions, DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVersion, - DriveVoteInsertMethodVersions, DriveVoteMethodVersions, + DriveVoteContestedResourceInsertMethodVersions, DriveVoteMethodVersions, }; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; use crate::version::{AbciStructureVersion, PlatformArchitectureVersion}; @@ -178,7 +178,7 @@ pub(super) const PLATFORM_V1: PlatformVersion = PlatformVersion { }, }, vote: DriveVoteMethodVersions { - insert: DriveVoteInsertMethodVersions { + contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { add_new_masternode_vote_type: 0, }, }, From 66857cbf9a44c4e5c8e4ff48765a3b9f817b7d7c Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 11 Oct 2023 09:57:15 +0700 Subject: [PATCH 010/135] a little cleanup --- .../tests/strategy_tests/core_update_tests.rs | 20 +- .../tests/strategy_tests/failures.rs | 5 +- .../tests/strategy_tests/frequency.rs | 1 - .../tests/strategy_tests/main.rs | 158 ++++----- .../tests/strategy_tests/masternodes.rs | 40 +-- .../strategy_tests/upgrade_fork_tests.rs | 24 +- .../tests/strategy_tests/voting_tests.rs | 300 +++++++++++++----- .../src/version/mocks/v2_test.rs | 43 +-- .../src/version/mocks/v3_test.rs | 43 +-- .../rs-platform-version/src/version/v1.rs | 43 +-- 10 files changed, 367 insertions(+), 310 deletions(-) diff --git a/packages/rs-drive-abci/tests/strategy_tests/core_update_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/core_update_tests.rs index aab92de122..20c48ccc74 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/core_update_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/core_update_tests.rs @@ -19,7 +19,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -28,7 +28,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, proposer_strategy: MasternodeListChangesStrategy { new_hpmns: Default::default(), @@ -37,7 +37,7 @@ mod tests { banned_hpmns: Frequency { times_per_block_range: 1..2, chance_per_block: Some(0.1), - only_once: false, + }, unbanned_hpmns: Default::default(), changed_ip_hpmns: Default::default(), @@ -125,7 +125,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -134,14 +134,14 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, proposer_strategy: MasternodeListChangesStrategy { new_hpmns: Default::default(), removed_hpmns: Frequency { times_per_block_range: 1..2, chance_per_block: Some(0.1), - only_once: false, + }, updated_hpmns: Default::default(), banned_hpmns: Default::default(), @@ -217,7 +217,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -226,7 +226,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, proposer_strategy: MasternodeListChangesStrategy { new_hpmns: Default::default(), @@ -235,12 +235,12 @@ mod tests { banned_hpmns: Frequency { times_per_block_range: 1..2, chance_per_block: Some(0.1), - only_once: false, //lower chance of banning + //lower chance of banning }, unbanned_hpmns: Frequency { times_per_block_range: 1..2, chance_per_block: Some(0.3), - only_once: false, //higher chance of unbanning + //higher chance of unbanning }, changed_ip_hpmns: Default::default(), changed_p2p_port_hpmns: Default::default(), diff --git a/packages/rs-drive-abci/tests/strategy_tests/failures.rs b/packages/rs-drive-abci/tests/strategy_tests/failures.rs index f2a3b94b8d..6f81a4c40c 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/failures.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/failures.rs @@ -32,7 +32,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -41,7 +41,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), @@ -216,6 +216,7 @@ mod tests { frequency: Frequency { times_per_block_range: 1..2, chance_per_block: None, + }, }, Operation { diff --git a/packages/rs-drive-abci/tests/strategy_tests/frequency.rs b/packages/rs-drive-abci/tests/strategy_tests/frequency.rs index 59f1e74f19..86a7b7ddc2 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/frequency.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/frequency.rs @@ -8,7 +8,6 @@ use std::ops::Range; pub struct Frequency { pub times_per_block_range: Range, //insertion count when block is chosen pub chance_per_block: Option, //chance of insertion if set - pub only_once: bool, //if set to true, only do this operation once } impl Frequency { diff --git a/packages/rs-drive-abci/tests/strategy_tests/main.rs b/packages/rs-drive-abci/tests/strategy_tests/main.rs index 204b0dcd8c..871f562335 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/main.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/main.rs @@ -126,7 +126,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -135,7 +135,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -181,7 +181,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -190,7 +190,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -236,7 +236,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -245,7 +245,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -372,7 +372,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -381,7 +381,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -440,7 +440,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -494,7 +494,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -503,7 +503,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..3, chance_per_block: Some(0.5), - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -621,7 +621,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, total_hpmns: 500, extra_normal_mns: 0, @@ -630,7 +630,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 5..6, chance_per_block: Some(0.5), - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: true, @@ -707,7 +707,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -716,13 +716,13 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: Some(0.2), - only_once: false, + }, proposer_strategy: MasternodeListChangesStrategy { new_hpmns: Frequency { times_per_block_range: 1..3, chance_per_block: Some(0.5), - only_once: false, + }, ..Default::default() }, @@ -778,7 +778,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -787,18 +787,18 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: Some(0.2), - only_once: false, + }, proposer_strategy: MasternodeListChangesStrategy { new_hpmns: Frequency { times_per_block_range: 1..3, chance_per_block: Some(0.5), - only_once: false, + }, removed_hpmns: Frequency { times_per_block_range: 1..3, chance_per_block: Some(0.5), - only_once: false, + }, ..Default::default() }, @@ -853,7 +853,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -862,13 +862,13 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: Some(0.2), - only_once: false, + }, proposer_strategy: MasternodeListChangesStrategy { updated_hpmns: Frequency { times_per_block_range: 1..3, chance_per_block: Some(0.5), - only_once: false, + }, ..Default::default() }, @@ -954,7 +954,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -963,7 +963,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -972,7 +972,7 @@ mod tests { query_identities_by_public_key_hashes: Frequency { times_per_block_range: 1..5, chance_per_block: None, - only_once: false, + }, }), verify_state_transition_results: true, @@ -1016,7 +1016,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -1025,7 +1025,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1100,7 +1100,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -1109,7 +1109,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1210,7 +1210,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -1219,7 +1219,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1309,14 +1309,14 @@ mod tests { frequency: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, }], start_identities: vec![], identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -1325,7 +1325,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1392,14 +1392,14 @@ mod tests { frequency: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, }], start_identities: vec![], identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -1408,7 +1408,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1495,7 +1495,7 @@ mod tests { frequency: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, }, Operation { @@ -1503,7 +1503,7 @@ mod tests { frequency: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, }, ], @@ -1511,7 +1511,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -1520,7 +1520,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1607,7 +1607,7 @@ mod tests { frequency: Frequency { times_per_block_range: 1..10, chance_per_block: None, - only_once: false, + }, }, Operation { @@ -1615,7 +1615,7 @@ mod tests { frequency: Frequency { times_per_block_range: 1..10, chance_per_block: None, - only_once: false, + }, }, ], @@ -1623,7 +1623,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -1632,7 +1632,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1733,7 +1733,7 @@ mod tests { frequency: Frequency { times_per_block_range: 1..40, chance_per_block: None, - only_once: false, + }, }, Operation { @@ -1741,7 +1741,7 @@ mod tests { frequency: Frequency { times_per_block_range: 1..15, chance_per_block: None, - only_once: false, + }, }, ], @@ -1749,7 +1749,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: 1..30, chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -1758,7 +1758,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1858,7 +1858,7 @@ mod tests { frequency: Frequency { times_per_block_range: 1..40, chance_per_block: None, - only_once: false, + }, }, Operation { @@ -1866,7 +1866,7 @@ mod tests { frequency: Frequency { times_per_block_range: 1..5, chance_per_block: None, - only_once: false, + }, }, Operation { @@ -1874,7 +1874,7 @@ mod tests { frequency: Frequency { times_per_block_range: 1..5, chance_per_block: None, - only_once: false, + }, }, ], @@ -1882,7 +1882,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: 1..6, chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -1891,7 +1891,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1951,14 +1951,14 @@ mod tests { frequency: Frequency { times_per_block_range: 1..3, chance_per_block: None, - only_once: false, + }, }], start_identities: vec![], identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -1967,7 +1967,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -2031,14 +2031,14 @@ mod tests { frequency: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, }], start_identities: vec![], identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -2047,7 +2047,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -2120,14 +2120,14 @@ mod tests { frequency: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, }], start_identities: vec![], identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -2136,7 +2136,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -2208,7 +2208,7 @@ mod tests { frequency: Frequency { times_per_block_range: 1..4, chance_per_block: None, - only_once: false, + }, }, Operation { @@ -2216,7 +2216,7 @@ mod tests { frequency: Frequency { times_per_block_range: 1..4, chance_per_block: None, - only_once: false, + }, }, ], @@ -2224,7 +2224,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -2233,7 +2233,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -2284,7 +2284,7 @@ mod tests { //we do this to create some paying transactions times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, total_hpmns: 50, extra_normal_mns: 0, @@ -2293,7 +2293,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: true, @@ -2440,7 +2440,7 @@ mod tests { //we do this to create some paying transactions times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, total_hpmns: 500, extra_normal_mns: 0, @@ -2449,7 +2449,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: true, @@ -2567,7 +2567,7 @@ mod tests { //we do this to create some paying transactions times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, total_hpmns: 500, extra_normal_mns: 0, @@ -2576,7 +2576,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: true, @@ -2694,7 +2694,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, total_hpmns: 500, extra_normal_mns: 0, @@ -2703,7 +2703,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -2829,14 +2829,14 @@ mod tests { frequency: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, }], start_identities: vec![], identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, - only_once: false, + }, total_hpmns: 100, extra_normal_mns: 0, @@ -2845,7 +2845,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, diff --git a/packages/rs-drive-abci/tests/strategy_tests/masternodes.rs b/packages/rs-drive-abci/tests/strategy_tests/masternodes.rs index d7c712a8b8..c8d9549e1f 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/masternodes.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/masternodes.rs @@ -603,52 +603,52 @@ mod tests { update_masternode_keys_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - only_once: false, + }, update_hpmn_keys_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - only_once: false, + }, ban_masternode_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - only_once: false, + }, ban_hpmn_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - only_once: false, + }, unban_masternode_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - only_once: false, + }, unban_hpmn_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - only_once: false, + }, change_masternode_ip_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - only_once: false, + }, change_hpmn_ip_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - only_once: false, + }, change_hpmn_p2p_port_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - only_once: false, + }, change_hpmn_http_port_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - only_once: false, + }, }); let mut rng1 = StdRng::seed_from_u64(12345); @@ -711,52 +711,52 @@ mod tests { update_masternode_keys_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - only_once: false, + }, update_hpmn_keys_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - only_once: false, + }, ban_masternode_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - only_once: false, + }, ban_hpmn_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - only_once: false, + }, unban_masternode_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - only_once: false, + }, unban_hpmn_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - only_once: false, + }, change_masternode_ip_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - only_once: false, + }, change_hpmn_ip_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - only_once: false, + }, change_hpmn_p2p_port_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - only_once: false, + }, change_hpmn_http_port_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - only_once: false, + }, }); diff --git a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs index bafca254c1..6e40252aa0 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs @@ -36,7 +36,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, total_hpmns: 460, extra_normal_mns: 0, @@ -49,7 +49,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -581,7 +581,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, total_hpmns: 120, extra_normal_mns: 0, @@ -594,7 +594,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -850,7 +850,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, total_hpmns: 200, extra_normal_mns: 0, @@ -863,7 +863,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1033,7 +1033,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, total_hpmns: 200, extra_normal_mns: 0, @@ -1049,7 +1049,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1222,7 +1222,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, total_hpmns: 200, extra_normal_mns: 0, @@ -1239,7 +1239,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1337,7 +1337,7 @@ mod tests { identities_inserts: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, total_hpmns: 200, extra_normal_mns: 0, @@ -1353,7 +1353,7 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, + }, proposer_strategy: Default::default(), rotate_quorums: false, diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index 0cf3a789a0..016391ff4d 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -1,91 +1,217 @@ -use crate::execution::run_chain_for_strategy; -use crate::frequency::Frequency; -use crate::operations::{DocumentAction, DocumentOp, Operation, OperationType}; -use crate::query::QueryStrategy; -use crate::strategy::Strategy; -use dpp::data_contract::accessors::v0::DataContractV0Getters; -use dpp::tests::fixtures::get_dpns_data_contract_fixture; -use drive_abci::config::{PlatformConfig, PlatformTestConfig}; -use drive_abci::test::helpers::setup::TestPlatformBuilder; -use tenderdash_abci::proto::types::CoreChainLock; - -#[test] -fn run_chain_one_username_voting() { - let dpns_contract = get_dpns_data_contract_fixture(None, 1); - - let contract = dpns_contract.data_contract(); - - let document_insertion_op = DocumentOp { - contract: contract.clone(), - action: DocumentAction::DocumentActionInsert, - document_type: contract - .document_type_for_name("contactRequest") - .expect("expected a profile document type") - .to_owned_document_type(), - }; - - let strategy = Strategy { - contracts_with_updates: vec![(dpns_contract, None)], - operations: vec![Operation { - op_type: OperationType::Document(document_insertion_op), - frequency: Frequency { - times_per_block_range: 1..2, + + +#[cfg(test)] +mod tests { + use std::collections::BTreeMap; + use rand::prelude::StdRng; + use rand::SeedableRng; + use crate::execution::run_chain_for_strategy; + use crate::frequency::Frequency; + use crate::operations::{DocumentAction, DocumentOp, Operation, OperationType}; + use crate::strategy::Strategy; + use dpp::data_contract::accessors::v0::DataContractV0Getters; + use drive_abci::config::{ExecutionConfig, PlatformConfig, PlatformTestConfig}; + use drive_abci::test::helpers::setup::TestPlatformBuilder; + use tenderdash_abci::proto::types::CoreChainLock; + use dpp::data_contract::document_type::random_document::{DocumentFieldFillSize, DocumentFieldFillType}; + use dpp::identity::accessors::IdentityGettersV0; + use dpp::identity::Identity; + use dpp::platform_value::Value; + use drive_abci::test::helpers::signer::SimpleSigner; + use platform_version::version::PlatformVersion; + + #[test] + fn run_chain_block_two_state_transitions_conflicting_unique_index() { + // In this test we try to insert two state transitions with the same unique index + // We use the dpns contract and we insert two documents both with the same "name" + // This is a common scenario we should see quite often + let config = PlatformConfig { + quorum_size: 100, + execution: ExecutionConfig { + //we disable document triggers because we are using dpns and dpns needs a preorder + use_document_triggers: false, + validator_set_quorum_rotation_block_count: 25, + ..Default::default() + }, + block_spacing_ms: 3000, + testing_configs: PlatformTestConfig::default_with_no_block_signing(), + ..Default::default() + }; + let mut platform = TestPlatformBuilder::new() + .with_config(config.clone()) + .build_with_mock_rpc(); + + let platform_version = PlatformVersion::latest(); + + let mut rng = StdRng::seed_from_u64(567); + + let mut simple_signer = SimpleSigner::default(); + + let (identity1, keys) = + Identity::random_identity_with_main_keys_with_private_key::>( + 2, + &mut rng, + platform_version, + ) + .unwrap(); + + simple_signer.add_keys(keys); + + let (identity2, keys) = + Identity::random_identity_with_main_keys_with_private_key::>( + 2, + &mut rng, + platform_version, + ) + .unwrap(); + + simple_signer.add_keys(keys); + + let start_identities = crate::transitions::create_state_transitions_for_identities( + vec![identity1, identity2], + &mut simple_signer, + &mut rng, + platform_version, + ); + + let document_op_1 = DocumentOp { + contract: platform.drive.system_contracts.dpns_contract.clone(), + action: DocumentAction::DocumentActionInsertSpecific( + BTreeMap::from([ + ("label".into(), "quantum".into()), + ("normalizedLabel".into(), "quantum".into()), + ("normalizedParentDomainName".into(), "dash".into()), + ( + "records".into(), + BTreeMap::from([( + "dashUniqueIdentityId", + Value::from(start_identities.first().unwrap().0.id()), + )]) + .into(), + ), + ]), + Some(start_identities.first().unwrap().0.id()), + DocumentFieldFillType::FillIfNotRequired, + DocumentFieldFillSize::AnyDocumentFillSize, + ), + document_type: platform + .drive + .system_contracts + .dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type") + .to_owned_document_type(), + }; + + let document_op_2 = DocumentOp { + contract: platform.drive.system_contracts.dpns_contract.clone(), + action: DocumentAction::DocumentActionInsertSpecific( + BTreeMap::from([ + ("label".into(), "quantum".into()), + ("normalizedLabel".into(), "quantum".into()), + ("normalizedParentDomainName".into(), "dash".into()), + ( + "records".into(), + BTreeMap::from([( + "dashUniqueIdentityId", + Value::from(start_identities.last().unwrap().0.id()), + )]) + .into(), + ), + ]), + Some(start_identities.last().unwrap().0.id()), + DocumentFieldFillType::FillIfNotRequired, + DocumentFieldFillSize::AnyDocumentFillSize, + ), + document_type: platform + .drive + .system_contracts + .dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type") + .to_owned_document_type(), + }; + + let strategy = Strategy { + contracts_with_updates: vec![], + operations: vec![ + Operation { + op_type: OperationType::Document(document_op_1), + frequency: Frequency { + times_per_block_range: 1..2, + chance_per_block: None, + + }, + }, + Operation { + op_type: OperationType::Document(document_op_2), + frequency: Frequency { + times_per_block_range: 1..2, + chance_per_block: None, + }, + }, + ], + start_identities, + identities_inserts: Frequency { + times_per_block_range: Default::default(), chance_per_block: None, - only_once: true, }, - }], - identities_inserts: Frequency { - times_per_block_range: 1..2, - chance_per_block: None, - only_once: false, - }, - total_hpmns: 100, - extra_normal_mns: 200, - quorum_count: 24, - upgrading_info: None, - core_height_increase: Frequency { - times_per_block_range: Default::default(), - chance_per_block: None, - only_once: false, - }, - proposer_strategy: Default::default(), - rotate_quorums: false, - failure_testing: None, - query_testing: Some(QueryStrategy { - query_identities_by_public_key_hashes: Frequency { - times_per_block_range: 1..5, + total_hpmns: 100, + extra_normal_mns: 0, + quorum_count: 24, + upgrading_info: None, + core_height_increase: Frequency { + times_per_block_range: Default::default(), chance_per_block: None, - only_once: false, }, - }), - verify_state_transition_results: true, - }; - - let config = PlatformConfig { - verify_sum_trees: true, - quorum_size: 100, - validator_set_quorum_rotation_block_count: 25, - block_spacing_ms: 3000, - testing_configs: PlatformTestConfig::default(), - ..Default::default() - }; - - let mut platform = TestPlatformBuilder::new() - .with_config(config.clone()) - .build_with_mock_rpc(); - - platform - .core_rpc - .expect_get_best_chain_lock() - .returning(move || { - Ok(CoreChainLock { - core_block_height: 10, - core_block_hash: [1; 32].to_vec(), - signature: [2; 96].to_vec(), - }) - }); - - let outcome = run_chain_for_strategy(&mut platform, 100, strategy, config, 15); - - assert_eq!(outcome.identities.len(), 100); -} + + proposer_strategy: Default::default(), + rotate_quorums: false, + failure_testing: None, + query_testing: None, + verify_state_transition_results: true, + signer: Some(simple_signer), + }; + + let mut core_block_heights = vec![10, 11]; + + platform + .core_rpc + .expect_get_best_chain_lock() + .returning(move || { + let core_block_height = if core_block_heights.len() == 1 { + *core_block_heights.first().unwrap() + } else { + core_block_heights.remove(0) + }; + Ok(CoreChainLock { + core_block_height, + core_block_hash: [1; 32].to_vec(), + signature: [2; 96].to_vec(), + }) + }); + // On the first block we only have identities and contracts + let outcome = + run_chain_for_strategy(&mut platform, 2, strategy.clone(), config.clone(), 15); + + let state_transitions_block_2 = &outcome + .state_transition_results_per_block + .get(&2) + .expect("expected to get block 2"); + + let first_document_insert_result = &state_transitions_block_2 + .first() + .as_ref() + .expect("expected a document insert") + .1; + assert_eq!(first_document_insert_result.code, 0); + + let second_document_insert_result = &state_transitions_block_2 + .get(1) + .as_ref() + .expect("expected a document insert") + .1; + + assert_eq!(second_document_insert_result.code, 4009); // we expect an error + } +} \ No newline at end of file diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index a732e7c319..f27b7b04ee 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -23,38 +23,7 @@ use crate::version::drive_abci_versions::{ DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, DriveAbciWithdrawalsMethodVersions, }; -use crate::version::drive_versions::{ - DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, - DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, - DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, - DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, - DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, - DriveCreditPoolPendingEpochRefundsMethodVersions, - DriveCreditPoolStorageFeeDistributionPoolMethodVersions, - DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, - DriveDocumentEstimationCostsMethodVersions, DriveDocumentIndexUniquenessMethodVersions, - DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, - DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, - DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveGroveApplyMethodVersions, - DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, - DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, - DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, - DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, - DriveIdentityFetchPartialIdentityMethodVersions, - DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, - DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, - DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, - DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, - DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, - DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, - DrivePlatformSystemMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, - DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, - DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, - DriveSystemProtocolVersionMethodVersions, DriveVerifyContractMethodVersions, - DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, - DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVersion, - DriveVoteContestedResourceInsertMethodVersions, DriveVoteMethodVersions, -}; +use crate::version::drive_versions::{DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, DriveCreditPoolPendingEpochRefundsMethodVersions, DriveCreditPoolStorageFeeDistributionPoolMethodVersions, DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformSystemMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, DriveSystemProtocolVersionMethodVersions, DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions}; use crate::version::mocks::TEST_BYTES; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; use crate::version::{AbciStructureVersion, PlatformArchitectureVersion}; @@ -183,8 +152,16 @@ pub(crate) const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { }, }, vote: DriveVoteMethodVersions { + insert: DriveVoteInsertMethodVersions { register_identity_vote: 0 }, contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { - add_new_masternode_vote_type: 0, + register_contested_resource_identity_vote: 0, + register_identity_vote_for_identity_queries: 0, + }, + cleanup: DriveVoteCleanupMethodVersions { + remove_votes_for_identity: 0, + }, + setup: DriveVoteSetupMethodVersions { + setup_initial_vote_tree_main_structure: 0, }, }, contract: DriveContractMethodVersions { diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 7ca3a26849..67827c8a84 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -23,38 +23,7 @@ use crate::version::drive_abci_versions::{ DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, DriveAbciWithdrawalsMethodVersions, }; -use crate::version::drive_versions::{ - DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, - DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, - DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, - DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, - DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, - DriveCreditPoolPendingEpochRefundsMethodVersions, - DriveCreditPoolStorageFeeDistributionPoolMethodVersions, - DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, - DriveDocumentEstimationCostsMethodVersions, DriveDocumentIndexUniquenessMethodVersions, - DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, - DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, - DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveGroveApplyMethodVersions, - DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, - DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, - DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, - DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, - DriveIdentityFetchPartialIdentityMethodVersions, - DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, - DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, - DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, - DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, - DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, - DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, - DrivePlatformSystemMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, - DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, - DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, - DriveSystemProtocolVersionMethodVersions, DriveVerifyContractMethodVersions, - DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, - DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVersion, - DriveVoteContestedResourceInsertMethodVersions, DriveVoteMethodVersions, -}; +use crate::version::drive_versions::{DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, DriveCreditPoolPendingEpochRefundsMethodVersions, DriveCreditPoolStorageFeeDistributionPoolMethodVersions, DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformSystemMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, DriveSystemProtocolVersionMethodVersions, DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions}; use crate::version::mocks::TEST_BYTES; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; use crate::version::{AbciStructureVersion, PlatformArchitectureVersion}; @@ -191,8 +160,16 @@ pub(crate) const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { }, }, vote: DriveVoteMethodVersions { + insert: DriveVoteInsertMethodVersions { register_identity_vote: 0 }, contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { - add_new_masternode_vote_type: 0, + register_contested_resource_identity_vote: 0, + register_identity_vote_for_identity_queries: 0, + }, + cleanup: DriveVoteCleanupMethodVersions { + remove_votes_for_identity: 0, + }, + setup: DriveVoteSetupMethodVersions { + setup_initial_vote_tree_main_structure: 0, }, }, contract: DriveContractMethodVersions { diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index ffa32bbf55..2e1f361605 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -23,38 +23,7 @@ use crate::version::drive_abci_versions::{ DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, DriveAbciWithdrawalsMethodVersions, }; -use crate::version::drive_versions::{ - DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, - DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, - DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, - DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, - DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, - DriveCreditPoolPendingEpochRefundsMethodVersions, - DriveCreditPoolStorageFeeDistributionPoolMethodVersions, - DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, - DriveDocumentEstimationCostsMethodVersions, DriveDocumentIndexUniquenessMethodVersions, - DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, - DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, - DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveGroveApplyMethodVersions, - DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, - DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, - DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, - DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, - DriveIdentityFetchPartialIdentityMethodVersions, - DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, - DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, - DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, - DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, - DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, - DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, - DrivePlatformSystemMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, - DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, - DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, - DriveSystemProtocolVersionMethodVersions, DriveVerifyContractMethodVersions, - DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, - DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVersion, - DriveVoteContestedResourceInsertMethodVersions, DriveVoteMethodVersions, -}; +use crate::version::drive_versions::{DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, DriveCreditPoolPendingEpochRefundsMethodVersions, DriveCreditPoolStorageFeeDistributionPoolMethodVersions, DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformSystemMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, DriveSystemProtocolVersionMethodVersions, DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions}; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; use crate::version::{AbciStructureVersion, PlatformArchitectureVersion}; @@ -180,8 +149,16 @@ pub(super) const PLATFORM_V1: PlatformVersion = PlatformVersion { }, }, vote: DriveVoteMethodVersions { + insert: DriveVoteInsertMethodVersions { register_identity_vote: 0 }, contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { - add_new_masternode_vote_type: 0, + register_contested_resource_identity_vote: 0, + register_identity_vote_for_identity_queries: 0, + }, + cleanup: DriveVoteCleanupMethodVersions { + remove_votes_for_identity: 0, + }, + setup: DriveVoteSetupMethodVersions { + setup_initial_vote_tree_main_structure: 0, }, }, contract: DriveContractMethodVersions { From 94cdfff76045a6719526c232880093394cf455cc Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 8 Nov 2023 08:26:08 +0700 Subject: [PATCH 011/135] more fixes --- .../tests/strategy_tests/voting_tests.rs | 56 ++++++++++--------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index 016391ff4d..a6d648b1ff 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -6,9 +6,7 @@ mod tests { use rand::prelude::StdRng; use rand::SeedableRng; use crate::execution::run_chain_for_strategy; - use crate::frequency::Frequency; - use crate::operations::{DocumentAction, DocumentOp, Operation, OperationType}; - use crate::strategy::Strategy; + use crate::strategy::{NetworkStrategy, Strategy}; use dpp::data_contract::accessors::v0::DataContractV0Getters; use drive_abci::config::{ExecutionConfig, PlatformConfig, PlatformTestConfig}; use drive_abci::test::helpers::setup::TestPlatformBuilder; @@ -17,8 +15,11 @@ mod tests { use dpp::identity::accessors::IdentityGettersV0; use dpp::identity::Identity; use dpp::platform_value::Value; - use drive_abci::test::helpers::signer::SimpleSigner; use platform_version::version::PlatformVersion; + use simple_signer::signer::SimpleSigner; + use strategy_tests::frequency::Frequency; + use strategy_tests::operations::{DocumentAction, DocumentOp, Operation, OperationType}; + use strategy_tests::transitions::create_state_transitions_for_identities; #[test] fn run_chain_block_two_state_transitions_conflicting_unique_index() { @@ -67,7 +68,7 @@ mod tests { simple_signer.add_keys(keys); - let start_identities = crate::transitions::create_state_transitions_for_identities( + let start_identities = create_state_transitions_for_identities( vec![identity1, identity2], &mut simple_signer, &mut rng, @@ -132,29 +133,32 @@ mod tests { .to_owned_document_type(), }; - let strategy = Strategy { - contracts_with_updates: vec![], - operations: vec![ - Operation { - op_type: OperationType::Document(document_op_1), - frequency: Frequency { - times_per_block_range: 1..2, - chance_per_block: None, - + let strategy = NetworkStrategy { + strategy: Strategy { + contracts_with_updates: vec![], + operations: vec![ + Operation { + op_type: OperationType::Document(document_op_1), + frequency: Frequency { + times_per_block_range: 1..2, + chance_per_block: None, + + }, }, - }, - Operation { - op_type: OperationType::Document(document_op_2), - frequency: Frequency { - times_per_block_range: 1..2, - chance_per_block: None, + Operation { + op_type: OperationType::Document(document_op_2), + frequency: Frequency { + times_per_block_range: 1..2, + chance_per_block: None, + }, }, + ], + start_identities, + identities_inserts: Frequency { + times_per_block_range: Default::default(), + chance_per_block: None, }, - ], - start_identities, - identities_inserts: Frequency { - times_per_block_range: Default::default(), - chance_per_block: None, + signer: Some(simple_signer), }, total_hpmns: 100, extra_normal_mns: 0, @@ -170,7 +174,7 @@ mod tests { failure_testing: None, query_testing: None, verify_state_transition_results: true, - signer: Some(simple_signer), + }; let mut core_block_heights = vec![10, 11]; From 50b0ae318c29f907ac056d691ae0b277239bf512 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 4 Dec 2023 02:55:35 +0700 Subject: [PATCH 012/135] small fix --- packages/rs-dpp/src/state_transition/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/rs-dpp/src/state_transition/mod.rs b/packages/rs-dpp/src/state_transition/mod.rs index 7469e184fc..bc63da39b6 100644 --- a/packages/rs-dpp/src/state_transition/mod.rs +++ b/packages/rs-dpp/src/state_transition/mod.rs @@ -293,6 +293,7 @@ impl StateTransition { Self::IdentityCreditWithdrawal(_) => "IdentityCreditWithdrawal", Self::IdentityUpdate(_) => "IdentityUpdate", Self::IdentityCreditTransfer(_) => "IdentityCreditTransfer", + Self::MasternodeVote(_) => "MasternodeVote", } .to_string() } From 83c8da0b2c4780f12b6807a2cabb059c8de005b7 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 17 Dec 2023 21:00:26 +0700 Subject: [PATCH 013/135] updated lock --- Cargo.lock | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 848dfe3a93..a6e538d8a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -946,7 +946,7 @@ dependencies = [ [[package]] name = "dapi-grpc" -version = "0.25.17" +version = "0.25.18" dependencies = [ "dapi-grpc-macros", "platform-version", @@ -960,7 +960,7 @@ dependencies = [ [[package]] name = "dapi-grpc-macros" -version = "0.25.17" +version = "0.25.18" dependencies = [ "dapi-grpc", "heck", @@ -1066,7 +1066,7 @@ dependencies = [ [[package]] name = "dashpay-contract" -version = "0.25.17" +version = "0.25.18" dependencies = [ "platform-value", "serde_json", @@ -1074,7 +1074,7 @@ dependencies = [ [[package]] name = "data-contracts" -version = "0.25.17" +version = "0.25.18" dependencies = [ "dashpay-contract", "dpns-contract", @@ -1165,7 +1165,7 @@ checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" [[package]] name = "dpns-contract" -version = "0.25.17" +version = "0.25.18" dependencies = [ "platform-value", "serde_json", @@ -1173,7 +1173,7 @@ dependencies = [ [[package]] name = "dpp" -version = "0.25.17" +version = "0.25.18" dependencies = [ "anyhow", "async-trait", @@ -1224,7 +1224,7 @@ dependencies = [ [[package]] name = "drive" -version = "0.25.17" +version = "0.25.18" dependencies = [ "anyhow", "base64 0.21.5", @@ -1259,7 +1259,7 @@ dependencies = [ [[package]] name = "drive-abci" -version = "0.25.17" +version = "0.25.18" dependencies = [ "atty", "base64 0.20.0", @@ -1313,7 +1313,7 @@ dependencies = [ [[package]] name = "drive-proof-verifier" -version = "0.25.17" +version = "0.25.18" dependencies = [ "dapi-grpc", "dpp", @@ -1514,7 +1514,7 @@ checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "feature-flags-contract" -version = "0.25.17" +version = "0.25.18" dependencies = [ "platform-value", "serde_json", @@ -2371,7 +2371,7 @@ dependencies = [ [[package]] name = "masternode-reward-shares-contract" -version = "0.25.17" +version = "0.25.18" dependencies = [ "platform-value", "serde_json", @@ -2849,7 +2849,7 @@ checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "platform-serialization" -version = "0.25.17" +version = "0.25.18" dependencies = [ "bincode 2.0.0-rc.3", "platform-version", @@ -2857,7 +2857,7 @@ dependencies = [ [[package]] name = "platform-serialization-derive" -version = "0.25.17" +version = "0.25.18" dependencies = [ "proc-macro2", "quote", @@ -2867,7 +2867,7 @@ dependencies = [ [[package]] name = "platform-value" -version = "0.25.17" +version = "0.25.18" dependencies = [ "base64 0.13.1", "bincode 2.0.0-rc.3", @@ -2888,7 +2888,7 @@ dependencies = [ [[package]] name = "platform-value-convertible" -version = "0.25.17" +version = "0.25.18" dependencies = [ "quote", "syn 2.0.40", @@ -2896,14 +2896,14 @@ dependencies = [ [[package]] name = "platform-version" -version = "0.25.17" +version = "0.25.18" dependencies = [ "thiserror", ] [[package]] name = "platform-versioning" -version = "0.25.17" +version = "0.25.18" dependencies = [ "proc-macro2", "quote", @@ -3445,7 +3445,7 @@ dependencies = [ [[package]] name = "rs-dapi-client" -version = "0.25.17" +version = "0.25.18" dependencies = [ "backon", "chrono", @@ -3465,7 +3465,7 @@ dependencies = [ [[package]] name = "rs-sdk" -version = "0.25.17" +version = "0.25.18" dependencies = [ "async-trait", "base64 0.21.5", @@ -3915,7 +3915,7 @@ checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" [[package]] name = "simple-signer" -version = "0.25.17" +version = "0.25.18" dependencies = [ "anyhow", "bincode 2.0.0-rc.3", @@ -4006,7 +4006,7 @@ dependencies = [ [[package]] name = "strategy-tests" -version = "0.25.17" +version = "0.25.18" dependencies = [ "bincode 2.0.0-rc.3", "dpp", @@ -4860,7 +4860,7 @@ checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" [[package]] name = "wasm-dpp" -version = "0.25.17" +version = "0.25.18" dependencies = [ "anyhow", "async-trait", @@ -5102,7 +5102,7 @@ dependencies = [ [[package]] name = "withdrawals-contract" -version = "0.25.17" +version = "0.25.18" dependencies = [ "num_enum", "platform-value", From a17afb9f6e9ed57b857ce9d095fa3c20a34c7a87 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 17 Dec 2023 22:35:29 +0700 Subject: [PATCH 014/135] updated proto requests --- .../dash/platform/dapi/v0/PlatformGrpc.java | 222 + .../platform/v0/nodejs/platform_pbjs.js | 4465 ++++ .../platform/v0/nodejs/platform_protoc.js | 20270 ++++++++++------ .../platform/v0/objective-c/Platform.pbobjc.h | 441 + .../platform/v0/objective-c/Platform.pbobjc.m | 1203 + .../platform/v0/objective-c/Platform.pbrpc.h | 39 + .../platform/v0/objective-c/Platform.pbrpc.m | 60 + .../platform/v0/python/platform_pb2.py | 1095 +- .../platform/v0/python/platform_pb2_grpc.py | 99 + .../clients/platform/v0/web/platform_pb.d.ts | 595 + .../clients/platform/v0/web/platform_pb.js | 20270 ++++++++++------ .../platform/v0/web/platform_pb_service.d.ts | 57 + .../platform/v0/web/platform_pb_service.js | 120 + .../protos/platform/v0/platform.proto | 119 + .../proto/org.dash.platform.dapi.v0.rs | 403 + 15 files changed, 33787 insertions(+), 15671 deletions(-) diff --git a/packages/dapi-grpc/clients/platform/v0/java/org/dash/platform/dapi/v0/PlatformGrpc.java b/packages/dapi-grpc/clients/platform/v0/java/org/dash/platform/dapi/v0/PlatformGrpc.java index a27ed63482..ff0fc66d9f 100644 --- a/packages/dapi-grpc/clients/platform/v0/java/org/dash/platform/dapi/v0/PlatformGrpc.java +++ b/packages/dapi-grpc/clients/platform/v0/java/org/dash/platform/dapi/v0/PlatformGrpc.java @@ -573,6 +573,99 @@ org.dash.platform.dapi.v0.PlatformOuterClass.GetEpochsInfoResponse> getGetEpochs return getGetEpochsInfoMethod; } + private static volatile io.grpc.MethodDescriptor getGetContestedResourcesMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "getContestedResources", + requestType = org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourcesRequest.class, + responseType = org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourcesResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getGetContestedResourcesMethod() { + io.grpc.MethodDescriptor getGetContestedResourcesMethod; + if ((getGetContestedResourcesMethod = PlatformGrpc.getGetContestedResourcesMethod) == null) { + synchronized (PlatformGrpc.class) { + if ((getGetContestedResourcesMethod = PlatformGrpc.getGetContestedResourcesMethod) == null) { + PlatformGrpc.getGetContestedResourcesMethod = getGetContestedResourcesMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "getContestedResources")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourcesRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourcesResponse.getDefaultInstance())) + .setSchemaDescriptor(new PlatformMethodDescriptorSupplier("getContestedResources")) + .build(); + } + } + } + return getGetContestedResourcesMethod; + } + + private static volatile io.grpc.MethodDescriptor getGetContestedResourceVoteStateMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "getContestedResourceVoteState", + requestType = org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStateRequest.class, + responseType = org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStateResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getGetContestedResourceVoteStateMethod() { + io.grpc.MethodDescriptor getGetContestedResourceVoteStateMethod; + if ((getGetContestedResourceVoteStateMethod = PlatformGrpc.getGetContestedResourceVoteStateMethod) == null) { + synchronized (PlatformGrpc.class) { + if ((getGetContestedResourceVoteStateMethod = PlatformGrpc.getGetContestedResourceVoteStateMethod) == null) { + PlatformGrpc.getGetContestedResourceVoteStateMethod = getGetContestedResourceVoteStateMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "getContestedResourceVoteState")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStateRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStateResponse.getDefaultInstance())) + .setSchemaDescriptor(new PlatformMethodDescriptorSupplier("getContestedResourceVoteState")) + .build(); + } + } + } + return getGetContestedResourceVoteStateMethod; + } + + private static volatile io.grpc.MethodDescriptor getGetContestedResourceVoteStatusMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "getContestedResourceVoteStatus", + requestType = org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStatusRequest.class, + responseType = org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStatusResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getGetContestedResourceVoteStatusMethod() { + io.grpc.MethodDescriptor getGetContestedResourceVoteStatusMethod; + if ((getGetContestedResourceVoteStatusMethod = PlatformGrpc.getGetContestedResourceVoteStatusMethod) == null) { + synchronized (PlatformGrpc.class) { + if ((getGetContestedResourceVoteStatusMethod = PlatformGrpc.getGetContestedResourceVoteStatusMethod) == null) { + PlatformGrpc.getGetContestedResourceVoteStatusMethod = getGetContestedResourceVoteStatusMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "getContestedResourceVoteStatus")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStatusRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStatusResponse.getDefaultInstance())) + .setSchemaDescriptor(new PlatformMethodDescriptorSupplier("getContestedResourceVoteStatus")) + .build(); + } + } + } + return getGetContestedResourceVoteStatusMethod; + } + /** * Creates a new async stub that supports all call types for the service */ @@ -747,6 +840,27 @@ public void getEpochsInfo(org.dash.platform.dapi.v0.PlatformOuterClass.GetEpochs io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetEpochsInfoMethod(), responseObserver); } + /** + */ + public void getContestedResources(org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourcesRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetContestedResourcesMethod(), responseObserver); + } + + /** + */ + public void getContestedResourceVoteState(org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStateRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetContestedResourceVoteStateMethod(), responseObserver); + } + + /** + */ + public void getContestedResourceVoteStatus(org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStatusRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetContestedResourceVoteStatusMethod(), responseObserver); + } + @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) .addMethod( @@ -875,6 +989,27 @@ public void getEpochsInfo(org.dash.platform.dapi.v0.PlatformOuterClass.GetEpochs org.dash.platform.dapi.v0.PlatformOuterClass.GetEpochsInfoRequest, org.dash.platform.dapi.v0.PlatformOuterClass.GetEpochsInfoResponse>( this, METHODID_GET_EPOCHS_INFO))) + .addMethod( + getGetContestedResourcesMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourcesRequest, + org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourcesResponse>( + this, METHODID_GET_CONTESTED_RESOURCES))) + .addMethod( + getGetContestedResourceVoteStateMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStateRequest, + org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStateResponse>( + this, METHODID_GET_CONTESTED_RESOURCE_VOTE_STATE))) + .addMethod( + getGetContestedResourceVoteStatusMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStatusRequest, + org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStatusResponse>( + this, METHODID_GET_CONTESTED_RESOURCE_VOTE_STATUS))) .build(); } } @@ -1036,6 +1171,30 @@ public void getEpochsInfo(org.dash.platform.dapi.v0.PlatformOuterClass.GetEpochs io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getGetEpochsInfoMethod(), getCallOptions()), request, responseObserver); } + + /** + */ + public void getContestedResources(org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourcesRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getGetContestedResourcesMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getContestedResourceVoteState(org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStateRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getGetContestedResourceVoteStateMethod(), getCallOptions()), request, responseObserver); + } + + /** + */ + public void getContestedResourceVoteStatus(org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStatusRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getGetContestedResourceVoteStatusMethod(), getCallOptions()), request, responseObserver); + } } /** @@ -1177,6 +1336,27 @@ public org.dash.platform.dapi.v0.PlatformOuterClass.GetEpochsInfoResponse getEpo return io.grpc.stub.ClientCalls.blockingUnaryCall( getChannel(), getGetEpochsInfoMethod(), getCallOptions(), request); } + + /** + */ + public org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourcesResponse getContestedResources(org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourcesRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getGetContestedResourcesMethod(), getCallOptions(), request); + } + + /** + */ + public org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStateResponse getContestedResourceVoteState(org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStateRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getGetContestedResourceVoteStateMethod(), getCallOptions(), request); + } + + /** + */ + public org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStatusResponse getContestedResourceVoteStatus(org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStatusRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getGetContestedResourceVoteStatusMethod(), getCallOptions(), request); + } } /** @@ -1336,6 +1516,30 @@ public com.google.common.util.concurrent.ListenableFuture getContestedResources( + org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourcesRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getGetContestedResourcesMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getContestedResourceVoteState( + org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStateRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getGetContestedResourceVoteStateMethod(), getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getContestedResourceVoteStatus( + org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStatusRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getGetContestedResourceVoteStatusMethod(), getCallOptions()), request); + } } private static final int METHODID_BROADCAST_STATE_TRANSITION = 0; @@ -1356,6 +1560,9 @@ public com.google.common.util.concurrent.ListenableFuture implements io.grpc.stub.ServerCalls.UnaryMethod, @@ -1446,6 +1653,18 @@ public void invoke(Req request, io.grpc.stub.StreamObserver responseObserv serviceImpl.getEpochsInfo((org.dash.platform.dapi.v0.PlatformOuterClass.GetEpochsInfoRequest) request, (io.grpc.stub.StreamObserver) responseObserver); break; + case METHODID_GET_CONTESTED_RESOURCES: + serviceImpl.getContestedResources((org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourcesRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_CONTESTED_RESOURCE_VOTE_STATE: + serviceImpl.getContestedResourceVoteState((org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStateRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_CONTESTED_RESOURCE_VOTE_STATUS: + serviceImpl.getContestedResourceVoteStatus((org.dash.platform.dapi.v0.PlatformOuterClass.GetContestedResourceVoteStatusRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; default: throw new AssertionError(); } @@ -1525,6 +1744,9 @@ public static io.grpc.ServiceDescriptor getServiceDescriptor() { .addMethod(getGetProtocolVersionUpgradeStateMethod()) .addMethod(getGetProtocolVersionUpgradeVoteStatusMethod()) .addMethod(getGetEpochsInfoMethod()) + .addMethod(getGetContestedResourcesMethod()) + .addMethod(getGetContestedResourceVoteStateMethod()) + .addMethod(getGetContestedResourceVoteStatusMethod()) .build(); } } diff --git a/packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js b/packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js index f1dafcc929..fcd56bb6c9 100644 --- a/packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js +++ b/packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js @@ -680,6 +680,105 @@ $root.org = (function() { * @variation 2 */ + /** + * Callback as used by {@link org.dash.platform.dapi.v0.Platform#getContestedResources}. + * @memberof org.dash.platform.dapi.v0.Platform + * @typedef getContestedResourcesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {org.dash.platform.dapi.v0.GetContestedResourcesResponse} [response] GetContestedResourcesResponse + */ + + /** + * Calls getContestedResources. + * @function getContestedResources + * @memberof org.dash.platform.dapi.v0.Platform + * @instance + * @param {org.dash.platform.dapi.v0.IGetContestedResourcesRequest} request GetContestedResourcesRequest message or plain object + * @param {org.dash.platform.dapi.v0.Platform.getContestedResourcesCallback} callback Node-style callback called with the error, if any, and GetContestedResourcesResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Platform.prototype.getContestedResources = function getContestedResources(request, callback) { + return this.rpcCall(getContestedResources, $root.org.dash.platform.dapi.v0.GetContestedResourcesRequest, $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse, request, callback); + }, "name", { value: "getContestedResources" }); + + /** + * Calls getContestedResources. + * @function getContestedResources + * @memberof org.dash.platform.dapi.v0.Platform + * @instance + * @param {org.dash.platform.dapi.v0.IGetContestedResourcesRequest} request GetContestedResourcesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link org.dash.platform.dapi.v0.Platform#getContestedResourceVoteState}. + * @memberof org.dash.platform.dapi.v0.Platform + * @typedef getContestedResourceVoteStateCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse} [response] GetContestedResourceVoteStateResponse + */ + + /** + * Calls getContestedResourceVoteState. + * @function getContestedResourceVoteState + * @memberof org.dash.platform.dapi.v0.Platform + * @instance + * @param {org.dash.platform.dapi.v0.IGetContestedResourceVoteStateRequest} request GetContestedResourceVoteStateRequest message or plain object + * @param {org.dash.platform.dapi.v0.Platform.getContestedResourceVoteStateCallback} callback Node-style callback called with the error, if any, and GetContestedResourceVoteStateResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Platform.prototype.getContestedResourceVoteState = function getContestedResourceVoteState(request, callback) { + return this.rpcCall(getContestedResourceVoteState, $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest, $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse, request, callback); + }, "name", { value: "getContestedResourceVoteState" }); + + /** + * Calls getContestedResourceVoteState. + * @function getContestedResourceVoteState + * @memberof org.dash.platform.dapi.v0.Platform + * @instance + * @param {org.dash.platform.dapi.v0.IGetContestedResourceVoteStateRequest} request GetContestedResourceVoteStateRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link org.dash.platform.dapi.v0.Platform#getContestedResourceVoteStatus}. + * @memberof org.dash.platform.dapi.v0.Platform + * @typedef getContestedResourceVoteStatusCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse} [response] GetContestedResourceVoteStatusResponse + */ + + /** + * Calls getContestedResourceVoteStatus. + * @function getContestedResourceVoteStatus + * @memberof org.dash.platform.dapi.v0.Platform + * @instance + * @param {org.dash.platform.dapi.v0.IGetContestedResourceVoteStatusRequest} request GetContestedResourceVoteStatusRequest message or plain object + * @param {org.dash.platform.dapi.v0.Platform.getContestedResourceVoteStatusCallback} callback Node-style callback called with the error, if any, and GetContestedResourceVoteStatusResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Platform.prototype.getContestedResourceVoteStatus = function getContestedResourceVoteStatus(request, callback) { + return this.rpcCall(getContestedResourceVoteStatus, $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest, $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse, request, callback); + }, "name", { value: "getContestedResourceVoteStatus" }); + + /** + * Calls getContestedResourceVoteStatus. + * @function getContestedResourceVoteStatus + * @memberof org.dash.platform.dapi.v0.Platform + * @instance + * @param {org.dash.platform.dapi.v0.IGetContestedResourceVoteStatusRequest} request GetContestedResourceVoteStatusRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + return Platform; })(); @@ -24126,6 +24225,4372 @@ $root.org = (function() { return GetEpochsInfoResponse; })(); + v0.GetContestedResourcesRequest = (function() { + + /** + * Properties of a GetContestedResourcesRequest. + * @memberof org.dash.platform.dapi.v0 + * @interface IGetContestedResourcesRequest + * @property {org.dash.platform.dapi.v0.GetContestedResourcesRequest.IGetContestedResourcesRequestV0|null} [v0] GetContestedResourcesRequest v0 + */ + + /** + * Constructs a new GetContestedResourcesRequest. + * @memberof org.dash.platform.dapi.v0 + * @classdesc Represents a GetContestedResourcesRequest. + * @implements IGetContestedResourcesRequest + * @constructor + * @param {org.dash.platform.dapi.v0.IGetContestedResourcesRequest=} [properties] Properties to set + */ + function GetContestedResourcesRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetContestedResourcesRequest v0. + * @member {org.dash.platform.dapi.v0.GetContestedResourcesRequest.IGetContestedResourcesRequestV0|null|undefined} v0 + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest + * @instance + */ + GetContestedResourcesRequest.prototype.v0 = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GetContestedResourcesRequest version. + * @member {"v0"|undefined} version + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest + * @instance + */ + Object.defineProperty(GetContestedResourcesRequest.prototype, "version", { + get: $util.oneOfGetter($oneOfFields = ["v0"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new GetContestedResourcesRequest instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest + * @static + * @param {org.dash.platform.dapi.v0.IGetContestedResourcesRequest=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesRequest} GetContestedResourcesRequest instance + */ + GetContestedResourcesRequest.create = function create(properties) { + return new GetContestedResourcesRequest(properties); + }; + + /** + * Encodes the specified GetContestedResourcesRequest message. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourcesRequest.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest + * @static + * @param {org.dash.platform.dapi.v0.IGetContestedResourcesRequest} message GetContestedResourcesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourcesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.v0 != null && Object.hasOwnProperty.call(message, "v0")) + $root.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.encode(message.v0, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetContestedResourcesRequest message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourcesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest + * @static + * @param {org.dash.platform.dapi.v0.IGetContestedResourcesRequest} message GetContestedResourcesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourcesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetContestedResourcesRequest message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesRequest} GetContestedResourcesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourcesRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetContestedResourcesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.v0 = $root.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetContestedResourcesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesRequest} GetContestedResourcesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourcesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetContestedResourcesRequest message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetContestedResourcesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + properties.version = 1; + { + var error = $root.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.verify(message.v0); + if (error) + return "v0." + error; + } + } + return null; + }; + + /** + * Creates a GetContestedResourcesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesRequest} GetContestedResourcesRequest + */ + GetContestedResourcesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetContestedResourcesRequest) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetContestedResourcesRequest(); + if (object.v0 != null) { + if (typeof object.v0 !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourcesRequest.v0: object expected"); + message.v0 = $root.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.fromObject(object.v0); + } + return message; + }; + + /** + * Creates a plain object from a GetContestedResourcesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourcesRequest} message GetContestedResourcesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetContestedResourcesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + object.v0 = $root.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.toObject(message.v0, options); + if (options.oneofs) + object.version = "v0"; + } + return object; + }; + + /** + * Converts this GetContestedResourcesRequest to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest + * @instance + * @returns {Object.} JSON object + */ + GetContestedResourcesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + GetContestedResourcesRequest.GetContestedResourcesRequestV0 = (function() { + + /** + * Properties of a GetContestedResourcesRequestV0. + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest + * @interface IGetContestedResourcesRequestV0 + * @property {boolean|null} [prove] GetContestedResourcesRequestV0 prove + * @property {Array.|null} [resourcePath] GetContestedResourcesRequestV0 resourcePath + * @property {Uint8Array|null} [startContestedResourceIdentifier] GetContestedResourcesRequestV0 startContestedResourceIdentifier + * @property {number|null} [count] GetContestedResourcesRequestV0 count + * @property {boolean|null} [ascending] GetContestedResourcesRequestV0 ascending + */ + + /** + * Constructs a new GetContestedResourcesRequestV0. + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest + * @classdesc Represents a GetContestedResourcesRequestV0. + * @implements IGetContestedResourcesRequestV0 + * @constructor + * @param {org.dash.platform.dapi.v0.GetContestedResourcesRequest.IGetContestedResourcesRequestV0=} [properties] Properties to set + */ + function GetContestedResourcesRequestV0(properties) { + this.resourcePath = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetContestedResourcesRequestV0 prove. + * @member {boolean} prove + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0 + * @instance + */ + GetContestedResourcesRequestV0.prototype.prove = false; + + /** + * GetContestedResourcesRequestV0 resourcePath. + * @member {Array.} resourcePath + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0 + * @instance + */ + GetContestedResourcesRequestV0.prototype.resourcePath = $util.emptyArray; + + /** + * GetContestedResourcesRequestV0 startContestedResourceIdentifier. + * @member {Uint8Array} startContestedResourceIdentifier + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0 + * @instance + */ + GetContestedResourcesRequestV0.prototype.startContestedResourceIdentifier = $util.newBuffer([]); + + /** + * GetContestedResourcesRequestV0 count. + * @member {number} count + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0 + * @instance + */ + GetContestedResourcesRequestV0.prototype.count = 0; + + /** + * GetContestedResourcesRequestV0 ascending. + * @member {boolean} ascending + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0 + * @instance + */ + GetContestedResourcesRequestV0.prototype.ascending = false; + + /** + * Creates a new GetContestedResourcesRequestV0 instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourcesRequest.IGetContestedResourcesRequestV0=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} GetContestedResourcesRequestV0 instance + */ + GetContestedResourcesRequestV0.create = function create(properties) { + return new GetContestedResourcesRequestV0(properties); + }; + + /** + * Encodes the specified GetContestedResourcesRequestV0 message. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourcesRequest.IGetContestedResourcesRequestV0} message GetContestedResourcesRequestV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourcesRequestV0.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.prove != null && Object.hasOwnProperty.call(message, "prove")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.prove); + if (message.resourcePath != null && message.resourcePath.length) + for (var i = 0; i < message.resourcePath.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.resourcePath[i]); + if (message.startContestedResourceIdentifier != null && Object.hasOwnProperty.call(message, "startContestedResourceIdentifier")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.startContestedResourceIdentifier); + if (message.count != null && Object.hasOwnProperty.call(message, "count")) + writer.uint32(/* id 4, wireType 0 =*/32).uint32(message.count); + if (message.ascending != null && Object.hasOwnProperty.call(message, "ascending")) + writer.uint32(/* id 5, wireType 0 =*/40).bool(message.ascending); + return writer; + }; + + /** + * Encodes the specified GetContestedResourcesRequestV0 message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourcesRequest.IGetContestedResourcesRequestV0} message GetContestedResourcesRequestV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourcesRequestV0.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetContestedResourcesRequestV0 message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} GetContestedResourcesRequestV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourcesRequestV0.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.prove = reader.bool(); + break; + case 2: + if (!(message.resourcePath && message.resourcePath.length)) + message.resourcePath = []; + message.resourcePath.push(reader.bytes()); + break; + case 3: + message.startContestedResourceIdentifier = reader.bytes(); + break; + case 4: + message.count = reader.uint32(); + break; + case 5: + message.ascending = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetContestedResourcesRequestV0 message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} GetContestedResourcesRequestV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourcesRequestV0.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetContestedResourcesRequestV0 message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0 + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetContestedResourcesRequestV0.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.prove != null && message.hasOwnProperty("prove")) + if (typeof message.prove !== "boolean") + return "prove: boolean expected"; + if (message.resourcePath != null && message.hasOwnProperty("resourcePath")) { + if (!Array.isArray(message.resourcePath)) + return "resourcePath: array expected"; + for (var i = 0; i < message.resourcePath.length; ++i) + if (!(message.resourcePath[i] && typeof message.resourcePath[i].length === "number" || $util.isString(message.resourcePath[i]))) + return "resourcePath: buffer[] expected"; + } + if (message.startContestedResourceIdentifier != null && message.hasOwnProperty("startContestedResourceIdentifier")) + if (!(message.startContestedResourceIdentifier && typeof message.startContestedResourceIdentifier.length === "number" || $util.isString(message.startContestedResourceIdentifier))) + return "startContestedResourceIdentifier: buffer expected"; + if (message.count != null && message.hasOwnProperty("count")) + if (!$util.isInteger(message.count)) + return "count: integer expected"; + if (message.ascending != null && message.hasOwnProperty("ascending")) + if (typeof message.ascending !== "boolean") + return "ascending: boolean expected"; + return null; + }; + + /** + * Creates a GetContestedResourcesRequestV0 message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0 + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} GetContestedResourcesRequestV0 + */ + GetContestedResourcesRequestV0.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0(); + if (object.prove != null) + message.prove = Boolean(object.prove); + if (object.resourcePath) { + if (!Array.isArray(object.resourcePath)) + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.resourcePath: array expected"); + message.resourcePath = []; + for (var i = 0; i < object.resourcePath.length; ++i) + if (typeof object.resourcePath[i] === "string") + $util.base64.decode(object.resourcePath[i], message.resourcePath[i] = $util.newBuffer($util.base64.length(object.resourcePath[i])), 0); + else if (object.resourcePath[i].length >= 0) + message.resourcePath[i] = object.resourcePath[i]; + } + if (object.startContestedResourceIdentifier != null) + if (typeof object.startContestedResourceIdentifier === "string") + $util.base64.decode(object.startContestedResourceIdentifier, message.startContestedResourceIdentifier = $util.newBuffer($util.base64.length(object.startContestedResourceIdentifier)), 0); + else if (object.startContestedResourceIdentifier.length >= 0) + message.startContestedResourceIdentifier = object.startContestedResourceIdentifier; + if (object.count != null) + message.count = object.count >>> 0; + if (object.ascending != null) + message.ascending = Boolean(object.ascending); + return message; + }; + + /** + * Creates a plain object from a GetContestedResourcesRequestV0 message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} message GetContestedResourcesRequestV0 + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetContestedResourcesRequestV0.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.resourcePath = []; + if (options.defaults) { + object.prove = false; + if (options.bytes === String) + object.startContestedResourceIdentifier = ""; + else { + object.startContestedResourceIdentifier = []; + if (options.bytes !== Array) + object.startContestedResourceIdentifier = $util.newBuffer(object.startContestedResourceIdentifier); + } + object.count = 0; + object.ascending = false; + } + if (message.prove != null && message.hasOwnProperty("prove")) + object.prove = message.prove; + if (message.resourcePath && message.resourcePath.length) { + object.resourcePath = []; + for (var j = 0; j < message.resourcePath.length; ++j) + object.resourcePath[j] = options.bytes === String ? $util.base64.encode(message.resourcePath[j], 0, message.resourcePath[j].length) : options.bytes === Array ? Array.prototype.slice.call(message.resourcePath[j]) : message.resourcePath[j]; + } + if (message.startContestedResourceIdentifier != null && message.hasOwnProperty("startContestedResourceIdentifier")) + object.startContestedResourceIdentifier = options.bytes === String ? $util.base64.encode(message.startContestedResourceIdentifier, 0, message.startContestedResourceIdentifier.length) : options.bytes === Array ? Array.prototype.slice.call(message.startContestedResourceIdentifier) : message.startContestedResourceIdentifier; + if (message.count != null && message.hasOwnProperty("count")) + object.count = message.count; + if (message.ascending != null && message.hasOwnProperty("ascending")) + object.ascending = message.ascending; + return object; + }; + + /** + * Converts this GetContestedResourcesRequestV0 to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0 + * @instance + * @returns {Object.} JSON object + */ + GetContestedResourcesRequestV0.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GetContestedResourcesRequestV0; + })(); + + return GetContestedResourcesRequest; + })(); + + v0.GetContestedResourcesResponse = (function() { + + /** + * Properties of a GetContestedResourcesResponse. + * @memberof org.dash.platform.dapi.v0 + * @interface IGetContestedResourcesResponse + * @property {org.dash.platform.dapi.v0.GetContestedResourcesResponse.IGetContestedResourcesResponseV0|null} [v0] GetContestedResourcesResponse v0 + */ + + /** + * Constructs a new GetContestedResourcesResponse. + * @memberof org.dash.platform.dapi.v0 + * @classdesc Represents a GetContestedResourcesResponse. + * @implements IGetContestedResourcesResponse + * @constructor + * @param {org.dash.platform.dapi.v0.IGetContestedResourcesResponse=} [properties] Properties to set + */ + function GetContestedResourcesResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetContestedResourcesResponse v0. + * @member {org.dash.platform.dapi.v0.GetContestedResourcesResponse.IGetContestedResourcesResponseV0|null|undefined} v0 + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse + * @instance + */ + GetContestedResourcesResponse.prototype.v0 = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GetContestedResourcesResponse version. + * @member {"v0"|undefined} version + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse + * @instance + */ + Object.defineProperty(GetContestedResourcesResponse.prototype, "version", { + get: $util.oneOfGetter($oneOfFields = ["v0"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new GetContestedResourcesResponse instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse + * @static + * @param {org.dash.platform.dapi.v0.IGetContestedResourcesResponse=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesResponse} GetContestedResourcesResponse instance + */ + GetContestedResourcesResponse.create = function create(properties) { + return new GetContestedResourcesResponse(properties); + }; + + /** + * Encodes the specified GetContestedResourcesResponse message. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourcesResponse.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse + * @static + * @param {org.dash.platform.dapi.v0.IGetContestedResourcesResponse} message GetContestedResourcesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourcesResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.v0 != null && Object.hasOwnProperty.call(message, "v0")) + $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.encode(message.v0, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetContestedResourcesResponse message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourcesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse + * @static + * @param {org.dash.platform.dapi.v0.IGetContestedResourcesResponse} message GetContestedResourcesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourcesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetContestedResourcesResponse message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesResponse} GetContestedResourcesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourcesResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.v0 = $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetContestedResourcesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesResponse} GetContestedResourcesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourcesResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetContestedResourcesResponse message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetContestedResourcesResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + properties.version = 1; + { + var error = $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.verify(message.v0); + if (error) + return "v0." + error; + } + } + return null; + }; + + /** + * Creates a GetContestedResourcesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesResponse} GetContestedResourcesResponse + */ + GetContestedResourcesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse(); + if (object.v0 != null) { + if (typeof object.v0 !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourcesResponse.v0: object expected"); + message.v0 = $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.fromObject(object.v0); + } + return message; + }; + + /** + * Creates a plain object from a GetContestedResourcesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourcesResponse} message GetContestedResourcesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetContestedResourcesResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + object.v0 = $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.toObject(message.v0, options); + if (options.oneofs) + object.version = "v0"; + } + return object; + }; + + /** + * Converts this GetContestedResourcesResponse to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse + * @instance + * @returns {Object.} JSON object + */ + GetContestedResourcesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + GetContestedResourcesResponse.GetContestedResourcesResponseV0 = (function() { + + /** + * Properties of a GetContestedResourcesResponseV0. + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse + * @interface IGetContestedResourcesResponseV0 + * @property {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.IContestedResources|null} [contestedResources] GetContestedResourcesResponseV0 contestedResources + * @property {org.dash.platform.dapi.v0.IProof|null} [proof] GetContestedResourcesResponseV0 proof + * @property {org.dash.platform.dapi.v0.IResponseMetadata|null} [metadata] GetContestedResourcesResponseV0 metadata + */ + + /** + * Constructs a new GetContestedResourcesResponseV0. + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse + * @classdesc Represents a GetContestedResourcesResponseV0. + * @implements IGetContestedResourcesResponseV0 + * @constructor + * @param {org.dash.platform.dapi.v0.GetContestedResourcesResponse.IGetContestedResourcesResponseV0=} [properties] Properties to set + */ + function GetContestedResourcesResponseV0(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetContestedResourcesResponseV0 contestedResources. + * @member {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.IContestedResources|null|undefined} contestedResources + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0 + * @instance + */ + GetContestedResourcesResponseV0.prototype.contestedResources = null; + + /** + * GetContestedResourcesResponseV0 proof. + * @member {org.dash.platform.dapi.v0.IProof|null|undefined} proof + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0 + * @instance + */ + GetContestedResourcesResponseV0.prototype.proof = null; + + /** + * GetContestedResourcesResponseV0 metadata. + * @member {org.dash.platform.dapi.v0.IResponseMetadata|null|undefined} metadata + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0 + * @instance + */ + GetContestedResourcesResponseV0.prototype.metadata = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GetContestedResourcesResponseV0 result. + * @member {"contestedResources"|"proof"|undefined} result + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0 + * @instance + */ + Object.defineProperty(GetContestedResourcesResponseV0.prototype, "result", { + get: $util.oneOfGetter($oneOfFields = ["contestedResources", "proof"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new GetContestedResourcesResponseV0 instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourcesResponse.IGetContestedResourcesResponseV0=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} GetContestedResourcesResponseV0 instance + */ + GetContestedResourcesResponseV0.create = function create(properties) { + return new GetContestedResourcesResponseV0(properties); + }; + + /** + * Encodes the specified GetContestedResourcesResponseV0 message. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourcesResponse.IGetContestedResourcesResponseV0} message GetContestedResourcesResponseV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourcesResponseV0.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.contestedResources != null && Object.hasOwnProperty.call(message, "contestedResources")) + $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.encode(message.contestedResources, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.proof != null && Object.hasOwnProperty.call(message, "proof")) + $root.org.dash.platform.dapi.v0.Proof.encode(message.proof, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata")) + $root.org.dash.platform.dapi.v0.ResponseMetadata.encode(message.metadata, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetContestedResourcesResponseV0 message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourcesResponse.IGetContestedResourcesResponseV0} message GetContestedResourcesResponseV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourcesResponseV0.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetContestedResourcesResponseV0 message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} GetContestedResourcesResponseV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourcesResponseV0.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.contestedResources = $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.decode(reader, reader.uint32()); + break; + case 2: + message.proof = $root.org.dash.platform.dapi.v0.Proof.decode(reader, reader.uint32()); + break; + case 3: + message.metadata = $root.org.dash.platform.dapi.v0.ResponseMetadata.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetContestedResourcesResponseV0 message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} GetContestedResourcesResponseV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourcesResponseV0.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetContestedResourcesResponseV0 message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0 + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetContestedResourcesResponseV0.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.contestedResources != null && message.hasOwnProperty("contestedResources")) { + properties.result = 1; + { + var error = $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.verify(message.contestedResources); + if (error) + return "contestedResources." + error; + } + } + if (message.proof != null && message.hasOwnProperty("proof")) { + if (properties.result === 1) + return "result: multiple values"; + properties.result = 1; + { + var error = $root.org.dash.platform.dapi.v0.Proof.verify(message.proof); + if (error) + return "proof." + error; + } + } + if (message.metadata != null && message.hasOwnProperty("metadata")) { + var error = $root.org.dash.platform.dapi.v0.ResponseMetadata.verify(message.metadata); + if (error) + return "metadata." + error; + } + return null; + }; + + /** + * Creates a GetContestedResourcesResponseV0 message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0 + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} GetContestedResourcesResponseV0 + */ + GetContestedResourcesResponseV0.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0(); + if (object.contestedResources != null) { + if (typeof object.contestedResources !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.contestedResources: object expected"); + message.contestedResources = $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.fromObject(object.contestedResources); + } + if (object.proof != null) { + if (typeof object.proof !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.proof: object expected"); + message.proof = $root.org.dash.platform.dapi.v0.Proof.fromObject(object.proof); + } + if (object.metadata != null) { + if (typeof object.metadata !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.metadata: object expected"); + message.metadata = $root.org.dash.platform.dapi.v0.ResponseMetadata.fromObject(object.metadata); + } + return message; + }; + + /** + * Creates a plain object from a GetContestedResourcesResponseV0 message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} message GetContestedResourcesResponseV0 + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetContestedResourcesResponseV0.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.metadata = null; + if (message.contestedResources != null && message.hasOwnProperty("contestedResources")) { + object.contestedResources = $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.toObject(message.contestedResources, options); + if (options.oneofs) + object.result = "contestedResources"; + } + if (message.proof != null && message.hasOwnProperty("proof")) { + object.proof = $root.org.dash.platform.dapi.v0.Proof.toObject(message.proof, options); + if (options.oneofs) + object.result = "proof"; + } + if (message.metadata != null && message.hasOwnProperty("metadata")) + object.metadata = $root.org.dash.platform.dapi.v0.ResponseMetadata.toObject(message.metadata, options); + return object; + }; + + /** + * Converts this GetContestedResourcesResponseV0 to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0 + * @instance + * @returns {Object.} JSON object + */ + GetContestedResourcesResponseV0.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + GetContestedResourcesResponseV0.ContestedResources = (function() { + + /** + * Properties of a ContestedResources. + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0 + * @interface IContestedResources + * @property {Array.|null} [contestedResources] ContestedResources contestedResources + * @property {boolean|null} [finishedResults] ContestedResources finishedResults + */ + + /** + * Constructs a new ContestedResources. + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0 + * @classdesc Represents a ContestedResources. + * @implements IContestedResources + * @constructor + * @param {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.IContestedResources=} [properties] Properties to set + */ + function ContestedResources(properties) { + this.contestedResources = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ContestedResources contestedResources. + * @member {Array.} contestedResources + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources + * @instance + */ + ContestedResources.prototype.contestedResources = $util.emptyArray; + + /** + * ContestedResources finishedResults. + * @member {boolean} finishedResults + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources + * @instance + */ + ContestedResources.prototype.finishedResults = false; + + /** + * Creates a new ContestedResources instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.IContestedResources=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} ContestedResources instance + */ + ContestedResources.create = function create(properties) { + return new ContestedResources(properties); + }; + + /** + * Encodes the specified ContestedResources message. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.IContestedResources} message ContestedResources message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ContestedResources.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.contestedResources != null && message.contestedResources.length) + for (var i = 0; i < message.contestedResources.length; ++i) + $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.encode(message.contestedResources[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.finishedResults != null && Object.hasOwnProperty.call(message, "finishedResults")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.finishedResults); + return writer; + }; + + /** + * Encodes the specified ContestedResources message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.IContestedResources} message ContestedResources message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ContestedResources.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ContestedResources message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} ContestedResources + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ContestedResources.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.contestedResources && message.contestedResources.length)) + message.contestedResources = []; + message.contestedResources.push($root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.decode(reader, reader.uint32())); + break; + case 2: + message.finishedResults = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ContestedResources message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} ContestedResources + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ContestedResources.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ContestedResources message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ContestedResources.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.contestedResources != null && message.hasOwnProperty("contestedResources")) { + if (!Array.isArray(message.contestedResources)) + return "contestedResources: array expected"; + for (var i = 0; i < message.contestedResources.length; ++i) { + var error = $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.verify(message.contestedResources[i]); + if (error) + return "contestedResources." + error; + } + } + if (message.finishedResults != null && message.hasOwnProperty("finishedResults")) + if (typeof message.finishedResults !== "boolean") + return "finishedResults: boolean expected"; + return null; + }; + + /** + * Creates a ContestedResources message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} ContestedResources + */ + ContestedResources.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources(); + if (object.contestedResources) { + if (!Array.isArray(object.contestedResources)) + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.contestedResources: array expected"); + message.contestedResources = []; + for (var i = 0; i < object.contestedResources.length; ++i) { + if (typeof object.contestedResources[i] !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.contestedResources: object expected"); + message.contestedResources[i] = $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.fromObject(object.contestedResources[i]); + } + } + if (object.finishedResults != null) + message.finishedResults = Boolean(object.finishedResults); + return message; + }; + + /** + * Creates a plain object from a ContestedResources message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} message ContestedResources + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ContestedResources.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.contestedResources = []; + if (options.defaults) + object.finishedResults = false; + if (message.contestedResources && message.contestedResources.length) { + object.contestedResources = []; + for (var j = 0; j < message.contestedResources.length; ++j) + object.contestedResources[j] = $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.toObject(message.contestedResources[j], options); + } + if (message.finishedResults != null && message.hasOwnProperty("finishedResults")) + object.finishedResults = message.finishedResults; + return object; + }; + + /** + * Converts this ContestedResources to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources + * @instance + * @returns {Object.} JSON object + */ + ContestedResources.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ContestedResources; + })(); + + GetContestedResourcesResponseV0.ContestedResource = (function() { + + /** + * Properties of a ContestedResource. + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0 + * @interface IContestedResource + * @property {Uint8Array|null} [identifier] ContestedResource identifier + */ + + /** + * Constructs a new ContestedResource. + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0 + * @classdesc Represents a ContestedResource. + * @implements IContestedResource + * @constructor + * @param {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.IContestedResource=} [properties] Properties to set + */ + function ContestedResource(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ContestedResource identifier. + * @member {Uint8Array} identifier + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource + * @instance + */ + ContestedResource.prototype.identifier = $util.newBuffer([]); + + /** + * Creates a new ContestedResource instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.IContestedResource=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource} ContestedResource instance + */ + ContestedResource.create = function create(properties) { + return new ContestedResource(properties); + }; + + /** + * Encodes the specified ContestedResource message. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.IContestedResource} message ContestedResource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ContestedResource.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.identifier != null && Object.hasOwnProperty.call(message, "identifier")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.identifier); + return writer; + }; + + /** + * Encodes the specified ContestedResource message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.IContestedResource} message ContestedResource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ContestedResource.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ContestedResource message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource} ContestedResource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ContestedResource.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.identifier = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ContestedResource message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource} ContestedResource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ContestedResource.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ContestedResource message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ContestedResource.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.identifier != null && message.hasOwnProperty("identifier")) + if (!(message.identifier && typeof message.identifier.length === "number" || $util.isString(message.identifier))) + return "identifier: buffer expected"; + return null; + }; + + /** + * Creates a ContestedResource message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource} ContestedResource + */ + ContestedResource.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource(); + if (object.identifier != null) + if (typeof object.identifier === "string") + $util.base64.decode(object.identifier, message.identifier = $util.newBuffer($util.base64.length(object.identifier)), 0); + else if (object.identifier.length >= 0) + message.identifier = object.identifier; + return message; + }; + + /** + * Creates a plain object from a ContestedResource message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource} message ContestedResource + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ContestedResource.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if (options.bytes === String) + object.identifier = ""; + else { + object.identifier = []; + if (options.bytes !== Array) + object.identifier = $util.newBuffer(object.identifier); + } + if (message.identifier != null && message.hasOwnProperty("identifier")) + object.identifier = options.bytes === String ? $util.base64.encode(message.identifier, 0, message.identifier.length) : options.bytes === Array ? Array.prototype.slice.call(message.identifier) : message.identifier; + return object; + }; + + /** + * Converts this ContestedResource to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource + * @instance + * @returns {Object.} JSON object + */ + ContestedResource.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ContestedResource; + })(); + + return GetContestedResourcesResponseV0; + })(); + + return GetContestedResourcesResponse; + })(); + + v0.GetContestedResourceVoteStateRequest = (function() { + + /** + * Properties of a GetContestedResourceVoteStateRequest. + * @memberof org.dash.platform.dapi.v0 + * @interface IGetContestedResourceVoteStateRequest + * @property {org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.IGetContestedResourceVoteStateRequestV0|null} [v0] GetContestedResourceVoteStateRequest v0 + */ + + /** + * Constructs a new GetContestedResourceVoteStateRequest. + * @memberof org.dash.platform.dapi.v0 + * @classdesc Represents a GetContestedResourceVoteStateRequest. + * @implements IGetContestedResourceVoteStateRequest + * @constructor + * @param {org.dash.platform.dapi.v0.IGetContestedResourceVoteStateRequest=} [properties] Properties to set + */ + function GetContestedResourceVoteStateRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetContestedResourceVoteStateRequest v0. + * @member {org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.IGetContestedResourceVoteStateRequestV0|null|undefined} v0 + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest + * @instance + */ + GetContestedResourceVoteStateRequest.prototype.v0 = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GetContestedResourceVoteStateRequest version. + * @member {"v0"|undefined} version + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest + * @instance + */ + Object.defineProperty(GetContestedResourceVoteStateRequest.prototype, "version", { + get: $util.oneOfGetter($oneOfFields = ["v0"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new GetContestedResourceVoteStateRequest instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest + * @static + * @param {org.dash.platform.dapi.v0.IGetContestedResourceVoteStateRequest=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest} GetContestedResourceVoteStateRequest instance + */ + GetContestedResourceVoteStateRequest.create = function create(properties) { + return new GetContestedResourceVoteStateRequest(properties); + }; + + /** + * Encodes the specified GetContestedResourceVoteStateRequest message. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest + * @static + * @param {org.dash.platform.dapi.v0.IGetContestedResourceVoteStateRequest} message GetContestedResourceVoteStateRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourceVoteStateRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.v0 != null && Object.hasOwnProperty.call(message, "v0")) + $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.encode(message.v0, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetContestedResourceVoteStateRequest message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest + * @static + * @param {org.dash.platform.dapi.v0.IGetContestedResourceVoteStateRequest} message GetContestedResourceVoteStateRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourceVoteStateRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetContestedResourceVoteStateRequest message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest} GetContestedResourceVoteStateRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourceVoteStateRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.v0 = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetContestedResourceVoteStateRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest} GetContestedResourceVoteStateRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourceVoteStateRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetContestedResourceVoteStateRequest message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetContestedResourceVoteStateRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + properties.version = 1; + { + var error = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.verify(message.v0); + if (error) + return "v0." + error; + } + } + return null; + }; + + /** + * Creates a GetContestedResourceVoteStateRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest} GetContestedResourceVoteStateRequest + */ + GetContestedResourceVoteStateRequest.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest(); + if (object.v0 != null) { + if (typeof object.v0 !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.v0: object expected"); + message.v0 = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.fromObject(object.v0); + } + return message; + }; + + /** + * Creates a plain object from a GetContestedResourceVoteStateRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest} message GetContestedResourceVoteStateRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetContestedResourceVoteStateRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + object.v0 = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.toObject(message.v0, options); + if (options.oneofs) + object.version = "v0"; + } + return object; + }; + + /** + * Converts this GetContestedResourceVoteStateRequest to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest + * @instance + * @returns {Object.} JSON object + */ + GetContestedResourceVoteStateRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0 = (function() { + + /** + * Properties of a GetContestedResourceVoteStateRequestV0. + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest + * @interface IGetContestedResourceVoteStateRequestV0 + * @property {boolean|null} [prove] GetContestedResourceVoteStateRequestV0 prove + * @property {Array.|null} [resourcePath] GetContestedResourceVoteStateRequestV0 resourcePath + * @property {Uint8Array|null} [contestedResource] GetContestedResourceVoteStateRequestV0 contestedResource + * @property {Uint8Array|null} [startIdentifier] GetContestedResourceVoteStateRequestV0 startIdentifier + * @property {number|null} [count] GetContestedResourceVoteStateRequestV0 count + * @property {boolean|null} [ascending] GetContestedResourceVoteStateRequestV0 ascending + */ + + /** + * Constructs a new GetContestedResourceVoteStateRequestV0. + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest + * @classdesc Represents a GetContestedResourceVoteStateRequestV0. + * @implements IGetContestedResourceVoteStateRequestV0 + * @constructor + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.IGetContestedResourceVoteStateRequestV0=} [properties] Properties to set + */ + function GetContestedResourceVoteStateRequestV0(properties) { + this.resourcePath = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetContestedResourceVoteStateRequestV0 prove. + * @member {boolean} prove + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0 + * @instance + */ + GetContestedResourceVoteStateRequestV0.prototype.prove = false; + + /** + * GetContestedResourceVoteStateRequestV0 resourcePath. + * @member {Array.} resourcePath + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0 + * @instance + */ + GetContestedResourceVoteStateRequestV0.prototype.resourcePath = $util.emptyArray; + + /** + * GetContestedResourceVoteStateRequestV0 contestedResource. + * @member {Uint8Array} contestedResource + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0 + * @instance + */ + GetContestedResourceVoteStateRequestV0.prototype.contestedResource = $util.newBuffer([]); + + /** + * GetContestedResourceVoteStateRequestV0 startIdentifier. + * @member {Uint8Array} startIdentifier + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0 + * @instance + */ + GetContestedResourceVoteStateRequestV0.prototype.startIdentifier = $util.newBuffer([]); + + /** + * GetContestedResourceVoteStateRequestV0 count. + * @member {number} count + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0 + * @instance + */ + GetContestedResourceVoteStateRequestV0.prototype.count = 0; + + /** + * GetContestedResourceVoteStateRequestV0 ascending. + * @member {boolean} ascending + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0 + * @instance + */ + GetContestedResourceVoteStateRequestV0.prototype.ascending = false; + + /** + * Creates a new GetContestedResourceVoteStateRequestV0 instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.IGetContestedResourceVoteStateRequestV0=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} GetContestedResourceVoteStateRequestV0 instance + */ + GetContestedResourceVoteStateRequestV0.create = function create(properties) { + return new GetContestedResourceVoteStateRequestV0(properties); + }; + + /** + * Encodes the specified GetContestedResourceVoteStateRequestV0 message. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.IGetContestedResourceVoteStateRequestV0} message GetContestedResourceVoteStateRequestV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourceVoteStateRequestV0.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.prove != null && Object.hasOwnProperty.call(message, "prove")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.prove); + if (message.resourcePath != null && message.resourcePath.length) + for (var i = 0; i < message.resourcePath.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.resourcePath[i]); + if (message.contestedResource != null && Object.hasOwnProperty.call(message, "contestedResource")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.contestedResource); + if (message.startIdentifier != null && Object.hasOwnProperty.call(message, "startIdentifier")) + writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.startIdentifier); + if (message.count != null && Object.hasOwnProperty.call(message, "count")) + writer.uint32(/* id 5, wireType 0 =*/40).uint32(message.count); + if (message.ascending != null && Object.hasOwnProperty.call(message, "ascending")) + writer.uint32(/* id 6, wireType 0 =*/48).bool(message.ascending); + return writer; + }; + + /** + * Encodes the specified GetContestedResourceVoteStateRequestV0 message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.IGetContestedResourceVoteStateRequestV0} message GetContestedResourceVoteStateRequestV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourceVoteStateRequestV0.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetContestedResourceVoteStateRequestV0 message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} GetContestedResourceVoteStateRequestV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourceVoteStateRequestV0.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.prove = reader.bool(); + break; + case 2: + if (!(message.resourcePath && message.resourcePath.length)) + message.resourcePath = []; + message.resourcePath.push(reader.bytes()); + break; + case 3: + message.contestedResource = reader.bytes(); + break; + case 4: + message.startIdentifier = reader.bytes(); + break; + case 5: + message.count = reader.uint32(); + break; + case 6: + message.ascending = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetContestedResourceVoteStateRequestV0 message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} GetContestedResourceVoteStateRequestV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourceVoteStateRequestV0.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetContestedResourceVoteStateRequestV0 message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0 + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetContestedResourceVoteStateRequestV0.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.prove != null && message.hasOwnProperty("prove")) + if (typeof message.prove !== "boolean") + return "prove: boolean expected"; + if (message.resourcePath != null && message.hasOwnProperty("resourcePath")) { + if (!Array.isArray(message.resourcePath)) + return "resourcePath: array expected"; + for (var i = 0; i < message.resourcePath.length; ++i) + if (!(message.resourcePath[i] && typeof message.resourcePath[i].length === "number" || $util.isString(message.resourcePath[i]))) + return "resourcePath: buffer[] expected"; + } + if (message.contestedResource != null && message.hasOwnProperty("contestedResource")) + if (!(message.contestedResource && typeof message.contestedResource.length === "number" || $util.isString(message.contestedResource))) + return "contestedResource: buffer expected"; + if (message.startIdentifier != null && message.hasOwnProperty("startIdentifier")) + if (!(message.startIdentifier && typeof message.startIdentifier.length === "number" || $util.isString(message.startIdentifier))) + return "startIdentifier: buffer expected"; + if (message.count != null && message.hasOwnProperty("count")) + if (!$util.isInteger(message.count)) + return "count: integer expected"; + if (message.ascending != null && message.hasOwnProperty("ascending")) + if (typeof message.ascending !== "boolean") + return "ascending: boolean expected"; + return null; + }; + + /** + * Creates a GetContestedResourceVoteStateRequestV0 message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0 + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} GetContestedResourceVoteStateRequestV0 + */ + GetContestedResourceVoteStateRequestV0.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0(); + if (object.prove != null) + message.prove = Boolean(object.prove); + if (object.resourcePath) { + if (!Array.isArray(object.resourcePath)) + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.resourcePath: array expected"); + message.resourcePath = []; + for (var i = 0; i < object.resourcePath.length; ++i) + if (typeof object.resourcePath[i] === "string") + $util.base64.decode(object.resourcePath[i], message.resourcePath[i] = $util.newBuffer($util.base64.length(object.resourcePath[i])), 0); + else if (object.resourcePath[i].length >= 0) + message.resourcePath[i] = object.resourcePath[i]; + } + if (object.contestedResource != null) + if (typeof object.contestedResource === "string") + $util.base64.decode(object.contestedResource, message.contestedResource = $util.newBuffer($util.base64.length(object.contestedResource)), 0); + else if (object.contestedResource.length >= 0) + message.contestedResource = object.contestedResource; + if (object.startIdentifier != null) + if (typeof object.startIdentifier === "string") + $util.base64.decode(object.startIdentifier, message.startIdentifier = $util.newBuffer($util.base64.length(object.startIdentifier)), 0); + else if (object.startIdentifier.length >= 0) + message.startIdentifier = object.startIdentifier; + if (object.count != null) + message.count = object.count >>> 0; + if (object.ascending != null) + message.ascending = Boolean(object.ascending); + return message; + }; + + /** + * Creates a plain object from a GetContestedResourceVoteStateRequestV0 message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} message GetContestedResourceVoteStateRequestV0 + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetContestedResourceVoteStateRequestV0.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.resourcePath = []; + if (options.defaults) { + object.prove = false; + if (options.bytes === String) + object.contestedResource = ""; + else { + object.contestedResource = []; + if (options.bytes !== Array) + object.contestedResource = $util.newBuffer(object.contestedResource); + } + if (options.bytes === String) + object.startIdentifier = ""; + else { + object.startIdentifier = []; + if (options.bytes !== Array) + object.startIdentifier = $util.newBuffer(object.startIdentifier); + } + object.count = 0; + object.ascending = false; + } + if (message.prove != null && message.hasOwnProperty("prove")) + object.prove = message.prove; + if (message.resourcePath && message.resourcePath.length) { + object.resourcePath = []; + for (var j = 0; j < message.resourcePath.length; ++j) + object.resourcePath[j] = options.bytes === String ? $util.base64.encode(message.resourcePath[j], 0, message.resourcePath[j].length) : options.bytes === Array ? Array.prototype.slice.call(message.resourcePath[j]) : message.resourcePath[j]; + } + if (message.contestedResource != null && message.hasOwnProperty("contestedResource")) + object.contestedResource = options.bytes === String ? $util.base64.encode(message.contestedResource, 0, message.contestedResource.length) : options.bytes === Array ? Array.prototype.slice.call(message.contestedResource) : message.contestedResource; + if (message.startIdentifier != null && message.hasOwnProperty("startIdentifier")) + object.startIdentifier = options.bytes === String ? $util.base64.encode(message.startIdentifier, 0, message.startIdentifier.length) : options.bytes === Array ? Array.prototype.slice.call(message.startIdentifier) : message.startIdentifier; + if (message.count != null && message.hasOwnProperty("count")) + object.count = message.count; + if (message.ascending != null && message.hasOwnProperty("ascending")) + object.ascending = message.ascending; + return object; + }; + + /** + * Converts this GetContestedResourceVoteStateRequestV0 to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0 + * @instance + * @returns {Object.} JSON object + */ + GetContestedResourceVoteStateRequestV0.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GetContestedResourceVoteStateRequestV0; + })(); + + return GetContestedResourceVoteStateRequest; + })(); + + v0.GetContestedResourceVoteStateResponse = (function() { + + /** + * Properties of a GetContestedResourceVoteStateResponse. + * @memberof org.dash.platform.dapi.v0 + * @interface IGetContestedResourceVoteStateResponse + * @property {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.IGetContestedResourceVoteStateResponseV0|null} [v0] GetContestedResourceVoteStateResponse v0 + */ + + /** + * Constructs a new GetContestedResourceVoteStateResponse. + * @memberof org.dash.platform.dapi.v0 + * @classdesc Represents a GetContestedResourceVoteStateResponse. + * @implements IGetContestedResourceVoteStateResponse + * @constructor + * @param {org.dash.platform.dapi.v0.IGetContestedResourceVoteStateResponse=} [properties] Properties to set + */ + function GetContestedResourceVoteStateResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetContestedResourceVoteStateResponse v0. + * @member {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.IGetContestedResourceVoteStateResponseV0|null|undefined} v0 + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse + * @instance + */ + GetContestedResourceVoteStateResponse.prototype.v0 = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GetContestedResourceVoteStateResponse version. + * @member {"v0"|undefined} version + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse + * @instance + */ + Object.defineProperty(GetContestedResourceVoteStateResponse.prototype, "version", { + get: $util.oneOfGetter($oneOfFields = ["v0"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new GetContestedResourceVoteStateResponse instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse + * @static + * @param {org.dash.platform.dapi.v0.IGetContestedResourceVoteStateResponse=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse} GetContestedResourceVoteStateResponse instance + */ + GetContestedResourceVoteStateResponse.create = function create(properties) { + return new GetContestedResourceVoteStateResponse(properties); + }; + + /** + * Encodes the specified GetContestedResourceVoteStateResponse message. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse + * @static + * @param {org.dash.platform.dapi.v0.IGetContestedResourceVoteStateResponse} message GetContestedResourceVoteStateResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourceVoteStateResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.v0 != null && Object.hasOwnProperty.call(message, "v0")) + $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.encode(message.v0, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetContestedResourceVoteStateResponse message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse + * @static + * @param {org.dash.platform.dapi.v0.IGetContestedResourceVoteStateResponse} message GetContestedResourceVoteStateResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourceVoteStateResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetContestedResourceVoteStateResponse message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse} GetContestedResourceVoteStateResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourceVoteStateResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.v0 = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetContestedResourceVoteStateResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse} GetContestedResourceVoteStateResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourceVoteStateResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetContestedResourceVoteStateResponse message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetContestedResourceVoteStateResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + properties.version = 1; + { + var error = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.verify(message.v0); + if (error) + return "v0." + error; + } + } + return null; + }; + + /** + * Creates a GetContestedResourceVoteStateResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse} GetContestedResourceVoteStateResponse + */ + GetContestedResourceVoteStateResponse.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse(); + if (object.v0 != null) { + if (typeof object.v0 !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.v0: object expected"); + message.v0 = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.fromObject(object.v0); + } + return message; + }; + + /** + * Creates a plain object from a GetContestedResourceVoteStateResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse} message GetContestedResourceVoteStateResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetContestedResourceVoteStateResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + object.v0 = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.toObject(message.v0, options); + if (options.oneofs) + object.version = "v0"; + } + return object; + }; + + /** + * Converts this GetContestedResourceVoteStateResponse to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse + * @instance + * @returns {Object.} JSON object + */ + GetContestedResourceVoteStateResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0 = (function() { + + /** + * Properties of a GetContestedResourceVoteStateResponseV0. + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse + * @interface IGetContestedResourceVoteStateResponseV0 + * @property {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.IContestedResourceContenders|null} [contestedResourceContenders] GetContestedResourceVoteStateResponseV0 contestedResourceContenders + * @property {org.dash.platform.dapi.v0.IProof|null} [proof] GetContestedResourceVoteStateResponseV0 proof + * @property {org.dash.platform.dapi.v0.IResponseMetadata|null} [metadata] GetContestedResourceVoteStateResponseV0 metadata + */ + + /** + * Constructs a new GetContestedResourceVoteStateResponseV0. + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse + * @classdesc Represents a GetContestedResourceVoteStateResponseV0. + * @implements IGetContestedResourceVoteStateResponseV0 + * @constructor + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.IGetContestedResourceVoteStateResponseV0=} [properties] Properties to set + */ + function GetContestedResourceVoteStateResponseV0(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetContestedResourceVoteStateResponseV0 contestedResourceContenders. + * @member {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.IContestedResourceContenders|null|undefined} contestedResourceContenders + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0 + * @instance + */ + GetContestedResourceVoteStateResponseV0.prototype.contestedResourceContenders = null; + + /** + * GetContestedResourceVoteStateResponseV0 proof. + * @member {org.dash.platform.dapi.v0.IProof|null|undefined} proof + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0 + * @instance + */ + GetContestedResourceVoteStateResponseV0.prototype.proof = null; + + /** + * GetContestedResourceVoteStateResponseV0 metadata. + * @member {org.dash.platform.dapi.v0.IResponseMetadata|null|undefined} metadata + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0 + * @instance + */ + GetContestedResourceVoteStateResponseV0.prototype.metadata = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GetContestedResourceVoteStateResponseV0 result. + * @member {"contestedResourceContenders"|"proof"|undefined} result + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0 + * @instance + */ + Object.defineProperty(GetContestedResourceVoteStateResponseV0.prototype, "result", { + get: $util.oneOfGetter($oneOfFields = ["contestedResourceContenders", "proof"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new GetContestedResourceVoteStateResponseV0 instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.IGetContestedResourceVoteStateResponseV0=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} GetContestedResourceVoteStateResponseV0 instance + */ + GetContestedResourceVoteStateResponseV0.create = function create(properties) { + return new GetContestedResourceVoteStateResponseV0(properties); + }; + + /** + * Encodes the specified GetContestedResourceVoteStateResponseV0 message. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.IGetContestedResourceVoteStateResponseV0} message GetContestedResourceVoteStateResponseV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourceVoteStateResponseV0.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.contestedResourceContenders != null && Object.hasOwnProperty.call(message, "contestedResourceContenders")) + $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.encode(message.contestedResourceContenders, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.proof != null && Object.hasOwnProperty.call(message, "proof")) + $root.org.dash.platform.dapi.v0.Proof.encode(message.proof, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata")) + $root.org.dash.platform.dapi.v0.ResponseMetadata.encode(message.metadata, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetContestedResourceVoteStateResponseV0 message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.IGetContestedResourceVoteStateResponseV0} message GetContestedResourceVoteStateResponseV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourceVoteStateResponseV0.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetContestedResourceVoteStateResponseV0 message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} GetContestedResourceVoteStateResponseV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourceVoteStateResponseV0.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.contestedResourceContenders = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.decode(reader, reader.uint32()); + break; + case 2: + message.proof = $root.org.dash.platform.dapi.v0.Proof.decode(reader, reader.uint32()); + break; + case 3: + message.metadata = $root.org.dash.platform.dapi.v0.ResponseMetadata.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetContestedResourceVoteStateResponseV0 message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} GetContestedResourceVoteStateResponseV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourceVoteStateResponseV0.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetContestedResourceVoteStateResponseV0 message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0 + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetContestedResourceVoteStateResponseV0.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.contestedResourceContenders != null && message.hasOwnProperty("contestedResourceContenders")) { + properties.result = 1; + { + var error = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.verify(message.contestedResourceContenders); + if (error) + return "contestedResourceContenders." + error; + } + } + if (message.proof != null && message.hasOwnProperty("proof")) { + if (properties.result === 1) + return "result: multiple values"; + properties.result = 1; + { + var error = $root.org.dash.platform.dapi.v0.Proof.verify(message.proof); + if (error) + return "proof." + error; + } + } + if (message.metadata != null && message.hasOwnProperty("metadata")) { + var error = $root.org.dash.platform.dapi.v0.ResponseMetadata.verify(message.metadata); + if (error) + return "metadata." + error; + } + return null; + }; + + /** + * Creates a GetContestedResourceVoteStateResponseV0 message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0 + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} GetContestedResourceVoteStateResponseV0 + */ + GetContestedResourceVoteStateResponseV0.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0(); + if (object.contestedResourceContenders != null) { + if (typeof object.contestedResourceContenders !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.contestedResourceContenders: object expected"); + message.contestedResourceContenders = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.fromObject(object.contestedResourceContenders); + } + if (object.proof != null) { + if (typeof object.proof !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.proof: object expected"); + message.proof = $root.org.dash.platform.dapi.v0.Proof.fromObject(object.proof); + } + if (object.metadata != null) { + if (typeof object.metadata !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.metadata: object expected"); + message.metadata = $root.org.dash.platform.dapi.v0.ResponseMetadata.fromObject(object.metadata); + } + return message; + }; + + /** + * Creates a plain object from a GetContestedResourceVoteStateResponseV0 message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} message GetContestedResourceVoteStateResponseV0 + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetContestedResourceVoteStateResponseV0.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.metadata = null; + if (message.contestedResourceContenders != null && message.hasOwnProperty("contestedResourceContenders")) { + object.contestedResourceContenders = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.toObject(message.contestedResourceContenders, options); + if (options.oneofs) + object.result = "contestedResourceContenders"; + } + if (message.proof != null && message.hasOwnProperty("proof")) { + object.proof = $root.org.dash.platform.dapi.v0.Proof.toObject(message.proof, options); + if (options.oneofs) + object.result = "proof"; + } + if (message.metadata != null && message.hasOwnProperty("metadata")) + object.metadata = $root.org.dash.platform.dapi.v0.ResponseMetadata.toObject(message.metadata, options); + return object; + }; + + /** + * Converts this GetContestedResourceVoteStateResponseV0 to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0 + * @instance + * @returns {Object.} JSON object + */ + GetContestedResourceVoteStateResponseV0.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + GetContestedResourceVoteStateResponseV0.ContestedResourceContenders = (function() { + + /** + * Properties of a ContestedResourceContenders. + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0 + * @interface IContestedResourceContenders + * @property {Array.|null} [contenders] ContestedResourceContenders contenders + * @property {boolean|null} [finishedResults] ContestedResourceContenders finishedResults + */ + + /** + * Constructs a new ContestedResourceContenders. + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0 + * @classdesc Represents a ContestedResourceContenders. + * @implements IContestedResourceContenders + * @constructor + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.IContestedResourceContenders=} [properties] Properties to set + */ + function ContestedResourceContenders(properties) { + this.contenders = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ContestedResourceContenders contenders. + * @member {Array.} contenders + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders + * @instance + */ + ContestedResourceContenders.prototype.contenders = $util.emptyArray; + + /** + * ContestedResourceContenders finishedResults. + * @member {boolean} finishedResults + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders + * @instance + */ + ContestedResourceContenders.prototype.finishedResults = false; + + /** + * Creates a new ContestedResourceContenders instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.IContestedResourceContenders=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} ContestedResourceContenders instance + */ + ContestedResourceContenders.create = function create(properties) { + return new ContestedResourceContenders(properties); + }; + + /** + * Encodes the specified ContestedResourceContenders message. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.IContestedResourceContenders} message ContestedResourceContenders message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ContestedResourceContenders.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.contenders != null && message.contenders.length) + for (var i = 0; i < message.contenders.length; ++i) + $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.encode(message.contenders[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.finishedResults != null && Object.hasOwnProperty.call(message, "finishedResults")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.finishedResults); + return writer; + }; + + /** + * Encodes the specified ContestedResourceContenders message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.IContestedResourceContenders} message ContestedResourceContenders message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ContestedResourceContenders.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ContestedResourceContenders message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} ContestedResourceContenders + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ContestedResourceContenders.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.contenders && message.contenders.length)) + message.contenders = []; + message.contenders.push($root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.decode(reader, reader.uint32())); + break; + case 2: + message.finishedResults = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ContestedResourceContenders message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} ContestedResourceContenders + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ContestedResourceContenders.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ContestedResourceContenders message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ContestedResourceContenders.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.contenders != null && message.hasOwnProperty("contenders")) { + if (!Array.isArray(message.contenders)) + return "contenders: array expected"; + for (var i = 0; i < message.contenders.length; ++i) { + var error = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.verify(message.contenders[i]); + if (error) + return "contenders." + error; + } + } + if (message.finishedResults != null && message.hasOwnProperty("finishedResults")) + if (typeof message.finishedResults !== "boolean") + return "finishedResults: boolean expected"; + return null; + }; + + /** + * Creates a ContestedResourceContenders message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} ContestedResourceContenders + */ + ContestedResourceContenders.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders(); + if (object.contenders) { + if (!Array.isArray(object.contenders)) + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.contenders: array expected"); + message.contenders = []; + for (var i = 0; i < object.contenders.length; ++i) { + if (typeof object.contenders[i] !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.contenders: object expected"); + message.contenders[i] = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.fromObject(object.contenders[i]); + } + } + if (object.finishedResults != null) + message.finishedResults = Boolean(object.finishedResults); + return message; + }; + + /** + * Creates a plain object from a ContestedResourceContenders message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} message ContestedResourceContenders + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ContestedResourceContenders.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.contenders = []; + if (options.defaults) + object.finishedResults = false; + if (message.contenders && message.contenders.length) { + object.contenders = []; + for (var j = 0; j < message.contenders.length; ++j) + object.contenders[j] = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.toObject(message.contenders[j], options); + } + if (message.finishedResults != null && message.hasOwnProperty("finishedResults")) + object.finishedResults = message.finishedResults; + return object; + }; + + /** + * Converts this ContestedResourceContenders to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders + * @instance + * @returns {Object.} JSON object + */ + ContestedResourceContenders.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ContestedResourceContenders; + })(); + + GetContestedResourceVoteStateResponseV0.Contender = (function() { + + /** + * Properties of a Contender. + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0 + * @interface IContender + * @property {Uint8Array|null} [identifier] Contender identifier + * @property {number|null} [voteCount] Contender voteCount + */ + + /** + * Constructs a new Contender. + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0 + * @classdesc Represents a Contender. + * @implements IContender + * @constructor + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.IContender=} [properties] Properties to set + */ + function Contender(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Contender identifier. + * @member {Uint8Array} identifier + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender + * @instance + */ + Contender.prototype.identifier = $util.newBuffer([]); + + /** + * Contender voteCount. + * @member {number} voteCount + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender + * @instance + */ + Contender.prototype.voteCount = 0; + + /** + * Creates a new Contender instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.IContender=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender} Contender instance + */ + Contender.create = function create(properties) { + return new Contender(properties); + }; + + /** + * Encodes the specified Contender message. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.IContender} message Contender message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Contender.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.identifier != null && Object.hasOwnProperty.call(message, "identifier")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.identifier); + if (message.voteCount != null && Object.hasOwnProperty.call(message, "voteCount")) + writer.uint32(/* id 2, wireType 0 =*/16).uint32(message.voteCount); + return writer; + }; + + /** + * Encodes the specified Contender message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.IContender} message Contender message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Contender.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Contender message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender} Contender + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Contender.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.identifier = reader.bytes(); + break; + case 2: + message.voteCount = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Contender message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender} Contender + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Contender.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Contender message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Contender.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.identifier != null && message.hasOwnProperty("identifier")) + if (!(message.identifier && typeof message.identifier.length === "number" || $util.isString(message.identifier))) + return "identifier: buffer expected"; + if (message.voteCount != null && message.hasOwnProperty("voteCount")) + if (!$util.isInteger(message.voteCount)) + return "voteCount: integer expected"; + return null; + }; + + /** + * Creates a Contender message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender} Contender + */ + Contender.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender(); + if (object.identifier != null) + if (typeof object.identifier === "string") + $util.base64.decode(object.identifier, message.identifier = $util.newBuffer($util.base64.length(object.identifier)), 0); + else if (object.identifier.length >= 0) + message.identifier = object.identifier; + if (object.voteCount != null) + message.voteCount = object.voteCount >>> 0; + return message; + }; + + /** + * Creates a plain object from a Contender message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender} message Contender + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Contender.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if (options.bytes === String) + object.identifier = ""; + else { + object.identifier = []; + if (options.bytes !== Array) + object.identifier = $util.newBuffer(object.identifier); + } + object.voteCount = 0; + } + if (message.identifier != null && message.hasOwnProperty("identifier")) + object.identifier = options.bytes === String ? $util.base64.encode(message.identifier, 0, message.identifier.length) : options.bytes === Array ? Array.prototype.slice.call(message.identifier) : message.identifier; + if (message.voteCount != null && message.hasOwnProperty("voteCount")) + object.voteCount = message.voteCount; + return object; + }; + + /** + * Converts this Contender to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender + * @instance + * @returns {Object.} JSON object + */ + Contender.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Contender; + })(); + + return GetContestedResourceVoteStateResponseV0; + })(); + + return GetContestedResourceVoteStateResponse; + })(); + + v0.GetContestedResourceVoteStatusRequest = (function() { + + /** + * Properties of a GetContestedResourceVoteStatusRequest. + * @memberof org.dash.platform.dapi.v0 + * @interface IGetContestedResourceVoteStatusRequest + * @property {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.IGetContestedResourceVoteStatusRequestV0|null} [v0] GetContestedResourceVoteStatusRequest v0 + */ + + /** + * Constructs a new GetContestedResourceVoteStatusRequest. + * @memberof org.dash.platform.dapi.v0 + * @classdesc Represents a GetContestedResourceVoteStatusRequest. + * @implements IGetContestedResourceVoteStatusRequest + * @constructor + * @param {org.dash.platform.dapi.v0.IGetContestedResourceVoteStatusRequest=} [properties] Properties to set + */ + function GetContestedResourceVoteStatusRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetContestedResourceVoteStatusRequest v0. + * @member {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.IGetContestedResourceVoteStatusRequestV0|null|undefined} v0 + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest + * @instance + */ + GetContestedResourceVoteStatusRequest.prototype.v0 = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GetContestedResourceVoteStatusRequest version. + * @member {"v0"|undefined} version + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest + * @instance + */ + Object.defineProperty(GetContestedResourceVoteStatusRequest.prototype, "version", { + get: $util.oneOfGetter($oneOfFields = ["v0"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new GetContestedResourceVoteStatusRequest instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest + * @static + * @param {org.dash.platform.dapi.v0.IGetContestedResourceVoteStatusRequest=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest} GetContestedResourceVoteStatusRequest instance + */ + GetContestedResourceVoteStatusRequest.create = function create(properties) { + return new GetContestedResourceVoteStatusRequest(properties); + }; + + /** + * Encodes the specified GetContestedResourceVoteStatusRequest message. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest + * @static + * @param {org.dash.platform.dapi.v0.IGetContestedResourceVoteStatusRequest} message GetContestedResourceVoteStatusRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourceVoteStatusRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.v0 != null && Object.hasOwnProperty.call(message, "v0")) + $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.encode(message.v0, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetContestedResourceVoteStatusRequest message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest + * @static + * @param {org.dash.platform.dapi.v0.IGetContestedResourceVoteStatusRequest} message GetContestedResourceVoteStatusRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourceVoteStatusRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetContestedResourceVoteStatusRequest message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest} GetContestedResourceVoteStatusRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourceVoteStatusRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.v0 = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetContestedResourceVoteStatusRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest} GetContestedResourceVoteStatusRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourceVoteStatusRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetContestedResourceVoteStatusRequest message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetContestedResourceVoteStatusRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + properties.version = 1; + { + var error = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.verify(message.v0); + if (error) + return "v0." + error; + } + } + return null; + }; + + /** + * Creates a GetContestedResourceVoteStatusRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest} GetContestedResourceVoteStatusRequest + */ + GetContestedResourceVoteStatusRequest.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest(); + if (object.v0 != null) { + if (typeof object.v0 !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.v0: object expected"); + message.v0 = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.fromObject(object.v0); + } + return message; + }; + + /** + * Creates a plain object from a GetContestedResourceVoteStatusRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest} message GetContestedResourceVoteStatusRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetContestedResourceVoteStatusRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + object.v0 = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.toObject(message.v0, options); + if (options.oneofs) + object.version = "v0"; + } + return object; + }; + + /** + * Converts this GetContestedResourceVoteStatusRequest to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest + * @instance + * @returns {Object.} JSON object + */ + GetContestedResourceVoteStatusRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0 = (function() { + + /** + * Properties of a GetContestedResourceVoteStatusRequestV0. + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest + * @interface IGetContestedResourceVoteStatusRequestV0 + * @property {boolean|null} [prove] GetContestedResourceVoteStatusRequestV0 prove + * @property {Array.|null} [resourcePath] GetContestedResourceVoteStatusRequestV0 resourcePath + * @property {Uint8Array|null} [resourceIdentifier] GetContestedResourceVoteStatusRequestV0 resourceIdentifier + * @property {Uint8Array|null} [voterIdentifier] GetContestedResourceVoteStatusRequestV0 voterIdentifier + * @property {number|null} [count] GetContestedResourceVoteStatusRequestV0 count + * @property {boolean|null} [ascending] GetContestedResourceVoteStatusRequestV0 ascending + */ + + /** + * Constructs a new GetContestedResourceVoteStatusRequestV0. + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest + * @classdesc Represents a GetContestedResourceVoteStatusRequestV0. + * @implements IGetContestedResourceVoteStatusRequestV0 + * @constructor + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.IGetContestedResourceVoteStatusRequestV0=} [properties] Properties to set + */ + function GetContestedResourceVoteStatusRequestV0(properties) { + this.resourcePath = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetContestedResourceVoteStatusRequestV0 prove. + * @member {boolean} prove + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0 + * @instance + */ + GetContestedResourceVoteStatusRequestV0.prototype.prove = false; + + /** + * GetContestedResourceVoteStatusRequestV0 resourcePath. + * @member {Array.} resourcePath + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0 + * @instance + */ + GetContestedResourceVoteStatusRequestV0.prototype.resourcePath = $util.emptyArray; + + /** + * GetContestedResourceVoteStatusRequestV0 resourceIdentifier. + * @member {Uint8Array} resourceIdentifier + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0 + * @instance + */ + GetContestedResourceVoteStatusRequestV0.prototype.resourceIdentifier = $util.newBuffer([]); + + /** + * GetContestedResourceVoteStatusRequestV0 voterIdentifier. + * @member {Uint8Array} voterIdentifier + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0 + * @instance + */ + GetContestedResourceVoteStatusRequestV0.prototype.voterIdentifier = $util.newBuffer([]); + + /** + * GetContestedResourceVoteStatusRequestV0 count. + * @member {number} count + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0 + * @instance + */ + GetContestedResourceVoteStatusRequestV0.prototype.count = 0; + + /** + * GetContestedResourceVoteStatusRequestV0 ascending. + * @member {boolean} ascending + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0 + * @instance + */ + GetContestedResourceVoteStatusRequestV0.prototype.ascending = false; + + /** + * Creates a new GetContestedResourceVoteStatusRequestV0 instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.IGetContestedResourceVoteStatusRequestV0=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} GetContestedResourceVoteStatusRequestV0 instance + */ + GetContestedResourceVoteStatusRequestV0.create = function create(properties) { + return new GetContestedResourceVoteStatusRequestV0(properties); + }; + + /** + * Encodes the specified GetContestedResourceVoteStatusRequestV0 message. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.IGetContestedResourceVoteStatusRequestV0} message GetContestedResourceVoteStatusRequestV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourceVoteStatusRequestV0.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.prove != null && Object.hasOwnProperty.call(message, "prove")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.prove); + if (message.resourcePath != null && message.resourcePath.length) + for (var i = 0; i < message.resourcePath.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.resourcePath[i]); + if (message.resourceIdentifier != null && Object.hasOwnProperty.call(message, "resourceIdentifier")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.resourceIdentifier); + if (message.voterIdentifier != null && Object.hasOwnProperty.call(message, "voterIdentifier")) + writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.voterIdentifier); + if (message.count != null && Object.hasOwnProperty.call(message, "count")) + writer.uint32(/* id 5, wireType 0 =*/40).uint32(message.count); + if (message.ascending != null && Object.hasOwnProperty.call(message, "ascending")) + writer.uint32(/* id 6, wireType 0 =*/48).bool(message.ascending); + return writer; + }; + + /** + * Encodes the specified GetContestedResourceVoteStatusRequestV0 message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.IGetContestedResourceVoteStatusRequestV0} message GetContestedResourceVoteStatusRequestV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourceVoteStatusRequestV0.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetContestedResourceVoteStatusRequestV0 message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} GetContestedResourceVoteStatusRequestV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourceVoteStatusRequestV0.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.prove = reader.bool(); + break; + case 2: + if (!(message.resourcePath && message.resourcePath.length)) + message.resourcePath = []; + message.resourcePath.push(reader.bytes()); + break; + case 3: + message.resourceIdentifier = reader.bytes(); + break; + case 4: + message.voterIdentifier = reader.bytes(); + break; + case 5: + message.count = reader.uint32(); + break; + case 6: + message.ascending = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetContestedResourceVoteStatusRequestV0 message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} GetContestedResourceVoteStatusRequestV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourceVoteStatusRequestV0.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetContestedResourceVoteStatusRequestV0 message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0 + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetContestedResourceVoteStatusRequestV0.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.prove != null && message.hasOwnProperty("prove")) + if (typeof message.prove !== "boolean") + return "prove: boolean expected"; + if (message.resourcePath != null && message.hasOwnProperty("resourcePath")) { + if (!Array.isArray(message.resourcePath)) + return "resourcePath: array expected"; + for (var i = 0; i < message.resourcePath.length; ++i) + if (!(message.resourcePath[i] && typeof message.resourcePath[i].length === "number" || $util.isString(message.resourcePath[i]))) + return "resourcePath: buffer[] expected"; + } + if (message.resourceIdentifier != null && message.hasOwnProperty("resourceIdentifier")) + if (!(message.resourceIdentifier && typeof message.resourceIdentifier.length === "number" || $util.isString(message.resourceIdentifier))) + return "resourceIdentifier: buffer expected"; + if (message.voterIdentifier != null && message.hasOwnProperty("voterIdentifier")) + if (!(message.voterIdentifier && typeof message.voterIdentifier.length === "number" || $util.isString(message.voterIdentifier))) + return "voterIdentifier: buffer expected"; + if (message.count != null && message.hasOwnProperty("count")) + if (!$util.isInteger(message.count)) + return "count: integer expected"; + if (message.ascending != null && message.hasOwnProperty("ascending")) + if (typeof message.ascending !== "boolean") + return "ascending: boolean expected"; + return null; + }; + + /** + * Creates a GetContestedResourceVoteStatusRequestV0 message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0 + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} GetContestedResourceVoteStatusRequestV0 + */ + GetContestedResourceVoteStatusRequestV0.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0(); + if (object.prove != null) + message.prove = Boolean(object.prove); + if (object.resourcePath) { + if (!Array.isArray(object.resourcePath)) + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.resourcePath: array expected"); + message.resourcePath = []; + for (var i = 0; i < object.resourcePath.length; ++i) + if (typeof object.resourcePath[i] === "string") + $util.base64.decode(object.resourcePath[i], message.resourcePath[i] = $util.newBuffer($util.base64.length(object.resourcePath[i])), 0); + else if (object.resourcePath[i].length >= 0) + message.resourcePath[i] = object.resourcePath[i]; + } + if (object.resourceIdentifier != null) + if (typeof object.resourceIdentifier === "string") + $util.base64.decode(object.resourceIdentifier, message.resourceIdentifier = $util.newBuffer($util.base64.length(object.resourceIdentifier)), 0); + else if (object.resourceIdentifier.length >= 0) + message.resourceIdentifier = object.resourceIdentifier; + if (object.voterIdentifier != null) + if (typeof object.voterIdentifier === "string") + $util.base64.decode(object.voterIdentifier, message.voterIdentifier = $util.newBuffer($util.base64.length(object.voterIdentifier)), 0); + else if (object.voterIdentifier.length >= 0) + message.voterIdentifier = object.voterIdentifier; + if (object.count != null) + message.count = object.count >>> 0; + if (object.ascending != null) + message.ascending = Boolean(object.ascending); + return message; + }; + + /** + * Creates a plain object from a GetContestedResourceVoteStatusRequestV0 message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} message GetContestedResourceVoteStatusRequestV0 + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetContestedResourceVoteStatusRequestV0.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.resourcePath = []; + if (options.defaults) { + object.prove = false; + if (options.bytes === String) + object.resourceIdentifier = ""; + else { + object.resourceIdentifier = []; + if (options.bytes !== Array) + object.resourceIdentifier = $util.newBuffer(object.resourceIdentifier); + } + if (options.bytes === String) + object.voterIdentifier = ""; + else { + object.voterIdentifier = []; + if (options.bytes !== Array) + object.voterIdentifier = $util.newBuffer(object.voterIdentifier); + } + object.count = 0; + object.ascending = false; + } + if (message.prove != null && message.hasOwnProperty("prove")) + object.prove = message.prove; + if (message.resourcePath && message.resourcePath.length) { + object.resourcePath = []; + for (var j = 0; j < message.resourcePath.length; ++j) + object.resourcePath[j] = options.bytes === String ? $util.base64.encode(message.resourcePath[j], 0, message.resourcePath[j].length) : options.bytes === Array ? Array.prototype.slice.call(message.resourcePath[j]) : message.resourcePath[j]; + } + if (message.resourceIdentifier != null && message.hasOwnProperty("resourceIdentifier")) + object.resourceIdentifier = options.bytes === String ? $util.base64.encode(message.resourceIdentifier, 0, message.resourceIdentifier.length) : options.bytes === Array ? Array.prototype.slice.call(message.resourceIdentifier) : message.resourceIdentifier; + if (message.voterIdentifier != null && message.hasOwnProperty("voterIdentifier")) + object.voterIdentifier = options.bytes === String ? $util.base64.encode(message.voterIdentifier, 0, message.voterIdentifier.length) : options.bytes === Array ? Array.prototype.slice.call(message.voterIdentifier) : message.voterIdentifier; + if (message.count != null && message.hasOwnProperty("count")) + object.count = message.count; + if (message.ascending != null && message.hasOwnProperty("ascending")) + object.ascending = message.ascending; + return object; + }; + + /** + * Converts this GetContestedResourceVoteStatusRequestV0 to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0 + * @instance + * @returns {Object.} JSON object + */ + GetContestedResourceVoteStatusRequestV0.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GetContestedResourceVoteStatusRequestV0; + })(); + + return GetContestedResourceVoteStatusRequest; + })(); + + v0.GetContestedResourceVoteStatusResponse = (function() { + + /** + * Properties of a GetContestedResourceVoteStatusResponse. + * @memberof org.dash.platform.dapi.v0 + * @interface IGetContestedResourceVoteStatusResponse + * @property {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.IGetContestedResourceVoteStatusResponseV0|null} [v0] GetContestedResourceVoteStatusResponse v0 + */ + + /** + * Constructs a new GetContestedResourceVoteStatusResponse. + * @memberof org.dash.platform.dapi.v0 + * @classdesc Represents a GetContestedResourceVoteStatusResponse. + * @implements IGetContestedResourceVoteStatusResponse + * @constructor + * @param {org.dash.platform.dapi.v0.IGetContestedResourceVoteStatusResponse=} [properties] Properties to set + */ + function GetContestedResourceVoteStatusResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetContestedResourceVoteStatusResponse v0. + * @member {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.IGetContestedResourceVoteStatusResponseV0|null|undefined} v0 + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse + * @instance + */ + GetContestedResourceVoteStatusResponse.prototype.v0 = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GetContestedResourceVoteStatusResponse version. + * @member {"v0"|undefined} version + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse + * @instance + */ + Object.defineProperty(GetContestedResourceVoteStatusResponse.prototype, "version", { + get: $util.oneOfGetter($oneOfFields = ["v0"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new GetContestedResourceVoteStatusResponse instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse + * @static + * @param {org.dash.platform.dapi.v0.IGetContestedResourceVoteStatusResponse=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse} GetContestedResourceVoteStatusResponse instance + */ + GetContestedResourceVoteStatusResponse.create = function create(properties) { + return new GetContestedResourceVoteStatusResponse(properties); + }; + + /** + * Encodes the specified GetContestedResourceVoteStatusResponse message. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse + * @static + * @param {org.dash.platform.dapi.v0.IGetContestedResourceVoteStatusResponse} message GetContestedResourceVoteStatusResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourceVoteStatusResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.v0 != null && Object.hasOwnProperty.call(message, "v0")) + $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.encode(message.v0, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetContestedResourceVoteStatusResponse message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse + * @static + * @param {org.dash.platform.dapi.v0.IGetContestedResourceVoteStatusResponse} message GetContestedResourceVoteStatusResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourceVoteStatusResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetContestedResourceVoteStatusResponse message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse} GetContestedResourceVoteStatusResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourceVoteStatusResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.v0 = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetContestedResourceVoteStatusResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse} GetContestedResourceVoteStatusResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourceVoteStatusResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetContestedResourceVoteStatusResponse message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetContestedResourceVoteStatusResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + properties.version = 1; + { + var error = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.verify(message.v0); + if (error) + return "v0." + error; + } + } + return null; + }; + + /** + * Creates a GetContestedResourceVoteStatusResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse} GetContestedResourceVoteStatusResponse + */ + GetContestedResourceVoteStatusResponse.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse(); + if (object.v0 != null) { + if (typeof object.v0 !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.v0: object expected"); + message.v0 = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.fromObject(object.v0); + } + return message; + }; + + /** + * Creates a plain object from a GetContestedResourceVoteStatusResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse} message GetContestedResourceVoteStatusResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetContestedResourceVoteStatusResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.v0 != null && message.hasOwnProperty("v0")) { + object.v0 = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.toObject(message.v0, options); + if (options.oneofs) + object.version = "v0"; + } + return object; + }; + + /** + * Converts this GetContestedResourceVoteStatusResponse to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse + * @instance + * @returns {Object.} JSON object + */ + GetContestedResourceVoteStatusResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0 = (function() { + + /** + * Properties of a GetContestedResourceVoteStatusResponseV0. + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse + * @interface IGetContestedResourceVoteStatusResponseV0 + * @property {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.IContestedResourceVoters|null} [contestedResourceVoters] GetContestedResourceVoteStatusResponseV0 contestedResourceVoters + * @property {org.dash.platform.dapi.v0.IProof|null} [proof] GetContestedResourceVoteStatusResponseV0 proof + * @property {org.dash.platform.dapi.v0.IResponseMetadata|null} [metadata] GetContestedResourceVoteStatusResponseV0 metadata + */ + + /** + * Constructs a new GetContestedResourceVoteStatusResponseV0. + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse + * @classdesc Represents a GetContestedResourceVoteStatusResponseV0. + * @implements IGetContestedResourceVoteStatusResponseV0 + * @constructor + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.IGetContestedResourceVoteStatusResponseV0=} [properties] Properties to set + */ + function GetContestedResourceVoteStatusResponseV0(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetContestedResourceVoteStatusResponseV0 contestedResourceVoters. + * @member {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.IContestedResourceVoters|null|undefined} contestedResourceVoters + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0 + * @instance + */ + GetContestedResourceVoteStatusResponseV0.prototype.contestedResourceVoters = null; + + /** + * GetContestedResourceVoteStatusResponseV0 proof. + * @member {org.dash.platform.dapi.v0.IProof|null|undefined} proof + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0 + * @instance + */ + GetContestedResourceVoteStatusResponseV0.prototype.proof = null; + + /** + * GetContestedResourceVoteStatusResponseV0 metadata. + * @member {org.dash.platform.dapi.v0.IResponseMetadata|null|undefined} metadata + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0 + * @instance + */ + GetContestedResourceVoteStatusResponseV0.prototype.metadata = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GetContestedResourceVoteStatusResponseV0 result. + * @member {"contestedResourceVoters"|"proof"|undefined} result + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0 + * @instance + */ + Object.defineProperty(GetContestedResourceVoteStatusResponseV0.prototype, "result", { + get: $util.oneOfGetter($oneOfFields = ["contestedResourceVoters", "proof"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new GetContestedResourceVoteStatusResponseV0 instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.IGetContestedResourceVoteStatusResponseV0=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} GetContestedResourceVoteStatusResponseV0 instance + */ + GetContestedResourceVoteStatusResponseV0.create = function create(properties) { + return new GetContestedResourceVoteStatusResponseV0(properties); + }; + + /** + * Encodes the specified GetContestedResourceVoteStatusResponseV0 message. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.IGetContestedResourceVoteStatusResponseV0} message GetContestedResourceVoteStatusResponseV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourceVoteStatusResponseV0.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.contestedResourceVoters != null && Object.hasOwnProperty.call(message, "contestedResourceVoters")) + $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.encode(message.contestedResourceVoters, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.proof != null && Object.hasOwnProperty.call(message, "proof")) + $root.org.dash.platform.dapi.v0.Proof.encode(message.proof, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata")) + $root.org.dash.platform.dapi.v0.ResponseMetadata.encode(message.metadata, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetContestedResourceVoteStatusResponseV0 message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.IGetContestedResourceVoteStatusResponseV0} message GetContestedResourceVoteStatusResponseV0 message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetContestedResourceVoteStatusResponseV0.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetContestedResourceVoteStatusResponseV0 message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} GetContestedResourceVoteStatusResponseV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourceVoteStatusResponseV0.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.contestedResourceVoters = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.decode(reader, reader.uint32()); + break; + case 2: + message.proof = $root.org.dash.platform.dapi.v0.Proof.decode(reader, reader.uint32()); + break; + case 3: + message.metadata = $root.org.dash.platform.dapi.v0.ResponseMetadata.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetContestedResourceVoteStatusResponseV0 message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0 + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} GetContestedResourceVoteStatusResponseV0 + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetContestedResourceVoteStatusResponseV0.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetContestedResourceVoteStatusResponseV0 message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0 + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetContestedResourceVoteStatusResponseV0.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.contestedResourceVoters != null && message.hasOwnProperty("contestedResourceVoters")) { + properties.result = 1; + { + var error = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.verify(message.contestedResourceVoters); + if (error) + return "contestedResourceVoters." + error; + } + } + if (message.proof != null && message.hasOwnProperty("proof")) { + if (properties.result === 1) + return "result: multiple values"; + properties.result = 1; + { + var error = $root.org.dash.platform.dapi.v0.Proof.verify(message.proof); + if (error) + return "proof." + error; + } + } + if (message.metadata != null && message.hasOwnProperty("metadata")) { + var error = $root.org.dash.platform.dapi.v0.ResponseMetadata.verify(message.metadata); + if (error) + return "metadata." + error; + } + return null; + }; + + /** + * Creates a GetContestedResourceVoteStatusResponseV0 message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0 + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} GetContestedResourceVoteStatusResponseV0 + */ + GetContestedResourceVoteStatusResponseV0.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0(); + if (object.contestedResourceVoters != null) { + if (typeof object.contestedResourceVoters !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.contestedResourceVoters: object expected"); + message.contestedResourceVoters = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.fromObject(object.contestedResourceVoters); + } + if (object.proof != null) { + if (typeof object.proof !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.proof: object expected"); + message.proof = $root.org.dash.platform.dapi.v0.Proof.fromObject(object.proof); + } + if (object.metadata != null) { + if (typeof object.metadata !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.metadata: object expected"); + message.metadata = $root.org.dash.platform.dapi.v0.ResponseMetadata.fromObject(object.metadata); + } + return message; + }; + + /** + * Creates a plain object from a GetContestedResourceVoteStatusResponseV0 message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0 + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} message GetContestedResourceVoteStatusResponseV0 + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetContestedResourceVoteStatusResponseV0.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.metadata = null; + if (message.contestedResourceVoters != null && message.hasOwnProperty("contestedResourceVoters")) { + object.contestedResourceVoters = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.toObject(message.contestedResourceVoters, options); + if (options.oneofs) + object.result = "contestedResourceVoters"; + } + if (message.proof != null && message.hasOwnProperty("proof")) { + object.proof = $root.org.dash.platform.dapi.v0.Proof.toObject(message.proof, options); + if (options.oneofs) + object.result = "proof"; + } + if (message.metadata != null && message.hasOwnProperty("metadata")) + object.metadata = $root.org.dash.platform.dapi.v0.ResponseMetadata.toObject(message.metadata, options); + return object; + }; + + /** + * Converts this GetContestedResourceVoteStatusResponseV0 to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0 + * @instance + * @returns {Object.} JSON object + */ + GetContestedResourceVoteStatusResponseV0.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters = (function() { + + /** + * Properties of a ContestedResourceVoters. + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0 + * @interface IContestedResourceVoters + * @property {Array.|null} [voters] ContestedResourceVoters voters + * @property {boolean|null} [finishedResults] ContestedResourceVoters finishedResults + */ + + /** + * Constructs a new ContestedResourceVoters. + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0 + * @classdesc Represents a ContestedResourceVoters. + * @implements IContestedResourceVoters + * @constructor + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.IContestedResourceVoters=} [properties] Properties to set + */ + function ContestedResourceVoters(properties) { + this.voters = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ContestedResourceVoters voters. + * @member {Array.} voters + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters + * @instance + */ + ContestedResourceVoters.prototype.voters = $util.emptyArray; + + /** + * ContestedResourceVoters finishedResults. + * @member {boolean} finishedResults + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters + * @instance + */ + ContestedResourceVoters.prototype.finishedResults = false; + + /** + * Creates a new ContestedResourceVoters instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.IContestedResourceVoters=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} ContestedResourceVoters instance + */ + ContestedResourceVoters.create = function create(properties) { + return new ContestedResourceVoters(properties); + }; + + /** + * Encodes the specified ContestedResourceVoters message. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.IContestedResourceVoters} message ContestedResourceVoters message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ContestedResourceVoters.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.voters != null && message.voters.length) + for (var i = 0; i < message.voters.length; ++i) + $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.encode(message.voters[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.finishedResults != null && Object.hasOwnProperty.call(message, "finishedResults")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.finishedResults); + return writer; + }; + + /** + * Encodes the specified ContestedResourceVoters message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.IContestedResourceVoters} message ContestedResourceVoters message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ContestedResourceVoters.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ContestedResourceVoters message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} ContestedResourceVoters + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ContestedResourceVoters.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.voters && message.voters.length)) + message.voters = []; + message.voters.push($root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.decode(reader, reader.uint32())); + break; + case 2: + message.finishedResults = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ContestedResourceVoters message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} ContestedResourceVoters + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ContestedResourceVoters.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ContestedResourceVoters message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ContestedResourceVoters.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.voters != null && message.hasOwnProperty("voters")) { + if (!Array.isArray(message.voters)) + return "voters: array expected"; + for (var i = 0; i < message.voters.length; ++i) { + var error = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.verify(message.voters[i]); + if (error) + return "voters." + error; + } + } + if (message.finishedResults != null && message.hasOwnProperty("finishedResults")) + if (typeof message.finishedResults !== "boolean") + return "finishedResults: boolean expected"; + return null; + }; + + /** + * Creates a ContestedResourceVoters message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} ContestedResourceVoters + */ + ContestedResourceVoters.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters(); + if (object.voters) { + if (!Array.isArray(object.voters)) + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.voters: array expected"); + message.voters = []; + for (var i = 0; i < object.voters.length; ++i) { + if (typeof object.voters[i] !== "object") + throw TypeError(".org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.voters: object expected"); + message.voters[i] = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.fromObject(object.voters[i]); + } + } + if (object.finishedResults != null) + message.finishedResults = Boolean(object.finishedResults); + return message; + }; + + /** + * Creates a plain object from a ContestedResourceVoters message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} message ContestedResourceVoters + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ContestedResourceVoters.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.voters = []; + if (options.defaults) + object.finishedResults = false; + if (message.voters && message.voters.length) { + object.voters = []; + for (var j = 0; j < message.voters.length; ++j) + object.voters[j] = $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.toObject(message.voters[j], options); + } + if (message.finishedResults != null && message.hasOwnProperty("finishedResults")) + object.finishedResults = message.finishedResults; + return object; + }; + + /** + * Converts this ContestedResourceVoters to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters + * @instance + * @returns {Object.} JSON object + */ + ContestedResourceVoters.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ContestedResourceVoters; + })(); + + GetContestedResourceVoteStatusResponseV0.Voter = (function() { + + /** + * Properties of a Voter. + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0 + * @interface IVoter + * @property {Uint8Array|null} [identifier] Voter identifier + */ + + /** + * Constructs a new Voter. + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0 + * @classdesc Represents a Voter. + * @implements IVoter + * @constructor + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.IVoter=} [properties] Properties to set + */ + function Voter(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Voter identifier. + * @member {Uint8Array} identifier + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter + * @instance + */ + Voter.prototype.identifier = $util.newBuffer([]); + + /** + * Creates a new Voter instance using the specified properties. + * @function create + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.IVoter=} [properties] Properties to set + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter} Voter instance + */ + Voter.create = function create(properties) { + return new Voter(properties); + }; + + /** + * Encodes the specified Voter message. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.verify|verify} messages. + * @function encode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.IVoter} message Voter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Voter.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.identifier != null && Object.hasOwnProperty.call(message, "identifier")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.identifier); + return writer; + }; + + /** + * Encodes the specified Voter message, length delimited. Does not implicitly {@link org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.verify|verify} messages. + * @function encodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.IVoter} message Voter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Voter.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Voter message from the specified reader or buffer. + * @function decode + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter} Voter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Voter.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.identifier = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Voter message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter} Voter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Voter.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Voter message. + * @function verify + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Voter.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.identifier != null && message.hasOwnProperty("identifier")) + if (!(message.identifier && typeof message.identifier.length === "number" || $util.isString(message.identifier))) + return "identifier: buffer expected"; + return null; + }; + + /** + * Creates a Voter message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter + * @static + * @param {Object.} object Plain object + * @returns {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter} Voter + */ + Voter.fromObject = function fromObject(object) { + if (object instanceof $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter) + return object; + var message = new $root.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter(); + if (object.identifier != null) + if (typeof object.identifier === "string") + $util.base64.decode(object.identifier, message.identifier = $util.newBuffer($util.base64.length(object.identifier)), 0); + else if (object.identifier.length >= 0) + message.identifier = object.identifier; + return message; + }; + + /** + * Creates a plain object from a Voter message. Also converts values to other types if specified. + * @function toObject + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter + * @static + * @param {org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter} message Voter + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Voter.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if (options.bytes === String) + object.identifier = ""; + else { + object.identifier = []; + if (options.bytes !== Array) + object.identifier = $util.newBuffer(object.identifier); + } + if (message.identifier != null && message.hasOwnProperty("identifier")) + object.identifier = options.bytes === String ? $util.base64.encode(message.identifier, 0, message.identifier.length) : options.bytes === Array ? Array.prototype.slice.call(message.identifier) : message.identifier; + return object; + }; + + /** + * Converts this Voter to JSON. + * @function toJSON + * @memberof org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter + * @instance + * @returns {Object.} JSON object + */ + Voter.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Voter; + })(); + + return GetContestedResourceVoteStatusResponseV0; + })(); + + return GetContestedResourceVoteStatusResponse; + })(); + return v0; })(); diff --git a/packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js b/packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js index 9d6d3e76cf..3f9e383688 100644 --- a/packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js +++ b/packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js @@ -32,6 +32,33 @@ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.Co goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.VersionCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.VersionCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ResultCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.VersionCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.VersionCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ResultCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.VersionCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.VersionCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ResultCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.VersionCase', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.VersionCase', null, { proto }); @@ -2297,6 +2324,4590 @@ if (goog.DEBUG && !COMPILED) { */ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.displayName = 'proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo'; } +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.repeatedFields_, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.repeatedFields_, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.repeatedFields_, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.repeatedFields_, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.repeatedFields_, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.repeatedFields_, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter'; +} + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.Proof.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.Proof} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.Proof.toObject = function(includeInstance, msg) { + var f, obj = { + grovedbProof: msg.getGrovedbProof_asB64(), + quorumHash: msg.getQuorumHash_asB64(), + signature: msg.getSignature_asB64(), + round: jspb.Message.getFieldWithDefault(msg, 4, 0), + blockIdHash: msg.getBlockIdHash_asB64(), + quorumType: jspb.Message.getFieldWithDefault(msg, 6, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.Proof.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.Proof; + return proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.Proof} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setGrovedbProof(value); + break; + case 2: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setQuorumHash(value); + break; + case 3: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setSignature(value); + break; + case 4: + var value = /** @type {number} */ (reader.readUint32()); + msg.setRound(value); + break; + case 5: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setBlockIdHash(value); + break; + case 6: + var value = /** @type {number} */ (reader.readUint32()); + msg.setQuorumType(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.Proof} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getGrovedbProof_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } + f = message.getQuorumHash_asU8(); + if (f.length > 0) { + writer.writeBytes( + 2, + f + ); + } + f = message.getSignature_asU8(); + if (f.length > 0) { + writer.writeBytes( + 3, + f + ); + } + f = message.getRound(); + if (f !== 0) { + writer.writeUint32( + 4, + f + ); + } + f = message.getBlockIdHash_asU8(); + if (f.length > 0) { + writer.writeBytes( + 5, + f + ); + } + f = message.getQuorumType(); + if (f !== 0) { + writer.writeUint32( + 6, + f + ); + } +}; + + +/** + * optional bytes grovedb_proof = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getGrovedbProof = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes grovedb_proof = 1; + * This is a type-conversion wrapper around `getGrovedbProof()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getGrovedbProof_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getGrovedbProof())); +}; + + +/** + * optional bytes grovedb_proof = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getGrovedbProof()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getGrovedbProof_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getGrovedbProof())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.setGrovedbProof = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + +/** + * optional bytes quorum_hash = 2; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getQuorumHash = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * optional bytes quorum_hash = 2; + * This is a type-conversion wrapper around `getQuorumHash()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getQuorumHash_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getQuorumHash())); +}; + + +/** + * optional bytes quorum_hash = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getQuorumHash()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getQuorumHash_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getQuorumHash())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.setQuorumHash = function(value) { + return jspb.Message.setProto3BytesField(this, 2, value); +}; + + +/** + * optional bytes signature = 3; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getSignature = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * optional bytes signature = 3; + * This is a type-conversion wrapper around `getSignature()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getSignature_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getSignature())); +}; + + +/** + * optional bytes signature = 3; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getSignature()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getSignature_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getSignature())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.setSignature = function(value) { + return jspb.Message.setProto3BytesField(this, 3, value); +}; + + +/** + * optional uint32 round = 4; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getRound = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.setRound = function(value) { + return jspb.Message.setProto3IntField(this, 4, value); +}; + + +/** + * optional bytes block_id_hash = 5; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getBlockIdHash = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, "")); +}; + + +/** + * optional bytes block_id_hash = 5; + * This is a type-conversion wrapper around `getBlockIdHash()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getBlockIdHash_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getBlockIdHash())); +}; + + +/** + * optional bytes block_id_hash = 5; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getBlockIdHash()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getBlockIdHash_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getBlockIdHash())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.setBlockIdHash = function(value) { + return jspb.Message.setProto3BytesField(this, 5, value); +}; + + +/** + * optional uint32 quorum_type = 6; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getQuorumType = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 6, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.setQuorumType = function(value) { + return jspb.Message.setProto3IntField(this, 6, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.ResponseMetadata} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject = function(includeInstance, msg) { + var f, obj = { + height: jspb.Message.getFieldWithDefault(msg, 1, 0), + coreChainLockedHeight: jspb.Message.getFieldWithDefault(msg, 2, 0), + epoch: jspb.Message.getFieldWithDefault(msg, 3, 0), + timeMs: jspb.Message.getFieldWithDefault(msg, 4, 0), + protocolVersion: jspb.Message.getFieldWithDefault(msg, 5, 0), + chainId: jspb.Message.getFieldWithDefault(msg, 6, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + return proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.ResponseMetadata} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readUint64()); + msg.setHeight(value); + break; + case 2: + var value = /** @type {number} */ (reader.readUint32()); + msg.setCoreChainLockedHeight(value); + break; + case 3: + var value = /** @type {number} */ (reader.readUint32()); + msg.setEpoch(value); + break; + case 4: + var value = /** @type {number} */ (reader.readUint64()); + msg.setTimeMs(value); + break; + case 5: + var value = /** @type {number} */ (reader.readUint32()); + msg.setProtocolVersion(value); + break; + case 6: + var value = /** @type {string} */ (reader.readString()); + msg.setChainId(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.ResponseMetadata} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getHeight(); + if (f !== 0) { + writer.writeUint64( + 1, + f + ); + } + f = message.getCoreChainLockedHeight(); + if (f !== 0) { + writer.writeUint32( + 2, + f + ); + } + f = message.getEpoch(); + if (f !== 0) { + writer.writeUint32( + 3, + f + ); + } + f = message.getTimeMs(); + if (f !== 0) { + writer.writeUint64( + 4, + f + ); + } + f = message.getProtocolVersion(); + if (f !== 0) { + writer.writeUint32( + 5, + f + ); + } + f = message.getChainId(); + if (f.length > 0) { + writer.writeString( + 6, + f + ); + } +}; + + +/** + * optional uint64 height = 1; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getHeight = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setHeight = function(value) { + return jspb.Message.setProto3IntField(this, 1, value); +}; + + +/** + * optional uint32 core_chain_locked_height = 2; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getCoreChainLockedHeight = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setCoreChainLockedHeight = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); +}; + + +/** + * optional uint32 epoch = 3; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getEpoch = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setEpoch = function(value) { + return jspb.Message.setProto3IntField(this, 3, value); +}; + + +/** + * optional uint64 time_ms = 4; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getTimeMs = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setTimeMs = function(value) { + return jspb.Message.setProto3IntField(this, 4, value); +}; + + +/** + * optional uint32 protocol_version = 5; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getProtocolVersion = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setProtocolVersion = function(value) { + return jspb.Message.setProto3IntField(this, 5, value); +}; + + +/** + * optional string chain_id = 6; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getChainId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, "")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setChainId = function(value) { + return jspb.Message.setProto3StringField(this, 6, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.toObject = function(includeInstance, msg) { + var f, obj = { + code: jspb.Message.getFieldWithDefault(msg, 1, 0), + message: jspb.Message.getFieldWithDefault(msg, 2, ""), + data: msg.getData_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError; + return proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readUint32()); + msg.setCode(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setMessage(value); + break; + case 3: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setData(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getCode(); + if (f !== 0) { + writer.writeUint32( + 1, + f + ); + } + f = message.getMessage(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getData_asU8(); + if (f.length > 0) { + writer.writeBytes( + 3, + f + ); + } +}; + + +/** + * optional uint32 code = 1; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.getCode = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} returns this + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.setCode = function(value) { + return jspb.Message.setProto3IntField(this, 1, value); +}; + + +/** + * optional string message = 2; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.getMessage = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} returns this + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.setMessage = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional bytes data = 3; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.getData = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * optional bytes data = 3; + * This is a type-conversion wrapper around `getData()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.getData_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getData())); +}; + + +/** + * optional bytes data = 3; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getData()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.getData_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getData())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} returns this + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.setData = function(value) { + return jspb.Message.setProto3BytesField(this, 3, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.toObject = function(includeInstance, msg) { + var f, obj = { + stateTransition: msg.getStateTransition_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest; + return proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setStateTransition(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStateTransition_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } +}; + + +/** + * optional bytes state_transition = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.getStateTransition = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes state_transition = 1; + * This is a type-conversion wrapper around `getStateTransition()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.getStateTransition_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getStateTransition())); +}; + + +/** + * optional bytes state_transition = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getStateTransition()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.getStateTransition_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getStateTransition())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} returns this + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.setStateTransition = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse; + return proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentityRequest.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityRequest.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityRequest; + return proto.org.dash.platform.dapi.v0.GetIdentityRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentityRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.serializeBinaryToWriter + ); + } +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.toObject = function(includeInstance, msg) { + var f, obj = { + id: msg.getId_asB64(), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0; + return proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setId(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getId_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 2, + f + ); + } +}; + + +/** + * optional bytes id = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes id = 1; + * This is a type-conversion wrapper around `getId()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.getId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getId())); +}; + + +/** + * optional bytes id = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getId()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.getId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getId())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.setId = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + +/** + * optional bool prove = 2; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); +}; + + +/** + * optional GetIdentityRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest; + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.serializeBinaryToWriter + ); + } +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.toObject = function(includeInstance, msg) { + var f, obj = { + id: msg.getId_asB64(), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0; + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setId(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getId_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 2, + f + ); + } +}; + + +/** + * optional bytes id = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes id = 1; + * This is a type-conversion wrapper around `getId()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.getId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getId())); +}; + + +/** + * optional bytes id = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getId()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.getId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getId())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.setId = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + +/** + * optional bool prove = 2; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); +}; + + +/** + * optional GetIdentityBalanceRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest; + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.serializeBinaryToWriter + ); + } +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.toObject = function(includeInstance, msg) { + var f, obj = { + id: msg.getId_asB64(), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0; + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setId(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getId_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 2, + f + ); + } +}; + + +/** + * optional bytes id = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes id = 1; + * This is a type-conversion wrapper around `getId()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.getId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getId())); +}; + + +/** + * optional bytes id = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getId()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.getId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getId())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.setId = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + +/** + * optional bool prove = 2; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); +}; + + +/** + * optional GetIdentityBalanceAndRevisionRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentityResponse.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityResponse.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityResponse; + return proto.org.dash.platform.dapi.v0.GetIdentityResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentityResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.serializeBinaryToWriter + ); + } +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.oneofGroups_ = [[1,2]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + IDENTITY: 1, + PROOF: 2 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.ResultCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.toObject = function(includeInstance, msg) { + var f, obj = { + identity: msg.getIdentity_asB64(), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0; + return proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setIdentity(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeBytes( + 1, + f + ); + } + f = message.getProof(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + ); + } + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + ); + } +}; + + +/** + * optional bytes identity = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getIdentity = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes identity = 1; + * This is a type-conversion wrapper around `getIdentity()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getIdentity_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getIdentity())); +}; + + +/** + * optional bytes identity = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getIdentity()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getIdentity_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getIdentity())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.setIdentity = function(value) { + return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.clearIdentity = function() { + return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.oneofGroups_[0], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.hasIdentity = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional GetIdentityResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityResponse.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesRequest; + return proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.serializeBinaryToWriter + ); + } +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.repeatedFields_ = [1]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.toObject = function(includeInstance, msg) { + var f, obj = { + idsList: msg.getIdsList_asB64(), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0; + return proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.addIds(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getIdsList_asU8(); + if (f.length > 0) { + writer.writeRepeatedBytes( + 1, + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 2, + f + ); + } +}; + + +/** + * repeated bytes ids = 1; + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.getIdsList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); +}; + + +/** + * repeated bytes ids = 1; + * This is a type-conversion wrapper around `getIdsList()` + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.getIdsList_asB64 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsB64( + this.getIdsList())); +}; + + +/** + * repeated bytes ids = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getIdsList()` + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.getIdsList_asU8 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsU8( + this.getIdsList())); +}; + + +/** + * @param {!(Array|Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.setIdsList = function(value) { + return jspb.Message.setField(this, 1, value || []); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.addIds = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 1, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.clearIdsList = function() { + return this.setIdsList([]); +}; + + +/** + * optional bool prove = 2; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); +}; + + +/** + * optional GetIdentitiesRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse; + return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.serializeBinaryToWriter + ); + } +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.toObject = function(includeInstance, msg) { + var f, obj = { + value: msg.getValue_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue; + return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setValue(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getValue_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } +}; + + +/** + * optional bytes value = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.getValue = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes value = 1; + * This is a type-conversion wrapper around `getValue()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.getValue_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getValue())); +}; + + +/** + * optional bytes value = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getValue()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.getValue_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getValue())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.setValue = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.toObject = function(includeInstance, msg) { + var f, obj = { + key: msg.getKey_asB64(), + value: (f = msg.getValue()) && proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry; + return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setKey(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.deserializeBinaryFromReader); + msg.setValue(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getKey_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } + f = message.getValue(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.serializeBinaryToWriter + ); + } +}; + + +/** + * optional bytes key = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.getKey = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes key = 1; + * This is a type-conversion wrapper around `getKey()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.getKey_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getKey())); +}; + + +/** + * optional bytes key = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getKey()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.getKey_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getKey())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.setKey = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + +/** + * optional IdentityValue value = 2; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.getValue = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue, 2)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.setValue = function(value) { + return jspb.Message.setWrapperField(this, 2, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.clearValue = function() { + return this.setValue(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.hasValue = function() { + return jspb.Message.getField(this, 2) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.repeatedFields_ = [1]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.toObject = function(includeInstance, msg) { + var f, obj = { + identityEntriesList: jspb.Message.toObjectList(msg.getIdentityEntriesList(), + proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.toObject, includeInstance) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities; + return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.deserializeBinaryFromReader); + msg.addIdentityEntries(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getIdentityEntriesList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.serializeBinaryToWriter + ); + } +}; + + +/** + * repeated IdentityEntry identity_entries = 1; + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.getIdentityEntriesList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry, 1)); +}; + + +/** + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.setIdentityEntriesList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); +}; + + +/** + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry=} opt_value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.addIdentityEntries = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.clearIdentityEntriesList = function() { + return this.setIdentityEntriesList([]); +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.oneofGroups_ = [[1,2]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + IDENTITIES: 1, + PROOF: 2 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.ResultCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.toObject = function(includeInstance, msg) { + var f, obj = { + identities: (f = msg.getIdentities()) && proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.toObject(includeInstance, f), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0; + return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.deserializeBinaryFromReader); + msg.setIdentities(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getIdentities(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.serializeBinaryToWriter + ); + } + f = message.getProof(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + ); + } + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + ); + } +}; + + +/** + * optional Identities identities = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.getIdentities = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.setIdentities = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.clearIdentities = function() { + return this.setIdentities(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.hasIdentities = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional GetIdentitiesResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse; + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.serializeBinaryToWriter + ); + } +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.oneofGroups_ = [[1,2]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + BALANCE: 1, + PROOF: 2 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.ResultCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.oneofGroups_[0])); +}; @@ -2313,8 +6924,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.Proof.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.toObject(opt_includeInstance, this); }; @@ -2323,18 +6934,15 @@ proto.org.dash.platform.dapi.v0.Proof.prototype.toObject = function(opt_includeI * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.Proof} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.Proof.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - grovedbProof: msg.getGrovedbProof_asB64(), - quorumHash: msg.getQuorumHash_asB64(), - signature: msg.getSignature_asB64(), - round: jspb.Message.getFieldWithDefault(msg, 4, 0), - blockIdHash: msg.getBlockIdHash_asB64(), - quorumType: jspb.Message.getFieldWithDefault(msg, 6, 0) + balance: jspb.Message.getFieldWithDefault(msg, 1, 0), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; if (includeInstance) { @@ -2348,23 +6956,23 @@ proto.org.dash.platform.dapi.v0.Proof.toObject = function(includeInstance, msg) /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.Proof} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} */ -proto.org.dash.platform.dapi.v0.Proof.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.Proof; - return proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0; + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.Proof} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.Proof} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} */ -proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -2372,28 +6980,18 @@ proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader = function(msg var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setGrovedbProof(value); + var value = /** @type {number} */ (reader.readUint64()); + msg.setBalance(value); break; case 2: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setQuorumHash(value); + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); break; case 3: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setSignature(value); - break; - case 4: - var value = /** @type {number} */ (reader.readUint32()); - msg.setRound(value); - break; - case 5: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setBlockIdHash(value); - break; - case 6: - var value = /** @type {number} */ (reader.readUint32()); - msg.setQuorumType(value); + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); break; default: reader.skipField(); @@ -2408,9 +7006,9 @@ proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader = function(msg * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -2418,261 +7016,350 @@ proto.org.dash.platform.dapi.v0.Proof.prototype.serializeBinary = function() { /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.Proof} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getGrovedbProof_asU8(); - if (f.length > 0) { - writer.writeBytes( + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeUint64( 1, f ); } - f = message.getQuorumHash_asU8(); - if (f.length > 0) { - writer.writeBytes( + f = message.getProof(); + if (f != null) { + writer.writeMessage( 2, - f + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter ); } - f = message.getSignature_asU8(); - if (f.length > 0) { - writer.writeBytes( + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( 3, - f - ); - } - f = message.getRound(); - if (f !== 0) { - writer.writeUint32( - 4, - f - ); - } - f = message.getBlockIdHash_asU8(); - if (f.length > 0) { - writer.writeBytes( - 5, - f - ); - } - f = message.getQuorumType(); - if (f !== 0) { - writer.writeUint32( - 6, - f + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter ); } }; /** - * optional bytes grovedb_proof = 1; - * @return {string} + * optional uint64 balance = 1; + * @return {number} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getGrovedbProof = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.getBalance = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); }; /** - * optional bytes grovedb_proof = 1; - * This is a type-conversion wrapper around `getGrovedbProof()` - * @return {string} + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getGrovedbProof_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getGrovedbProof())); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.setBalance = function(value) { + return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.oneofGroups_[0], value); }; /** - * optional bytes grovedb_proof = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getGrovedbProof()` - * @return {!Uint8Array} + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getGrovedbProof_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getGrovedbProof())); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.clearBalance = function() { + return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.oneofGroups_[0], undefined); }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.setGrovedbProof = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.hasBalance = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); }; /** - * optional bytes quorum_hash = 2; - * @return {string} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getQuorumHash = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); }; /** - * optional bytes quorum_hash = 2; - * This is a type-conversion wrapper around `getQuorumHash()` - * @return {string} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getQuorumHash_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getQuorumHash())); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; }; /** - * optional bytes quorum_hash = 2; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getQuorumHash()` - * @return {!Uint8Array} + * optional GetIdentityBalanceResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getQuorumHash_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getQuorumHash())); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0, 1)); }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this - */ -proto.org.dash.platform.dapi.v0.Proof.prototype.setQuorumHash = function(value) { - return jspb.Message.setProto3BytesField(this, 2, value); + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.oneofGroups_[0], value); }; /** - * optional bytes signature = 3; - * @return {string} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} returns this */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getSignature = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * optional bytes signature = 3; - * This is a type-conversion wrapper around `getSignature()` - * @return {string} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getSignature_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getSignature())); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; + /** - * optional bytes signature = 3; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getSignature()` - * @return {!Uint8Array} + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getSignature_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getSignature())); -}; +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.oneofGroups_ = [[1]]; +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.setSignature = function(value) { - return jspb.Message.setProto3BytesField(this, 3, value); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.oneofGroups_[0])); }; + +if (jspb.Message.GENERATE_TO_OBJECT) { /** - * optional uint32 round = 4; - * @return {number} + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getRound = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.toObject(opt_includeInstance, this); }; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.Proof.prototype.setRound = function(value) { - return jspb.Message.setProto3IntField(this, 4, value); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; }; +} /** - * optional bytes block_id_hash = 5; - * @return {string} + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getBlockIdHash = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, "")); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse; + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.deserializeBinaryFromReader(msg, reader); }; /** - * optional bytes block_id_hash = 5; - * This is a type-conversion wrapper around `getBlockIdHash()` - * @return {string} + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getBlockIdHash_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getBlockIdHash())); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; }; /** - * optional bytes block_id_hash = 5; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getBlockIdHash()` + * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getBlockIdHash_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getBlockIdHash())); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.Proof.prototype.setBlockIdHash = function(value) { - return jspb.Message.setProto3BytesField(this, 5, value); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.serializeBinaryToWriter + ); + } }; + /** - * optional uint32 quorum_type = 6; - * @return {number} + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getQuorumType = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 6, 0)); -}; - +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.oneofGroups_ = [[1,2]]; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + * @enum {number} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.setQuorumType = function(value) { - return jspb.Message.setProto3IntField(this, 6, value); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + BALANCE_AND_REVISION: 1, + PROOF: 2 }; - +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.ResultCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.oneofGroups_[0])); +}; @@ -2689,8 +7376,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.toObject(opt_includeInstance, this); }; @@ -2699,18 +7386,15 @@ proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.toObject = function(o * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.ResponseMetadata} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - height: jspb.Message.getFieldWithDefault(msg, 1, 0), - coreChainLockedHeight: jspb.Message.getFieldWithDefault(msg, 2, 0), - epoch: jspb.Message.getFieldWithDefault(msg, 3, 0), - timeMs: jspb.Message.getFieldWithDefault(msg, 4, 0), - protocolVersion: jspb.Message.getFieldWithDefault(msg, 5, 0), - chainId: jspb.Message.getFieldWithDefault(msg, 6, "") + balanceAndRevision: (f = msg.getBalanceAndRevision()) && proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.toObject(includeInstance, f), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; if (includeInstance) { @@ -2724,23 +7408,23 @@ proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject = function(includeInst /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.ResponseMetadata; - return proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0; + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.ResponseMetadata} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -2748,28 +7432,19 @@ proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader = f var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {number} */ (reader.readUint64()); - msg.setHeight(value); + var value = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.deserializeBinaryFromReader); + msg.setBalanceAndRevision(value); break; case 2: - var value = /** @type {number} */ (reader.readUint32()); - msg.setCoreChainLockedHeight(value); + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); break; case 3: - var value = /** @type {number} */ (reader.readUint32()); - msg.setEpoch(value); - break; - case 4: - var value = /** @type {number} */ (reader.readUint64()); - msg.setTimeMs(value); - break; - case 5: - var value = /** @type {number} */ (reader.readUint32()); - msg.setProtocolVersion(value); - break; - case 6: - var value = /** @type {string} */ (reader.readString()); - msg.setChainId(value); + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); break; default: reader.skipField(); @@ -2784,9 +7459,9 @@ proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader = f * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -2794,165 +7469,39 @@ proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.serializeBinary = fun /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.ResponseMetadata} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getHeight(); - if (f !== 0) { - writer.writeUint64( + f = message.getBalanceAndRevision(); + if (f != null) { + writer.writeMessage( 1, - f + f, + proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.serializeBinaryToWriter ); } - f = message.getCoreChainLockedHeight(); - if (f !== 0) { - writer.writeUint32( + f = message.getProof(); + if (f != null) { + writer.writeMessage( 2, - f + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter ); } - f = message.getEpoch(); - if (f !== 0) { - writer.writeUint32( + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( 3, - f - ); - } - f = message.getTimeMs(); - if (f !== 0) { - writer.writeUint64( - 4, - f - ); - } - f = message.getProtocolVersion(); - if (f !== 0) { - writer.writeUint32( - 5, - f - ); - } - f = message.getChainId(); - if (f.length > 0) { - writer.writeString( - 6, - f + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter ); } }; -/** - * optional uint64 height = 1; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getHeight = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setHeight = function(value) { - return jspb.Message.setProto3IntField(this, 1, value); -}; - - -/** - * optional uint32 core_chain_locked_height = 2; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getCoreChainLockedHeight = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setCoreChainLockedHeight = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); -}; - - -/** - * optional uint32 epoch = 3; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getEpoch = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setEpoch = function(value) { - return jspb.Message.setProto3IntField(this, 3, value); -}; - - -/** - * optional uint64 time_ms = 4; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getTimeMs = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setTimeMs = function(value) { - return jspb.Message.setProto3IntField(this, 4, value); -}; - - -/** - * optional uint32 protocol_version = 5; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getProtocolVersion = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setProtocolVersion = function(value) { - return jspb.Message.setProto3IntField(this, 5, value); -}; - - -/** - * optional string chain_id = 6; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getChainId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, "")); -}; - - -/** - * @param {string} value - * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setChainId = function(value) { - return jspb.Message.setProto3StringField(this, 6, value); -}; - - @@ -2969,8 +7518,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.toObject(opt_includeInstance, this); }; @@ -2979,15 +7528,14 @@ proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.toObject * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.toObject = function(includeInstance, msg) { var f, obj = { - code: jspb.Message.getFieldWithDefault(msg, 1, 0), - message: jspb.Message.getFieldWithDefault(msg, 2, ""), - data: msg.getData_asB64() + balance: jspb.Message.getFieldWithDefault(msg, 1, 0), + revision: jspb.Message.getFieldWithDefault(msg, 2, 0) }; if (includeInstance) { @@ -3001,23 +7549,23 @@ proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.toObject = functio /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError; - return proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision; + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -3025,16 +7573,12 @@ proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.deserializeBinaryF var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {number} */ (reader.readUint32()); - msg.setCode(value); + var value = /** @type {number} */ (reader.readUint64()); + msg.setBalance(value); break; case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setMessage(value); - break; - case 3: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setData(value); + var value = /** @type {number} */ (reader.readUint64()); + msg.setRevision(value); break; default: reader.skipField(); @@ -3049,9 +7593,9 @@ proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.deserializeBinaryF * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -3059,30 +7603,23 @@ proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.serializ /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getCode(); - if (f !== 0) { - writer.writeUint32( - 1, - f - ); - } - f = message.getMessage(); - if (f.length > 0) { - writer.writeString( - 2, + f = message.getBalance(); + if (f !== 0) { + writer.writeUint64( + 1, f ); } - f = message.getData_asU8(); - if (f.length > 0) { - writer.writeBytes( - 3, + f = message.getRevision(); + if (f !== 0) { + writer.writeUint64( + 2, f ); } @@ -3090,240 +7627,219 @@ proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.serializeBinaryToW /** - * optional uint32 code = 1; + * optional uint64 balance = 1; * @return {number} */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.getCode = function() { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.getBalance = function() { return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); }; /** * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} returns this */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.setCode = function(value) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.setBalance = function(value) { return jspb.Message.setProto3IntField(this, 1, value); }; /** - * optional string message = 2; - * @return {string} + * optional uint64 revision = 2; + * @return {number} */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.getMessage = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.getRevision = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); }; /** - * @param {string} value - * @return {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} returns this + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} returns this */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.setMessage = function(value) { - return jspb.Message.setProto3StringField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.setRevision = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); }; /** - * optional bytes data = 3; - * @return {string} + * optional BalanceAndRevision balance_and_revision = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.getData = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.getBalanceAndRevision = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision, 1)); }; /** - * optional bytes data = 3; - * This is a type-conversion wrapper around `getData()` - * @return {string} + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.setBalanceAndRevision = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.getData_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getData())); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.clearBalanceAndRevision = function() { + return this.setBalanceAndRevision(undefined); }; /** - * optional bytes data = 3; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getData()` - * @return {!Uint8Array} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.getData_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getData())); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.hasBalanceAndRevision = function() { + return jspb.Message.getField(this, 1) != null; }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} returns this + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.setData = function(value) { - return jspb.Message.setProto3BytesField(this, 3, value); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; +/** + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.oneofGroups_[0], value); +}; + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); +}; -if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.toObject = function(includeInstance, msg) { - var f, obj = { - stateTransition: msg.getStateTransition_asB64() - }; +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +}; - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; + +/** + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest; - return proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setStateTransition(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; }; /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * optional GetIdentityBalanceAndRevisionResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0, 1)); }; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getStateTransition_asU8(); - if (f.length > 0) { - writer.writeBytes( - 1, - f - ); - } + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.oneofGroups_[0], value); }; /** - * optional bytes state_transition = 1; - * @return {string} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} returns this */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.getStateTransition = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * optional bytes state_transition = 1; - * This is a type-conversion wrapper around `getStateTransition()` - * @return {string} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.getStateTransition_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getStateTransition())); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; + /** - * optional bytes state_transition = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getStateTransition()` - * @return {!Uint8Array} + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.getStateTransition_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getStateTransition())); +proto.org.dash.platform.dapi.v0.KeyRequestType.oneofGroups_ = [[1,2,3]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.KeyRequestType.RequestCase = { + REQUEST_NOT_SET: 0, + ALL_KEYS: 1, + SPECIFIC_KEYS: 2, + SEARCH_KEY: 3 }; - /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} returns this + * @return {proto.org.dash.platform.dapi.v0.KeyRequestType.RequestCase} */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.setStateTransition = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.getRequestCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.KeyRequestType.RequestCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.KeyRequestType.oneofGroups_[0])); }; - - if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. @@ -3337,8 +7853,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.KeyRequestType.toObject(opt_includeInstance, this); }; @@ -3347,13 +7863,15 @@ proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.prototype.toObj * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.KeyRequestType} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.KeyRequestType.toObject = function(includeInstance, msg) { var f, obj = { - + allKeys: (f = msg.getAllKeys()) && proto.org.dash.platform.dapi.v0.AllKeys.toObject(includeInstance, f), + specificKeys: (f = msg.getSpecificKeys()) && proto.org.dash.platform.dapi.v0.SpecificKeys.toObject(includeInstance, f), + searchKey: (f = msg.getSearchKey()) && proto.org.dash.platform.dapi.v0.SearchKey.toObject(includeInstance, f) }; if (includeInstance) { @@ -3367,29 +7885,44 @@ proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.toObject = func /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse} + * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.KeyRequestType.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse; - return proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.KeyRequestType; + return proto.org.dash.platform.dapi.v0.KeyRequestType.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.KeyRequestType} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse} + * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.KeyRequestType.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.AllKeys; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.AllKeys.deserializeBinaryFromReader); + msg.setAllKeys(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.SpecificKeys; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.SpecificKeys.deserializeBinaryFromReader); + msg.setSpecificKeys(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.SearchKey; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.SearchKey.deserializeBinaryFromReader); + msg.setSearchKey(value); + break; default: reader.skipField(); break; @@ -3403,9 +7936,9 @@ proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.deserializeBina * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.KeyRequestType.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -3413,43 +7946,153 @@ proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.prototype.seria /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse} message + * @param {!proto.org.dash.platform.dapi.v0.KeyRequestType} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.KeyRequestType.serializeBinaryToWriter = function(message, writer) { var f = undefined; + f = message.getAllKeys(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.AllKeys.serializeBinaryToWriter + ); + } + f = message.getSpecificKeys(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.SpecificKeys.serializeBinaryToWriter + ); + } + f = message.getSearchKey(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.SearchKey.serializeBinaryToWriter + ); + } }; +/** + * optional AllKeys all_keys = 1; + * @return {?proto.org.dash.platform.dapi.v0.AllKeys} + */ +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.getAllKeys = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.AllKeys} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.AllKeys, 1)); +}; + /** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const + * @param {?proto.org.dash.platform.dapi.v0.AllKeys|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this +*/ +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.setAllKeys = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.KeyRequestType.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.clearAllKeys = function() { + return this.setAllKeys(undefined); +}; + /** - * @enum {number} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.hasAllKeys = function() { + return jspb.Message.getField(this, 1) != null; }; + /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityRequest.VersionCase} + * optional SpecificKeys specific_keys = 2; + * @return {?proto.org.dash.platform.dapi.v0.SpecificKeys} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.getSpecificKeys = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.SpecificKeys} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.SpecificKeys, 2)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.SpecificKeys|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this +*/ +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.setSpecificKeys = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.KeyRequestType.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this + */ +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.clearSpecificKeys = function() { + return this.setSpecificKeys(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.hasSpecificKeys = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional SearchKey search_key = 3; + * @return {?proto.org.dash.platform.dapi.v0.SearchKey} + */ +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.getSearchKey = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.SearchKey} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.SearchKey, 3)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.SearchKey|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this +*/ +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.setSearchKey = function(value) { + return jspb.Message.setOneofWrapperField(this, 3, proto.org.dash.platform.dapi.v0.KeyRequestType.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this + */ +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.clearSearchKey = function() { + return this.setSearchKey(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.hasSearchKey = function() { + return jspb.Message.getField(this, 3) != null; }; + + if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. @@ -3463,8 +8106,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.AllKeys.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.AllKeys.toObject(opt_includeInstance, this); }; @@ -3473,13 +8116,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.toObject = function * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.AllKeys} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.AllKeys.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.toObject(includeInstance, f) + }; if (includeInstance) { @@ -3493,34 +8136,29 @@ proto.org.dash.platform.dapi.v0.GetIdentityRequest.toObject = function(includeIn /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} + * @return {!proto.org.dash.platform.dapi.v0.AllKeys} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.AllKeys.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityRequest; - return proto.org.dash.platform.dapi.v0.GetIdentityRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.AllKeys; + return proto.org.dash.platform.dapi.v0.AllKeys.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.AllKeys} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} + * @return {!proto.org.dash.platform.dapi.v0.AllKeys} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.AllKeys.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { - case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.deserializeBinaryFromReader); - msg.setV0(value); - break; default: reader.skipField(); break; @@ -3534,9 +8172,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityRequest.deserializeBinaryFromReader = * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.AllKeys.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.AllKeys.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -3544,24 +8182,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.serializeBinary = f /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} message + * @param {!proto.org.dash.platform.dapi.v0.AllKeys} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.AllKeys.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getV0(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.serializeBinaryToWriter - ); - } }; +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.org.dash.platform.dapi.v0.SpecificKeys.repeatedFields_ = [1]; + if (jspb.Message.GENERATE_TO_OBJECT) { @@ -3577,8 +8214,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.SpecificKeys.toObject(opt_includeInstance, this); }; @@ -3587,14 +8224,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototyp * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.SpecificKeys} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.SpecificKeys.toObject = function(includeInstance, msg) { var f, obj = { - id: msg.getId_asB64(), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + keyIdsList: (f = jspb.Message.getRepeatedField(msg, 1)) == null ? undefined : f }; if (includeInstance) { @@ -3608,23 +8244,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.toObject /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.SpecificKeys} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.SpecificKeys.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0; - return proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.SpecificKeys; + return proto.org.dash.platform.dapi.v0.SpecificKeys.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.SpecificKeys} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.SpecificKeys} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.SpecificKeys.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -3632,12 +8268,10 @@ proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.deserial var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setId(value); - break; - case 2: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); + var values = /** @type {!Array} */ (reader.isDelimited() ? reader.readPackedUint32() : [reader.readUint32()]); + for (var i = 0; i < values.length; i++) { + msg.addKeyIds(values[i]); + } break; default: reader.skipField(); @@ -3652,9 +8286,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.deserial * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.SpecificKeys.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -3662,152 +8296,60 @@ proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototyp /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.SpecificKeys} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.SpecificKeys.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getId_asU8(); + f = message.getKeyIdsList(); if (f.length > 0) { - writer.writeBytes( + writer.writePackedUint32( 1, f ); } - f = message.getProve(); - if (f) { - writer.writeBool( - 2, - f - ); - } -}; - - -/** - * optional bytes id = 1; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.getId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * optional bytes id = 1; - * This is a type-conversion wrapper around `getId()` - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.getId_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getId())); -}; - - -/** - * optional bytes id = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getId()` - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.getId_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getId())); -}; - - -/** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.setId = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); -}; - - -/** - * optional bool prove = 2; - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); }; /** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} returns this + * repeated uint32 key_ids = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 2, value); +proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.getKeyIdsList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); }; /** - * optional GetIdentityRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.SpecificKeys} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0, 1)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.setKeyIdsList = function(value) { + return jspb.Message.setField(this, 1, value || []); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} returns this + * @param {number} value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.SpecificKeys} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.clearV0 = function() { - return this.setV0(undefined); +proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.addKeyIds = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 1, value, opt_index); }; /** - * Returns whether this field is set. - * @return {boolean} + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.SpecificKeys} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.clearKeyIdsList = function() { + return this.setKeyIdsList([]); }; -/** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.oneofGroups_ = [[1]]; - -/** - * @enum {number} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 -}; - -/** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.VersionCase} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.oneofGroups_[0])); -}; - if (jspb.Message.GENERATE_TO_OBJECT) { @@ -3823,8 +8365,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.SearchKey.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.SearchKey.toObject(opt_includeInstance, this); }; @@ -3833,13 +8375,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.toObject = f * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.SearchKey} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.SearchKey.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.toObject(includeInstance, f) + purposeMapMap: (f = msg.getPurposeMapMap()) ? f.toObject(includeInstance, proto.org.dash.platform.dapi.v0.SecurityLevelMap.toObject) : [] }; if (includeInstance) { @@ -3853,23 +8395,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.toObject = function(in /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} + * @return {!proto.org.dash.platform.dapi.v0.SearchKey} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.SearchKey.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest; - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.SearchKey; + return proto.org.dash.platform.dapi.v0.SearchKey.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.SearchKey} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} + * @return {!proto.org.dash.platform.dapi.v0.SearchKey} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.SearchKey.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -3877,9 +8419,10 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.deserializeBinaryFromR var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.deserializeBinaryFromReader); - msg.setV0(value); + var value = msg.getPurposeMapMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readUint32, jspb.BinaryReader.prototype.readMessage, proto.org.dash.platform.dapi.v0.SecurityLevelMap.deserializeBinaryFromReader, 0, new proto.org.dash.platform.dapi.v0.SecurityLevelMap()); + }); break; default: reader.skipField(); @@ -3894,9 +8437,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.deserializeBinaryFromR * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.SearchKey.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.SearchKey.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -3904,23 +8447,41 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.serializeBin /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} message + * @param {!proto.org.dash.platform.dapi.v0.SearchKey} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.SearchKey.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getV0(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.serializeBinaryToWriter - ); + f = message.getPurposeMapMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(1, writer, jspb.BinaryWriter.prototype.writeUint32, jspb.BinaryWriter.prototype.writeMessage, proto.org.dash.platform.dapi.v0.SecurityLevelMap.serializeBinaryToWriter); } }; +/** + * map purpose_map = 1; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.org.dash.platform.dapi.v0.SearchKey.prototype.getPurposeMapMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 1, opt_noLazyCreate, + proto.org.dash.platform.dapi.v0.SecurityLevelMap)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.org.dash.platform.dapi.v0.SearchKey} returns this + */ +proto.org.dash.platform.dapi.v0.SearchKey.prototype.clearPurposeMapMap = function() { + this.getPurposeMapMap().clear(); + return this;}; + + @@ -3937,8 +8498,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.SecurityLevelMap.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.SecurityLevelMap.toObject(opt_includeInstance, this); }; @@ -3947,14 +8508,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequ * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.SecurityLevelMap.toObject = function(includeInstance, msg) { var f, obj = { - id: msg.getId_asB64(), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + securityLevelMapMap: (f = msg.getSecurityLevelMapMap()) ? f.toObject(includeInstance, undefined) : [] }; if (includeInstance) { @@ -3968,23 +8528,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequ /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0; - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.SecurityLevelMap.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.SecurityLevelMap; + return proto.org.dash.platform.dapi.v0.SecurityLevelMap.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.SecurityLevelMap.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -3992,12 +8552,10 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequ var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setId(value); - break; - case 2: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); + var value = msg.getSecurityLevelMapMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readUint32, jspb.BinaryReader.prototype.readEnum, null, 0, 0); + }); break; default: reader.skipField(); @@ -4012,9 +8570,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequ * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.SecurityLevelMap.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.SecurityLevelMap.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -4022,124 +8580,47 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequ /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.SecurityLevelMap.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getId_asU8(); - if (f.length > 0) { - writer.writeBytes( - 1, - f - ); - } - f = message.getProve(); - if (f) { - writer.writeBool( - 2, - f - ); + f = message.getSecurityLevelMapMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(1, writer, jspb.BinaryWriter.prototype.writeUint32, jspb.BinaryWriter.prototype.writeEnum); } }; /** - * optional bytes id = 1; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.getId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * optional bytes id = 1; - * This is a type-conversion wrapper around `getId()` - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.getId_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getId())); -}; - - -/** - * optional bytes id = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getId()` - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.getId_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getId())); -}; - - -/** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.setId = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); -}; - - -/** - * optional bool prove = 2; - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); -}; - - -/** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 2, value); -}; - - -/** - * optional GetIdentityBalanceRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} + * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0, 1)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.SecurityLevelMap.KeyKindRequestType = { + CURRENT_KEY_OF_KIND_REQUEST: 0, + ALL_KEYS_OF_KIND_REQUEST: 1 }; - /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} returns this + * map security_level_map = 1; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.clearV0 = function() { - return this.setV0(undefined); +proto.org.dash.platform.dapi.v0.SecurityLevelMap.prototype.getSecurityLevelMapMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 1, opt_noLazyCreate, + null)); }; /** - * Returns whether this field is set. - * @return {boolean} + * Clears values from the map. The map will be non-null. + * @return {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; -}; +proto.org.dash.platform.dapi.v0.SecurityLevelMap.prototype.clearSecurityLevelMapMap = function() { + this.getSecurityLevelMapMap().clear(); + return this;}; @@ -4151,21 +8632,21 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.hasV0 = func * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.oneofGroups_[0])); }; @@ -4183,8 +8664,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.toObject(opt_includeInstance, this); }; @@ -4193,13 +8674,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.t * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -4213,23 +8694,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.toObject = /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest; - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest; + return proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -4237,8 +8718,8 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.deserialize var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -4254,9 +8735,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.deserialize * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -4264,18 +8745,18 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.s /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.serializeBinaryToWriter ); } }; @@ -4297,8 +8778,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.toObject(opt_includeInstance, this); }; @@ -4307,14 +8788,17 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentity * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - id: msg.getId_asB64(), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + identityId: msg.getIdentityId_asB64(), + requestType: (f = msg.getRequestType()) && proto.org.dash.platform.dapi.v0.KeyRequestType.toObject(includeInstance, f), + limit: (f = msg.getLimit()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), + offset: (f = msg.getOffset()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 5, false) }; if (includeInstance) { @@ -4328,23 +8812,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentity /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0; - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0; + return proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -4353,9 +8837,24 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentity switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setId(value); + msg.setIdentityId(value); break; case 2: + var value = new proto.org.dash.platform.dapi.v0.KeyRequestType; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.KeyRequestType.deserializeBinaryFromReader); + msg.setRequestType(value); + break; + case 3: + var value = new google_protobuf_wrappers_pb.UInt32Value; + reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); + msg.setLimit(value); + break; + case 4: + var value = new google_protobuf_wrappers_pb.UInt32Value; + reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); + msg.setOffset(value); + break; + case 5: var value = /** @type {boolean} */ (reader.readBool()); msg.setProve(value); break; @@ -4372,9 +8871,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentity * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -4382,23 +8881,47 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentity /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getId_asU8(); + f = message.getIdentityId_asU8(); if (f.length > 0) { writer.writeBytes( 1, f ); } + f = message.getRequestType(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.KeyRequestType.serializeBinaryToWriter + ); + } + f = message.getLimit(); + if (f != null) { + writer.writeMessage( + 3, + f, + google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter + ); + } + f = message.getOffset(); + if (f != null) { + writer.writeMessage( + 4, + f, + google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter + ); + } f = message.getProve(); if (f) { writer.writeBool( - 2, + 5, f ); } @@ -4406,90 +8929,109 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentity /** - * optional bytes id = 1; + * optional bytes identity_id = 1; * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.getId = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getIdentityId = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * optional bytes id = 1; - * This is a type-conversion wrapper around `getId()` + * optional bytes identity_id = 1; + * This is a type-conversion wrapper around `getIdentityId()` * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.getId_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getIdentityId_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getId())); + this.getIdentityId())); }; /** - * optional bytes id = 1; + * optional bytes identity_id = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getId()` + * This is a type-conversion wrapper around `getIdentityId()` * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.getId_asU8 = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getIdentityId_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getId())); + this.getIdentityId())); }; /** * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.setId = function(value) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.setIdentityId = function(value) { return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional bool prove = 2; - * @return {boolean} + * optional KeyRequestType request_type = 2; + * @return {?proto.org.dash.platform.dapi.v0.KeyRequestType} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getRequestType = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.KeyRequestType} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.KeyRequestType, 2)); }; /** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.KeyRequestType|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.setRequestType = function(value) { + return jspb.Message.setWrapperField(this, 2, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.clearRequestType = function() { + return this.setRequestType(undefined); }; /** - * optional GetIdentityBalanceAndRevisionRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.hasRequestType = function() { + return jspb.Message.getField(this, 2) != null; }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} returns this + * optional google.protobuf.UInt32Value limit = 3; + * @return {?proto.google.protobuf.UInt32Value} + */ +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getLimit = function() { + return /** @type{?proto.google.protobuf.UInt32Value} */ ( + jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 3)); +}; + + +/** + * @param {?proto.google.protobuf.UInt32Value|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.setLimit = function(value) { + return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.clearV0 = function() { - return this.setV0(undefined); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.clearLimit = function() { + return this.setLimit(undefined); }; @@ -4497,147 +9039,100 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.c * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.hasLimit = function() { + return jspb.Message.getField(this, 3) != null; }; - /** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const + * optional google.protobuf.UInt32Value offset = 4; + * @return {?proto.google.protobuf.UInt32Value} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getOffset = function() { + return /** @type{?proto.google.protobuf.UInt32Value} */ ( + jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 4)); +}; + /** - * @enum {number} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 + * @param {?proto.google.protobuf.UInt32Value|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.setOffset = function(value) { + return jspb.Message.setWrapperField(this, 4, value); }; + /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityResponse.VersionCase} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.clearOffset = function() { + return this.setOffset(undefined); }; - -if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.hasOffset = function() { + return jspb.Message.getField(this, 4) != null; }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional bool prove = 5; + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.toObject = function(includeInstance, msg) { - var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.toObject(includeInstance, f) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 5, false)); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityResponse; - return proto.org.dash.platform.dapi.v0.GetIdentityResponse.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 5, value); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} + * optional GetIdentityKeysRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.deserializeBinaryFromReader); - msg.setV0(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0, 1)); }; /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getV0(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.serializeBinaryToWriter - ); - } +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; @@ -4650,22 +9145,21 @@ proto.org.dash.platform.dapi.v0.GetIdentityResponse.serializeBinaryToWriter = fu * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.ResultCase = { - RESULT_NOT_SET: 0, - IDENTITY: 1, - PROOF: 2 +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.ResultCase} + * @return {proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.oneofGroups_[0])); }; @@ -4683,8 +9177,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.toObject(opt_includeInstance, this); }; @@ -4693,15 +9187,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.protot * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.toObject = function(includeInstance, msg) { var f, obj = { - identity: msg.getIdentity_asB64(), - proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), - metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -4715,23 +9207,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.toObje /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0; - return proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse; + return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -4739,18 +9231,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.deseri var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setIdentity(value); - break; - case 2: - var value = new proto.org.dash.platform.dapi.v0.Proof; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); - msg.setProof(value); - break; - case 3: - var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); - msg.setMetadata(value); + var value = new proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.deserializeBinaryFromReader); + msg.setV0(value); break; default: reader.skipField(); @@ -4765,9 +9248,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.deseri * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -4775,206 +9258,20 @@ proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.protot /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 1)); - if (f != null) { - writer.writeBytes( - 1, - f - ); - } - f = message.getProof(); - if (f != null) { - writer.writeMessage( - 2, - f, - proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter - ); - } - f = message.getMetadata(); + f = message.getV0(); if (f != null) { writer.writeMessage( - 3, - f, - proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter - ); - } -}; - - -/** - * optional bytes identity = 1; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getIdentity = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * optional bytes identity = 1; - * This is a type-conversion wrapper around `getIdentity()` - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getIdentity_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getIdentity())); -}; - - -/** - * optional bytes identity = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getIdentity()` - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getIdentity_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getIdentity())); -}; - - -/** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.setIdentity = function(value) { - return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.oneofGroups_[0], value); -}; - - -/** - * Clears the field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.clearIdentity = function() { - return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.oneofGroups_[0], undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.hasIdentity = function() { - return jspb.Message.getField(this, 1) != null; -}; - - -/** - * optional Proof proof = 2; - * @return {?proto.org.dash.platform.dapi.v0.Proof} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getProof = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.oneofGroups_[0], value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.clearProof = function() { - return this.setProof(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.hasProof = function() { - return jspb.Message.getField(this, 2) != null; -}; - - -/** - * optional ResponseMetadata metadata = 3; - * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getMetadata = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.setMetadata = function(value) { - return jspb.Message.setWrapperField(this, 3, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.clearMetadata = function() { - return this.setMetadata(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.hasMetadata = function() { - return jspb.Message.getField(this, 3) != null; -}; - - -/** - * optional GetIdentityResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0, 1)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityResponse.oneofGroups_[0], value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.clearV0 = function() { - return this.setV0(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.serializeBinaryToWriter + ); + } }; @@ -4987,21 +9284,22 @@ proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.hasV0 = function() * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + KEYS: 1, + PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.oneofGroups_[0])); }; @@ -5019,8 +9317,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.toObject(opt_includeInstance, this); }; @@ -5029,13 +9327,15 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.toObject = functi * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.toObject(includeInstance, f) + keys: (f = msg.getKeys()) && proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.toObject(includeInstance, f), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; if (includeInstance) { @@ -5049,23 +9349,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.toObject = function(include /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesRequest; - return proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0; + return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -5073,9 +9373,19 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.deserializeBinaryFromReader var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.deserializeBinaryFromReader); - msg.setV0(value); + var value = new proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.deserializeBinaryFromReader); + msg.setKeys(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); break; default: reader.skipField(); @@ -5090,9 +9400,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.deserializeBinaryFromReader * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -5100,18 +9410,34 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.serializeBinary = /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getV0(); + f = message.getKeys(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.serializeBinaryToWriter + ); + } + f = message.getProof(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + ); + } + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter ); } }; @@ -5123,7 +9449,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.serializeBinaryToWriter = f * @private {!Array} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.repeatedFields_ = [1]; @@ -5140,8 +9466,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.toObject(opt_includeInstance, this); }; @@ -5150,14 +9476,13 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prot * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.toObject = function(includeInstance, msg) { var f, obj = { - idsList: msg.getIdsList_asB64(), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + keysBytesList: msg.getKeysBytesList_asB64() }; if (includeInstance) { @@ -5171,23 +9496,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.toOb /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0; - return proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys; + return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -5196,11 +9521,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.dese switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.addIds(value); - break; - case 2: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); + msg.addKeysBytes(value); break; default: reader.skipField(); @@ -5215,9 +9536,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.dese * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -5225,132 +9546,218 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prot /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getIdsList_asU8(); + f = message.getKeysBytesList_asU8(); if (f.length > 0) { writer.writeRepeatedBytes( 1, f ); } - f = message.getProve(); - if (f) { - writer.writeBool( - 2, - f - ); - } }; /** - * repeated bytes ids = 1; + * repeated bytes keys_bytes = 1; * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.getIdsList = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.getKeysBytesList = function() { return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); }; /** - * repeated bytes ids = 1; - * This is a type-conversion wrapper around `getIdsList()` + * repeated bytes keys_bytes = 1; + * This is a type-conversion wrapper around `getKeysBytesList()` * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.getIdsList_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.getKeysBytesList_asB64 = function() { return /** @type {!Array} */ (jspb.Message.bytesListAsB64( - this.getIdsList())); + this.getKeysBytesList())); }; /** - * repeated bytes ids = 1; + * repeated bytes keys_bytes = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getIdsList()` + * This is a type-conversion wrapper around `getKeysBytesList()` * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.getIdsList_asU8 = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.getKeysBytesList_asU8 = function() { return /** @type {!Array} */ (jspb.Message.bytesListAsU8( - this.getIdsList())); + this.getKeysBytesList())); }; /** * @param {!(Array|Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.setIdsList = function(value) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.setKeysBytesList = function(value) { return jspb.Message.setField(this, 1, value || []); }; /** - * @param {!(string|Uint8Array)} value - * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} returns this + * @param {!(string|Uint8Array)} value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.addKeysBytes = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 1, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.clearKeysBytesList = function() { + return this.setKeysBytesList([]); +}; + + +/** + * optional Keys keys = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} + */ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.getKeys = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.setKeys = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.clearKeys = function() { + return this.setKeys(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.hasKeys = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.addIds = function(value, opt_index) { - return jspb.Message.addToRepeatedField(this, 1, value, opt_index); +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; /** - * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.clearIdsList = function() { - return this.setIdsList([]); + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); }; /** - * optional bool prove = 2; - * @return {boolean} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); }; /** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; }; /** - * optional GetIdentitiesRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} + * optional GetIdentityKeysResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -5359,7 +9766,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.clearV0 = functio * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -5373,21 +9780,21 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.hasV0 = function( * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetProofsRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetProofsRequest.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetProofsRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetProofsRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProofsRequest.oneofGroups_[0])); }; @@ -5405,8 +9812,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProofsRequest.toObject(opt_includeInstance, this); }; @@ -5415,13 +9822,13 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.toObject = funct * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -5435,23 +9842,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.toObject = function(includ /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse; - return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProofsRequest; + return proto.org.dash.platform.dapi.v0.GetProofsRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -5459,8 +9866,8 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.deserializeBinaryFromReade var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -5476,9 +9883,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.deserializeBinaryFromReade * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProofsRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -5486,24 +9893,31 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.serializeBinary /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.serializeBinaryToWriter ); } }; +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.repeatedFields_ = [1,2,3]; + if (jspb.Message.GENERATE_TO_OBJECT) { @@ -5519,8 +9933,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.toObject(opt_includeInstance, this); }; @@ -5529,13 +9943,18 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.to * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - value: msg.getValue_asB64() + identitiesList: jspb.Message.toObjectList(msg.getIdentitiesList(), + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.toObject, includeInstance), + contractsList: jspb.Message.toObjectList(msg.getContractsList(), + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.toObject, includeInstance), + documentsList: jspb.Message.toObjectList(msg.getDocumentsList(), + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.toObject, includeInstance) }; if (includeInstance) { @@ -5549,23 +9968,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.toObject = f /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue; - return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0; + return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -5573,8 +9992,19 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.deserializeB var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setValue(value); + var value = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.deserializeBinaryFromReader); + msg.addIdentities(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.deserializeBinaryFromReader); + msg.addContracts(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.deserializeBinaryFromReader); + msg.addDocuments(value); break; default: reader.skipField(); @@ -5589,9 +10019,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.deserializeB * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -5599,61 +10029,36 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.se /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} message + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getValue_asU8(); + f = message.getIdentitiesList(); if (f.length > 0) { - writer.writeBytes( + writer.writeRepeatedMessage( 1, - f + f, + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.serializeBinaryToWriter + ); + } + f = message.getContractsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.serializeBinaryToWriter + ); + } + f = message.getDocumentsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.serializeBinaryToWriter ); } -}; - - -/** - * optional bytes value = 1; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.getValue = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * optional bytes value = 1; - * This is a type-conversion wrapper around `getValue()` - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.getValue_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getValue())); -}; - - -/** - * optional bytes value = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getValue()` - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.getValue_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getValue())); -}; - - -/** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.setValue = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); }; @@ -5673,8 +10078,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.toObject(opt_includeInstance, this); }; @@ -5683,14 +10088,16 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.to * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.toObject = function(includeInstance, msg) { var f, obj = { - key: msg.getKey_asB64(), - value: (f = msg.getValue()) && proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.toObject(includeInstance, f) + contractId: msg.getContractId_asB64(), + documentType: jspb.Message.getFieldWithDefault(msg, 2, ""), + documentTypeKeepsHistory: jspb.Message.getBooleanFieldWithDefault(msg, 3, false), + documentId: msg.getDocumentId_asB64() }; if (includeInstance) { @@ -5704,23 +10111,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.toObject = f /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry; - return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest; + return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -5729,12 +10136,19 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.deserializeB switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setKey(value); + msg.setContractId(value); break; case 2: - var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.deserializeBinaryFromReader); - msg.setValue(value); + var value = /** @type {string} */ (reader.readString()); + msg.setDocumentType(value); + break; + case 3: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setDocumentTypeKeepsHistory(value); + break; + case 4: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setDocumentId(value); break; default: reader.skipField(); @@ -5749,9 +10163,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.deserializeB * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -5759,116 +10173,163 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.se /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} message + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getKey_asU8(); + f = message.getContractId_asU8(); if (f.length > 0) { writer.writeBytes( 1, f ); } - f = message.getValue(); - if (f != null) { - writer.writeMessage( + f = message.getDocumentType(); + if (f.length > 0) { + writer.writeString( 2, - f, - proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.serializeBinaryToWriter + f + ); + } + f = message.getDocumentTypeKeepsHistory(); + if (f) { + writer.writeBool( + 3, + f + ); + } + f = message.getDocumentId_asU8(); + if (f.length > 0) { + writer.writeBytes( + 4, + f ); } }; /** - * optional bytes key = 1; + * optional bytes contract_id = 1; * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.getKey = function() { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getContractId = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * optional bytes key = 1; - * This is a type-conversion wrapper around `getKey()` + * optional bytes contract_id = 1; + * This is a type-conversion wrapper around `getContractId()` * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.getKey_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getContractId_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getKey())); + this.getContractId())); }; /** - * optional bytes key = 1; + * optional bytes contract_id = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getKey()` + * This is a type-conversion wrapper around `getContractId()` * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.getKey_asU8 = function() { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getContractId_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getKey())); + this.getContractId())); }; /** * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.setKey = function(value) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.setContractId = function(value) { return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional IdentityValue value = 2; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} + * optional string document_type = 2; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.getValue = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue, 2)); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getDocumentType = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.setValue = function(value) { - return jspb.Message.setWrapperField(this, 2, value); + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} returns this + */ +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.setDocumentType = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} returns this + * optional bool document_type_keeps_history = 3; + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.clearValue = function() { - return this.setValue(undefined); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getDocumentTypeKeepsHistory = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 3, false)); }; /** - * Returns whether this field is set. - * @return {boolean} + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.hasValue = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.setDocumentTypeKeepsHistory = function(value) { + return jspb.Message.setProto3BooleanField(this, 3, value); }; +/** + * optional bytes document_id = 4; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getDocumentId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + /** - * List of repeated fields within this message type. - * @private {!Array} - * @const + * optional bytes document_id = 4; + * This is a type-conversion wrapper around `getDocumentId()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getDocumentId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getDocumentId())); +}; + + +/** + * optional bytes document_id = 4; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getDocumentId()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getDocumentId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getDocumentId())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} returns this + */ +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.setDocumentId = function(value) { + return jspb.Message.setProto3BytesField(this, 4, value); +}; + + @@ -5885,8 +10346,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.toObject(opt_includeInstance, this); }; @@ -5895,14 +10356,14 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.toObj * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.toObject = function(includeInstance, msg) { var f, obj = { - identityEntriesList: jspb.Message.toObjectList(msg.getIdentityEntriesList(), - proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.toObject, includeInstance) + identityId: msg.getIdentityId_asB64(), + requestType: jspb.Message.getFieldWithDefault(msg, 2, 0) }; if (includeInstance) { @@ -5916,23 +10377,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.toObject = func /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities; - return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest; + return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -5940,9 +10401,12 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.deserializeBina var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.deserializeBinaryFromReader); - msg.addIdentityEntries(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setIdentityId(value); + break; + case 2: + var value = /** @type {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type} */ (reader.readEnum()); + msg.setRequestType(value); break; default: reader.skipField(); @@ -5957,9 +10421,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.deserializeBina * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -5967,90 +10431,101 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.seria /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} message + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getIdentityEntriesList(); + f = message.getIdentityId_asU8(); if (f.length > 0) { - writer.writeRepeatedMessage( + writer.writeBytes( 1, - f, - proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.serializeBinaryToWriter + f + ); + } + f = message.getRequestType(); + if (f !== 0.0) { + writer.writeEnum( + 2, + f ); } }; /** - * repeated IdentityEntry identity_entries = 1; - * @return {!Array} + * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.getIdentityEntriesList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry, 1)); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type = { + FULL_IDENTITY: 0, + BALANCE: 1, + KEYS: 2 }; - /** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.setIdentityEntriesList = function(value) { - return jspb.Message.setRepeatedWrapperField(this, 1, value); + * optional bytes identity_id = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.getIdentityId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry=} opt_value - * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} + * optional bytes identity_id = 1; + * This is a type-conversion wrapper around `getIdentityId()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.addIdentityEntries = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry, opt_index); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.getIdentityId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getIdentityId())); }; /** - * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} returns this + * optional bytes identity_id = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getIdentityId()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.clearIdentityEntriesList = function() { - return this.setIdentityEntriesList([]); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.getIdentityId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getIdentityId())); }; - /** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.setIdentityId = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + /** - * @enum {number} + * optional Type request_type = 2; + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.ResultCase = { - RESULT_NOT_SET: 0, - IDENTITIES: 1, - PROOF: 2 +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.getRequestType = function() { + return /** @type {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); }; + /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.ResultCase} + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.setRequestType = function(value) { + return jspb.Message.setProto3EnumField(this, 2, value); }; + + if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. @@ -6064,8 +10539,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.toObject(opt_includeInstance, this); }; @@ -6074,15 +10549,13 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.pr * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.toObject = function(includeInstance, msg) { var f, obj = { - identities: (f = msg.getIdentities()) && proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.toObject(includeInstance, f), - proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), - metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + contractId: msg.getContractId_asB64() }; if (includeInstance) { @@ -6096,23 +10569,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.to /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0; - return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest; + return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -6120,19 +10593,8 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.de var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.deserializeBinaryFromReader); - msg.setIdentities(value); - break; - case 2: - var value = new proto.org.dash.platform.dapi.v0.Proof; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); - msg.setProof(value); - break; - case 3: - var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); - msg.setMetadata(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setContractId(value); break; default: reader.skipField(); @@ -6147,9 +10609,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.de * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -6157,174 +10619,202 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.pr /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getIdentities(); - if (f != null) { - writer.writeMessage( + f = message.getContractId_asU8(); + if (f.length > 0) { + writer.writeBytes( 1, - f, - proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.serializeBinaryToWriter - ); - } - f = message.getProof(); - if (f != null) { - writer.writeMessage( - 2, - f, - proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter - ); - } - f = message.getMetadata(); - if (f != null) { - writer.writeMessage( - 3, - f, - proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + f ); } }; /** - * optional Identities identities = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} + * optional bytes contract_id = 1; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.getIdentities = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities, 1)); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.getContractId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this + * optional bytes contract_id = 1; + * This is a type-conversion wrapper around `getContractId()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.getContractId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getContractId())); +}; + + +/** + * optional bytes contract_id = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getContractId()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.getContractId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getContractId())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} returns this + */ +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.setContractId = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + +/** + * repeated IdentityRequest identities = 1; + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.getIdentitiesList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest, 1)); +}; + + +/** + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.setIdentities = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.setIdentitiesList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest=} opt_value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.clearIdentities = function() { - return this.setIdentities(undefined); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.addIdentities = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest, opt_index); }; /** - * Returns whether this field is set. - * @return {boolean} + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.hasIdentities = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.clearIdentitiesList = function() { + return this.setIdentitiesList([]); }; /** - * optional Proof proof = 2; - * @return {?proto.org.dash.platform.dapi.v0.Proof} + * repeated ContractRequest contracts = 2; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.getProof = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.getContractsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest, 2)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.setContractsList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 2, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest=} opt_value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.clearProof = function() { - return this.setProof(undefined); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.addContracts = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 2, opt_value, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest, opt_index); }; /** - * Returns whether this field is set. - * @return {boolean} + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.hasProof = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.clearContractsList = function() { + return this.setContractsList([]); }; /** - * optional ResponseMetadata metadata = 3; - * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + * repeated DocumentRequest documents = 3; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.getMetadata = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.getDocumentsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest, 3)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.setMetadata = function(value) { - return jspb.Message.setWrapperField(this, 3, value); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.setDocumentsList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 3, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest=} opt_value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.clearMetadata = function() { - return this.setMetadata(undefined); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.addDocuments = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 3, opt_value, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest, opt_index); }; /** - * Returns whether this field is set. - * @return {boolean} + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.hasMetadata = function() { - return jspb.Message.getField(this, 3) != null; +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.clearDocumentsList = function() { + return this.setDocumentsList([]); }; /** - * optional GetIdentitiesResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} + * optional GetProofsRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProofsRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -6333,7 +10823,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.clearV0 = functi * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -6347,21 +10837,21 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.hasV0 = function * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetProofsResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetProofsResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetProofsResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetProofsResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProofsResponse.oneofGroups_[0])); }; @@ -6379,8 +10869,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProofsResponse.toObject(opt_includeInstance, this); }; @@ -6389,13 +10879,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.toObject = * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProofsResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -6409,23 +10899,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.toObject = function(i /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProofsResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse; - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProofsResponse; + return proto.org.dash.platform.dapi.v0.GetProofsResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProofsResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -6433,8 +10923,8 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.deserializeBinaryFrom var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -6450,9 +10940,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.deserializeBinaryFrom * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProofsResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -6460,18 +10950,18 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.serializeBi /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProofsResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.serializeBinaryToWriter ); } }; @@ -6486,22 +10976,21 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.serializeBinaryToWrit * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.ResultCase = { +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.ResultCase = { RESULT_NOT_SET: 0, - BALANCE: 1, - PROOF: 2 + PROOF: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.ResultCase} + * @return {proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.oneofGroups_[0])); }; @@ -6519,8 +11008,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.toObject(opt_includeInstance, this); }; @@ -6529,13 +11018,12 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceRes * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - balance: jspb.Message.getFieldWithDefault(msg, 1, 0), proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; @@ -6551,23 +11039,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceRes /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0; - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0; + return proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -6575,15 +11063,11 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceRes var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {number} */ (reader.readUint64()); - msg.setBalance(value); - break; - case 2: var value = new proto.org.dash.platform.dapi.v0.Proof; reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); msg.setProof(value); break; - case 3: + case 2: var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); msg.setMetadata(value); @@ -6601,9 +11085,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceRes * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -6611,23 +11095,16 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceRes /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = /** @type {number} */ (jspb.Message.getField(message, 1)); - if (f != null) { - writer.writeUint64( - 1, - f - ); - } f = message.getProof(); if (f != null) { writer.writeMessage( - 2, + 1, f, proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter ); @@ -6635,7 +11112,7 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceRes f = message.getMetadata(); if (f != null) { writer.writeMessage( - 3, + 2, f, proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter ); @@ -6644,140 +11121,30 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceRes /** - * optional uint64 balance = 1; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.getBalance = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.setBalance = function(value) { - return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.oneofGroups_[0], value); -}; - - -/** - * Clears the field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.clearBalance = function() { - return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.oneofGroups_[0], undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.hasBalance = function() { - return jspb.Message.getField(this, 1) != null; -}; - - -/** - * optional Proof proof = 2; + * optional Proof proof = 1; * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.getProof = function() { +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.getProof = function() { return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 1)); }; /** * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.oneofGroups_[0], value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.clearProof = function() { - return this.setProof(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.hasProof = function() { - return jspb.Message.getField(this, 2) != null; -}; - - -/** - * optional ResponseMetadata metadata = 3; - * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.getMetadata = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.setMetadata = function(value) { - return jspb.Message.setWrapperField(this, 3, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.clearMetadata = function() { - return this.setMetadata(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.hasMetadata = function() { - return jspb.Message.getField(this, 3) != null; -}; - - -/** - * optional GetIdentityBalanceResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0, 1)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.clearV0 = function() { - return this.setV0(undefined); +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); }; @@ -6785,147 +11152,82 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.clearV0 = f * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.hasProof = function() { return jspb.Message.getField(this, 1) != null; }; - -/** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.oneofGroups_ = [[1]]; - /** - * @enum {number} + * optional ResponseMetadata metadata = 2; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 2)); }; + /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.VersionCase} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.oneofGroups_[0])); + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 2, value); }; - -if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.toObject = function(includeInstance, msg) { - var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.toObject(includeInstance, f) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 2) != null; }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} + * optional GetProofsResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse; - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0, 1)); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.deserializeBinaryFromReader); - msg.setV0(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; + * @param {?proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProofsResponse.oneofGroups_[0], value); }; /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getV0(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.serializeBinaryToWriter - ); - } +proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; @@ -6938,22 +11240,21 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.serializeB * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetDataContractRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.ResultCase = { - RESULT_NOT_SET: 0, - BALANCE_AND_REVISION: 1, - PROOF: 2 +proto.org.dash.platform.dapi.v0.GetDataContractRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.ResultCase} + * @return {proto.org.dash.platform.dapi.v0.GetDataContractRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractRequest.oneofGroups_[0])); }; @@ -6971,8 +11272,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractRequest.toObject(opt_includeInstance, this); }; @@ -6981,15 +11282,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractRequest.toObject = function(includeInstance, msg) { var f, obj = { - balanceAndRevision: (f = msg.getBalanceAndRevision()) && proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.toObject(includeInstance, f), - proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), - metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -7003,23 +11302,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0; - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractRequest; + return proto.org.dash.platform.dapi.v0.GetDataContractRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -7027,19 +11326,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.deserializeBinaryFromReader); - msg.setBalanceAndRevision(value); - break; - case 2: - var value = new proto.org.dash.platform.dapi.v0.Proof; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); - msg.setProof(value); - break; - case 3: - var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); - msg.setMetadata(value); + var value = new proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.deserializeBinaryFromReader); + msg.setV0(value); break; default: reader.skipField(); @@ -7054,9 +11343,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -7064,34 +11353,18 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getBalanceAndRevision(); + f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.serializeBinaryToWriter - ); - } - f = message.getProof(); - if (f != null) { - writer.writeMessage( - 2, - f, - proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter - ); - } - f = message.getMetadata(); - if (f != null) { - writer.writeMessage( - 3, - f, - proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.serializeBinaryToWriter ); } }; @@ -7113,8 +11386,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.toObject(opt_includeInstance, this); }; @@ -7123,14 +11396,14 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - balance: jspb.Message.getFieldWithDefault(msg, 1, 0), - revision: jspb.Message.getFieldWithDefault(msg, 2, 0) + id: msg.getId_asB64(), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) }; if (includeInstance) { @@ -7144,23 +11417,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision; - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0; + return proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -7168,12 +11441,12 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {number} */ (reader.readUint64()); - msg.setBalance(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setId(value); break; case 2: - var value = /** @type {number} */ (reader.readUint64()); - msg.setRevision(value); + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); break; default: reader.skipField(); @@ -7188,9 +11461,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -7198,22 +11471,22 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getBalance(); - if (f !== 0) { - writer.writeUint64( + f = message.getId_asU8(); + if (f.length > 0) { + writer.writeBytes( 1, f ); } - f = message.getRevision(); - if (f !== 0) { - writer.writeUint64( + f = message.getProve(); + if (f) { + writer.writeBool( 2, f ); @@ -7222,103 +11495,90 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit /** - * optional uint64 balance = 1; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.getBalance = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} returns this + * optional bytes id = 1; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.setBalance = function(value) { - return jspb.Message.setProto3IntField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * optional uint64 revision = 2; - * @return {number} + * optional bytes id = 1; + * This is a type-conversion wrapper around `getId()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.getRevision = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.getId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getId())); }; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} returns this + * optional bytes id = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getId()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.setRevision = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.getId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getId())); }; /** - * optional BalanceAndRevision balance_and_revision = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.getBalanceAndRevision = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision, 1)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.setBalanceAndRevision = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.setId = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this + * optional bool prove = 2; + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.clearBalanceAndRevision = function() { - return this.setBalanceAndRevision(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); }; /** - * Returns whether this field is set. - * @return {boolean} + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.hasBalanceAndRevision = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); }; /** - * optional Proof proof = 2; - * @return {?proto.org.dash.platform.dapi.v0.Proof} + * optional GetDataContractRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.getProof = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.clearProof = function() { - return this.setProof(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.clearV0 = function() { + return this.setV0(undefined); }; @@ -7326,82 +11586,147 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.hasProof = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; + /** - * optional ResponseMetadata metadata = 3; - * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.getMetadata = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); -}; +proto.org.dash.platform.dapi.v0.GetDataContractResponse.oneofGroups_ = [[1]]; +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetDataContractResponse.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; /** - * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.setMetadata = function(value) { - return jspb.Message.setWrapperField(this, 3, value); + * @return {proto.org.dash.platform.dapi.v0.GetDataContractResponse.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractResponse.oneofGroups_[0])); }; + +if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.clearMetadata = function() { - return this.setMetadata(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractResponse.toObject(opt_includeInstance, this); }; /** - * Returns whether this field is set. - * @return {boolean} + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.hasMetadata = function() { - return jspb.Message.getField(this, 3) != null; +proto.org.dash.platform.dapi.v0.GetDataContractResponse.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; }; +} /** - * optional GetIdentityBalanceAndRevisionResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractResponse; + return proto.org.dash.platform.dapi.v0.GetDataContractResponse.deserializeBinaryFromReader(msg, reader); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.oneofGroups_[0], value); + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} + */ +proto.org.dash.platform.dapi.v0.GetDataContractResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} returns this + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.clearV0 = function() { - return this.setV0(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetDataContractResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); }; /** - * Returns whether this field is set. - * @return {boolean} + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetDataContractResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.serializeBinaryToWriter + ); + } }; @@ -7414,23 +11739,22 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype. * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.KeyRequestType.oneofGroups_ = [[1,2,3]]; +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.RequestCase = { - REQUEST_NOT_SET: 0, - ALL_KEYS: 1, - SPECIFIC_KEYS: 2, - SEARCH_KEY: 3 +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + DATA_CONTRACT: 1, + PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.KeyRequestType.RequestCase} + * @return {proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.getRequestCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.KeyRequestType.RequestCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.KeyRequestType.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.oneofGroups_[0])); }; @@ -7448,8 +11772,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.KeyRequestType.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.toObject(opt_includeInstance, this); }; @@ -7458,15 +11782,15 @@ proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.toObject = function(opt * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.KeyRequestType} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.KeyRequestType.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - allKeys: (f = msg.getAllKeys()) && proto.org.dash.platform.dapi.v0.AllKeys.toObject(includeInstance, f), - specificKeys: (f = msg.getSpecificKeys()) && proto.org.dash.platform.dapi.v0.SpecificKeys.toObject(includeInstance, f), - searchKey: (f = msg.getSearchKey()) && proto.org.dash.platform.dapi.v0.SearchKey.toObject(includeInstance, f) + dataContract: msg.getDataContract_asB64(), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; if (includeInstance) { @@ -7480,23 +11804,23 @@ proto.org.dash.platform.dapi.v0.KeyRequestType.toObject = function(includeInstan /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.KeyRequestType; - return proto.org.dash.platform.dapi.v0.KeyRequestType.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0; + return proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.KeyRequestType} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -7504,19 +11828,18 @@ proto.org.dash.platform.dapi.v0.KeyRequestType.deserializeBinaryFromReader = fun var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.AllKeys; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.AllKeys.deserializeBinaryFromReader); - msg.setAllKeys(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setDataContract(value); break; case 2: - var value = new proto.org.dash.platform.dapi.v0.SpecificKeys; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.SpecificKeys.deserializeBinaryFromReader); - msg.setSpecificKeys(value); + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); break; case 3: - var value = new proto.org.dash.platform.dapi.v0.SearchKey; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.SearchKey.deserializeBinaryFromReader); - msg.setSearchKey(value); + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); break; default: reader.skipField(); @@ -7531,9 +11854,9 @@ proto.org.dash.platform.dapi.v0.KeyRequestType.deserializeBinaryFromReader = fun * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.KeyRequestType.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -7541,64 +11864,86 @@ proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.serializeBinary = funct /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.KeyRequestType} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.KeyRequestType.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getAllKeys(); + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 1)); if (f != null) { - writer.writeMessage( + writer.writeBytes( 1, - f, - proto.org.dash.platform.dapi.v0.AllKeys.serializeBinaryToWriter + f ); } - f = message.getSpecificKeys(); + f = message.getProof(); if (f != null) { writer.writeMessage( 2, f, - proto.org.dash.platform.dapi.v0.SpecificKeys.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter ); } - f = message.getSearchKey(); + f = message.getMetadata(); if (f != null) { writer.writeMessage( 3, f, - proto.org.dash.platform.dapi.v0.SearchKey.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter ); } }; /** - * optional AllKeys all_keys = 1; - * @return {?proto.org.dash.platform.dapi.v0.AllKeys} + * optional bytes data_contract = 1; + * @return {string} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.getAllKeys = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.AllKeys} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.AllKeys, 1)); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getDataContract = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * @param {?proto.org.dash.platform.dapi.v0.AllKeys|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this -*/ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.setAllKeys = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.KeyRequestType.oneofGroups_[0], value); + * optional bytes data_contract = 1; + * This is a type-conversion wrapper around `getDataContract()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getDataContract_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getDataContract())); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this + * optional bytes data_contract = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getDataContract()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.clearAllKeys = function() { - return this.setAllKeys(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getDataContract_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getDataContract())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.setDataContract = function(value) { + return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.clearDataContract = function() { + return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.oneofGroups_[0], undefined); }; @@ -7606,36 +11951,36 @@ proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.clearAllKeys = function * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.hasAllKeys = function() { +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.hasDataContract = function() { return jspb.Message.getField(this, 1) != null; }; /** - * optional SpecificKeys specific_keys = 2; - * @return {?proto.org.dash.platform.dapi.v0.SpecificKeys} + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.getSpecificKeys = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.SpecificKeys} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.SpecificKeys, 2)); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.SpecificKeys|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.setSpecificKeys = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.KeyRequestType.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.clearSpecificKeys = function() { - return this.setSpecificKeys(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); }; @@ -7643,36 +11988,36 @@ proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.clearSpecificKeys = fun * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.hasSpecificKeys = function() { +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.hasProof = function() { return jspb.Message.getField(this, 2) != null; }; /** - * optional SearchKey search_key = 3; - * @return {?proto.org.dash.platform.dapi.v0.SearchKey} + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.getSearchKey = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.SearchKey} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.SearchKey, 3)); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.SearchKey|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.setSearchKey = function(value) { - return jspb.Message.setOneofWrapperField(this, 3, proto.org.dash.platform.dapi.v0.KeyRequestType.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.clearSearchKey = function() { - return this.setSearchKey(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); }; @@ -7680,119 +12025,73 @@ proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.clearSearchKey = functi * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.hasSearchKey = function() { +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.hasMetadata = function() { return jspb.Message.getField(this, 3) != null; }; - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.org.dash.platform.dapi.v0.AllKeys.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.AllKeys.toObject(opt_includeInstance, this); -}; - - /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.AllKeys} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional GetDataContractResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} */ -proto.org.dash.platform.dapi.v0.AllKeys.toObject = function(includeInstance, msg) { - var f, obj = { - - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; +proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0, 1)); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.AllKeys} - */ -proto.org.dash.platform.dapi.v0.AllKeys.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.AllKeys; - return proto.org.dash.platform.dapi.v0.AllKeys.deserializeBinaryFromReader(msg, reader); + * @param {?proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractResponse.oneofGroups_[0], value); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.AllKeys} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.AllKeys} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} returns this */ -proto.org.dash.platform.dapi.v0.AllKeys.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.AllKeys.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.AllKeys.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; + /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.AllKeys} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const */ -proto.org.dash.platform.dapi.v0.AllKeys.serializeBinaryToWriter = function(message, writer) { - var f = undefined; -}; - +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.oneofGroups_ = [[1]]; +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; /** - * List of repeated fields within this message type. - * @private {!Array} - * @const + * @return {proto.org.dash.platform.dapi.v0.GetDataContractsRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.SpecificKeys.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractsRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractsRequest.oneofGroups_[0])); +}; @@ -7809,8 +12108,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.SpecificKeys.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractsRequest.toObject(opt_includeInstance, this); }; @@ -7819,13 +12118,13 @@ proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.toObject = function(opt_i * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.SpecificKeys} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.SpecificKeys.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.toObject = function(includeInstance, msg) { var f, obj = { - keyIdsList: (f = jspb.Message.getRepeatedField(msg, 1)) == null ? undefined : f + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -7839,23 +12138,23 @@ proto.org.dash.platform.dapi.v0.SpecificKeys.toObject = function(includeInstance /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.SpecificKeys} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} */ -proto.org.dash.platform.dapi.v0.SpecificKeys.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.SpecificKeys; - return proto.org.dash.platform.dapi.v0.SpecificKeys.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsRequest; + return proto.org.dash.platform.dapi.v0.GetDataContractsRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.SpecificKeys} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.SpecificKeys} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} */ -proto.org.dash.platform.dapi.v0.SpecificKeys.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -7863,10 +12162,9 @@ proto.org.dash.platform.dapi.v0.SpecificKeys.deserializeBinaryFromReader = funct var field = reader.getFieldNumber(); switch (field) { case 1: - var values = /** @type {!Array} */ (reader.isDelimited() ? reader.readPackedUint32() : [reader.readUint32()]); - for (var i = 0; i < values.length; i++) { - msg.addKeyIds(values[i]); - } + var value = new proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.deserializeBinaryFromReader); + msg.setV0(value); break; default: reader.skipField(); @@ -7881,9 +12179,9 @@ proto.org.dash.platform.dapi.v0.SpecificKeys.deserializeBinaryFromReader = funct * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.SpecificKeys.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractsRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -7891,59 +12189,30 @@ proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.serializeBinary = functio /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.SpecificKeys} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.SpecificKeys.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getKeyIdsList(); - if (f.length > 0) { - writer.writePackedUint32( + f = message.getV0(); + if (f != null) { + writer.writeMessage( 1, - f + f, + proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.serializeBinaryToWriter ); } }; -/** - * repeated uint32 key_ids = 1; - * @return {!Array} - */ -proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.getKeyIdsList = function() { - return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); -}; - - -/** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.SpecificKeys} returns this - */ -proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.setKeyIdsList = function(value) { - return jspb.Message.setField(this, 1, value || []); -}; - - -/** - * @param {number} value - * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.SpecificKeys} returns this - */ -proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.addKeyIds = function(value, opt_index) { - return jspb.Message.addToRepeatedField(this, 1, value, opt_index); -}; - /** - * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.SpecificKeys} returns this + * List of repeated fields within this message type. + * @private {!Array} + * @const */ -proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.clearKeyIdsList = function() { - return this.setKeyIdsList([]); -}; - - +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.repeatedFields_ = [1]; @@ -7960,8 +12229,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.SearchKey.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.SearchKey.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.toObject(opt_includeInstance, this); }; @@ -7970,13 +12239,14 @@ proto.org.dash.platform.dapi.v0.SearchKey.prototype.toObject = function(opt_incl * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.SearchKey} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.SearchKey.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - purposeMapMap: (f = msg.getPurposeMapMap()) ? f.toObject(includeInstance, proto.org.dash.platform.dapi.v0.SecurityLevelMap.toObject) : [] + idsList: msg.getIdsList_asB64(), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) }; if (includeInstance) { @@ -7990,23 +12260,23 @@ proto.org.dash.platform.dapi.v0.SearchKey.toObject = function(includeInstance, m /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.SearchKey} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} */ -proto.org.dash.platform.dapi.v0.SearchKey.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.SearchKey; - return proto.org.dash.platform.dapi.v0.SearchKey.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0; + return proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.SearchKey} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.SearchKey} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} */ -proto.org.dash.platform.dapi.v0.SearchKey.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -8014,10 +12284,12 @@ proto.org.dash.platform.dapi.v0.SearchKey.deserializeBinaryFromReader = function var field = reader.getFieldNumber(); switch (field) { case 1: - var value = msg.getPurposeMapMap(); - reader.readMessage(value, function(message, reader) { - jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readUint32, jspb.BinaryReader.prototype.readMessage, proto.org.dash.platform.dapi.v0.SecurityLevelMap.deserializeBinaryFromReader, 0, new proto.org.dash.platform.dapi.v0.SecurityLevelMap()); - }); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.addIds(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); break; default: reader.skipField(); @@ -8032,9 +12304,9 @@ proto.org.dash.platform.dapi.v0.SearchKey.deserializeBinaryFromReader = function * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.SearchKey.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.SearchKey.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -8042,180 +12314,143 @@ proto.org.dash.platform.dapi.v0.SearchKey.prototype.serializeBinary = function() /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.SearchKey} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.SearchKey.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getPurposeMapMap(true); - if (f && f.getLength() > 0) { - f.serializeBinary(1, writer, jspb.BinaryWriter.prototype.writeUint32, jspb.BinaryWriter.prototype.writeMessage, proto.org.dash.platform.dapi.v0.SecurityLevelMap.serializeBinaryToWriter); + f = message.getIdsList_asU8(); + if (f.length > 0) { + writer.writeRepeatedBytes( + 1, + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 2, + f + ); } }; /** - * map purpose_map = 1; - * @param {boolean=} opt_noLazyCreate Do not create the map if - * empty, instead returning `undefined` - * @return {!jspb.Map} + * repeated bytes ids = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.SearchKey.prototype.getPurposeMapMap = function(opt_noLazyCreate) { - return /** @type {!jspb.Map} */ ( - jspb.Message.getMapField(this, 1, opt_noLazyCreate, - proto.org.dash.platform.dapi.v0.SecurityLevelMap)); +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.getIdsList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); }; /** - * Clears values from the map. The map will be non-null. - * @return {!proto.org.dash.platform.dapi.v0.SearchKey} returns this + * repeated bytes ids = 1; + * This is a type-conversion wrapper around `getIdsList()` + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.SearchKey.prototype.clearPurposeMapMap = function() { - this.getPurposeMapMap().clear(); - return this;}; - +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.getIdsList_asB64 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsB64( + this.getIdsList())); +}; +/** + * repeated bytes ids = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getIdsList()` + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.getIdsList_asU8 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsU8( + this.getIdsList())); +}; -if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} + * @param {!(Array|Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.SecurityLevelMap.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.SecurityLevelMap.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.setIdsList = function(value) { + return jspb.Message.setField(this, 1, value || []); }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * @param {!(string|Uint8Array)} value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.SecurityLevelMap.toObject = function(includeInstance, msg) { - var f, obj = { - securityLevelMapMap: (f = msg.getSecurityLevelMapMap()) ? f.toObject(includeInstance, undefined) : [] - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.addIds = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 1, value, opt_index); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.SecurityLevelMap.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.SecurityLevelMap; - return proto.org.dash.platform.dapi.v0.SecurityLevelMap.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.clearIdsList = function() { + return this.setIdsList([]); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} + * optional bool prove = 2; + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.SecurityLevelMap.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = msg.getSecurityLevelMapMap(); - reader.readMessage(value, function(message, reader) { - jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readUint32, jspb.BinaryReader.prototype.readEnum, null, 0, 0); - }); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); }; /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.SecurityLevelMap.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.SecurityLevelMap.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); }; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional GetDataContractsRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} */ -proto.org.dash.platform.dapi.v0.SecurityLevelMap.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getSecurityLevelMapMap(true); - if (f && f.getLength() > 0) { - f.serializeBinary(1, writer, jspb.BinaryWriter.prototype.writeUint32, jspb.BinaryWriter.prototype.writeEnum); - } +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0, 1)); }; /** - * @enum {number} - */ -proto.org.dash.platform.dapi.v0.SecurityLevelMap.KeyKindRequestType = { - CURRENT_KEY_OF_KIND_REQUEST: 0, - ALL_KEYS_OF_KIND_REQUEST: 1 + * @param {?proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractsRequest.oneofGroups_[0], value); }; + /** - * map security_level_map = 1; - * @param {boolean=} opt_noLazyCreate Do not create the map if - * empty, instead returning `undefined` - * @return {!jspb.Map} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} returns this */ -proto.org.dash.platform.dapi.v0.SecurityLevelMap.prototype.getSecurityLevelMapMap = function(opt_noLazyCreate) { - return /** @type {!jspb.Map} */ ( - jspb.Message.getMapField(this, 1, opt_noLazyCreate, - null)); +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * Clears values from the map. The map will be non-null. - * @return {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.SecurityLevelMap.prototype.clearSecurityLevelMapMap = function() { - this.getSecurityLevelMapMap().clear(); - return this;}; +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; @@ -8227,21 +12462,21 @@ proto.org.dash.platform.dapi.v0.SecurityLevelMap.prototype.clearSecurityLevelMap * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetDataContractsResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractsResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.oneofGroups_[0])); }; @@ -8259,8 +12494,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.toObject(opt_includeInstance, this); }; @@ -8269,13 +12504,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.toObject = func * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -8289,23 +12524,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.toObject = function(inclu /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest; - return proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse; + return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -8313,8 +12548,8 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.deserializeBinaryFromRead var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -8330,9 +12565,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.deserializeBinaryFromRead * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractsResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -8340,18 +12575,18 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.serializeBinary /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.serializeBinaryToWriter ); } }; @@ -8373,8 +12608,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.toObject(opt_includeInstance, this); }; @@ -8383,17 +12618,14 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.toObject = function(includeInstance, msg) { var f, obj = { - identityId: msg.getIdentityId_asB64(), - requestType: (f = msg.getRequestType()) && proto.org.dash.platform.dapi.v0.KeyRequestType.toObject(includeInstance, f), - limit: (f = msg.getLimit()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), - offset: (f = msg.getOffset()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 5, false) + identifier: msg.getIdentifier_asB64(), + dataContract: (f = msg.getDataContract()) && google_protobuf_wrappers_pb.BytesValue.toObject(includeInstance, f) }; if (includeInstance) { @@ -8407,23 +12639,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0. /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0; - return proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry; + return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -8432,26 +12664,12 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0. switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setIdentityId(value); + msg.setIdentifier(value); break; case 2: - var value = new proto.org.dash.platform.dapi.v0.KeyRequestType; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.KeyRequestType.deserializeBinaryFromReader); - msg.setRequestType(value); - break; - case 3: - var value = new google_protobuf_wrappers_pb.UInt32Value; - reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); - msg.setLimit(value); - break; - case 4: - var value = new google_protobuf_wrappers_pb.UInt32Value; - reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); - msg.setOffset(value); - break; - case 5: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); + var value = new google_protobuf_wrappers_pb.BytesValue; + reader.readMessage(value,google_protobuf_wrappers_pb.BytesValue.deserializeBinaryFromReader); + msg.setDataContract(value); break; default: reader.skipField(); @@ -8466,9 +12684,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0. * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -8476,120 +12694,97 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0. /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getIdentityId_asU8(); - if (f.length > 0) { - writer.writeBytes( - 1, - f - ); - } - f = message.getRequestType(); - if (f != null) { - writer.writeMessage( - 2, - f, - proto.org.dash.platform.dapi.v0.KeyRequestType.serializeBinaryToWriter - ); - } - f = message.getLimit(); - if (f != null) { - writer.writeMessage( - 3, - f, - google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getIdentifier_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f ); } - f = message.getOffset(); + f = message.getDataContract(); if (f != null) { writer.writeMessage( - 4, + 2, f, - google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter - ); - } - f = message.getProve(); - if (f) { - writer.writeBool( - 5, - f + google_protobuf_wrappers_pb.BytesValue.serializeBinaryToWriter ); } }; /** - * optional bytes identity_id = 1; + * optional bytes identifier = 1; * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getIdentityId = function() { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.getIdentifier = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * optional bytes identity_id = 1; - * This is a type-conversion wrapper around `getIdentityId()` + * optional bytes identifier = 1; + * This is a type-conversion wrapper around `getIdentifier()` * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getIdentityId_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.getIdentifier_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getIdentityId())); + this.getIdentifier())); }; /** - * optional bytes identity_id = 1; + * optional bytes identifier = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getIdentityId()` + * This is a type-conversion wrapper around `getIdentifier()` * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getIdentityId_asU8 = function() { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.getIdentifier_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getIdentityId())); + this.getIdentifier())); }; /** * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.setIdentityId = function(value) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.setIdentifier = function(value) { return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional KeyRequestType request_type = 2; - * @return {?proto.org.dash.platform.dapi.v0.KeyRequestType} + * optional google.protobuf.BytesValue data_contract = 2; + * @return {?proto.google.protobuf.BytesValue} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getRequestType = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.KeyRequestType} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.KeyRequestType, 2)); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.getDataContract = function() { + return /** @type{?proto.google.protobuf.BytesValue} */ ( + jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.BytesValue, 2)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.KeyRequestType|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this + * @param {?proto.google.protobuf.BytesValue|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.setRequestType = function(value) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.setDataContract = function(value) { return jspb.Message.setWrapperField(this, 2, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.clearRequestType = function() { - return this.setRequestType(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.clearDataContract = function() { + return this.setDataContract(undefined); }; @@ -8597,137 +12792,168 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0. * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.hasRequestType = function() { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.hasDataContract = function() { return jspb.Message.getField(this, 2) != null; }; -/** - * optional google.protobuf.UInt32Value limit = 3; - * @return {?proto.google.protobuf.UInt32Value} - */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getLimit = function() { - return /** @type{?proto.google.protobuf.UInt32Value} */ ( - jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 3)); -}; - - -/** - * @param {?proto.google.protobuf.UInt32Value|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.setLimit = function(value) { - return jspb.Message.setWrapperField(this, 3, value); -}; - /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this + * List of repeated fields within this message type. + * @private {!Array} + * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.clearLimit = function() { - return this.setLimit(undefined); -}; +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.repeatedFields_ = [1]; + +if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Returns whether this field is set. - * @return {boolean} + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.hasLimit = function() { - return jspb.Message.getField(this, 3) != null; +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.toObject(opt_includeInstance, this); }; /** - * optional google.protobuf.UInt32Value offset = 4; - * @return {?proto.google.protobuf.UInt32Value} + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getOffset = function() { - return /** @type{?proto.google.protobuf.UInt32Value} */ ( - jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 4)); -}; - +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.toObject = function(includeInstance, msg) { + var f, obj = { + dataContractEntriesList: jspb.Message.toObjectList(msg.getDataContractEntriesList(), + proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.toObject, includeInstance) + }; -/** - * @param {?proto.google.protobuf.UInt32Value|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.setOffset = function(value) { - return jspb.Message.setWrapperField(this, 4, value); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; }; +} /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.clearOffset = function() { - return this.setOffset(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts; + return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.deserializeBinaryFromReader(msg, reader); }; /** - * Returns whether this field is set. - * @return {boolean} + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.hasOffset = function() { - return jspb.Message.getField(this, 4) != null; +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.deserializeBinaryFromReader); + msg.addDataContractEntries(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; }; /** - * optional bool prove = 5; - * @return {boolean} + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 5, false)); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); }; /** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 5, value); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getDataContractEntriesList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.serializeBinaryToWriter + ); + } }; /** - * optional GetIdentityKeysRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} + * repeated DataContractEntry data_contract_entries = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.getDataContractEntriesList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} returns this + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.setDataContractEntriesList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} returns this + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry=} opt_value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.clearV0 = function() { - return this.setV0(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.addDataContractEntries = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry, opt_index); }; /** - * Returns whether this field is set. - * @return {boolean} + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.clearDataContractEntriesList = function() { + return this.setDataContractEntriesList([]); }; @@ -8740,21 +12966,22 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.hasV0 = functio * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.oneofGroups_ = [[1,2]]; /** - * @enum {number} - */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + DATA_CONTRACTS: 1, + PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.oneofGroups_[0])); }; @@ -8772,8 +12999,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.toObject(opt_includeInstance, this); }; @@ -8782,13 +13009,15 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.toObject = fun * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.toObject(includeInstance, f) + dataContracts: (f = msg.getDataContracts()) && proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.toObject(includeInstance, f), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; if (includeInstance) { @@ -8802,23 +13031,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.toObject = function(incl /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse; - return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0; + return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -8826,9 +13055,19 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.deserializeBinaryFromRea var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.deserializeBinaryFromReader); - msg.setV0(value); + var value = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.deserializeBinaryFromReader); + msg.setDataContracts(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); break; default: reader.skipField(); @@ -8843,9 +13082,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.deserializeBinaryFromRea * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -8853,23 +13092,187 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.serializeBinar /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getV0(); + f = message.getDataContracts(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.serializeBinaryToWriter + ); + } + f = message.getProof(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + ); + } + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter ); } }; +/** + * optional DataContracts data_contracts = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.getDataContracts = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.setDataContracts = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.clearDataContracts = function() { + return this.setDataContracts(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.hasDataContracts = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional GetDataContractsResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} returns this + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + /** * Oneof group definitions for this message. Each group defines the field @@ -8879,22 +13282,21 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.serializeBinaryToWriter * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.ResultCase = { - RESULT_NOT_SET: 0, - KEYS: 1, - PROOF: 2 +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.ResultCase} + * @return {proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.oneofGroups_[0])); }; @@ -8912,8 +13314,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.toObject(opt_includeInstance, this); }; @@ -8922,15 +13324,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.toObject = function(includeInstance, msg) { - var f, obj = { - keys: (f = msg.getKeys()) && proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.toObject(includeInstance, f), - proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), - metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -8944,23 +13344,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0; - return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest; + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -8968,19 +13368,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.deserializeBinaryFromReader); - msg.setKeys(value); - break; - case 2: - var value = new proto.org.dash.platform.dapi.v0.Proof; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); - msg.setProof(value); - break; - case 3: - var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); - msg.setMetadata(value); + var value = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.deserializeBinaryFromReader); + msg.setV0(value); break; default: reader.skipField(); @@ -8995,9 +13385,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -9005,47 +13395,24 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getKeys(); + f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.serializeBinaryToWriter - ); - } - f = message.getProof(); - if (f != null) { - writer.writeMessage( - 2, - f, - proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter - ); - } - f = message.getMetadata(); - if (f != null) { - writer.writeMessage( - 3, - f, - proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.serializeBinaryToWriter ); } }; -/** - * List of repeated fields within this message type. - * @private {!Array} - * @const - */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.repeatedFields_ = [1]; - if (jspb.Message.GENERATE_TO_OBJECT) { @@ -9061,8 +13428,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.toObject(opt_includeInstance, this); }; @@ -9071,13 +13438,17 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - keysBytesList: msg.getKeysBytesList_asB64() + id: msg.getId_asB64(), + limit: (f = msg.getLimit()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), + offset: (f = msg.getOffset()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), + startAtMs: jspb.Message.getFieldWithDefault(msg, 4, 0), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 5, false) }; if (includeInstance) { @@ -9091,23 +13462,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys; - return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0; + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -9116,7 +13487,25 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.addKeysBytes(value); + msg.setId(value); + break; + case 2: + var value = new google_protobuf_wrappers_pb.UInt32Value; + reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); + msg.setLimit(value); + break; + case 3: + var value = new google_protobuf_wrappers_pb.UInt32Value; + reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); + msg.setOffset(value); + break; + case 4: + var value = /** @type {number} */ (reader.readUint64()); + msg.setStartAtMs(value); + break; + case 5: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); break; default: reader.skipField(); @@ -9131,9 +13520,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -9141,108 +13530,119 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getKeysBytesList_asU8(); + f = message.getId_asU8(); if (f.length > 0) { - writer.writeRepeatedBytes( + writer.writeBytes( 1, f ); } + f = message.getLimit(); + if (f != null) { + writer.writeMessage( + 2, + f, + google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter + ); + } + f = message.getOffset(); + if (f != null) { + writer.writeMessage( + 3, + f, + google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter + ); + } + f = message.getStartAtMs(); + if (f !== 0) { + writer.writeUint64( + 4, + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 5, + f + ); + } }; /** - * repeated bytes keys_bytes = 1; - * @return {!Array} + * optional bytes id = 1; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.getKeysBytesList = function() { - return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * repeated bytes keys_bytes = 1; - * This is a type-conversion wrapper around `getKeysBytesList()` - * @return {!Array} + * optional bytes id = 1; + * This is a type-conversion wrapper around `getId()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.getKeysBytesList_asB64 = function() { - return /** @type {!Array} */ (jspb.Message.bytesListAsB64( - this.getKeysBytesList())); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getId())); }; /** - * repeated bytes keys_bytes = 1; + * optional bytes id = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getKeysBytesList()` - * @return {!Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.getKeysBytesList_asU8 = function() { - return /** @type {!Array} */ (jspb.Message.bytesListAsU8( - this.getKeysBytesList())); -}; - - -/** - * @param {!(Array|Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} returns this + * This is a type-conversion wrapper around `getId()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.setKeysBytesList = function(value) { - return jspb.Message.setField(this, 1, value || []); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getId())); }; /** * @param {!(string|Uint8Array)} value - * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.addKeysBytes = function(value, opt_index) { - return jspb.Message.addToRepeatedField(this, 1, value, opt_index); -}; - - -/** - * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.clearKeysBytesList = function() { - return this.setKeysBytesList([]); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.setId = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional Keys keys = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} + * optional google.protobuf.UInt32Value limit = 2; + * @return {?proto.google.protobuf.UInt32Value} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.getKeys = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys, 1)); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getLimit = function() { + return /** @type{?proto.google.protobuf.UInt32Value} */ ( + jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 2)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this + * @param {?proto.google.protobuf.UInt32Value|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.setKeys = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.setLimit = function(value) { + return jspb.Message.setWrapperField(this, 2, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.clearKeys = function() { - return this.setKeys(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.clearLimit = function() { + return this.setLimit(undefined); }; @@ -9250,36 +13650,36 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.hasKeys = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.hasLimit = function() { + return jspb.Message.getField(this, 2) != null; }; /** - * optional Proof proof = 2; - * @return {?proto.org.dash.platform.dapi.v0.Proof} + * optional google.protobuf.UInt32Value offset = 3; + * @return {?proto.google.protobuf.UInt32Value} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.getProof = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getOffset = function() { + return /** @type{?proto.google.protobuf.UInt32Value} */ ( + jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 3)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this + * @param {?proto.google.protobuf.UInt32Value|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.setOffset = function(value) { + return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.clearProof = function() { - return this.setProof(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.clearOffset = function() { + return this.setOffset(undefined); }; @@ -9287,72 +13687,71 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.hasProof = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.hasOffset = function() { + return jspb.Message.getField(this, 3) != null; }; /** - * optional ResponseMetadata metadata = 3; - * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + * optional uint64 start_at_ms = 4; + * @return {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.getMetadata = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getStartAtMs = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.setMetadata = function(value) { - return jspb.Message.setWrapperField(this, 3, value); + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.setStartAtMs = function(value) { + return jspb.Message.setProto3IntField(this, 4, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this + * optional bool prove = 5; + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.clearMetadata = function() { - return this.setMetadata(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 5, false)); }; /** - * Returns whether this field is set. - * @return {boolean} + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.hasMetadata = function() { - return jspb.Message.getField(this, 3) != null; +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 5, value); }; /** - * optional GetIdentityKeysResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} + * optional GetDataContractHistoryRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -9361,7 +13760,7 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.clearV0 = func * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -9375,21 +13774,21 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.hasV0 = functi * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetProofsRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetProofsRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProofsRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.oneofGroups_[0])); }; @@ -9407,8 +13806,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProofsRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.toObject(opt_includeInstance, this); }; @@ -9417,13 +13816,13 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.toObject = function(o * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -9437,23 +13836,23 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.toObject = function(includeInst /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProofsRequest; - return proto.org.dash.platform.dapi.v0.GetProofsRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse; + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -9461,8 +13860,8 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.deserializeBinaryFromReader = f var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -9478,9 +13877,9 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.deserializeBinaryFromReader = f * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProofsRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -9488,176 +13887,50 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.serializeBinary = fun /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.serializeBinaryToWriter - ); - } -}; - - - -/** - * List of repeated fields within this message type. - * @private {!Array} - * @const - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.repeatedFields_ = [1,2,3]; - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.toObject = function(includeInstance, msg) { - var f, obj = { - identitiesList: jspb.Message.toObjectList(msg.getIdentitiesList(), - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.toObject, includeInstance), - contractsList: jspb.Message.toObjectList(msg.getContractsList(), - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.toObject, includeInstance), - documentsList: jspb.Message.toObjectList(msg.getDocumentsList(), - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.toObject, includeInstance) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0; - return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.deserializeBinaryFromReader); - msg.addIdentities(value); - break; - case 2: - var value = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.deserializeBinaryFromReader); - msg.addContracts(value); - break; - case 3: - var value = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.deserializeBinaryFromReader); - msg.addDocuments(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getIdentitiesList(); - if (f.length > 0) { - writer.writeRepeatedMessage( - 1, - f, - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.serializeBinaryToWriter - ); - } - f = message.getContractsList(); - if (f.length > 0) { - writer.writeRepeatedMessage( - 2, - f, - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.serializeBinaryToWriter - ); - } - f = message.getDocumentsList(); - if (f.length > 0) { - writer.writeRepeatedMessage( - 3, - f, - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.serializeBinaryToWriter ); } }; +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.oneofGroups_ = [[1,2]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + DATA_CONTRACT_HISTORY: 1, + PROOF: 2 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.ResultCase} + */ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.oneofGroups_[0])); +}; + if (jspb.Message.GENERATE_TO_OBJECT) { @@ -9673,8 +13946,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.toObject(opt_includeInstance, this); }; @@ -9683,16 +13956,15 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequ * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - contractId: msg.getContractId_asB64(), - documentType: jspb.Message.getFieldWithDefault(msg, 2, ""), - documentTypeKeepsHistory: jspb.Message.getBooleanFieldWithDefault(msg, 3, false), - documentId: msg.getDocumentId_asB64() + dataContractHistory: (f = msg.getDataContractHistory()) && proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.toObject(includeInstance, f), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; if (includeInstance) { @@ -9706,23 +13978,23 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequ /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest; - return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0; + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -9730,20 +14002,19 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequ var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setContractId(value); + var value = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.deserializeBinaryFromReader); + msg.setDataContractHistory(value); break; case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setDocumentType(value); + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); break; case 3: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setDocumentTypeKeepsHistory(value); - break; - case 4: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setDocumentId(value); + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); break; default: reader.skipField(); @@ -9758,9 +14029,9 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequ * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -9768,163 +14039,39 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequ /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getContractId_asU8(); - if (f.length > 0) { - writer.writeBytes( + f = message.getDataContractHistory(); + if (f != null) { + writer.writeMessage( 1, - f + f, + proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.serializeBinaryToWriter ); } - f = message.getDocumentType(); - if (f.length > 0) { - writer.writeString( + f = message.getProof(); + if (f != null) { + writer.writeMessage( 2, - f + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter ); } - f = message.getDocumentTypeKeepsHistory(); - if (f) { - writer.writeBool( + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( 3, - f - ); - } - f = message.getDocumentId_asU8(); - if (f.length > 0) { - writer.writeBytes( - 4, - f + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter ); } }; -/** - * optional bytes contract_id = 1; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getContractId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * optional bytes contract_id = 1; - * This is a type-conversion wrapper around `getContractId()` - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getContractId_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getContractId())); -}; - - -/** - * optional bytes contract_id = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getContractId()` - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getContractId_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getContractId())); -}; - - -/** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} returns this - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.setContractId = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); -}; - - -/** - * optional string document_type = 2; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getDocumentType = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); -}; - - -/** - * @param {string} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} returns this - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.setDocumentType = function(value) { - return jspb.Message.setProto3StringField(this, 2, value); -}; - - -/** - * optional bool document_type_keeps_history = 3; - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getDocumentTypeKeepsHistory = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 3, false)); -}; - - -/** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} returns this - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.setDocumentTypeKeepsHistory = function(value) { - return jspb.Message.setProto3BooleanField(this, 3, value); -}; - - -/** - * optional bytes document_id = 4; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getDocumentId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); -}; - - -/** - * optional bytes document_id = 4; - * This is a type-conversion wrapper around `getDocumentId()` - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getDocumentId_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getDocumentId())); -}; - - -/** - * optional bytes document_id = 4; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getDocumentId()` - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getDocumentId_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getDocumentId())); -}; - - -/** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} returns this - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.setDocumentId = function(value) { - return jspb.Message.setProto3BytesField(this, 4, value); -}; - - @@ -9941,8 +14088,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.toObject(opt_includeInstance, this); }; @@ -9951,14 +14098,14 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequ * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.toObject = function(includeInstance, msg) { var f, obj = { - identityId: msg.getIdentityId_asB64(), - requestType: jspb.Message.getFieldWithDefault(msg, 2, 0) + date: jspb.Message.getFieldWithDefault(msg, 1, 0), + value: msg.getValue_asB64() }; if (includeInstance) { @@ -9972,23 +14119,23 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequ /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest; - return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry; + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -9996,12 +14143,12 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequ var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setIdentityId(value); + var value = /** @type {number} */ (reader.readUint64()); + msg.setDate(value); break; case 2: - var value = /** @type {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type} */ (reader.readEnum()); - msg.setRequestType(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setValue(value); break; default: reader.skipField(); @@ -10016,9 +14163,9 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequ * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -10026,22 +14173,22 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequ /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getIdentityId_asU8(); - if (f.length > 0) { - writer.writeBytes( + f = message.getDate(); + if (f !== 0) { + writer.writeUint64( 1, f ); } - f = message.getRequestType(); - if (f !== 0.0) { - writer.writeEnum( + f = message.getValue_asU8(); + if (f.length > 0) { + writer.writeBytes( 2, f ); @@ -10050,74 +14197,72 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequ /** - * @enum {number} + * optional uint64 date = 1; + * @return {number} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type = { - FULL_IDENTITY: 0, - BALANCE: 1, - KEYS: 2 +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.getDate = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); }; + /** - * optional bytes identity_id = 1; + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} returns this + */ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.setDate = function(value) { + return jspb.Message.setProto3IntField(this, 1, value); +}; + + +/** + * optional bytes value = 2; * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.getIdentityId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.getValue = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** - * optional bytes identity_id = 1; - * This is a type-conversion wrapper around `getIdentityId()` + * optional bytes value = 2; + * This is a type-conversion wrapper around `getValue()` * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.getIdentityId_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.getValue_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getIdentityId())); + this.getValue())); }; /** - * optional bytes identity_id = 1; + * optional bytes value = 2; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getIdentityId()` + * This is a type-conversion wrapper around `getValue()` * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.getIdentityId_asU8 = function() { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.getValue_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getIdentityId())); + this.getValue())); }; /** * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.setIdentityId = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.setValue = function(value) { + return jspb.Message.setProto3BytesField(this, 2, value); }; -/** - * optional Type request_type = 2; - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.getRequestType = function() { - return /** @type {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); -}; - /** - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} returns this + * List of repeated fields within this message type. + * @private {!Array} + * @const */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.setRequestType = function(value) { - return jspb.Message.setProto3EnumField(this, 2, value); -}; - - +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.repeatedFields_ = [1]; @@ -10134,8 +14279,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.toObject(opt_includeInstance, this); }; @@ -10144,13 +14289,14 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequ * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.toObject = function(includeInstance, msg) { var f, obj = { - contractId: msg.getContractId_asB64() + dataContractEntriesList: jspb.Message.toObjectList(msg.getDataContractEntriesList(), + proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.toObject, includeInstance) }; if (includeInstance) { @@ -10164,23 +14310,23 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequ /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest; - return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory; + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -10188,8 +14334,9 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequ var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setContractId(value); + var value = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.deserializeBinaryFromReader); + msg.addDataContractEntries(value); break; default: reader.skipField(); @@ -10204,9 +14351,9 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequ * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -10214,212 +14361,345 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequ /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getContractId_asU8(); + f = message.getDataContractEntriesList(); if (f.length > 0) { - writer.writeBytes( + writer.writeRepeatedMessage( 1, - f + f, + proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.serializeBinaryToWriter ); } }; /** - * optional bytes contract_id = 1; - * @return {string} + * repeated DataContractHistoryEntry data_contract_entries = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.getContractId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.getDataContractEntriesList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry, 1)); }; /** - * optional bytes contract_id = 1; - * This is a type-conversion wrapper around `getContractId()` - * @return {string} + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.setDataContractEntriesList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); +}; + + +/** + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry=} opt_value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.getContractId_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getContractId())); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.addDataContractEntries = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} returns this + */ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.clearDataContractEntriesList = function() { + return this.setDataContractEntriesList([]); +}; + + +/** + * optional DataContractHistory data_contract_history = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} + */ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.getDataContractHistory = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.setDataContractHistory = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.clearDataContractHistory = function() { + return this.setDataContractHistory(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.hasDataContractHistory = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.oneofGroups_[0], value); }; /** - * optional bytes contract_id = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getContractId()` - * @return {!Uint8Array} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.getContractId_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getContractId())); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.setContractId = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; }; /** - * repeated IdentityRequest identities = 1; - * @return {!Array} + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.getIdentitiesList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest, 1)); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; /** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.setIdentitiesList = function(value) { - return jspb.Message.setRepeatedWrapperField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); }; /** - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest=} opt_value - * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.addIdentities = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest, opt_index); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); }; /** - * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.clearIdentitiesList = function() { - return this.setIdentitiesList([]); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; }; /** - * repeated ContractRequest contracts = 2; - * @return {!Array} + * optional GetDataContractHistoryResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.getContractsList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest, 2)); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0, 1)); }; /** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.setContractsList = function(value) { - return jspb.Message.setRepeatedWrapperField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.oneofGroups_[0], value); }; /** - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest=} opt_value - * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.addContracts = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 2, opt_value, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest, opt_index); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.clearContractsList = function() { - return this.setContractsList([]); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; + /** - * repeated DocumentRequest documents = 3; - * @return {!Array} + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.getDocumentsList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest, 3)); -}; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.oneofGroups_ = [[1]]; +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; /** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.setDocumentsList = function(value) { - return jspb.Message.setRepeatedWrapperField(this, 3, value); + * @return {proto.org.dash.platform.dapi.v0.GetDocumentsRequest.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentsRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.oneofGroups_[0])); }; + +if (jspb.Message.GENERATE_TO_OBJECT) { /** - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest=} opt_value - * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.addDocuments = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 3, opt_value, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest, opt_index); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentsRequest.toObject(opt_includeInstance, this); }; /** - * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.clearDocumentsList = function() { - return this.setDocumentsList([]); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; }; +} /** - * optional GetProofsRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentsRequest; + return proto.org.dash.platform.dapi.v0.GetDocumentsRequest.deserializeBinaryFromReader(msg, reader); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest} returns this -*/ -proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProofsRequest.oneofGroups_[0], value); + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest} returns this + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.clearV0 = function() { - return this.setV0(undefined); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetDocumentsRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); }; /** - * Returns whether this field is set. - * @return {boolean} + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.serializeBinaryToWriter + ); + } }; @@ -10432,21 +14712,22 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.hasV0 = function() { * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_ = [[6,7]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.StartCase = { + START_NOT_SET: 0, + START_AFTER: 6, + START_AT: 7 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetProofsResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.StartCase} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetProofsResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProofsResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.StartCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_[0])); }; @@ -10464,8 +14745,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProofsResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.toObject(opt_includeInstance, this); }; @@ -10474,13 +14755,20 @@ proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.toObject = function( * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.toObject(includeInstance, f) + dataContractId: msg.getDataContractId_asB64(), + documentType: jspb.Message.getFieldWithDefault(msg, 2, ""), + where: msg.getWhere_asB64(), + orderBy: msg.getOrderBy_asB64(), + limit: jspb.Message.getFieldWithDefault(msg, 5, 0), + startAfter: msg.getStartAfter_asB64(), + startAt: msg.getStartAt_asB64(), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 8, false) }; if (includeInstance) { @@ -10494,23 +14782,23 @@ proto.org.dash.platform.dapi.v0.GetProofsResponse.toObject = function(includeIns /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProofsResponse; - return proto.org.dash.platform.dapi.v0.GetProofsResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0; + return proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -10518,9 +14806,36 @@ proto.org.dash.platform.dapi.v0.GetProofsResponse.deserializeBinaryFromReader = var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.deserializeBinaryFromReader); - msg.setV0(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setDataContractId(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setDocumentType(value); + break; + case 3: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setWhere(value); + break; + case 4: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setOrderBy(value); + break; + case 5: + var value = /** @type {number} */ (reader.readUint32()); + msg.setLimit(value); + break; + case 6: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setStartAfter(value); + break; + case 7: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setStartAt(value); + break; + case 8: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); break; default: reader.skipField(); @@ -10535,9 +14850,9 @@ proto.org.dash.platform.dapi.v0.GetProofsResponse.deserializeBinaryFromReader = * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProofsResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -10545,238 +14860,281 @@ proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.serializeBinary = fu /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getV0(); - if (f != null) { - writer.writeMessage( + f = message.getDataContractId_asU8(); + if (f.length > 0) { + writer.writeBytes( 1, - f, - proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.serializeBinaryToWriter + f + ); + } + f = message.getDocumentType(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getWhere_asU8(); + if (f.length > 0) { + writer.writeBytes( + 3, + f + ); + } + f = message.getOrderBy_asU8(); + if (f.length > 0) { + writer.writeBytes( + 4, + f + ); + } + f = message.getLimit(); + if (f !== 0) { + writer.writeUint32( + 5, + f + ); + } + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 6)); + if (f != null) { + writer.writeBytes( + 6, + f + ); + } + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 7)); + if (f != null) { + writer.writeBytes( + 7, + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 8, + f ); } }; +/** + * optional bytes data_contract_id = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getDataContractId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes data_contract_id = 1; + * This is a type-conversion wrapper around `getDataContractId()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getDataContractId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getDataContractId())); +}; + /** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const + * optional bytes data_contract_id = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getDataContractId()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getDataContractId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getDataContractId())); +}; + /** - * @enum {number} + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.ResultCase = { - RESULT_NOT_SET: 0, - PROOF: 1 +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setDataContractId = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); }; + /** - * @return {proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.ResultCase} + * optional string document_type = 2; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getDocumentType = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setDocumentType = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + -if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} + * optional bytes where = 3; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getWhere = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional bytes where = 3; + * This is a type-conversion wrapper around `getWhere()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.toObject = function(includeInstance, msg) { - var f, obj = { - proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), - metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) - }; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getWhere_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getWhere())); +}; - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; + +/** + * optional bytes where = 3; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getWhere()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getWhere_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getWhere())); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0; - return proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setWhere = function(value) { + return jspb.Message.setProto3BytesField(this, 3, value); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} + * optional bytes order_by = 4; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getOrderBy = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** + * optional bytes order_by = 4; + * This is a type-conversion wrapper around `getOrderBy()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.org.dash.platform.dapi.v0.Proof; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); - msg.setProof(value); - break; - case 2: - var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); - msg.setMetadata(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getOrderBy_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getOrderBy())); }; /** - * Serializes the message to binary data (in protobuf wire format). + * optional bytes order_by = 4; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getOrderBy()` * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getOrderBy_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getOrderBy())); }; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getProof(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter - ); - } - f = message.getMetadata(); - if (f != null) { - writer.writeMessage( - 2, - f, - proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter - ); - } +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setOrderBy = function(value) { + return jspb.Message.setProto3BytesField(this, 4, value); }; /** - * optional Proof proof = 1; - * @return {?proto.org.dash.platform.dapi.v0.Proof} + * optional uint32 limit = 5; + * @return {number} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.getProof = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 1)); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getLimit = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.oneofGroups_[0], value); + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setLimit = function(value) { + return jspb.Message.setProto3IntField(this, 5, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} returns this + * optional bytes start_after = 6; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.clearProof = function() { - return this.setProof(undefined); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAfter = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, "")); }; /** - * Returns whether this field is set. - * @return {boolean} + * optional bytes start_after = 6; + * This is a type-conversion wrapper around `getStartAfter()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.hasProof = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAfter_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getStartAfter())); }; /** - * optional ResponseMetadata metadata = 2; - * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + * optional bytes start_after = 6; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getStartAfter()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.getMetadata = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 2)); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAfter_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getStartAfter())); }; /** - * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.setMetadata = function(value) { - return jspb.Message.setWrapperField(this, 2, value); + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setStartAfter = function(value) { + return jspb.Message.setOneofField(this, 6, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_[0], value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} returns this + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.clearMetadata = function() { - return this.setMetadata(undefined); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.clearStartAfter = function() { + return jspb.Message.setOneofField(this, 6, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_[0], undefined); }; @@ -10784,187 +15142,151 @@ proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype. * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.hasMetadata = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.hasStartAfter = function() { + return jspb.Message.getField(this, 6) != null; }; /** - * optional GetProofsResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} + * optional bytes start_at = 7; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAt = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 7, "")); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse} returns this -*/ -proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProofsResponse.oneofGroups_[0], value); + * optional bytes start_at = 7; + * This is a type-conversion wrapper around `getStartAt()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAt_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getStartAt())); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse} returns this + * optional bytes start_at = 7; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getStartAt()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.clearV0 = function() { - return this.setV0(undefined); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAt_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getStartAt())); }; /** - * Returns whether this field is set. - * @return {boolean} + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setStartAt = function(value) { + return jspb.Message.setOneofField(this, 7, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_[0], value); }; - /** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.clearStartAt = function() { + return jspb.Message.setOneofField(this, 7, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_[0], undefined); +}; + /** - * @enum {number} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.hasStartAt = function() { + return jspb.Message.getField(this, 7) != null; }; + /** - * @return {proto.org.dash.platform.dapi.v0.GetDataContractRequest.VersionCase} + * optional bool prove = 8; + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 8, false)); }; - -if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 8, value); }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional GetDocumentsRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.toObject = function(includeInstance, msg) { - var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.toObject(includeInstance, f) - }; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0, 1)); +}; - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.oneofGroups_[0], value); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractRequest; - return proto.org.dash.platform.dapi.v0.GetDataContractRequest.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.deserializeBinaryFromReader); - msg.setV0(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; + /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.oneofGroups_ = [[1]]; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getV0(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.serializeBinaryToWriter - ); - } +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 }; - +/** + * @return {proto.org.dash.platform.dapi.v0.GetDocumentsResponse.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentsResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.oneofGroups_[0])); +}; @@ -10981,8 +15303,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.toObject(opt_includeInstance, this); }; @@ -10991,14 +15313,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.toObject = function(includeInstance, msg) { var f, obj = { - id: msg.getId_asB64(), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -11012,23 +15333,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0. /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0; - return proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentsResponse; + return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -11036,12 +15357,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0. var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setId(value); - break; - case 2: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); + var value = new proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.deserializeBinaryFromReader); + msg.setV0(value); break; default: reader.skipField(); @@ -11056,9 +15374,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0. * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDocumentsResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -11066,126 +15384,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0. /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getId_asU8(); - if (f.length > 0) { - writer.writeBytes( + f = message.getV0(); + if (f != null) { + writer.writeMessage( 1, - f - ); - } - f = message.getProve(); - if (f) { - writer.writeBool( - 2, - f + f, + proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.serializeBinaryToWriter ); } }; -/** - * optional bytes id = 1; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.getId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * optional bytes id = 1; - * This is a type-conversion wrapper around `getId()` - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.getId_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getId())); -}; - - -/** - * optional bytes id = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getId()` - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.getId_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getId())); -}; - - -/** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.setId = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); -}; - - -/** - * optional bool prove = 2; - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); -}; - - -/** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 2, value); -}; - - -/** - * optional GetDataContractRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} - */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0, 1)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} returns this -*/ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractRequest.oneofGroups_[0], value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} returns this - */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.clearV0 = function() { - return this.setV0(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; -}; - - /** * Oneof group definitions for this message. Each group defines the field @@ -11195,21 +15410,22 @@ proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.hasV0 = functio * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + DOCUMENTS: 1, + PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetDataContractResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.oneofGroups_[0])); }; @@ -11226,9 +15442,9 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @return {!Object} - */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractResponse.toObject(opt_includeInstance, this); + */ +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.toObject(opt_includeInstance, this); }; @@ -11237,13 +15453,15 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.toObject = fun * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.toObject(includeInstance, f) + documents: (f = msg.getDocuments()) && proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.toObject(includeInstance, f), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; if (includeInstance) { @@ -11257,23 +15475,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.toObject = function(incl /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractResponse; - return proto.org.dash.platform.dapi.v0.GetDataContractResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0; + return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -11281,9 +15499,19 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.deserializeBinaryFromRea var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.deserializeBinaryFromReader); - msg.setV0(value); + var value = new proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.deserializeBinaryFromReader); + msg.setDocuments(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); break; default: reader.skipField(); @@ -11298,9 +15526,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.deserializeBinaryFromRea * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -11308,18 +15536,34 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.serializeBinar /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getV0(); + f = message.getDocuments(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.serializeBinaryToWriter + ); + } + f = message.getProof(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + ); + } + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter ); } }; @@ -11327,30 +15571,11 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.serializeBinaryToWriter /** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} + * List of repeated fields within this message type. + * @private {!Array} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.oneofGroups_ = [[1,2]]; - -/** - * @enum {number} - */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.ResultCase = { - RESULT_NOT_SET: 0, - DATA_CONTRACT: 1, - PROOF: 2 -}; - -/** - * @return {proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.ResultCase} - */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.oneofGroups_[0])); -}; +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.repeatedFields_ = [1]; @@ -11367,8 +15592,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.toObject(opt_includeInstance, this); }; @@ -11377,15 +15602,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.toObject = function(includeInstance, msg) { var f, obj = { - dataContract: msg.getDataContract_asB64(), - proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), - metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + documentsList: msg.getDocumentsList_asB64() }; if (includeInstance) { @@ -11399,23 +15622,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0; - return proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents; + return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -11424,17 +15647,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setDataContract(value); - break; - case 2: - var value = new proto.org.dash.platform.dapi.v0.Proof; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); - msg.setProof(value); - break; - case 3: - var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); - msg.setMetadata(value); + msg.addDocuments(value); break; default: reader.skipField(); @@ -11449,9 +15662,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -11459,86 +15672,108 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 1)); - if (f != null) { - writer.writeBytes( + f = message.getDocumentsList_asU8(); + if (f.length > 0) { + writer.writeRepeatedBytes( 1, f ); } - f = message.getProof(); - if (f != null) { - writer.writeMessage( - 2, - f, - proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter - ); - } - f = message.getMetadata(); - if (f != null) { - writer.writeMessage( - 3, - f, - proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter - ); - } }; /** - * optional bytes data_contract = 1; - * @return {string} + * repeated bytes documents = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getDataContract = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.getDocumentsList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); }; /** - * optional bytes data_contract = 1; - * This is a type-conversion wrapper around `getDataContract()` - * @return {string} + * repeated bytes documents = 1; + * This is a type-conversion wrapper around `getDocumentsList()` + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getDataContract_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getDataContract())); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.getDocumentsList_asB64 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsB64( + this.getDocumentsList())); }; /** - * optional bytes data_contract = 1; + * repeated bytes documents = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getDataContract()` - * @return {!Uint8Array} + * This is a type-conversion wrapper around `getDocumentsList()` + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getDataContract_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getDataContract())); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.getDocumentsList_asU8 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsU8( + this.getDocumentsList())); +}; + + +/** + * @param {!(Array|Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.setDocumentsList = function(value) { + return jspb.Message.setField(this, 1, value || []); }; /** * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.setDataContract = function(value) { - return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.addDocuments = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 1, value, opt_index); }; /** - * Clears the field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.clearDataContract = function() { - return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.oneofGroups_[0], undefined); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.clearDocumentsList = function() { + return this.setDocumentsList([]); +}; + + +/** + * optional Documents documents = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} + */ +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.getDocuments = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.setDocuments = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.clearDocuments = function() { + return this.setDocuments(undefined); }; @@ -11546,7 +15781,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.hasDataContract = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.hasDocuments = function() { return jspb.Message.getField(this, 1) != null; }; @@ -11555,7 +15790,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV * optional Proof proof = 2; * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getProof = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.getProof = function() { return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; @@ -11563,18 +15798,18 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV /** * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.clearProof = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.clearProof = function() { return this.setProof(undefined); }; @@ -11583,7 +15818,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.hasProof = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.hasProof = function() { return jspb.Message.getField(this, 2) != null; }; @@ -11592,7 +15827,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV * optional ResponseMetadata metadata = 3; * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getMetadata = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.getMetadata = function() { return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; @@ -11600,18 +15835,18 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV /** * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.setMetadata = function(value) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.setMetadata = function(value) { return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.clearMetadata = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.clearMetadata = function() { return this.setMetadata(undefined); }; @@ -11620,35 +15855,35 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.hasMetadata = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.hasMetadata = function() { return jspb.Message.getField(this, 3) != null; }; /** - * optional GetDataContractResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} + * optional GetDocumentsResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -11657,7 +15892,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.clearV0 = func * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -11671,21 +15906,21 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.hasV0 = functi * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetDataContractsRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractsRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractsRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.oneofGroups_[0])); }; @@ -11703,8 +15938,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractsRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.toObject(opt_includeInstance, this); }; @@ -11713,13 +15948,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.toObject = fun * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -11733,23 +15968,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.toObject = function(incl /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsRequest; - return proto.org.dash.platform.dapi.v0.GetDataContractsRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest; + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -11757,8 +15992,8 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.deserializeBinaryFromRea var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -11774,9 +16009,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.deserializeBinaryFromRea * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractsRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -11784,18 +16019,18 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.serializeBinar /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.serializeBinaryToWriter ); } }; @@ -11807,7 +16042,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.serializeBinaryToWriter * @private {!Array} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.repeatedFields_ = [1]; @@ -11824,8 +16059,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.toObject(opt_includeInstance, this); }; @@ -11834,13 +16069,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - idsList: msg.getIdsList_asB64(), + publicKeyHashesList: msg.getPublicKeyHashesList_asB64(), prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) }; @@ -11855,23 +16090,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0; - return proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0; + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -11880,7 +16115,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.addIds(value); + msg.addPublicKeyHashes(value); break; case 2: var value = /** @type {boolean} */ (reader.readBool()); @@ -11899,9 +16134,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -11909,13 +16144,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getIdsList_asU8(); + f = message.getPublicKeyHashesList_asU8(); if (f.length > 0) { writer.writeRepeatedBytes( 1, @@ -11933,43 +16168,43 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV /** - * repeated bytes ids = 1; + * repeated bytes public_key_hashes = 1; * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.getIdsList = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.getPublicKeyHashesList = function() { return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); }; /** - * repeated bytes ids = 1; - * This is a type-conversion wrapper around `getIdsList()` + * repeated bytes public_key_hashes = 1; + * This is a type-conversion wrapper around `getPublicKeyHashesList()` * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.getIdsList_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.getPublicKeyHashesList_asB64 = function() { return /** @type {!Array} */ (jspb.Message.bytesListAsB64( - this.getIdsList())); + this.getPublicKeyHashesList())); }; /** - * repeated bytes ids = 1; + * repeated bytes public_key_hashes = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getIdsList()` + * This is a type-conversion wrapper around `getPublicKeyHashesList()` * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.getIdsList_asU8 = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.getPublicKeyHashesList_asU8 = function() { return /** @type {!Array} */ (jspb.Message.bytesListAsU8( - this.getIdsList())); + this.getPublicKeyHashesList())); }; /** * @param {!(Array|Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.setIdsList = function(value) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.setPublicKeyHashesList = function(value) { return jspb.Message.setField(this, 1, value || []); }; @@ -11977,19 +16212,19 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV /** * @param {!(string|Uint8Array)} value * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.addIds = function(value, opt_index) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.addPublicKeyHashes = function(value, opt_index) { return jspb.Message.addToRepeatedField(this, 1, value, opt_index); }; /** * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.clearIdsList = function() { - return this.setIdsList([]); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.clearPublicKeyHashesList = function() { + return this.setPublicKeyHashesList([]); }; @@ -11997,44 +16232,44 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV * optional bool prove = 2; * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.getProve = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.getProve = function() { return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); }; /** * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.setProve = function(value) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.setProve = function(value) { return jspb.Message.setProto3BooleanField(this, 2, value); }; /** - * optional GetDataContractsRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} + * optional GetIdentitiesByPublicKeyHashesRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractsRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -12043,7 +16278,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.clearV0 = func * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -12057,21 +16292,21 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.hasV0 = functi * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetDataContractsResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractsResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.oneofGroups_[0])); }; @@ -12089,8 +16324,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.toObject(opt_includeInstance, this); }; @@ -12099,13 +16334,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.toObject = fu * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -12119,23 +16354,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.toObject = function(inc /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse; - return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse; + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -12143,8 +16378,8 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.deserializeBinaryFromRe var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -12160,9 +16395,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.deserializeBinaryFromRe * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractsResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -12170,18 +16405,18 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.serializeBina /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.serializeBinaryToWriter ); } }; @@ -12203,8 +16438,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.toObject(opt_includeInstance, this); }; @@ -12213,14 +16448,14 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.proto * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.toObject = function(includeInstance, msg) { var f, obj = { - identifier: msg.getIdentifier_asB64(), - dataContract: (f = msg.getDataContract()) && google_protobuf_wrappers_pb.BytesValue.toObject(includeInstance, f) + publicKeyHash: msg.getPublicKeyHash_asB64(), + value: (f = msg.getValue()) && google_protobuf_wrappers_pb.BytesValue.toObject(includeInstance, f) }; if (includeInstance) { @@ -12234,23 +16469,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.toObj /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry; - return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry; + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -12259,12 +16494,12 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.deser switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setIdentifier(value); + msg.setPublicKeyHash(value); break; case 2: var value = new google_protobuf_wrappers_pb.BytesValue; reader.readMessage(value,google_protobuf_wrappers_pb.BytesValue.deserializeBinaryFromReader); - msg.setDataContract(value); + msg.setValue(value); break; default: reader.skipField(); @@ -12279,9 +16514,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.deser * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -12289,20 +16524,20 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.proto /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getIdentifier_asU8(); + f = message.getPublicKeyHash_asU8(); if (f.length > 0) { writer.writeBytes( 1, f ); } - f = message.getDataContract(); + f = message.getValue(); if (f != null) { writer.writeMessage( 2, @@ -12314,52 +16549,52 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.seria /** - * optional bytes identifier = 1; + * optional bytes public_key_hash = 1; * @return {string} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.getIdentifier = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.getPublicKeyHash = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * optional bytes identifier = 1; - * This is a type-conversion wrapper around `getIdentifier()` + * optional bytes public_key_hash = 1; + * This is a type-conversion wrapper around `getPublicKeyHash()` * @return {string} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.getIdentifier_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.getPublicKeyHash_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getIdentifier())); + this.getPublicKeyHash())); }; /** - * optional bytes identifier = 1; + * optional bytes public_key_hash = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getIdentifier()` + * This is a type-conversion wrapper around `getPublicKeyHash()` * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.getIdentifier_asU8 = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.getPublicKeyHash_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getIdentifier())); + this.getPublicKeyHash())); }; /** * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.setIdentifier = function(value) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.setPublicKeyHash = function(value) { return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional google.protobuf.BytesValue data_contract = 2; + * optional google.protobuf.BytesValue value = 2; * @return {?proto.google.protobuf.BytesValue} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.getDataContract = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.getValue = function() { return /** @type{?proto.google.protobuf.BytesValue} */ ( jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.BytesValue, 2)); }; @@ -12367,19 +16602,19 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.proto /** * @param {?proto.google.protobuf.BytesValue|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.setDataContract = function(value) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.setValue = function(value) { return jspb.Message.setWrapperField(this, 2, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.clearDataContract = function() { - return this.setDataContract(undefined); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.clearValue = function() { + return this.setValue(undefined); }; @@ -12387,7 +16622,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.proto * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.hasDataContract = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.hasValue = function() { return jspb.Message.getField(this, 2) != null; }; @@ -12398,7 +16633,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.proto * @private {!Array} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.repeatedFields_ = [1]; @@ -12415,8 +16650,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.toObject(opt_includeInstance, this); }; @@ -12425,14 +16660,14 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.toObject = function(includeInstance, msg) { var f, obj = { - dataContractEntriesList: jspb.Message.toObjectList(msg.getDataContractEntriesList(), - proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.toObject, includeInstance) + identityEntriesList: jspb.Message.toObjectList(msg.getIdentityEntriesList(), + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.toObject, includeInstance) }; if (includeInstance) { @@ -12446,23 +16681,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.toObject /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts; - return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes; + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -12470,9 +16705,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.deseriali var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.deserializeBinaryFromReader); - msg.addDataContractEntries(value); + var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.deserializeBinaryFromReader); + msg.addIdentityEntries(value); break; default: reader.skipField(); @@ -12487,9 +16722,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.deseriali * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -12497,58 +16732,58 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getDataContractEntriesList(); + f = message.getIdentityEntriesList(); if (f.length > 0) { writer.writeRepeatedMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.serializeBinaryToWriter ); } }; /** - * repeated DataContractEntry data_contract_entries = 1; - * @return {!Array} + * repeated PublicKeyHashIdentityEntry identity_entries = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.getDataContractEntriesList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry, 1)); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.getIdentityEntriesList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry, 1)); }; /** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} returns this + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.setDataContractEntriesList = function(value) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.setIdentityEntriesList = function(value) { return jspb.Message.setRepeatedWrapperField(this, 1, value); }; /** - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry=} opt_value + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry=} opt_value * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.addDataContractEntries = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry, opt_index); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.addIdentityEntries = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry, opt_index); }; /** * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.clearDataContractEntriesList = function() { - return this.setDataContractEntriesList([]); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.clearIdentityEntriesList = function() { + return this.setIdentityEntriesList([]); }; @@ -12561,22 +16796,22 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.ResultCase = { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.ResultCase = { RESULT_NOT_SET: 0, - DATA_CONTRACTS: 1, + IDENTITIES: 1, PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.ResultCase} + * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.oneofGroups_[0])); }; @@ -12594,8 +16829,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.toObject(opt_includeInstance, this); }; @@ -12604,13 +16839,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - dataContracts: (f = msg.getDataContracts()) && proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.toObject(includeInstance, f), + identities: (f = msg.getIdentities()) && proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.toObject(includeInstance, f), proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; @@ -12626,23 +16861,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0; - return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0; + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -12650,9 +16885,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.deserializeBinaryFromReader); - msg.setDataContracts(value); + var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.deserializeBinaryFromReader); + msg.setIdentities(value); break; case 2: var value = new proto.org.dash.platform.dapi.v0.Proof; @@ -12677,9 +16912,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -12687,18 +16922,18 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getDataContracts(); + f = message.getIdentities(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.serializeBinaryToWriter ); } f = message.getProof(); @@ -12721,30 +16956,30 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons /** - * optional DataContracts data_contracts = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} + * optional IdentitiesByPublicKeyHashes identities = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.getDataContracts = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts, 1)); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.getIdentities = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.setDataContracts = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.setIdentities = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.clearDataContracts = function() { - return this.setDataContracts(undefined); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.clearIdentities = function() { + return this.setIdentities(undefined); }; @@ -12752,7 +16987,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.hasDataContracts = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.hasIdentities = function() { return jspb.Message.getField(this, 1) != null; }; @@ -12761,7 +16996,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons * optional Proof proof = 2; * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.getProof = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.getProof = function() { return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; @@ -12769,18 +17004,18 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons /** * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.clearProof = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.clearProof = function() { return this.setProof(undefined); }; @@ -12789,7 +17024,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.hasProof = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.hasProof = function() { return jspb.Message.getField(this, 2) != null; }; @@ -12798,7 +17033,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons * optional ResponseMetadata metadata = 3; * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.getMetadata = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.getMetadata = function() { return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; @@ -12806,18 +17041,18 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons /** * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.setMetadata = function(value) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.setMetadata = function(value) { return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.clearMetadata = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.clearMetadata = function() { return this.setMetadata(undefined); }; @@ -12826,35 +17061,35 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.hasMetadata = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.hasMetadata = function() { return jspb.Message.getField(this, 3) != null; }; /** - * optional GetDataContractsResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} + * optional GetIdentitiesByPublicKeyHashesResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -12863,7 +17098,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.clearV0 = fun * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -12877,21 +17112,21 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.hasV0 = funct * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.oneofGroups_[0])); }; @@ -12909,8 +17144,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.toObject(opt_includeInstance, this); }; @@ -12919,13 +17154,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.toObject * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -12939,23 +17174,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.toObject = functio /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest; - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest; + return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -12963,8 +17198,8 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.deserializeBinaryF var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -12980,9 +17215,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.deserializeBinaryF * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -12990,18 +17225,18 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.serializ /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.serializeBinaryToWriter ); } }; @@ -13023,8 +17258,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.toObject(opt_includeInstance, this); }; @@ -13033,17 +17268,14 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHis * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - id: msg.getId_asB64(), - limit: (f = msg.getLimit()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), - offset: (f = msg.getOffset()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), - startAtMs: jspb.Message.getFieldWithDefault(msg, 4, 0), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 5, false) + publicKeyHash: msg.getPublicKeyHash_asB64(), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) }; if (includeInstance) { @@ -13057,23 +17289,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHis /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0; - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0; + return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -13082,23 +17314,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHis switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setId(value); + msg.setPublicKeyHash(value); break; case 2: - var value = new google_protobuf_wrappers_pb.UInt32Value; - reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); - msg.setLimit(value); - break; - case 3: - var value = new google_protobuf_wrappers_pb.UInt32Value; - reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); - msg.setOffset(value); - break; - case 4: - var value = /** @type {number} */ (reader.readUint64()); - msg.setStartAtMs(value); - break; - case 5: var value = /** @type {boolean} */ (reader.readBool()); msg.setProve(value); break; @@ -13115,9 +17333,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHis * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -13125,46 +17343,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHis /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getId_asU8(); + f = message.getPublicKeyHash_asU8(); if (f.length > 0) { writer.writeBytes( 1, f ); } - f = message.getLimit(); - if (f != null) { - writer.writeMessage( - 2, - f, - google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter - ); - } - f = message.getOffset(); - if (f != null) { - writer.writeMessage( - 3, - f, - google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter - ); - } - f = message.getStartAtMs(); - if (f !== 0) { - writer.writeUint64( - 4, - f - ); - } f = message.getProve(); if (f) { writer.writeBool( - 5, + 2, f ); } @@ -13172,181 +17367,89 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHis /** - * optional bytes id = 1; + * optional bytes public_key_hash = 1; * @return {string} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getId = function() { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.getPublicKeyHash = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * optional bytes id = 1; - * This is a type-conversion wrapper around `getId()` + * optional bytes public_key_hash = 1; + * This is a type-conversion wrapper around `getPublicKeyHash()` * @return {string} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getId_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.getPublicKeyHash_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getId())); + this.getPublicKeyHash())); }; /** - * optional bytes id = 1; + * optional bytes public_key_hash = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getId()` + * This is a type-conversion wrapper around `getPublicKeyHash()` * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getId_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getId())); -}; - - -/** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.setId = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); -}; - - -/** - * optional google.protobuf.UInt32Value limit = 2; - * @return {?proto.google.protobuf.UInt32Value} - */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getLimit = function() { - return /** @type{?proto.google.protobuf.UInt32Value} */ ( - jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 2)); -}; - - -/** - * @param {?proto.google.protobuf.UInt32Value|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.setLimit = function(value) { - return jspb.Message.setWrapperField(this, 2, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.clearLimit = function() { - return this.setLimit(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.hasLimit = function() { - return jspb.Message.getField(this, 2) != null; -}; - - -/** - * optional google.protobuf.UInt32Value offset = 3; - * @return {?proto.google.protobuf.UInt32Value} - */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getOffset = function() { - return /** @type{?proto.google.protobuf.UInt32Value} */ ( - jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 3)); -}; - - -/** - * @param {?proto.google.protobuf.UInt32Value|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.setOffset = function(value) { - return jspb.Message.setWrapperField(this, 3, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.clearOffset = function() { - return this.setOffset(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.hasOffset = function() { - return jspb.Message.getField(this, 3) != null; -}; - - -/** - * optional uint64 start_at_ms = 4; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getStartAtMs = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.getPublicKeyHash_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getPublicKeyHash())); }; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.setStartAtMs = function(value) { - return jspb.Message.setProto3IntField(this, 4, value); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.setPublicKeyHash = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional bool prove = 5; + * optional bool prove = 2; * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 5, false)); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); }; /** * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 5, value); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); }; /** - * optional GetDataContractHistoryRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} + * optional GetIdentityByPublicKeyHashRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -13355,7 +17458,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.clearV0 * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -13369,21 +17472,21 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.hasV0 = * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.oneofGroups_[0])); }; @@ -13401,8 +17504,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.toObject(opt_includeInstance, this); }; @@ -13411,13 +17514,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.toObjec * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -13431,23 +17534,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.toObject = functi /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse; - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse; + return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -13455,8 +17558,8 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.deserializeBinary var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -13472,9 +17575,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.deserializeBinary * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -13482,18 +17585,18 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.seriali /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.serializeBinaryToWriter ); } }; @@ -13508,22 +17611,22 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.serializeBinaryTo * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.ResultCase = { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.ResultCase = { RESULT_NOT_SET: 0, - DATA_CONTRACT_HISTORY: 1, + IDENTITY: 1, PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.ResultCase} + * @return {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.oneofGroups_[0])); }; @@ -13541,8 +17644,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.toObject(opt_includeInstance, this); }; @@ -13551,13 +17654,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - dataContractHistory: (f = msg.getDataContractHistory()) && proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.toObject(includeInstance, f), + identity: msg.getIdentity_asB64(), proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; @@ -13573,23 +17676,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0; - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0; + return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -13597,9 +17700,8 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.deserializeBinaryFromReader); - msg.setDataContractHistory(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setIdentity(value); break; case 2: var value = new proto.org.dash.platform.dapi.v0.Proof; @@ -13624,9 +17726,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -13634,18 +17736,17 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getDataContractHistory(); + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 1)); if (f != null) { - writer.writeMessage( + writer.writeBytes( 1, - f, - proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.serializeBinaryToWriter + f ); } f = message.getProof(); @@ -13667,197 +17768,202 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi }; +/** + * optional bytes identity = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getIdentity = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; - -if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} + * optional bytes identity = 1; + * This is a type-conversion wrapper around `getIdentity()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getIdentity_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getIdentity())); }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional bytes identity = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getIdentity()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.toObject = function(includeInstance, msg) { - var f, obj = { - date: jspb.Message.getFieldWithDefault(msg, 1, 0), - value: msg.getValue_asB64() - }; +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getIdentity_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getIdentity())); +}; - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.setIdentity = function(value) { + return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.oneofGroups_[0], value); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry; - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.clearIdentity = function() { + return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.oneofGroups_[0], undefined); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {number} */ (reader.readUint64()); - msg.setDate(value); - break; - case 2: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setValue(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.hasIdentity = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); }; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getDate(); - if (f !== 0) { - writer.writeUint64( - 1, - f - ); - } - f = message.getValue_asU8(); - if (f.length > 0) { - writer.writeBytes( - 2, - f - ); - } +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; }; /** - * optional uint64 date = 1; - * @return {number} + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.getDate = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} returns this + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.setDate = function(value) { - return jspb.Message.setProto3IntField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); }; /** - * optional bytes value = 2; - * @return {string} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.getValue = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; }; /** - * optional bytes value = 2; - * This is a type-conversion wrapper around `getValue()` - * @return {string} + * optional GetIdentityByPublicKeyHashResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.getValue_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getValue())); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0, 1)); }; /** - * optional bytes value = 2; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getValue()` - * @return {!Uint8Array} + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.getValue_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getValue())); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.setValue = function(value) { - return jspb.Message.setProto3BytesField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; /** - * List of repeated fields within this message type. - * @private {!Array} + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.VersionCase} + */ +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.oneofGroups_[0])); +}; @@ -13874,8 +17980,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.toObject(opt_includeInstance, this); }; @@ -13884,14 +17990,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.toObject = function(includeInstance, msg) { var f, obj = { - dataContractEntriesList: jspb.Message.toObjectList(msg.getDataContractEntriesList(), - proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.toObject, includeInstance) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -13905,23 +18010,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory; - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest; + return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -13929,9 +18034,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.deserializeBinaryFromReader); - msg.addDataContractEntries(value); + var value = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.deserializeBinaryFromReader); + msg.setV0(value); break; default: reader.skipField(); @@ -13946,9 +18051,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -13956,196 +18061,231 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} message + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getDataContractEntriesList(); - if (f.length > 0) { - writer.writeRepeatedMessage( + f = message.getV0(); + if (f != null) { + writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.serializeBinaryToWriter ); } }; -/** - * repeated DataContractHistoryEntry data_contract_entries = 1; - * @return {!Array} - */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.getDataContractEntriesList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry, 1)); -}; - - -/** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} returns this -*/ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.setDataContractEntriesList = function(value) { - return jspb.Message.setRepeatedWrapperField(this, 1, value); -}; - -/** - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry=} opt_value - * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} - */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.addDataContractEntries = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry, opt_index); -}; +if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} returns this + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.clearDataContractEntriesList = function() { - return this.setDataContractEntriesList([]); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.toObject(opt_includeInstance, this); }; /** - * optional DataContractHistory data_contract_history = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.getDataContractHistory = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory, 1)); -}; - +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.toObject = function(includeInstance, msg) { + var f, obj = { + stateTransitionHash: msg.getStateTransitionHash_asB64(), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + }; -/** - * @param {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.setDataContractHistory = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.oneofGroups_[0], value); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; }; +} /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.clearDataContractHistory = function() { - return this.setDataContractHistory(undefined); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0; + return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.deserializeBinaryFromReader(msg, reader); }; /** - * Returns whether this field is set. - * @return {boolean} + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.hasDataContractHistory = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setStateTransitionHash(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; }; /** - * optional Proof proof = 2; - * @return {?proto.org.dash.platform.dapi.v0.Proof} + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.getProof = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); }; /** - * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.oneofGroups_[0], value); + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStateTransitionHash_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 2, + f + ); + } }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this + * optional bytes state_transition_hash = 1; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.clearProof = function() { - return this.setProof(undefined); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.getStateTransitionHash = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * Returns whether this field is set. - * @return {boolean} + * optional bytes state_transition_hash = 1; + * This is a type-conversion wrapper around `getStateTransitionHash()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.hasProof = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.getStateTransitionHash_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getStateTransitionHash())); }; /** - * optional ResponseMetadata metadata = 3; - * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + * optional bytes state_transition_hash = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getStateTransitionHash()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.getMetadata = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.getStateTransitionHash_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getStateTransitionHash())); }; /** - * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.setMetadata = function(value) { - return jspb.Message.setWrapperField(this, 3, value); + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.setStateTransitionHash = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this + * optional bool prove = 2; + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.clearMetadata = function() { - return this.setMetadata(undefined); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); }; /** - * Returns whether this field is set. - * @return {boolean} + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.hasMetadata = function() { - return jspb.Message.getField(this, 3) != null; +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); }; /** - * optional GetDataContractHistoryResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} + * optional WaitForStateTransitionResultRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0, 1)); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -14154,7 +18294,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.clearV0 * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -14168,21 +18308,21 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.hasV0 = * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetDocumentsRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentsRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.oneofGroups_[0])); }; @@ -14200,8 +18340,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDocumentsRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.toObject(opt_includeInstance, this); }; @@ -14210,13 +18350,13 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.toObject = functio * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -14230,23 +18370,23 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.toObject = function(includeI /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDocumentsRequest; - return proto.org.dash.platform.dapi.v0.GetDocumentsRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse; + return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -14254,8 +18394,8 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.deserializeBinaryFromReader var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -14271,9 +18411,9 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.deserializeBinaryFromReader * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDocumentsRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -14281,18 +18421,18 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.serializeBinary = /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} message + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.serializeBinaryToWriter ); } }; @@ -14307,22 +18447,22 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.serializeBinaryToWriter = fu * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_ = [[6,7]]; +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.StartCase = { - START_NOT_SET: 0, - START_AFTER: 6, - START_AT: 7 +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + ERROR: 1, + PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.StartCase} + * @return {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.StartCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.oneofGroups_[0])); }; @@ -14340,8 +18480,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.toObject(opt_includeInstance, this); }; @@ -14350,20 +18490,15 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.protot * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - dataContractId: msg.getDataContractId_asB64(), - documentType: jspb.Message.getFieldWithDefault(msg, 2, ""), - where: msg.getWhere_asB64(), - orderBy: msg.getOrderBy_asB64(), - limit: jspb.Message.getFieldWithDefault(msg, 5, 0), - startAfter: msg.getStartAfter_asB64(), - startAt: msg.getStartAt_asB64(), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 8, false) + error: (f = msg.getError()) && proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.toObject(includeInstance, f), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; if (includeInstance) { @@ -14377,23 +18512,23 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.toObje /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0; - return proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0; + return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -14401,36 +18536,19 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.deseri var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setDataContractId(value); + var value = new proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.deserializeBinaryFromReader); + msg.setError(value); break; case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setDocumentType(value); + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); break; case 3: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setWhere(value); - break; - case 4: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setOrderBy(value); - break; - case 5: - var value = /** @type {number} */ (reader.readUint32()); - msg.setLimit(value); - break; - case 6: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setStartAfter(value); - break; - case 7: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setStartAt(value); - break; - case 8: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); break; default: reader.skipField(); @@ -14445,9 +18563,9 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.deseri * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -14455,395 +18573,510 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.protot /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getDataContractId_asU8(); - if (f.length > 0) { - writer.writeBytes( + f = message.getError(); + if (f != null) { + writer.writeMessage( 1, - f - ); - } - f = message.getDocumentType(); - if (f.length > 0) { - writer.writeString( - 2, - f - ); - } - f = message.getWhere_asU8(); - if (f.length > 0) { - writer.writeBytes( - 3, - f - ); - } - f = message.getOrderBy_asU8(); - if (f.length > 0) { - writer.writeBytes( - 4, - f - ); - } - f = message.getLimit(); - if (f !== 0) { - writer.writeUint32( - 5, - f + f, + proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.serializeBinaryToWriter ); } - f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 6)); + f = message.getProof(); if (f != null) { - writer.writeBytes( - 6, - f + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter ); } - f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 7)); + f = message.getMetadata(); if (f != null) { - writer.writeBytes( - 7, - f - ); - } - f = message.getProve(); - if (f) { - writer.writeBool( - 8, - f + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter ); } }; /** - * optional bytes data_contract_id = 1; - * @return {string} + * optional StateTransitionBroadcastError error = 1; + * @return {?proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getDataContractId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.getError = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError, 1)); }; /** - * optional bytes data_contract_id = 1; - * This is a type-conversion wrapper around `getDataContractId()` - * @return {string} + * @param {?proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.setError = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getDataContractId_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getDataContractId())); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.clearError = function() { + return this.setError(undefined); }; /** - * optional bytes data_contract_id = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getDataContractId()` - * @return {!Uint8Array} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getDataContractId_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getDataContractId())); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.hasError = function() { + return jspb.Message.getField(this, 1) != null; }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setDataContractId = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; /** - * optional string document_type = 2; - * @return {string} + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getDocumentType = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); }; /** - * @param {string} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setDocumentType = function(value) { - return jspb.Message.setProto3StringField(this, 2, value); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; }; /** - * optional bytes where = 3; - * @return {string} + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getWhere = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; /** - * optional bytes where = 3; - * This is a type-conversion wrapper around `getWhere()` - * @return {string} + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getWhere_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getWhere())); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); }; /** - * optional bytes where = 3; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getWhere()` - * @return {!Uint8Array} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getWhere_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getWhere())); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + * optional WaitForStateTransitionResultResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setWhere = function(value) { - return jspb.Message.setProto3BytesField(this, 3, value); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0, 1)); }; /** - * optional bytes order_by = 4; - * @return {string} + * @param {?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getOrderBy = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * optional bytes order_by = 4; - * This is a type-conversion wrapper around `getOrderBy()` - * @return {string} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getOrderBy_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getOrderBy())); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; + /** - * optional bytes order_by = 4; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getOrderBy()` - * @return {!Uint8Array} + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getOrderBy_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getOrderBy())); -}; +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.oneofGroups_ = [[1]]; +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + * @return {proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setOrderBy = function(value) { - return jspb.Message.setProto3BytesField(this, 4, value); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.oneofGroups_[0])); }; + +if (jspb.Message.GENERATE_TO_OBJECT) { /** - * optional uint32 limit = 5; - * @return {number} + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getLimit = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.toObject(opt_includeInstance, this); }; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setLimit = function(value) { - return jspb.Message.setProto3IntField(this, 5, value); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; }; +} /** - * optional bytes start_after = 6; - * @return {string} + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAfter = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, "")); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest; + return proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.deserializeBinaryFromReader(msg, reader); }; /** - * optional bytes start_after = 6; - * This is a type-conversion wrapper around `getStartAfter()` - * @return {string} + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAfter_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getStartAfter())); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; }; /** - * optional bytes start_after = 6; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getStartAfter()` + * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAfter_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getStartAfter())); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setStartAfter = function(value) { - return jspb.Message.setOneofField(this, 6, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.serializeBinaryToWriter + ); + } }; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Clears the field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.clearStartAfter = function() { - return jspb.Message.setOneofField(this, 6, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_[0], undefined); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.toObject(opt_includeInstance, this); }; /** - * Returns whether this field is set. - * @return {boolean} + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.hasStartAfter = function() { - return jspb.Message.getField(this, 6) != null; +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.toObject = function(includeInstance, msg) { + var f, obj = { + height: jspb.Message.getFieldWithDefault(msg, 1, 0), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; }; +} /** - * optional bytes start_at = 7; - * @return {string} + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAt = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 7, "")); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0; + return proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.deserializeBinaryFromReader(msg, reader); }; /** - * optional bytes start_at = 7; - * This is a type-conversion wrapper around `getStartAt()` - * @return {string} + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAt_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getStartAt())); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setHeight(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; }; /** - * optional bytes start_at = 7; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getStartAt()` + * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAt_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getStartAt())); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setStartAt = function(value) { - return jspb.Message.setOneofField(this, 7, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getHeight(); + if (f !== 0) { + writer.writeInt32( + 1, + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 2, + f + ); + } }; /** - * Clears the field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + * optional int32 height = 1; + * @return {number} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.clearStartAt = function() { - return jspb.Message.setOneofField(this, 7, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_[0], undefined); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.getHeight = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); }; /** - * Returns whether this field is set. - * @return {boolean} + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.hasStartAt = function() { - return jspb.Message.getField(this, 7) != null; +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.setHeight = function(value) { + return jspb.Message.setProto3IntField(this, 1, value); }; /** - * optional bool prove = 8; + * optional bool prove = 2; * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 8, false)); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); }; /** * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 8, value); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); }; /** - * optional GetDocumentsRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} + * optional GetConsensusParamsRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -14852,7 +19085,7 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.clearV0 = function * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -14866,21 +19099,21 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.hasV0 = function() * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetDocumentsResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentsResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.oneofGroups_[0])); }; @@ -14898,8 +19131,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.toObject(opt_includeInstance, this); }; @@ -14908,13 +19141,13 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.toObject = functi * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -14928,23 +19161,23 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.toObject = function(include /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDocumentsResponse; - return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse; + return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -14952,8 +19185,8 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.deserializeBinaryFromReader var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -14969,9 +19202,9 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.deserializeBinaryFromReader * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDocumentsResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -14979,50 +19212,24 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.serializeBinary = /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.serializeBinaryToWriter ); } }; -/** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const - */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.oneofGroups_ = [[1,2]]; - -/** - * @enum {number} - */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.ResultCase = { - RESULT_NOT_SET: 0, - DOCUMENTS: 1, - PROOF: 2 -}; - -/** - * @return {proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.ResultCase} - */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.oneofGroups_[0])); -}; - if (jspb.Message.GENERATE_TO_OBJECT) { @@ -15038,8 +19245,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.toObject(opt_includeInstance, this); }; @@ -15048,15 +19255,15 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prot * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.toObject = function(includeInstance, msg) { var f, obj = { - documents: (f = msg.getDocuments()) && proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.toObject(includeInstance, f), - proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), - metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + maxBytes: jspb.Message.getFieldWithDefault(msg, 1, ""), + maxGas: jspb.Message.getFieldWithDefault(msg, 2, ""), + timeIotaMs: jspb.Message.getFieldWithDefault(msg, 3, "") }; if (includeInstance) { @@ -15070,23 +19277,23 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.toOb /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0; - return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock; + return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -15094,19 +19301,16 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.dese var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.deserializeBinaryFromReader); - msg.setDocuments(value); + var value = /** @type {string} */ (reader.readString()); + msg.setMaxBytes(value); break; case 2: - var value = new proto.org.dash.platform.dapi.v0.Proof; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); - msg.setProof(value); + var value = /** @type {string} */ (reader.readString()); + msg.setMaxGas(value); break; case 3: - var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); - msg.setMetadata(value); + var value = /** @type {string} */ (reader.readString()); + msg.setTimeIotaMs(value); break; default: reader.skipField(); @@ -15121,9 +19325,9 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.dese * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -15131,46 +19335,90 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prot /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getDocuments(); - if (f != null) { - writer.writeMessage( + f = message.getMaxBytes(); + if (f.length > 0) { + writer.writeString( 1, - f, - proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.serializeBinaryToWriter + f ); } - f = message.getProof(); - if (f != null) { - writer.writeMessage( + f = message.getMaxGas(); + if (f.length > 0) { + writer.writeString( 2, - f, - proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + f ); } - f = message.getMetadata(); - if (f != null) { - writer.writeMessage( + f = message.getTimeIotaMs(); + if (f.length > 0) { + writer.writeString( 3, - f, - proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + f ); } }; +/** + * optional string max_bytes = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.getMaxBytes = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} returns this + */ +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.setMaxBytes = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string max_gas = 2; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.getMaxGas = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} returns this + */ +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.setMaxGas = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional string time_iota_ms = 3; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.getTimeIotaMs = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + /** - * List of repeated fields within this message type. - * @private {!Array} - * @const + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.setTimeIotaMs = function(value) { + return jspb.Message.setProto3StringField(this, 3, value); +}; + + @@ -15187,8 +19435,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.toObject(opt_includeInstance, this); }; @@ -15197,13 +19445,15 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Docu * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.toObject = function(includeInstance, msg) { var f, obj = { - documentsList: msg.getDocumentsList_asB64() + maxAgeNumBlocks: jspb.Message.getFieldWithDefault(msg, 1, ""), + maxAgeDuration: jspb.Message.getFieldWithDefault(msg, 2, ""), + maxBytes: jspb.Message.getFieldWithDefault(msg, 3, "") }; if (includeInstance) { @@ -15217,23 +19467,23 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Docu /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents; - return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence; + return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -15241,8 +19491,16 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Docu var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.addDocuments(value); + var value = /** @type {string} */ (reader.readString()); + msg.setMaxAgeNumBlocks(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setMaxAgeDuration(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setMaxBytes(value); break; default: reader.skipField(); @@ -15257,9 +19515,9 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Docu * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -15267,145 +19525,243 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Docu /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} message + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getDocumentsList_asU8(); + f = message.getMaxAgeNumBlocks(); if (f.length > 0) { - writer.writeRepeatedBytes( + writer.writeString( 1, f ); } + f = message.getMaxAgeDuration(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getMaxBytes(); + if (f.length > 0) { + writer.writeString( + 3, + f + ); + } }; /** - * repeated bytes documents = 1; - * @return {!Array} + * optional string max_age_num_blocks = 1; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.getDocumentsList = function() { - return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.getMaxAgeNumBlocks = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * repeated bytes documents = 1; - * This is a type-conversion wrapper around `getDocumentsList()` - * @return {!Array} + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.getDocumentsList_asB64 = function() { - return /** @type {!Array} */ (jspb.Message.bytesListAsB64( - this.getDocumentsList())); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.setMaxAgeNumBlocks = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); }; /** - * repeated bytes documents = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getDocumentsList()` - * @return {!Array} + * optional string max_age_duration = 2; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.getDocumentsList_asU8 = function() { - return /** @type {!Array} */ (jspb.Message.bytesListAsU8( - this.getDocumentsList())); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.getMaxAgeDuration = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** - * @param {!(Array|Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} returns this + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.setDocumentsList = function(value) { - return jspb.Message.setField(this, 1, value || []); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.setMaxAgeDuration = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); }; /** - * @param {!(string|Uint8Array)} value - * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} returns this + * optional string max_bytes = 3; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.addDocuments = function(value, opt_index) { - return jspb.Message.addToRepeatedField(this, 1, value, opt_index); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.getMaxBytes = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); }; /** - * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} returns this + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.clearDocumentsList = function() { - return this.setDocumentsList([]); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.setMaxBytes = function(value) { + return jspb.Message.setProto3StringField(this, 3, value); }; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { /** - * optional Documents documents = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.getDocuments = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents, 1)); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.toObject(opt_includeInstance, this); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.setDocuments = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.oneofGroups_[0], value); + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.toObject = function(includeInstance, msg) { + var f, obj = { + block: (f = msg.getBlock()) && proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.toObject(includeInstance, f), + evidence: (f = msg.getEvidence()) && proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; }; +} /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.clearDocuments = function() { - return this.setDocuments(undefined); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0; + return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.deserializeBinaryFromReader(msg, reader); }; /** - * Returns whether this field is set. - * @return {boolean} + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.hasDocuments = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.deserializeBinaryFromReader); + msg.setBlock(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.deserializeBinaryFromReader); + msg.setEvidence(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getBlock(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.serializeBinaryToWriter + ); + } + f = message.getEvidence(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.serializeBinaryToWriter + ); + } }; /** - * optional Proof proof = 2; - * @return {?proto.org.dash.platform.dapi.v0.Proof} + * optional ConsensusParamsBlock block = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.getProof = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.getBlock = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.setBlock = function(value) { + return jspb.Message.setWrapperField(this, 1, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.clearProof = function() { - return this.setProof(undefined); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.clearBlock = function() { + return this.setBlock(undefined); }; @@ -15413,36 +19769,36 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prot * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.hasProof = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.hasBlock = function() { + return jspb.Message.getField(this, 1) != null; }; /** - * optional ResponseMetadata metadata = 3; - * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + * optional ConsensusParamsEvidence evidence = 2; + * @return {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.getMetadata = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.getEvidence = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence, 2)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.setMetadata = function(value) { - return jspb.Message.setWrapperField(this, 3, value); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.setEvidence = function(value) { + return jspb.Message.setWrapperField(this, 2, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.clearMetadata = function() { - return this.setMetadata(undefined); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.clearEvidence = function() { + return this.setEvidence(undefined); }; @@ -15450,35 +19806,35 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prot * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.hasMetadata = function() { - return jspb.Message.getField(this, 3) != null; +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.hasEvidence = function() { + return jspb.Message.getField(this, 2) != null; }; /** - * optional GetDocumentsResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} + * optional GetConsensusParamsResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -15487,7 +19843,7 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.clearV0 = functio * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -15501,21 +19857,21 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.hasV0 = function( * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.oneofGroups_[0])); }; @@ -15533,8 +19889,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.toObject(opt_includeInstance, this); }; @@ -15543,13 +19899,13 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -15563,23 +19919,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.toObject = /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest; - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -15587,8 +19943,8 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.deserializ var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -15604,9 +19960,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.deserializ * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -15614,31 +19970,24 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype. /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.serializeBinaryToWriter ); } }; -/** - * List of repeated fields within this message type. - * @private {!Array} - * @const - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.repeatedFields_ = [1]; - if (jspb.Message.GENERATE_TO_OBJECT) { @@ -15654,8 +20003,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.toObject(opt_includeInstance, this); }; @@ -15664,14 +20013,13 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentit * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - publicKeyHashesList: msg.getPublicKeyHashesList_asB64(), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + prove: jspb.Message.getBooleanFieldWithDefault(msg, 1, false) }; if (includeInstance) { @@ -15685,23 +20033,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentit /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0; - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -15709,10 +20057,6 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentit var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.addPublicKeyHashes(value); - break; - case 2: var value = /** @type {boolean} */ (reader.readBool()); msg.setProve(value); break; @@ -15729,9 +20073,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentit * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -15739,132 +20083,64 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentit /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getPublicKeyHashesList_asU8(); - if (f.length > 0) { - writer.writeRepeatedBytes( - 1, - f - ); - } f = message.getProve(); if (f) { writer.writeBool( - 2, - f - ); - } -}; - - -/** - * repeated bytes public_key_hashes = 1; - * @return {!Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.getPublicKeyHashesList = function() { - return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); -}; - - -/** - * repeated bytes public_key_hashes = 1; - * This is a type-conversion wrapper around `getPublicKeyHashesList()` - * @return {!Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.getPublicKeyHashesList_asB64 = function() { - return /** @type {!Array} */ (jspb.Message.bytesListAsB64( - this.getPublicKeyHashesList())); -}; - - -/** - * repeated bytes public_key_hashes = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getPublicKeyHashesList()` - * @return {!Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.getPublicKeyHashesList_asU8 = function() { - return /** @type {!Array} */ (jspb.Message.bytesListAsU8( - this.getPublicKeyHashesList())); -}; - - -/** - * @param {!(Array|Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.setPublicKeyHashesList = function(value) { - return jspb.Message.setField(this, 1, value || []); -}; - - -/** - * @param {!(string|Uint8Array)} value - * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.addPublicKeyHashes = function(value, opt_index) { - return jspb.Message.addToRepeatedField(this, 1, value, opt_index); -}; - - -/** - * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.clearPublicKeyHashesList = function() { - return this.setPublicKeyHashesList([]); + 1, + f + ); + } }; /** - * optional bool prove = 2; + * optional bool prove = 1; * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 1, false)); }; /** * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 1, value); }; /** - * optional GetIdentitiesByPublicKeyHashesRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} + * optional GetProtocolVersionUpgradeStateRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -15873,7 +20149,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype. * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -15887,21 +20163,21 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype. * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.oneofGroups_[0])); }; @@ -15919,8 +20195,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.toObject(opt_includeInstance, this); }; @@ -15929,13 +20205,13 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -15949,23 +20225,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.toObject /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse; - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -15973,8 +20249,8 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.deseriali var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -15990,9 +20266,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.deseriali * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -16000,24 +20276,50 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.serializeBinaryToWriter ); } }; +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.oneofGroups_ = [[1,2]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + VERSIONS: 1, + PROOF: 2 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.ResultCase} + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.oneofGroups_[0])); +}; + if (jspb.Message.GENERATE_TO_OBJECT) { @@ -16033,8 +20335,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.toObject(opt_includeInstance, this); }; @@ -16043,14 +20345,15 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKey * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - publicKeyHash: msg.getPublicKeyHash_asB64(), - value: (f = msg.getValue()) && google_protobuf_wrappers_pb.BytesValue.toObject(includeInstance, f) + versions: (f = msg.getVersions()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.toObject(includeInstance, f), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; if (includeInstance) { @@ -16064,23 +20367,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKey /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry; - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -16088,137 +20391,73 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKey var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setPublicKeyHash(value); + var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.deserializeBinaryFromReader); + msg.setVersions(value); break; case 2: - var value = new google_protobuf_wrappers_pb.BytesValue; - reader.readMessage(value,google_protobuf_wrappers_pb.BytesValue.deserializeBinaryFromReader); - msg.setValue(value); + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); break; default: reader.skipField(); break; } } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getPublicKeyHash_asU8(); - if (f.length > 0) { - writer.writeBytes( - 1, - f - ); - } - f = message.getValue(); - if (f != null) { - writer.writeMessage( - 2, - f, - google_protobuf_wrappers_pb.BytesValue.serializeBinaryToWriter - ); - } -}; - - -/** - * optional bytes public_key_hash = 1; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.getPublicKeyHash = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * optional bytes public_key_hash = 1; - * This is a type-conversion wrapper around `getPublicKeyHash()` - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.getPublicKeyHash_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getPublicKeyHash())); -}; - - -/** - * optional bytes public_key_hash = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getPublicKeyHash()` - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.getPublicKeyHash_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getPublicKeyHash())); -}; - - -/** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.setPublicKeyHash = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); -}; - - -/** - * optional google.protobuf.BytesValue value = 2; - * @return {?proto.google.protobuf.BytesValue} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.getValue = function() { - return /** @type{?proto.google.protobuf.BytesValue} */ ( - jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.BytesValue, 2)); -}; - - -/** - * @param {?proto.google.protobuf.BytesValue|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.setValue = function(value) { - return jspb.Message.setWrapperField(this, 2, value); + return msg; }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} returns this + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.clearValue = function() { - return this.setValue(undefined); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); }; /** - * Returns whether this field is set. - * @return {boolean} + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.hasValue = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getVersions(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.serializeBinaryToWriter + ); + } + f = message.getProof(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + ); + } + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + ); + } }; @@ -16228,7 +20467,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKey * @private {!Array} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.repeatedFields_ = [1]; @@ -16245,8 +20484,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.toObject(opt_includeInstance, this); }; @@ -16255,14 +20494,14 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.Identitie * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.toObject = function(includeInstance, msg) { var f, obj = { - identityEntriesList: jspb.Message.toObjectList(msg.getIdentityEntriesList(), - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.toObject, includeInstance) + versionsList: jspb.Message.toObjectList(msg.getVersionsList(), + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.toObject, includeInstance) }; if (includeInstance) { @@ -16276,23 +20515,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.Identitie /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes; - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -16300,9 +20539,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.Identitie var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.deserializeBinaryFromReader); - msg.addIdentityEntries(value); + var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.deserializeBinaryFromReader); + msg.addVersions(value); break; default: reader.skipField(); @@ -16317,9 +20556,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.Identitie * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -16327,88 +20566,62 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.Identitie /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} message + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getIdentityEntriesList(); + f = message.getVersionsList(); if (f.length > 0) { writer.writeRepeatedMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.serializeBinaryToWriter ); } }; /** - * repeated PublicKeyHashIdentityEntry identity_entries = 1; - * @return {!Array} + * repeated VersionEntry versions = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.getIdentityEntriesList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry, 1)); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.getVersionsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry, 1)); }; /** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} returns this + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.setIdentityEntriesList = function(value) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.setVersionsList = function(value) { return jspb.Message.setRepeatedWrapperField(this, 1, value); }; /** - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry=} opt_value + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry=} opt_value * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.addIdentityEntries = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry, opt_index); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.addVersions = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry, opt_index); }; /** * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.clearIdentityEntriesList = function() { - return this.setIdentityEntriesList([]); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.clearVersionsList = function() { + return this.setVersionsList([]); }; -/** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.oneofGroups_ = [[1,2]]; - -/** - * @enum {number} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.ResultCase = { - RESULT_NOT_SET: 0, - IDENTITIES: 1, - PROOF: 2 -}; - -/** - * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.ResultCase} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.oneofGroups_[0])); -}; - if (jspb.Message.GENERATE_TO_OBJECT) { @@ -16424,8 +20637,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.toObject(opt_includeInstance, this); }; @@ -16434,15 +20647,14 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.toObject = function(includeInstance, msg) { var f, obj = { - identities: (f = msg.getIdentities()) && proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.toObject(includeInstance, f), - proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), - metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + versionNumber: jspb.Message.getFieldWithDefault(msg, 1, 0), + voteCount: jspb.Message.getFieldWithDefault(msg, 2, 0) }; if (includeInstance) { @@ -16456,23 +20668,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0; - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -16480,19 +20692,12 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.deserializeBinaryFromReader); - msg.setIdentities(value); + var value = /** @type {number} */ (reader.readUint32()); + msg.setVersionNumber(value); break; case 2: - var value = new proto.org.dash.platform.dapi.v0.Proof; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); - msg.setProof(value); - break; - case 3: - var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); - msg.setMetadata(value); + var value = /** @type {number} */ (reader.readUint32()); + msg.setVoteCount(value); break; default: reader.skipField(); @@ -16507,9 +20712,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -16517,64 +20722,90 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getIdentities(); - if (f != null) { - writer.writeMessage( + f = message.getVersionNumber(); + if (f !== 0) { + writer.writeUint32( 1, - f, - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.serializeBinaryToWriter + f ); } - f = message.getProof(); - if (f != null) { - writer.writeMessage( + f = message.getVoteCount(); + if (f !== 0) { + writer.writeUint32( 2, - f, - proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter - ); - } - f = message.getMetadata(); - if (f != null) { - writer.writeMessage( - 3, - f, - proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + f ); } }; /** - * optional IdentitiesByPublicKeyHashes identities = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} + * optional uint32 version_number = 1; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.getVersionNumber = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} returns this + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.setVersionNumber = function(value) { + return jspb.Message.setProto3IntField(this, 1, value); +}; + + +/** + * optional uint32 vote_count = 2; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.getVoteCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} returns this + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.setVoteCount = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); +}; + + +/** + * optional Versions versions = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.getIdentities = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes, 1)); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.getVersions = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.setIdentities = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.setVersions = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.clearIdentities = function() { - return this.setIdentities(undefined); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.clearVersions = function() { + return this.setVersions(undefined); }; @@ -16582,7 +20813,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.hasIdentities = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.hasVersions = function() { return jspb.Message.getField(this, 1) != null; }; @@ -16591,7 +20822,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti * optional Proof proof = 2; * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.getProof = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.getProof = function() { return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; @@ -16599,18 +20830,18 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti /** * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.clearProof = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.clearProof = function() { return this.setProof(undefined); }; @@ -16619,7 +20850,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.hasProof = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.hasProof = function() { return jspb.Message.getField(this, 2) != null; }; @@ -16628,7 +20859,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti * optional ResponseMetadata metadata = 3; * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.getMetadata = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.getMetadata = function() { return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; @@ -16636,18 +20867,18 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti /** * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.setMetadata = function(value) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.setMetadata = function(value) { return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.clearMetadata = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.clearMetadata = function() { return this.setMetadata(undefined); }; @@ -16656,35 +20887,35 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.hasMetadata = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.hasMetadata = function() { return jspb.Message.getField(this, 3) != null; }; /** - * optional GetIdentitiesByPublicKeyHashesResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} + * optional GetProtocolVersionUpgradeStateResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -16693,7 +20924,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -16707,21 +20938,21 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.oneofGroups_[0])); }; @@ -16739,8 +20970,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.toObject(opt_includeInstance, this); }; @@ -16749,13 +20980,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.toOb * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -16769,23 +21000,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.toObject = fun /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest; - return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -16793,8 +21024,8 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.deserializeBin var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -16810,9 +21041,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.deserializeBin * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -16820,18 +21051,18 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.seri /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.serializeBinaryToWriter ); } }; @@ -16853,8 +21084,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.toObject(opt_includeInstance, this); }; @@ -16863,14 +21094,15 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByP * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - publicKeyHash: msg.getPublicKeyHash_asB64(), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + startProTxHash: msg.getStartProTxHash_asB64(), + count: jspb.Message.getFieldWithDefault(msg, 2, 0), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 3, false) }; if (includeInstance) { @@ -16884,23 +21116,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByP /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0; - return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -16909,9 +21141,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByP switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setPublicKeyHash(value); + msg.setStartProTxHash(value); break; case 2: + var value = /** @type {number} */ (reader.readUint32()); + msg.setCount(value); + break; + case 3: var value = /** @type {boolean} */ (reader.readBool()); msg.setProve(value); break; @@ -16928,9 +21164,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByP * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -16938,23 +21174,30 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByP /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getPublicKeyHash_asU8(); + f = message.getStartProTxHash_asU8(); if (f.length > 0) { writer.writeBytes( 1, f ); } + f = message.getCount(); + if (f !== 0) { + writer.writeUint32( + 2, + f + ); + } f = message.getProve(); if (f) { writer.writeBool( - 2, + 3, f ); } @@ -16962,89 +21205,107 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByP /** - * optional bytes public_key_hash = 1; + * optional bytes start_pro_tx_hash = 1; * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.getPublicKeyHash = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.getStartProTxHash = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * optional bytes public_key_hash = 1; - * This is a type-conversion wrapper around `getPublicKeyHash()` + * optional bytes start_pro_tx_hash = 1; + * This is a type-conversion wrapper around `getStartProTxHash()` * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.getPublicKeyHash_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.getStartProTxHash_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getPublicKeyHash())); + this.getStartProTxHash())); }; /** - * optional bytes public_key_hash = 1; + * optional bytes start_pro_tx_hash = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getPublicKeyHash()` + * This is a type-conversion wrapper around `getStartProTxHash()` * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.getPublicKeyHash_asU8 = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.getStartProTxHash_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getPublicKeyHash())); + this.getStartProTxHash())); }; /** * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.setPublicKeyHash = function(value) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.setStartProTxHash = function(value) { return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional bool prove = 2; + * optional uint32 count = 2; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.getCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.setCount = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); +}; + + +/** + * optional bool prove = 3; * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 3, false)); }; /** * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 3, value); }; /** - * optional GetIdentityByPublicKeyHashRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} + * optional GetProtocolVersionUpgradeVoteStatusRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -17053,7 +21314,7 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.clea * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -17067,21 +21328,21 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.hasV * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.oneofGroups_[0])); }; @@ -17099,8 +21360,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.toObject(opt_includeInstance, this); }; @@ -17109,13 +21370,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.toO * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -17129,23 +21390,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.toObject = fu /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse; - return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -17153,8 +21414,8 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.deserializeBi var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -17170,9 +21431,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.deserializeBi * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -17180,18 +21441,18 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.ser /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.serializeBinaryToWriter ); } }; @@ -17206,22 +21467,22 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.serializeBina * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.ResultCase = { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.ResultCase = { RESULT_NOT_SET: 0, - IDENTITY: 1, + VERSIONS: 1, PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.ResultCase} + * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.oneofGroups_[0])); }; @@ -17239,8 +21500,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.toObject(opt_includeInstance, this); }; @@ -17249,13 +21510,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityBy * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - identity: msg.getIdentity_asB64(), + versions: (f = msg.getVersions()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.toObject(includeInstance, f), proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; @@ -17271,23 +21532,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityBy /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0; - return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -17295,8 +21556,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityBy var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setIdentity(value); + var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.deserializeBinaryFromReader); + msg.setVersions(value); break; case 2: var value = new proto.org.dash.platform.dapi.v0.Proof; @@ -17321,9 +21583,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityBy * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -17331,17 +21593,18 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityBy /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 1)); + f = message.getVersions(); if (f != null) { - writer.writeBytes( + writer.writeMessage( 1, - f + f, + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.serializeBinaryToWriter ); } f = message.getProof(); @@ -17363,203 +21626,167 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityBy }; -/** - * optional bytes identity = 1; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getIdentity = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * optional bytes identity = 1; - * This is a type-conversion wrapper around `getIdentity()` - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getIdentity_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getIdentity())); -}; - - -/** - * optional bytes identity = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getIdentity()` - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getIdentity_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getIdentity())); -}; - /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this + * List of repeated fields within this message type. + * @private {!Array} + * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.setIdentity = function(value) { - return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.oneofGroups_[0], value); -}; - +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.repeatedFields_ = [1]; -/** - * Clears the field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.clearIdentity = function() { - return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.oneofGroups_[0], undefined); -}; +if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Returns whether this field is set. - * @return {boolean} + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.hasIdentity = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.toObject(opt_includeInstance, this); }; /** - * optional Proof proof = 2; - * @return {?proto.org.dash.platform.dapi.v0.Proof} + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getProof = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.oneofGroups_[0], value); -}; - +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.toObject = function(includeInstance, msg) { + var f, obj = { + versionSignalsList: jspb.Message.toObjectList(msg.getVersionSignalsList(), + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.toObject, includeInstance) + }; -/** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.clearProof = function() { - return this.setProof(undefined); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; }; +} /** - * Returns whether this field is set. - * @return {boolean} + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.hasProof = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.deserializeBinaryFromReader(msg, reader); }; /** - * optional ResponseMetadata metadata = 3; - * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getMetadata = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.setMetadata = function(value) { - return jspb.Message.setWrapperField(this, 3, value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.deserializeBinaryFromReader); + msg.addVersionSignals(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.clearMetadata = function() { - return this.setMetadata(undefined); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); }; /** - * Returns whether this field is set. - * @return {boolean} + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.hasMetadata = function() { - return jspb.Message.getField(this, 3) != null; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getVersionSignalsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.serializeBinaryToWriter + ); + } }; /** - * optional GetIdentityByPublicKeyHashResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} + * repeated VersionSignal version_signals = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.getVersionSignalsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} returns this + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.setVersionSignalsList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} returns this + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal=} opt_value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.clearV0 = function() { - return this.setV0(undefined); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.addVersionSignals = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal, opt_index); }; /** - * Returns whether this field is set. - * @return {boolean} + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.clearVersionSignalsList = function() { + return this.setVersionSignalsList([]); }; -/** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const - */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.oneofGroups_ = [[1]]; - -/** - * @enum {number} - */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 -}; - -/** - * @return {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.VersionCase} - */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.oneofGroups_[0])); -}; - if (jspb.Message.GENERATE_TO_OBJECT) { @@ -17575,8 +21802,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.toObject(opt_includeInstance, this); }; @@ -17585,13 +21812,14 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.to * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.toObject(includeInstance, f) + proTxHash: msg.getProTxHash_asB64(), + version: jspb.Message.getFieldWithDefault(msg, 2, 0) }; if (includeInstance) { @@ -17605,23 +21833,23 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.toObject = f /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest; - return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -17629,9 +21857,12 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.deserializeB var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.deserializeBinaryFromReader); - msg.setV0(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setProTxHash(value); + break; + case 2: + var value = /** @type {number} */ (reader.readUint32()); + msg.setVersion(value); break; default: reader.skipField(); @@ -17646,9 +21877,9 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.deserializeB * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -17656,231 +21887,224 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.se /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getV0(); - if (f != null) { - writer.writeMessage( + f = message.getProTxHash_asU8(); + if (f.length > 0) { + writer.writeBytes( 1, - f, - proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.serializeBinaryToWriter + f + ); + } + f = message.getVersion(); + if (f !== 0) { + writer.writeUint32( + 2, + f ); } }; +/** + * optional bytes pro_tx_hash = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.getProTxHash = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + +/** + * optional bytes pro_tx_hash = 1; + * This is a type-conversion wrapper around `getProTxHash()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.getProTxHash_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getProTxHash())); +}; -if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} + * optional bytes pro_tx_hash = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getProTxHash()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.getProTxHash_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getProTxHash())); }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.toObject = function(includeInstance, msg) { - var f, obj = { - stateTransitionHash: msg.getStateTransitionHash_asB64(), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) - }; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.setProTxHash = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; + +/** + * optional uint32 version = 2; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.getVersion = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0; - return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.setVersion = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); +}; + + +/** + * optional VersionSignals versions = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.getVersions = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.setVersions = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.clearVersions = function() { + return this.setVersions(undefined); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setStateTransitionHash(value); - break; - case 2: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.hasVersions = function() { + return jspb.Message.getField(this, 1) != null; }; /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getStateTransitionHash_asU8(); - if (f.length > 0) { - writer.writeBytes( - 1, - f - ); - } - f = message.getProve(); - if (f) { - writer.writeBool( - 2, - f - ); - } + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.oneofGroups_[0], value); }; /** - * optional bytes state_transition_hash = 1; - * @return {string} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.getStateTransitionHash = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); }; /** - * optional bytes state_transition_hash = 1; - * This is a type-conversion wrapper around `getStateTransitionHash()` - * @return {string} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.getStateTransitionHash_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getStateTransitionHash())); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; }; /** - * optional bytes state_transition_hash = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getStateTransitionHash()` - * @return {!Uint8Array} + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.getStateTransitionHash_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getStateTransitionHash())); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.setStateTransitionHash = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); }; /** - * optional bool prove = 2; - * @return {boolean} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); }; /** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; }; /** - * optional WaitForStateTransitionResultRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} + * optional GetProtocolVersionUpgradeVoteStatusResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -17889,7 +22113,7 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.cl * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -17903,21 +22127,21 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.ha * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.oneofGroups_[0])); }; @@ -17935,8 +22159,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.toObject(opt_includeInstance, this); }; @@ -17945,13 +22169,13 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.t * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -17965,23 +22189,23 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.toObject = /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse; - return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest; + return proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -17989,8 +22213,8 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.deserialize var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -18006,9 +22230,9 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.deserialize * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -18016,50 +22240,24 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.s /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.serializeBinaryToWriter ); } }; -/** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const - */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.oneofGroups_ = [[1,2]]; - -/** - * @enum {number} - */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.ResultCase = { - RESULT_NOT_SET: 0, - ERROR: 1, - PROOF: 2 -}; - -/** - * @return {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.ResultCase} - */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.oneofGroups_[0])); -}; - if (jspb.Message.GENERATE_TO_OBJECT) { @@ -18075,8 +22273,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.toObject(opt_includeInstance, this); }; @@ -18085,15 +22283,16 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStat * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - error: (f = msg.getError()) && proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.toObject(includeInstance, f), - proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), - metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + startEpoch: (f = msg.getStartEpoch()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), + count: jspb.Message.getFieldWithDefault(msg, 2, 0), + ascending: jspb.Message.getBooleanFieldWithDefault(msg, 3, false), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 4, false) }; if (includeInstance) { @@ -18107,23 +22306,23 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStat /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0; - return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0; + return proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -18131,19 +22330,21 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStat var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.deserializeBinaryFromReader); - msg.setError(value); + var value = new google_protobuf_wrappers_pb.UInt32Value; + reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); + msg.setStartEpoch(value); break; case 2: - var value = new proto.org.dash.platform.dapi.v0.Proof; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); - msg.setProof(value); + var value = /** @type {number} */ (reader.readUint32()); + msg.setCount(value); break; case 3: - var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); - msg.setMetadata(value); + var value = /** @type {boolean} */ (reader.readBool()); + msg.setAscending(value); + break; + case 4: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); break; default: reader.skipField(); @@ -18158,9 +22359,9 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStat * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -18168,64 +22369,69 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStat /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getError(); + f = message.getStartEpoch(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.serializeBinaryToWriter + google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter ); } - f = message.getProof(); - if (f != null) { - writer.writeMessage( + f = message.getCount(); + if (f !== 0) { + writer.writeUint32( 2, - f, - proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + f ); } - f = message.getMetadata(); - if (f != null) { - writer.writeMessage( + f = message.getAscending(); + if (f) { + writer.writeBool( 3, - f, - proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 4, + f ); } }; /** - * optional StateTransitionBroadcastError error = 1; - * @return {?proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} + * optional google.protobuf.UInt32Value start_epoch = 1; + * @return {?proto.google.protobuf.UInt32Value} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.getError = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError, 1)); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.getStartEpoch = function() { + return /** @type{?proto.google.protobuf.UInt32Value} */ ( + jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this + * @param {?proto.google.protobuf.UInt32Value|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.setError = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.setStartEpoch = function(value) { + return jspb.Message.setWrapperField(this, 1, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.clearError = function() { - return this.setError(undefined); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.clearStartEpoch = function() { + return this.setStartEpoch(undefined); }; @@ -18233,261 +22439,127 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStat * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.hasError = function() { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.hasStartEpoch = function() { return jspb.Message.getField(this, 1) != null; }; /** - * optional Proof proof = 2; - * @return {?proto.org.dash.platform.dapi.v0.Proof} + * optional uint32 count = 2; + * @return {number} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.getProof = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.getCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.clearProof = function() { - return this.setProof(undefined); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.setCount = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); }; /** - * Returns whether this field is set. + * optional bool ascending = 3; * @return {boolean} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.hasProof = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.getAscending = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 3, false)); }; /** - * optional ResponseMetadata metadata = 3; - * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.getMetadata = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.setMetadata = function(value) { - return jspb.Message.setWrapperField(this, 3, value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.setAscending = function(value) { + return jspb.Message.setProto3BooleanField(this, 3, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this + * optional bool prove = 4; + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.clearMetadata = function() { - return this.setMetadata(undefined); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 4, false)); }; /** - * Returns whether this field is set. - * @return {boolean} + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.hasMetadata = function() { - return jspb.Message.getField(this, 3) != null; +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 4, value); }; /** - * optional WaitForStateTransitionResultResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} + * optional GetEpochsInfoRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} returns this - */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.clearV0 = function() { - return this.setV0(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; -}; - - - -/** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.oneofGroups_ = [[1]]; - -/** - * @enum {number} - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 -}; - -/** - * @return {proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.VersionCase} - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.oneofGroups_[0])); -}; - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.toObject = function(includeInstance, msg) { - var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.toObject(includeInstance, f) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest; - return proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.deserializeBinaryFromReader); - msg.setV0(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; + /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.oneofGroups_ = [[1]]; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getV0(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.serializeBinaryToWriter - ); - } +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 }; - +/** + * @return {proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.oneofGroups_[0])); +}; @@ -18504,8 +22576,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.toObject(opt_includeInstance, this); }; @@ -18514,14 +22586,13 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequ * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.toObject = function(includeInstance, msg) { var f, obj = { - height: jspb.Message.getFieldWithDefault(msg, 1, 0), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -18535,23 +22606,23 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequ /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0; - return proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse; + return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -18559,12 +22630,9 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequ var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {number} */ (reader.readInt32()); - msg.setHeight(value); - break; - case 2: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); + var value = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.deserializeBinaryFromReader); + msg.setV0(value); break; default: reader.skipField(); @@ -18579,9 +22647,9 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequ * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -18589,102 +22657,23 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequ /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getHeight(); - if (f !== 0) { - writer.writeInt32( + f = message.getV0(); + if (f != null) { + writer.writeMessage( 1, - f - ); - } - f = message.getProve(); - if (f) { - writer.writeBool( - 2, - f + f, + proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.serializeBinaryToWriter ); } }; -/** - * optional int32 height = 1; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.getHeight = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.setHeight = function(value) { - return jspb.Message.setProto3IntField(this, 1, value); -}; - - -/** - * optional bool prove = 2; - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); -}; - - -/** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 2, value); -}; - - -/** - * optional GetConsensusParamsRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0, 1)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} returns this -*/ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.oneofGroups_[0], value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} returns this - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.clearV0 = function() { - return this.setV0(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; -}; - - /** * Oneof group definitions for this message. Each group defines the field @@ -18694,21 +22683,22 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.hasV0 = func * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + EPOCHS: 1, + PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.oneofGroups_[0])); }; @@ -18726,8 +22716,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.toObject(opt_includeInstance, this); }; @@ -18736,13 +22726,15 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.toObject = * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.toObject(includeInstance, f) + epochs: (f = msg.getEpochs()) && proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.toObject(includeInstance, f), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; if (includeInstance) { @@ -18756,33 +22748,43 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.toObject = function(i /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse; - return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0; + return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.deserializeBinaryFromReader); - msg.setV0(value); + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.deserializeBinaryFromReader); + msg.setEpochs(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); break; default: reader.skipField(); @@ -18797,9 +22799,9 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.deserializeBinaryFrom * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -18807,24 +22809,47 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.serializeBi /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getV0(); + f = message.getEpochs(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.serializeBinaryToWriter + ); + } + f = message.getProof(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + ); + } + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter ); } }; +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.repeatedFields_ = [1]; + if (jspb.Message.GENERATE_TO_OBJECT) { @@ -18840,8 +22865,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.toObject(opt_includeInstance, this); }; @@ -18850,15 +22875,14 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.toObject = function(includeInstance, msg) { var f, obj = { - maxBytes: jspb.Message.getFieldWithDefault(msg, 1, ""), - maxGas: jspb.Message.getFieldWithDefault(msg, 2, ""), - timeIotaMs: jspb.Message.getFieldWithDefault(msg, 3, "") + epochInfosList: jspb.Message.toObjectList(msg.getEpochInfosList(), + proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.toObject, includeInstance) }; if (includeInstance) { @@ -18872,23 +22896,23 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock. /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock; - return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos; + return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -18896,16 +22920,9 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock. var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setMaxBytes(value); - break; - case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setMaxGas(value); - break; - case 3: - var value = /** @type {string} */ (reader.readString()); - msg.setTimeIotaMs(value); + var value = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.deserializeBinaryFromReader); + msg.addEpochInfos(value); break; default: reader.skipField(); @@ -18920,9 +22937,9 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock. * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -18930,87 +22947,58 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock. /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} message + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getMaxBytes(); + f = message.getEpochInfosList(); if (f.length > 0) { - writer.writeString( + writer.writeRepeatedMessage( 1, - f - ); - } - f = message.getMaxGas(); - if (f.length > 0) { - writer.writeString( - 2, - f - ); - } - f = message.getTimeIotaMs(); - if (f.length > 0) { - writer.writeString( - 3, - f + f, + proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.serializeBinaryToWriter ); } }; /** - * optional string max_bytes = 1; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.getMaxBytes = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} returns this - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.setMaxBytes = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - -/** - * optional string max_gas = 2; - * @return {string} + * repeated EpochInfo epoch_infos = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.getMaxGas = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.getEpochInfosList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo, 1)); }; /** - * @param {string} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} returns this - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.setMaxGas = function(value) { - return jspb.Message.setProto3StringField(this, 2, value); + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} returns this +*/ +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.setEpochInfosList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); }; /** - * optional string time_iota_ms = 3; - * @return {string} + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo=} opt_value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.getTimeIotaMs = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.addEpochInfos = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo, opt_index); }; /** - * @param {string} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} returns this + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.setTimeIotaMs = function(value) { - return jspb.Message.setProto3StringField(this, 3, value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.clearEpochInfosList = function() { + return this.setEpochInfosList([]); }; @@ -19030,8 +23018,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.toObject(opt_includeInstance, this); }; @@ -19040,15 +23028,17 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEviden * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.toObject = function(includeInstance, msg) { var f, obj = { - maxAgeNumBlocks: jspb.Message.getFieldWithDefault(msg, 1, ""), - maxAgeDuration: jspb.Message.getFieldWithDefault(msg, 2, ""), - maxBytes: jspb.Message.getFieldWithDefault(msg, 3, "") + number: jspb.Message.getFieldWithDefault(msg, 1, 0), + firstBlockHeight: jspb.Message.getFieldWithDefault(msg, 2, 0), + firstCoreBlockHeight: jspb.Message.getFieldWithDefault(msg, 3, 0), + startTime: jspb.Message.getFieldWithDefault(msg, 4, 0), + feeMultiplier: jspb.Message.getFloatingPointFieldWithDefault(msg, 5, 0.0) }; if (includeInstance) { @@ -19062,23 +23052,23 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEviden /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence; - return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo; + return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -19086,16 +23076,24 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEviden var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setMaxAgeNumBlocks(value); + var value = /** @type {number} */ (reader.readUint32()); + msg.setNumber(value); break; case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setMaxAgeDuration(value); + var value = /** @type {number} */ (reader.readUint64()); + msg.setFirstBlockHeight(value); break; case 3: - var value = /** @type {string} */ (reader.readString()); - msg.setMaxBytes(value); + var value = /** @type {number} */ (reader.readUint32()); + msg.setFirstCoreBlockHeight(value); + break; + case 4: + var value = /** @type {number} */ (reader.readUint64()); + msg.setStartTime(value); + break; + case 5: + var value = /** @type {number} */ (reader.readDouble()); + msg.setFeeMultiplier(value); break; default: reader.skipField(); @@ -19110,9 +23108,9 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEviden * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -19120,243 +23118,202 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEviden /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} message + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getMaxAgeNumBlocks(); - if (f.length > 0) { - writer.writeString( + f = message.getNumber(); + if (f !== 0) { + writer.writeUint32( 1, f ); } - f = message.getMaxAgeDuration(); - if (f.length > 0) { - writer.writeString( + f = message.getFirstBlockHeight(); + if (f !== 0) { + writer.writeUint64( 2, f ); } - f = message.getMaxBytes(); - if (f.length > 0) { - writer.writeString( + f = message.getFirstCoreBlockHeight(); + if (f !== 0) { + writer.writeUint32( 3, f ); } + f = message.getStartTime(); + if (f !== 0) { + writer.writeUint64( + 4, + f + ); + } + f = message.getFeeMultiplier(); + if (f !== 0.0) { + writer.writeDouble( + 5, + f + ); + } }; /** - * optional string max_age_num_blocks = 1; - * @return {string} + * optional uint32 number = 1; + * @return {number} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.getMaxAgeNumBlocks = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getNumber = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); }; /** - * @param {string} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} returns this + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.setMaxAgeNumBlocks = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setNumber = function(value) { + return jspb.Message.setProto3IntField(this, 1, value); }; /** - * optional string max_age_duration = 2; - * @return {string} + * optional uint64 first_block_height = 2; + * @return {number} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.getMaxAgeDuration = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getFirstBlockHeight = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); }; /** - * @param {string} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} returns this + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.setMaxAgeDuration = function(value) { - return jspb.Message.setProto3StringField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setFirstBlockHeight = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); }; /** - * optional string max_bytes = 3; - * @return {string} + * optional uint32 first_core_block_height = 3; + * @return {number} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.getMaxBytes = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getFirstCoreBlockHeight = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); }; /** - * @param {string} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} returns this + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.setMaxBytes = function(value) { - return jspb.Message.setProto3StringField(this, 3, value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setFirstCoreBlockHeight = function(value) { + return jspb.Message.setProto3IntField(this, 3, value); }; +/** + * optional uint64 start_time = 4; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getStartTime = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +}; - -if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setStartTime = function(value) { + return jspb.Message.setProto3IntField(this, 4, value); }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional double fee_multiplier = 5; + * @return {number} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.toObject = function(includeInstance, msg) { - var f, obj = { - block: (f = msg.getBlock()) && proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.toObject(includeInstance, f), - evidence: (f = msg.getEvidence()) && proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.toObject(includeInstance, f) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getFeeMultiplier = function() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 5, 0.0)); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0; - return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setFeeMultiplier = function(value) { + return jspb.Message.setProto3FloatField(this, 5, value); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} + * optional EpochInfos epochs = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.deserializeBinaryFromReader); - msg.setBlock(value); - break; - case 2: - var value = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.deserializeBinaryFromReader); - msg.setEvidence(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.getEpochs = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos, 1)); }; /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * @param {?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.setEpochs = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.clearEpochs = function() { + return this.setEpochs(undefined); }; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getBlock(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.serializeBinaryToWriter - ); - } - f = message.getEvidence(); - if (f != null) { - writer.writeMessage( - 2, - f, - proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.serializeBinaryToWriter - ); - } +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.hasEpochs = function() { + return jspb.Message.getField(this, 1) != null; }; /** - * optional ConsensusParamsBlock block = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.getBlock = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock, 1)); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.setBlock = function(value) { - return jspb.Message.setWrapperField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.clearBlock = function() { - return this.setBlock(undefined); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); }; @@ -19364,36 +23321,36 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsRes * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.hasBlock = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; }; /** - * optional ConsensusParamsEvidence evidence = 2; - * @return {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.getEvidence = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence, 2)); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.setEvidence = function(value) { - return jspb.Message.setWrapperField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.clearEvidence = function() { - return this.setEvidence(undefined); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); }; @@ -19401,35 +23358,35 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsRes * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.hasEvidence = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; }; /** - * optional GetConsensusParamsResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} + * optional GetEpochsInfoResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -19438,7 +23395,7 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.clearV0 = f * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -19452,21 +23409,21 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.hasV0 = fun * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.oneofGroups_[0])); }; @@ -19484,8 +23441,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.toObject(opt_includeInstance, this); }; @@ -19494,13 +23451,13 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -19514,23 +23471,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.toObject = /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest; + return proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -19538,8 +23495,8 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.deserializ var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -19555,9 +23512,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.deserializ * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -19565,24 +23522,31 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype. /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.serializeBinaryToWriter ); } }; +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.repeatedFields_ = [2]; + if (jspb.Message.GENERATE_TO_OBJECT) { @@ -19598,144 +23562,385 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.toObject = function(includeInstance, msg) { + var f, obj = { + prove: jspb.Message.getBooleanFieldWithDefault(msg, 1, false), + resourcePathList: msg.getResourcePathList_asB64(), + startContestedResourceIdentifier: msg.getStartContestedResourceIdentifier_asB64(), + count: jspb.Message.getFieldWithDefault(msg, 4, 0), + ascending: jspb.Message.getBooleanFieldWithDefault(msg, 5, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0; + return proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); + break; + case 2: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.addResourcePath(value); + break; + case 3: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setStartContestedResourceIdentifier(value); + break; + case 4: + var value = /** @type {number} */ (reader.readUint32()); + msg.setCount(value); + break; + case 5: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setAscending(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getProve(); + if (f) { + writer.writeBool( + 1, + f + ); + } + f = message.getResourcePathList_asU8(); + if (f.length > 0) { + writer.writeRepeatedBytes( + 2, + f + ); + } + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeBytes( + 3, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeUint32( + 4, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 5)); + if (f != null) { + writer.writeBool( + 5, + f + ); + } +}; + + +/** + * optional bool prove = 1; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 1, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 1, value); +}; + + +/** + * repeated bytes resource_path = 2; + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.getResourcePathList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); +}; + + +/** + * repeated bytes resource_path = 2; + * This is a type-conversion wrapper around `getResourcePathList()` + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.getResourcePathList_asB64 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsB64( + this.getResourcePathList())); +}; + + +/** + * repeated bytes resource_path = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getResourcePathList()` + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.getResourcePathList_asU8 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsU8( + this.getResourcePathList())); +}; + + +/** + * @param {!(Array|Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.setResourcePathList = function(value) { + return jspb.Message.setField(this, 2, value || []); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.addResourcePath = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 2, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.clearResourcePathList = function() { + return this.setResourcePathList([]); +}; + + +/** + * optional bytes start_contested_resource_identifier = 3; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.getStartContestedResourceIdentifier = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * optional bytes start_contested_resource_identifier = 3; + * This is a type-conversion wrapper around `getStartContestedResourceIdentifier()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.getStartContestedResourceIdentifier_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getStartContestedResourceIdentifier())); +}; + + +/** + * optional bytes start_contested_resource_identifier = 3; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getStartContestedResourceIdentifier()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.getStartContestedResourceIdentifier_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getStartContestedResourceIdentifier())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.setStartContestedResourceIdentifier = function(value) { + return jspb.Message.setField(this, 3, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.clearStartContestedResourceIdentifier = function() { + return jspb.Message.setField(this, 3, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.hasStartContestedResourceIdentifier = function() { + return jspb.Message.getField(this, 3) != null; }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional uint32 count = 4; + * @return {number} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.toObject = function(includeInstance, msg) { - var f, obj = { - prove: jspb.Message.getBooleanFieldWithDefault(msg, 1, false) - }; +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.getCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +}; - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.setCount = function(value) { + return jspb.Message.setField(this, 4, value); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.clearCount = function() { + return jspb.Message.setField(this, 4, undefined); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.hasCount = function() { + return jspb.Message.getField(this, 4) != null; }; /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * optional bool ascending = 5; + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.getAscending = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 5, false)); }; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getProve(); - if (f) { - writer.writeBool( - 1, - f - ); - } +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.setAscending = function(value) { + return jspb.Message.setField(this, 5, value); }; /** - * optional bool prove = 1; - * @return {boolean} + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 1, false)); +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.clearAscending = function() { + return jspb.Message.setField(this, 5, undefined); }; /** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.hasAscending = function() { + return jspb.Message.getField(this, 5) != null; }; /** - * optional GetProtocolVersionUpgradeStateRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} + * optional GetContestedResourcesRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -19744,7 +23949,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype. * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -19758,21 +23963,21 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype. * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.oneofGroups_[0])); }; @@ -19790,8 +23995,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.toObject(opt_includeInstance, this); }; @@ -19800,13 +24005,13 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -19820,23 +24025,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.toObject /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse; + return proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -19844,8 +24049,8 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.deseriali var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -19861,9 +24066,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.deseriali * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -19871,18 +24076,18 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.serializeBinaryToWriter ); } }; @@ -19897,22 +24102,22 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.serialize * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.ResultCase = { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ResultCase = { RESULT_NOT_SET: 0, - VERSIONS: 1, + CONTESTED_RESOURCES: 1, PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.ResultCase} + * @return {proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.oneofGroups_[0])); }; @@ -19930,8 +24135,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.toObject(opt_includeInstance, this); }; @@ -19940,13 +24145,13 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - versions: (f = msg.getVersions()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.toObject(includeInstance, f), + contestedResources: (f = msg.getContestedResources()) && proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.toObject(includeInstance, f), proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; @@ -19962,23 +24167,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0; + return proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -19986,9 +24191,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.deserializeBinaryFromReader); - msg.setVersions(value); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.deserializeBinaryFromReader); + msg.setContestedResources(value); break; case 2: var value = new proto.org.dash.platform.dapi.v0.Proof; @@ -20013,9 +24218,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -20023,18 +24228,18 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getVersions(); + f = message.getContestedResources(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.serializeBinaryToWriter ); } f = message.getProof(); @@ -20062,7 +24267,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * @private {!Array} * @const */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.repeatedFields_ = [1]; @@ -20079,8 +24284,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.toObject(opt_includeInstance, this); }; @@ -20089,14 +24294,15 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.toObject = function(includeInstance, msg) { var f, obj = { - versionsList: jspb.Message.toObjectList(msg.getVersionsList(), - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.toObject, includeInstance) + contestedResourcesList: jspb.Message.toObjectList(msg.getContestedResourcesList(), + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.toObject, includeInstance), + finishedResults: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) }; if (includeInstance) { @@ -20110,23 +24316,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources; + return proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -20134,9 +24340,13 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.deserializeBinaryFromReader); - msg.addVersions(value); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.deserializeBinaryFromReader); + msg.addContestedResources(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setFinishedResults(value); break; default: reader.skipField(); @@ -20151,9 +24361,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -20161,58 +24371,83 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getVersionsList(); + f = message.getContestedResourcesList(); if (f.length > 0) { writer.writeRepeatedMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.serializeBinaryToWriter + ); + } + f = message.getFinishedResults(); + if (f) { + writer.writeBool( + 2, + f ); } }; /** - * repeated VersionEntry versions = 1; - * @return {!Array} + * repeated ContestedResource contested_resources = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.getVersionsList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.prototype.getContestedResourcesList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource, 1)); }; /** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} returns this + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.setVersionsList = function(value) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.prototype.setContestedResourcesList = function(value) { return jspb.Message.setRepeatedWrapperField(this, 1, value); }; /** - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry=} opt_value + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource=} opt_value * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.addVersions = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry, opt_index); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.prototype.addContestedResources = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource, opt_index); }; /** * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.clearVersionsList = function() { - return this.setVersionsList([]); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.prototype.clearContestedResourcesList = function() { + return this.setContestedResourcesList([]); +}; + + +/** + * optional bool finished_results = 2; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.prototype.getFinishedResults = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.prototype.setFinishedResults = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); }; @@ -20232,8 +24467,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.toObject(opt_includeInstance, this); }; @@ -20242,14 +24477,13 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.toObject = function(includeInstance, msg) { var f, obj = { - versionNumber: jspb.Message.getFieldWithDefault(msg, 1, 0), - voteCount: jspb.Message.getFieldWithDefault(msg, 2, 0) + identifier: msg.getIdentifier_asB64() }; if (includeInstance) { @@ -20263,23 +24497,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource; + return proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -20287,12 +24521,8 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {number} */ (reader.readUint32()); - msg.setVersionNumber(value); - break; - case 2: - var value = /** @type {number} */ (reader.readUint32()); - msg.setVoteCount(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setIdentifier(value); break; default: reader.skipField(); @@ -20307,9 +24537,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -20317,90 +24547,89 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getVersionNumber(); - if (f !== 0) { - writer.writeUint32( + f = message.getIdentifier_asU8(); + if (f.length > 0) { + writer.writeBytes( 1, f ); } - f = message.getVoteCount(); - if (f !== 0) { - writer.writeUint32( - 2, - f - ); - } }; /** - * optional uint32 version_number = 1; - * @return {number} + * optional bytes identifier = 1; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.getVersionNumber = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.prototype.getIdentifier = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} returns this + * optional bytes identifier = 1; + * This is a type-conversion wrapper around `getIdentifier()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.setVersionNumber = function(value) { - return jspb.Message.setProto3IntField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.prototype.getIdentifier_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getIdentifier())); }; /** - * optional uint32 vote_count = 2; - * @return {number} + * optional bytes identifier = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getIdentifier()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.getVoteCount = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.prototype.getIdentifier_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getIdentifier())); }; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} returns this + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.setVoteCount = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.prototype.setIdentifier = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional Versions versions = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} + * optional ContestedResources contested_resources = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.getVersions = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.getContestedResources = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.setVersions = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.setContestedResources = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.clearVersions = function() { - return this.setVersions(undefined); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.clearContestedResources = function() { + return this.setContestedResources(undefined); }; @@ -20408,7 +24637,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.hasVersions = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.hasContestedResources = function() { return jspb.Message.getField(this, 1) != null; }; @@ -20417,7 +24646,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * optional Proof proof = 2; * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.getProof = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.getProof = function() { return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; @@ -20425,18 +24654,18 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc /** * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.clearProof = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.clearProof = function() { return this.setProof(undefined); }; @@ -20445,7 +24674,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.hasProof = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.hasProof = function() { return jspb.Message.getField(this, 2) != null; }; @@ -20454,7 +24683,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * optional ResponseMetadata metadata = 3; * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.getMetadata = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.getMetadata = function() { return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; @@ -20462,18 +24691,18 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc /** * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.setMetadata = function(value) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.setMetadata = function(value) { return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.clearMetadata = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.clearMetadata = function() { return this.setMetadata(undefined); }; @@ -20482,35 +24711,35 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.hasMetadata = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.hasMetadata = function() { return jspb.Message.getField(this, 3) != null; }; /** - * optional GetProtocolVersionUpgradeStateResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} + * optional GetContestedResourcesResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -20519,7 +24748,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -20533,21 +24762,21 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.oneofGroups_[0])); }; @@ -20565,8 +24794,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.toObject(opt_includeInstance, this); }; @@ -20575,13 +24804,13 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.proto * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -20595,23 +24824,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.toObj /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -20619,8 +24848,8 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.deser var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -20636,9 +24865,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.deser * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -20646,24 +24875,31 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.proto /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.serializeBinaryToWriter ); } }; +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.repeatedFields_ = [2]; + if (jspb.Message.GENERATE_TO_OBJECT) { @@ -20679,8 +24915,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.toObject(opt_includeInstance, this); }; @@ -20689,15 +24925,18 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetPr * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - startProTxHash: msg.getStartProTxHash_asB64(), - count: jspb.Message.getFieldWithDefault(msg, 2, 0), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 3, false) + prove: jspb.Message.getBooleanFieldWithDefault(msg, 1, false), + resourcePathList: msg.getResourcePathList_asB64(), + contestedResource: msg.getContestedResource_asB64(), + startIdentifier: msg.getStartIdentifier_asB64(), + count: jspb.Message.getFieldWithDefault(msg, 5, 0), + ascending: jspb.Message.getBooleanFieldWithDefault(msg, 6, false) }; if (includeInstance) { @@ -20711,23 +24950,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetPr /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -20735,16 +24974,28 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetPr var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setStartProTxHash(value); + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); break; case 2: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.addResourcePath(value); + break; + case 3: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setContestedResource(value); + break; + case 4: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setStartIdentifier(value); + break; + case 5: var value = /** @type {number} */ (reader.readUint32()); msg.setCount(value); break; - case 3: + case 6: var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); + msg.setAscending(value); break; default: reader.skipField(); @@ -20759,9 +25010,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetPr * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -20769,138 +25020,334 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetPr /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getStartProTxHash_asU8(); - if (f.length > 0) { - writer.writeBytes( - 1, - f - ); - } - f = message.getCount(); - if (f !== 0) { - writer.writeUint32( - 2, - f - ); - } - f = message.getProve(); - if (f) { - writer.writeBool( - 3, - f - ); - } +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getProve(); + if (f) { + writer.writeBool( + 1, + f + ); + } + f = message.getResourcePathList_asU8(); + if (f.length > 0) { + writer.writeRepeatedBytes( + 2, + f + ); + } + f = message.getContestedResource_asU8(); + if (f.length > 0) { + writer.writeBytes( + 3, + f + ); + } + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeBytes( + 4, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 5)); + if (f != null) { + writer.writeUint32( + 5, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 6)); + if (f != null) { + writer.writeBool( + 6, + f + ); + } +}; + + +/** + * optional bool prove = 1; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 1, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 1, value); +}; + + +/** + * repeated bytes resource_path = 2; + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getResourcePathList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); +}; + + +/** + * repeated bytes resource_path = 2; + * This is a type-conversion wrapper around `getResourcePathList()` + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getResourcePathList_asB64 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsB64( + this.getResourcePathList())); +}; + + +/** + * repeated bytes resource_path = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getResourcePathList()` + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getResourcePathList_asU8 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsU8( + this.getResourcePathList())); +}; + + +/** + * @param {!(Array|Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.setResourcePathList = function(value) { + return jspb.Message.setField(this, 2, value || []); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.addResourcePath = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 2, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.clearResourcePathList = function() { + return this.setResourcePathList([]); +}; + + +/** + * optional bytes contested_resource = 3; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getContestedResource = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * optional bytes contested_resource = 3; + * This is a type-conversion wrapper around `getContestedResource()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getContestedResource_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getContestedResource())); +}; + + +/** + * optional bytes contested_resource = 3; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getContestedResource()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getContestedResource_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getContestedResource())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.setContestedResource = function(value) { + return jspb.Message.setProto3BytesField(this, 3, value); }; /** - * optional bytes start_pro_tx_hash = 1; + * optional bytes start_identifier = 4; * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.getStartProTxHash = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getStartIdentifier = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); }; /** - * optional bytes start_pro_tx_hash = 1; - * This is a type-conversion wrapper around `getStartProTxHash()` + * optional bytes start_identifier = 4; + * This is a type-conversion wrapper around `getStartIdentifier()` * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.getStartProTxHash_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getStartIdentifier_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getStartProTxHash())); + this.getStartIdentifier())); }; /** - * optional bytes start_pro_tx_hash = 1; + * optional bytes start_identifier = 4; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getStartProTxHash()` + * This is a type-conversion wrapper around `getStartIdentifier()` * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.getStartProTxHash_asU8 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getStartIdentifier_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getStartProTxHash())); + this.getStartIdentifier())); }; /** * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.setStartProTxHash = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.setStartIdentifier = function(value) { + return jspb.Message.setField(this, 4, value); }; /** - * optional uint32 count = 2; + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.clearStartIdentifier = function() { + return jspb.Message.setField(this, 4, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.hasStartIdentifier = function() { + return jspb.Message.getField(this, 4) != null; +}; + + +/** + * optional uint32 count = 5; * @return {number} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.getCount = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); }; /** * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.setCount = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.setCount = function(value) { + return jspb.Message.setField(this, 5, value); }; /** - * optional bool prove = 3; + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.clearCount = function() { + return jspb.Message.setField(this, 5, undefined); +}; + + +/** + * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 3, false)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.hasCount = function() { + return jspb.Message.getField(this, 5) != null; +}; + + +/** + * optional bool ascending = 6; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getAscending = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 6, false)); }; /** * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 3, value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.setAscending = function(value) { + return jspb.Message.setField(this, 6, value); }; /** - * optional GetProtocolVersionUpgradeVoteStatusRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.clearAscending = function() { + return jspb.Message.setField(this, 6, undefined); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} returns this + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.hasAscending = function() { + return jspb.Message.getField(this, 6) != null; +}; + + +/** + * optional GetContestedResourceVoteStateRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -20909,7 +25356,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.proto * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -20923,21 +25370,21 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.proto * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.oneofGroups_[0])); }; @@ -20955,8 +25402,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.toObject(opt_includeInstance, this); }; @@ -20965,13 +25412,13 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prot * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -20985,23 +25432,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.toOb /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -21009,8 +25456,8 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.dese var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -21026,9 +25473,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.dese * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -21036,18 +25483,18 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prot /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.serializeBinaryToWriter ); } }; @@ -21062,22 +25509,22 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.seri * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.ResultCase = { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ResultCase = { RESULT_NOT_SET: 0, - VERSIONS: 1, + CONTESTED_RESOURCE_CONTENDERS: 1, PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.ResultCase} + * @return {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.oneofGroups_[0])); }; @@ -21095,8 +25542,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.toObject(opt_includeInstance, this); }; @@ -21105,13 +25552,13 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - versions: (f = msg.getVersions()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.toObject(includeInstance, f), + contestedResourceContenders: (f = msg.getContestedResourceContenders()) && proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.toObject(includeInstance, f), proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; @@ -21127,23 +25574,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -21151,9 +25598,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.deserializeBinaryFromReader); - msg.setVersions(value); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.deserializeBinaryFromReader); + msg.setContestedResourceContenders(value); break; case 2: var value = new proto.org.dash.platform.dapi.v0.Proof; @@ -21178,9 +25625,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -21188,18 +25635,18 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getVersions(); + f = message.getContestedResourceContenders(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.serializeBinaryToWriter ); } f = message.getProof(); @@ -21227,7 +25674,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * @private {!Array} * @const */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.repeatedFields_ = [1]; @@ -21244,8 +25691,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.toObject(opt_includeInstance, this); }; @@ -21254,14 +25701,15 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.toObject = function(includeInstance, msg) { var f, obj = { - versionSignalsList: jspb.Message.toObjectList(msg.getVersionSignalsList(), - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.toObject, includeInstance) + contendersList: jspb.Message.toObjectList(msg.getContendersList(), + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.toObject, includeInstance), + finishedResults: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) }; if (includeInstance) { @@ -21275,23 +25723,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -21299,9 +25747,13 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.deserializeBinaryFromReader); - msg.addVersionSignals(value); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.deserializeBinaryFromReader); + msg.addContenders(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setFinishedResults(value); break; default: reader.skipField(); @@ -21316,9 +25768,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -21326,58 +25778,83 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getVersionSignalsList(); + f = message.getContendersList(); if (f.length > 0) { writer.writeRepeatedMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.serializeBinaryToWriter + ); + } + f = message.getFinishedResults(); + if (f) { + writer.writeBool( + 2, + f ); } }; /** - * repeated VersionSignal version_signals = 1; - * @return {!Array} + * repeated Contender contenders = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.getVersionSignalsList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.prototype.getContendersList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender, 1)); }; /** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} returns this + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.setVersionSignalsList = function(value) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.prototype.setContendersList = function(value) { return jspb.Message.setRepeatedWrapperField(this, 1, value); }; /** - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal=} opt_value + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender=} opt_value * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.addVersionSignals = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal, opt_index); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.prototype.addContenders = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender, opt_index); }; /** * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.clearVersionSignalsList = function() { - return this.setVersionSignalsList([]); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.prototype.clearContendersList = function() { + return this.setContendersList([]); +}; + + +/** + * optional bool finished_results = 2; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.prototype.getFinishedResults = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.prototype.setFinishedResults = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); }; @@ -21397,8 +25874,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.toObject(opt_includeInstance, this); }; @@ -21407,14 +25884,14 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.toObject = function(includeInstance, msg) { var f, obj = { - proTxHash: msg.getProTxHash_asB64(), - version: jspb.Message.getFieldWithDefault(msg, 2, 0) + identifier: msg.getIdentifier_asB64(), + voteCount: jspb.Message.getFieldWithDefault(msg, 2, 0) }; if (includeInstance) { @@ -21428,23 +25905,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -21453,11 +25930,11 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setProTxHash(value); + msg.setIdentifier(value); break; case 2: var value = /** @type {number} */ (reader.readUint32()); - msg.setVersion(value); + msg.setVoteCount(value); break; default: reader.skipField(); @@ -21472,9 +25949,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -21482,20 +25959,20 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getProTxHash_asU8(); + f = message.getIdentifier_asU8(); if (f.length > 0) { writer.writeBytes( 1, f ); } - f = message.getVersion(); + f = message.getVoteCount(); if (f !== 0) { writer.writeUint32( 2, @@ -21506,90 +25983,90 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP /** - * optional bytes pro_tx_hash = 1; + * optional bytes identifier = 1; * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.getProTxHash = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.prototype.getIdentifier = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * optional bytes pro_tx_hash = 1; - * This is a type-conversion wrapper around `getProTxHash()` + * optional bytes identifier = 1; + * This is a type-conversion wrapper around `getIdentifier()` * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.getProTxHash_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.prototype.getIdentifier_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getProTxHash())); + this.getIdentifier())); }; /** - * optional bytes pro_tx_hash = 1; + * optional bytes identifier = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getProTxHash()` + * This is a type-conversion wrapper around `getIdentifier()` * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.getProTxHash_asU8 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.prototype.getIdentifier_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getProTxHash())); + this.getIdentifier())); }; /** * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.setProTxHash = function(value) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.prototype.setIdentifier = function(value) { return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional uint32 version = 2; + * optional uint32 vote_count = 2; * @return {number} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.getVersion = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.prototype.getVoteCount = function() { return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); }; /** * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.setVersion = function(value) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.prototype.setVoteCount = function(value) { return jspb.Message.setProto3IntField(this, 2, value); }; /** - * optional VersionSignals versions = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} + * optional ContestedResourceContenders contested_resource_contenders = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.getVersions = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.getContestedResourceContenders = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.setVersions = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.setContestedResourceContenders = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.clearVersions = function() { - return this.setVersions(undefined); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.clearContestedResourceContenders = function() { + return this.setContestedResourceContenders(undefined); }; @@ -21597,7 +26074,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.hasVersions = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.hasContestedResourceContenders = function() { return jspb.Message.getField(this, 1) != null; }; @@ -21606,7 +26083,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * optional Proof proof = 2; * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.getProof = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.getProof = function() { return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; @@ -21614,18 +26091,18 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP /** * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.clearProof = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.clearProof = function() { return this.setProof(undefined); }; @@ -21634,7 +26111,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.hasProof = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.hasProof = function() { return jspb.Message.getField(this, 2) != null; }; @@ -21643,7 +26120,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * optional ResponseMetadata metadata = 3; * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.getMetadata = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.getMetadata = function() { return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; @@ -21651,18 +26128,18 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP /** * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.setMetadata = function(value) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.setMetadata = function(value) { return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.clearMetadata = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.clearMetadata = function() { return this.setMetadata(undefined); }; @@ -21671,35 +26148,35 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.hasMetadata = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.hasMetadata = function() { return jspb.Message.getField(this, 3) != null; }; /** - * optional GetProtocolVersionUpgradeVoteStatusResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} + * optional GetContestedResourceVoteStateResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -21708,7 +26185,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prot * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -21722,21 +26199,21 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prot * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.oneofGroups_[0])); }; @@ -21754,8 +26231,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.toObject(opt_includeInstance, this); }; @@ -21764,13 +26241,13 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.toObject = functi * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -21784,23 +26261,23 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.toObject = function(include /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest; - return proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -21808,8 +26285,8 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.deserializeBinaryFromReader var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -21825,9 +26302,9 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.deserializeBinaryFromReader * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -21835,24 +26312,31 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.serializeBinary = /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.serializeBinaryToWriter ); } }; +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.repeatedFields_ = [2]; + if (jspb.Message.GENERATE_TO_OBJECT) { @@ -21868,165 +26352,331 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.toObject = function(includeInstance, msg) { + var f, obj = { + prove: jspb.Message.getBooleanFieldWithDefault(msg, 1, false), + resourcePathList: msg.getResourcePathList_asB64(), + resourceIdentifier: msg.getResourceIdentifier_asB64(), + voterIdentifier: msg.getVoterIdentifier_asB64(), + count: jspb.Message.getFieldWithDefault(msg, 5, 0), + ascending: jspb.Message.getBooleanFieldWithDefault(msg, 6, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); + break; + case 2: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.addResourcePath(value); + break; + case 3: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setResourceIdentifier(value); + break; + case 4: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setVoterIdentifier(value); + break; + case 5: + var value = /** @type {number} */ (reader.readUint32()); + msg.setCount(value); + break; + case 6: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setAscending(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getProve(); + if (f) { + writer.writeBool( + 1, + f + ); + } + f = message.getResourcePathList_asU8(); + if (f.length > 0) { + writer.writeRepeatedBytes( + 2, + f + ); + } + f = message.getResourceIdentifier_asU8(); + if (f.length > 0) { + writer.writeBytes( + 3, + f + ); + } + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeBytes( + 4, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 5)); + if (f != null) { + writer.writeUint32( + 5, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 6)); + if (f != null) { + writer.writeBool( + 6, + f + ); + } +}; + + +/** + * optional bool prove = 1; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 1, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 1, value); +}; + + +/** + * repeated bytes resource_path = 2; + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getResourcePathList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); +}; + + +/** + * repeated bytes resource_path = 2; + * This is a type-conversion wrapper around `getResourcePathList()` + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getResourcePathList_asB64 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsB64( + this.getResourcePathList())); +}; + + +/** + * repeated bytes resource_path = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getResourcePathList()` + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getResourcePathList_asU8 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsU8( + this.getResourcePathList())); +}; + + +/** + * @param {!(Array|Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.setResourcePathList = function(value) { + return jspb.Message.setField(this, 2, value || []); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.addResourcePath = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 2, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.clearResourcePathList = function() { + return this.setResourcePathList([]); }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional bytes resource_identifier = 3; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.toObject = function(includeInstance, msg) { - var f, obj = { - startEpoch: (f = msg.getStartEpoch()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), - count: jspb.Message.getFieldWithDefault(msg, 2, 0), - ascending: jspb.Message.getBooleanFieldWithDefault(msg, 3, false), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 4, false) - }; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getResourceIdentifier = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; + +/** + * optional bytes resource_identifier = 3; + * This is a type-conversion wrapper around `getResourceIdentifier()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getResourceIdentifier_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getResourceIdentifier())); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} + * optional bytes resource_identifier = 3; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getResourceIdentifier()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0; - return proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getResourceIdentifier_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getResourceIdentifier())); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new google_protobuf_wrappers_pb.UInt32Value; - reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); - msg.setStartEpoch(value); - break; - case 2: - var value = /** @type {number} */ (reader.readUint32()); - msg.setCount(value); - break; - case 3: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setAscending(value); - break; - case 4: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.setResourceIdentifier = function(value) { + return jspb.Message.setProto3BytesField(this, 3, value); }; /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * optional bytes voter_identifier = 4; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getVoterIdentifier = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); }; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional bytes voter_identifier = 4; + * This is a type-conversion wrapper around `getVoterIdentifier()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getStartEpoch(); - if (f != null) { - writer.writeMessage( - 1, - f, - google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter - ); - } - f = message.getCount(); - if (f !== 0) { - writer.writeUint32( - 2, - f - ); - } - f = message.getAscending(); - if (f) { - writer.writeBool( - 3, - f - ); - } - f = message.getProve(); - if (f) { - writer.writeBool( - 4, - f - ); - } +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getVoterIdentifier_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getVoterIdentifier())); }; /** - * optional google.protobuf.UInt32Value start_epoch = 1; - * @return {?proto.google.protobuf.UInt32Value} + * optional bytes voter_identifier = 4; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getVoterIdentifier()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.getStartEpoch = function() { - return /** @type{?proto.google.protobuf.UInt32Value} */ ( - jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getVoterIdentifier_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getVoterIdentifier())); }; /** - * @param {?proto.google.protobuf.UInt32Value|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.setStartEpoch = function(value) { - return jspb.Message.setWrapperField(this, 1, value); + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.setVoterIdentifier = function(value) { + return jspb.Message.setField(this, 4, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} returns this + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.clearStartEpoch = function() { - return this.setStartEpoch(undefined); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.clearVoterIdentifier = function() { + return jspb.Message.setField(this, 4, undefined); }; @@ -22034,89 +26684,107 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prot * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.hasStartEpoch = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.hasVoterIdentifier = function() { + return jspb.Message.getField(this, 4) != null; }; /** - * optional uint32 count = 2; + * optional uint32 count = 5; * @return {number} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.getCount = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); }; /** * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.setCount = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.setCount = function(value) { + return jspb.Message.setField(this, 5, value); }; /** - * optional bool ascending = 3; - * @return {boolean} + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.getAscending = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 3, false)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.clearCount = function() { + return jspb.Message.setField(this, 5, undefined); }; /** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.setAscending = function(value) { - return jspb.Message.setProto3BooleanField(this, 3, value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.hasCount = function() { + return jspb.Message.getField(this, 5) != null; }; /** - * optional bool prove = 4; + * optional bool ascending = 6; * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 4, false)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getAscending = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 6, false)); }; /** * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 4, value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.setAscending = function(value) { + return jspb.Message.setField(this, 6, value); }; /** - * optional GetEpochsInfoRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.clearAscending = function() { + return jspb.Message.setField(this, 6, undefined); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} returns this + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.hasAscending = function() { + return jspb.Message.getField(this, 6) != null; +}; + + +/** + * optional GetContestedResourceVoteStatusRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -22125,7 +26793,7 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.clearV0 = functio * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -22139,21 +26807,21 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.hasV0 = function( * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.oneofGroups_[0])); }; @@ -22171,8 +26839,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.toObject(opt_includeInstance, this); }; @@ -22181,13 +26849,13 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.toObject = funct * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -22201,23 +26869,23 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.toObject = function(includ /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse; - return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -22225,8 +26893,8 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.deserializeBinaryFromReade var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -22242,9 +26910,9 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.deserializeBinaryFromReade * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -22252,18 +26920,18 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.serializeBinary /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.serializeBinaryToWriter ); } }; @@ -22278,22 +26946,22 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.serializeBinaryToWriter = * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.ResultCase = { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ResultCase = { RESULT_NOT_SET: 0, - EPOCHS: 1, + CONTESTED_RESOURCE_VOTERS: 1, PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.ResultCase} + * @return {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.oneofGroups_[0])); }; @@ -22311,8 +26979,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.toObject(opt_includeInstance, this); }; @@ -22321,13 +26989,13 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.pr * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - epochs: (f = msg.getEpochs()) && proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.toObject(includeInstance, f), + contestedResourceVoters: (f = msg.getContestedResourceVoters()) && proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.toObject(includeInstance, f), proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; @@ -22343,23 +27011,23 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.to /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0; - return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -22367,9 +27035,9 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.de var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.deserializeBinaryFromReader); - msg.setEpochs(value); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.deserializeBinaryFromReader); + msg.setContestedResourceVoters(value); break; case 2: var value = new proto.org.dash.platform.dapi.v0.Proof; @@ -22394,9 +27062,9 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.de * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -22404,18 +27072,18 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.pr /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getEpochs(); + f = message.getContestedResourceVoters(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.serializeBinaryToWriter ); } f = message.getProof(); @@ -22443,7 +27111,7 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.se * @private {!Array} * @const */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.repeatedFields_ = [1]; @@ -22460,8 +27128,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.toObject(opt_includeInstance, this); }; @@ -22470,14 +27138,15 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.toObject = function(includeInstance, msg) { var f, obj = { - epochInfosList: jspb.Message.toObjectList(msg.getEpochInfosList(), - proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.toObject, includeInstance) + votersList: jspb.Message.toObjectList(msg.getVotersList(), + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.toObject, includeInstance), + finishedResults: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) }; if (includeInstance) { @@ -22491,23 +27160,23 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos; - return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -22515,9 +27184,13 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.deserializeBinaryFromReader); - msg.addEpochInfos(value); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.deserializeBinaryFromReader); + msg.addVoters(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setFinishedResults(value); break; default: reader.skipField(); @@ -22532,9 +27205,9 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -22542,58 +27215,83 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getEpochInfosList(); + f = message.getVotersList(); if (f.length > 0) { writer.writeRepeatedMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.serializeBinaryToWriter + ); + } + f = message.getFinishedResults(); + if (f) { + writer.writeBool( + 2, + f ); } }; /** - * repeated EpochInfo epoch_infos = 1; - * @return {!Array} + * repeated Voter voters = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.getEpochInfosList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.prototype.getVotersList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter, 1)); }; /** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} returns this + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.setEpochInfosList = function(value) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.prototype.setVotersList = function(value) { return jspb.Message.setRepeatedWrapperField(this, 1, value); }; /** - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo=} opt_value + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter=} opt_value * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.addEpochInfos = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo, opt_index); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.prototype.addVoters = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter, opt_index); }; /** * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.clearEpochInfosList = function() { - return this.setEpochInfosList([]); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.prototype.clearVotersList = function() { + return this.setVotersList([]); +}; + + +/** + * optional bool finished_results = 2; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.prototype.getFinishedResults = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.prototype.setFinishedResults = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); }; @@ -22613,8 +27311,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.toObject(opt_includeInstance, this); }; @@ -22623,17 +27321,13 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.toObject = function(includeInstance, msg) { var f, obj = { - number: jspb.Message.getFieldWithDefault(msg, 1, 0), - firstBlockHeight: jspb.Message.getFieldWithDefault(msg, 2, 0), - firstCoreBlockHeight: jspb.Message.getFieldWithDefault(msg, 3, 0), - startTime: jspb.Message.getFieldWithDefault(msg, 4, 0), - feeMultiplier: jspb.Message.getFloatingPointFieldWithDefault(msg, 5, 0.0) + identifier: msg.getIdentifier_asB64() }; if (includeInstance) { @@ -22647,23 +27341,23 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo; - return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -22671,24 +27365,8 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {number} */ (reader.readUint32()); - msg.setNumber(value); - break; - case 2: - var value = /** @type {number} */ (reader.readUint64()); - msg.setFirstBlockHeight(value); - break; - case 3: - var value = /** @type {number} */ (reader.readUint32()); - msg.setFirstCoreBlockHeight(value); - break; - case 4: - var value = /** @type {number} */ (reader.readUint64()); - msg.setStartTime(value); - break; - case 5: - var value = /** @type {number} */ (reader.readDouble()); - msg.setFeeMultiplier(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setIdentifier(value); break; default: reader.skipField(); @@ -22703,9 +27381,9 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -22713,165 +27391,89 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getNumber(); - if (f !== 0) { - writer.writeUint32( + f = message.getIdentifier_asU8(); + if (f.length > 0) { + writer.writeBytes( 1, f ); } - f = message.getFirstBlockHeight(); - if (f !== 0) { - writer.writeUint64( - 2, - f - ); - } - f = message.getFirstCoreBlockHeight(); - if (f !== 0) { - writer.writeUint32( - 3, - f - ); - } - f = message.getStartTime(); - if (f !== 0) { - writer.writeUint64( - 4, - f - ); - } - f = message.getFeeMultiplier(); - if (f !== 0.0) { - writer.writeDouble( - 5, - f - ); - } -}; - - -/** - * optional uint32 number = 1; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getNumber = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this - */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setNumber = function(value) { - return jspb.Message.setProto3IntField(this, 1, value); -}; - - -/** - * optional uint64 first_block_height = 2; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getFirstBlockHeight = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this - */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setFirstBlockHeight = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); -}; - - -/** - * optional uint32 first_core_block_height = 3; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getFirstCoreBlockHeight = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); }; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this - */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setFirstCoreBlockHeight = function(value) { - return jspb.Message.setProto3IntField(this, 3, value); -}; - - -/** - * optional uint64 start_time = 4; - * @return {number} + * optional bytes identifier = 1; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getStartTime = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.prototype.getIdentifier = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this + * optional bytes identifier = 1; + * This is a type-conversion wrapper around `getIdentifier()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setStartTime = function(value) { - return jspb.Message.setProto3IntField(this, 4, value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.prototype.getIdentifier_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getIdentifier())); }; /** - * optional double fee_multiplier = 5; - * @return {number} + * optional bytes identifier = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getIdentifier()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getFeeMultiplier = function() { - return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 5, 0.0)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.prototype.getIdentifier_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getIdentifier())); }; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setFeeMultiplier = function(value) { - return jspb.Message.setProto3FloatField(this, 5, value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.prototype.setIdentifier = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional EpochInfos epochs = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} + * optional ContestedResourceVoters contested_resource_voters = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.getEpochs = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.getContestedResourceVoters = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.setEpochs = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.setContestedResourceVoters = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.clearEpochs = function() { - return this.setEpochs(undefined); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.clearContestedResourceVoters = function() { + return this.setContestedResourceVoters(undefined); }; @@ -22879,7 +27481,7 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.pr * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.hasEpochs = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.hasContestedResourceVoters = function() { return jspb.Message.getField(this, 1) != null; }; @@ -22888,7 +27490,7 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.pr * optional Proof proof = 2; * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.getProof = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.getProof = function() { return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; @@ -22896,18 +27498,18 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.pr /** * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.clearProof = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.clearProof = function() { return this.setProof(undefined); }; @@ -22916,7 +27518,7 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.pr * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.hasProof = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.hasProof = function() { return jspb.Message.getField(this, 2) != null; }; @@ -22925,7 +27527,7 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.pr * optional ResponseMetadata metadata = 3; * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.getMetadata = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.getMetadata = function() { return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; @@ -22933,18 +27535,18 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.pr /** * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.setMetadata = function(value) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.setMetadata = function(value) { return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.clearMetadata = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.clearMetadata = function() { return this.setMetadata(undefined); }; @@ -22953,35 +27555,35 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.pr * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.hasMetadata = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.hasMetadata = function() { return jspb.Message.getField(this, 3) != null; }; /** - * optional GetEpochsInfoResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} + * optional GetContestedResourceVoteStatusResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -22990,7 +27592,7 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.clearV0 = functi * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; diff --git a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h index 6939dd72dc..03e051d2e0 100644 --- a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h +++ b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h @@ -34,6 +34,18 @@ CF_EXTERN_C_BEGIN @class GetConsensusParamsResponse_ConsensusParamsBlock; @class GetConsensusParamsResponse_ConsensusParamsEvidence; @class GetConsensusParamsResponse_GetConsensusParamsResponseV0; +@class GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0; +@class GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0; +@class GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Contender; +@class GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_ContestedResourceContenders; +@class GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0; +@class GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0; +@class GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_ContestedResourceVoters; +@class GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_Voter; +@class GetContestedResourcesRequest_GetContestedResourcesRequestV0; +@class GetContestedResourcesResponse_GetContestedResourcesResponseV0; +@class GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResource; +@class GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResources; @class GetDataContractHistoryRequest_GetDataContractHistoryRequestV0; @class GetDataContractHistoryResponse_GetDataContractHistoryResponseV0; @class GetDataContractHistoryResponse_GetDataContractHistoryResponseV0_DataContractHistory; @@ -2391,6 +2403,435 @@ GPB_FINAL @interface GetEpochsInfoResponse_GetEpochsInfoResponseV0_EpochInfo : G @end +#pragma mark - GetContestedResourcesRequest + +typedef GPB_ENUM(GetContestedResourcesRequest_FieldNumber) { + GetContestedResourcesRequest_FieldNumber_V0 = 1, +}; + +typedef GPB_ENUM(GetContestedResourcesRequest_Version_OneOfCase) { + GetContestedResourcesRequest_Version_OneOfCase_GPBUnsetOneOfCase = 0, + GetContestedResourcesRequest_Version_OneOfCase_V0 = 1, +}; + +GPB_FINAL @interface GetContestedResourcesRequest : GPBMessage + +@property(nonatomic, readonly) GetContestedResourcesRequest_Version_OneOfCase versionOneOfCase; + +@property(nonatomic, readwrite, strong, null_resettable) GetContestedResourcesRequest_GetContestedResourcesRequestV0 *v0; + +@end + +/** + * Clears whatever value was set for the oneof 'version'. + **/ +void GetContestedResourcesRequest_ClearVersionOneOfCase(GetContestedResourcesRequest *message); + +#pragma mark - GetContestedResourcesRequest_GetContestedResourcesRequestV0 + +typedef GPB_ENUM(GetContestedResourcesRequest_GetContestedResourcesRequestV0_FieldNumber) { + GetContestedResourcesRequest_GetContestedResourcesRequestV0_FieldNumber_Prove = 1, + GetContestedResourcesRequest_GetContestedResourcesRequestV0_FieldNumber_ResourcePathArray = 2, + GetContestedResourcesRequest_GetContestedResourcesRequestV0_FieldNumber_StartContestedResourceIdentifier = 3, + GetContestedResourcesRequest_GetContestedResourcesRequestV0_FieldNumber_Count = 4, + GetContestedResourcesRequest_GetContestedResourcesRequestV0_FieldNumber_Ascending = 5, +}; + +GPB_FINAL @interface GetContestedResourcesRequest_GetContestedResourcesRequestV0 : GPBMessage + +@property(nonatomic, readwrite) BOOL prove; + +@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *resourcePathArray; +/** The number of items in @c resourcePathArray without causing the array to be created. */ +@property(nonatomic, readonly) NSUInteger resourcePathArray_Count; + +@property(nonatomic, readwrite, copy, null_resettable) NSData *startContestedResourceIdentifier; +/** Test to see if @c startContestedResourceIdentifier has been set. */ +@property(nonatomic, readwrite) BOOL hasStartContestedResourceIdentifier; + +@property(nonatomic, readwrite) uint32_t count; + +@property(nonatomic, readwrite) BOOL hasCount; +@property(nonatomic, readwrite) BOOL ascending; + +@property(nonatomic, readwrite) BOOL hasAscending; +@end + +#pragma mark - GetContestedResourcesResponse + +typedef GPB_ENUM(GetContestedResourcesResponse_FieldNumber) { + GetContestedResourcesResponse_FieldNumber_V0 = 1, +}; + +typedef GPB_ENUM(GetContestedResourcesResponse_Version_OneOfCase) { + GetContestedResourcesResponse_Version_OneOfCase_GPBUnsetOneOfCase = 0, + GetContestedResourcesResponse_Version_OneOfCase_V0 = 1, +}; + +GPB_FINAL @interface GetContestedResourcesResponse : GPBMessage + +@property(nonatomic, readonly) GetContestedResourcesResponse_Version_OneOfCase versionOneOfCase; + +@property(nonatomic, readwrite, strong, null_resettable) GetContestedResourcesResponse_GetContestedResourcesResponseV0 *v0; + +@end + +/** + * Clears whatever value was set for the oneof 'version'. + **/ +void GetContestedResourcesResponse_ClearVersionOneOfCase(GetContestedResourcesResponse *message); + +#pragma mark - GetContestedResourcesResponse_GetContestedResourcesResponseV0 + +typedef GPB_ENUM(GetContestedResourcesResponse_GetContestedResourcesResponseV0_FieldNumber) { + GetContestedResourcesResponse_GetContestedResourcesResponseV0_FieldNumber_ContestedResources = 1, + GetContestedResourcesResponse_GetContestedResourcesResponseV0_FieldNumber_Proof = 2, + GetContestedResourcesResponse_GetContestedResourcesResponseV0_FieldNumber_Metadata = 3, +}; + +typedef GPB_ENUM(GetContestedResourcesResponse_GetContestedResourcesResponseV0_Result_OneOfCase) { + GetContestedResourcesResponse_GetContestedResourcesResponseV0_Result_OneOfCase_GPBUnsetOneOfCase = 0, + GetContestedResourcesResponse_GetContestedResourcesResponseV0_Result_OneOfCase_ContestedResources = 1, + GetContestedResourcesResponse_GetContestedResourcesResponseV0_Result_OneOfCase_Proof = 2, +}; + +GPB_FINAL @interface GetContestedResourcesResponse_GetContestedResourcesResponseV0 : GPBMessage + +@property(nonatomic, readonly) GetContestedResourcesResponse_GetContestedResourcesResponseV0_Result_OneOfCase resultOneOfCase; + +@property(nonatomic, readwrite, strong, null_resettable) GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResources *contestedResources; + +@property(nonatomic, readwrite, strong, null_resettable) Proof *proof; + +@property(nonatomic, readwrite, strong, null_resettable) ResponseMetadata *metadata; +/** Test to see if @c metadata has been set. */ +@property(nonatomic, readwrite) BOOL hasMetadata; + +@end + +/** + * Clears whatever value was set for the oneof 'result'. + **/ +void GetContestedResourcesResponse_GetContestedResourcesResponseV0_ClearResultOneOfCase(GetContestedResourcesResponse_GetContestedResourcesResponseV0 *message); + +#pragma mark - GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResources + +typedef GPB_ENUM(GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResources_FieldNumber) { + GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResources_FieldNumber_ContestedResourcesArray = 1, + GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResources_FieldNumber_FinishedResults = 2, +}; + +GPB_FINAL @interface GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResources : GPBMessage + +@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *contestedResourcesArray; +/** The number of items in @c contestedResourcesArray without causing the array to be created. */ +@property(nonatomic, readonly) NSUInteger contestedResourcesArray_Count; + +@property(nonatomic, readwrite) BOOL finishedResults; + +@end + +#pragma mark - GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResource + +typedef GPB_ENUM(GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResource_FieldNumber) { + GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResource_FieldNumber_Identifier = 1, +}; + +GPB_FINAL @interface GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResource : GPBMessage + +@property(nonatomic, readwrite, copy, null_resettable) NSData *identifier; + +@end + +#pragma mark - GetContestedResourceVoteStateRequest + +typedef GPB_ENUM(GetContestedResourceVoteStateRequest_FieldNumber) { + GetContestedResourceVoteStateRequest_FieldNumber_V0 = 1, +}; + +typedef GPB_ENUM(GetContestedResourceVoteStateRequest_Version_OneOfCase) { + GetContestedResourceVoteStateRequest_Version_OneOfCase_GPBUnsetOneOfCase = 0, + GetContestedResourceVoteStateRequest_Version_OneOfCase_V0 = 1, +}; + +GPB_FINAL @interface GetContestedResourceVoteStateRequest : GPBMessage + +@property(nonatomic, readonly) GetContestedResourceVoteStateRequest_Version_OneOfCase versionOneOfCase; + +@property(nonatomic, readwrite, strong, null_resettable) GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0 *v0; + +@end + +/** + * Clears whatever value was set for the oneof 'version'. + **/ +void GetContestedResourceVoteStateRequest_ClearVersionOneOfCase(GetContestedResourceVoteStateRequest *message); + +#pragma mark - GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0 + +typedef GPB_ENUM(GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0_FieldNumber) { + GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0_FieldNumber_Prove = 1, + GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0_FieldNumber_ResourcePathArray = 2, + GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0_FieldNumber_ContestedResource = 3, + GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0_FieldNumber_StartIdentifier = 4, + GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0_FieldNumber_Count = 5, + GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0_FieldNumber_Ascending = 6, +}; + +GPB_FINAL @interface GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0 : GPBMessage + +@property(nonatomic, readwrite) BOOL prove; + +@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *resourcePathArray; +/** The number of items in @c resourcePathArray without causing the array to be created. */ +@property(nonatomic, readonly) NSUInteger resourcePathArray_Count; + +@property(nonatomic, readwrite, copy, null_resettable) NSData *contestedResource; + +@property(nonatomic, readwrite, copy, null_resettable) NSData *startIdentifier; +/** Test to see if @c startIdentifier has been set. */ +@property(nonatomic, readwrite) BOOL hasStartIdentifier; + +@property(nonatomic, readwrite) uint32_t count; + +@property(nonatomic, readwrite) BOOL hasCount; +@property(nonatomic, readwrite) BOOL ascending; + +@property(nonatomic, readwrite) BOOL hasAscending; +@end + +#pragma mark - GetContestedResourceVoteStateResponse + +typedef GPB_ENUM(GetContestedResourceVoteStateResponse_FieldNumber) { + GetContestedResourceVoteStateResponse_FieldNumber_V0 = 1, +}; + +typedef GPB_ENUM(GetContestedResourceVoteStateResponse_Version_OneOfCase) { + GetContestedResourceVoteStateResponse_Version_OneOfCase_GPBUnsetOneOfCase = 0, + GetContestedResourceVoteStateResponse_Version_OneOfCase_V0 = 1, +}; + +GPB_FINAL @interface GetContestedResourceVoteStateResponse : GPBMessage + +@property(nonatomic, readonly) GetContestedResourceVoteStateResponse_Version_OneOfCase versionOneOfCase; + +@property(nonatomic, readwrite, strong, null_resettable) GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0 *v0; + +@end + +/** + * Clears whatever value was set for the oneof 'version'. + **/ +void GetContestedResourceVoteStateResponse_ClearVersionOneOfCase(GetContestedResourceVoteStateResponse *message); + +#pragma mark - GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0 + +typedef GPB_ENUM(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_FieldNumber) { + GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_FieldNumber_ContestedResourceContenders = 1, + GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_FieldNumber_Proof = 2, + GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_FieldNumber_Metadata = 3, +}; + +typedef GPB_ENUM(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Result_OneOfCase) { + GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Result_OneOfCase_GPBUnsetOneOfCase = 0, + GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Result_OneOfCase_ContestedResourceContenders = 1, + GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Result_OneOfCase_Proof = 2, +}; + +GPB_FINAL @interface GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0 : GPBMessage + +@property(nonatomic, readonly) GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Result_OneOfCase resultOneOfCase; + +@property(nonatomic, readwrite, strong, null_resettable) GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_ContestedResourceContenders *contestedResourceContenders; + +@property(nonatomic, readwrite, strong, null_resettable) Proof *proof; + +@property(nonatomic, readwrite, strong, null_resettable) ResponseMetadata *metadata; +/** Test to see if @c metadata has been set. */ +@property(nonatomic, readwrite) BOOL hasMetadata; + +@end + +/** + * Clears whatever value was set for the oneof 'result'. + **/ +void GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_ClearResultOneOfCase(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0 *message); + +#pragma mark - GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_ContestedResourceContenders + +typedef GPB_ENUM(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_ContestedResourceContenders_FieldNumber) { + GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_ContestedResourceContenders_FieldNumber_ContendersArray = 1, + GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_ContestedResourceContenders_FieldNumber_FinishedResults = 2, +}; + +GPB_FINAL @interface GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_ContestedResourceContenders : GPBMessage + +@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *contendersArray; +/** The number of items in @c contendersArray without causing the array to be created. */ +@property(nonatomic, readonly) NSUInteger contendersArray_Count; + +@property(nonatomic, readwrite) BOOL finishedResults; + +@end + +#pragma mark - GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Contender + +typedef GPB_ENUM(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Contender_FieldNumber) { + GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Contender_FieldNumber_Identifier = 1, + GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Contender_FieldNumber_VoteCount = 2, +}; + +GPB_FINAL @interface GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Contender : GPBMessage + +@property(nonatomic, readwrite, copy, null_resettable) NSData *identifier; + +@property(nonatomic, readwrite) uint32_t voteCount; + +@end + +#pragma mark - GetContestedResourceVoteStatusRequest + +typedef GPB_ENUM(GetContestedResourceVoteStatusRequest_FieldNumber) { + GetContestedResourceVoteStatusRequest_FieldNumber_V0 = 1, +}; + +typedef GPB_ENUM(GetContestedResourceVoteStatusRequest_Version_OneOfCase) { + GetContestedResourceVoteStatusRequest_Version_OneOfCase_GPBUnsetOneOfCase = 0, + GetContestedResourceVoteStatusRequest_Version_OneOfCase_V0 = 1, +}; + +GPB_FINAL @interface GetContestedResourceVoteStatusRequest : GPBMessage + +@property(nonatomic, readonly) GetContestedResourceVoteStatusRequest_Version_OneOfCase versionOneOfCase; + +@property(nonatomic, readwrite, strong, null_resettable) GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0 *v0; + +@end + +/** + * Clears whatever value was set for the oneof 'version'. + **/ +void GetContestedResourceVoteStatusRequest_ClearVersionOneOfCase(GetContestedResourceVoteStatusRequest *message); + +#pragma mark - GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0 + +typedef GPB_ENUM(GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0_FieldNumber) { + GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0_FieldNumber_Prove = 1, + GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0_FieldNumber_ResourcePathArray = 2, + GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0_FieldNumber_ResourceIdentifier = 3, + GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0_FieldNumber_VoterIdentifier = 4, + GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0_FieldNumber_Count = 5, + GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0_FieldNumber_Ascending = 6, +}; + +GPB_FINAL @interface GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0 : GPBMessage + +@property(nonatomic, readwrite) BOOL prove; + +@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *resourcePathArray; +/** The number of items in @c resourcePathArray without causing the array to be created. */ +@property(nonatomic, readonly) NSUInteger resourcePathArray_Count; + +@property(nonatomic, readwrite, copy, null_resettable) NSData *resourceIdentifier; + +@property(nonatomic, readwrite, copy, null_resettable) NSData *voterIdentifier; +/** Test to see if @c voterIdentifier has been set. */ +@property(nonatomic, readwrite) BOOL hasVoterIdentifier; + +@property(nonatomic, readwrite) uint32_t count; + +@property(nonatomic, readwrite) BOOL hasCount; +@property(nonatomic, readwrite) BOOL ascending; + +@property(nonatomic, readwrite) BOOL hasAscending; +@end + +#pragma mark - GetContestedResourceVoteStatusResponse + +typedef GPB_ENUM(GetContestedResourceVoteStatusResponse_FieldNumber) { + GetContestedResourceVoteStatusResponse_FieldNumber_V0 = 1, +}; + +typedef GPB_ENUM(GetContestedResourceVoteStatusResponse_Version_OneOfCase) { + GetContestedResourceVoteStatusResponse_Version_OneOfCase_GPBUnsetOneOfCase = 0, + GetContestedResourceVoteStatusResponse_Version_OneOfCase_V0 = 1, +}; + +GPB_FINAL @interface GetContestedResourceVoteStatusResponse : GPBMessage + +@property(nonatomic, readonly) GetContestedResourceVoteStatusResponse_Version_OneOfCase versionOneOfCase; + +@property(nonatomic, readwrite, strong, null_resettable) GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0 *v0; + +@end + +/** + * Clears whatever value was set for the oneof 'version'. + **/ +void GetContestedResourceVoteStatusResponse_ClearVersionOneOfCase(GetContestedResourceVoteStatusResponse *message); + +#pragma mark - GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0 + +typedef GPB_ENUM(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_FieldNumber) { + GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_FieldNumber_ContestedResourceVoters = 1, + GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_FieldNumber_Proof = 2, + GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_FieldNumber_Metadata = 3, +}; + +typedef GPB_ENUM(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_Result_OneOfCase) { + GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_Result_OneOfCase_GPBUnsetOneOfCase = 0, + GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_Result_OneOfCase_ContestedResourceVoters = 1, + GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_Result_OneOfCase_Proof = 2, +}; + +GPB_FINAL @interface GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0 : GPBMessage + +@property(nonatomic, readonly) GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_Result_OneOfCase resultOneOfCase; + +@property(nonatomic, readwrite, strong, null_resettable) GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_ContestedResourceVoters *contestedResourceVoters; + +@property(nonatomic, readwrite, strong, null_resettable) Proof *proof; + +@property(nonatomic, readwrite, strong, null_resettable) ResponseMetadata *metadata; +/** Test to see if @c metadata has been set. */ +@property(nonatomic, readwrite) BOOL hasMetadata; + +@end + +/** + * Clears whatever value was set for the oneof 'result'. + **/ +void GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_ClearResultOneOfCase(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0 *message); + +#pragma mark - GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_ContestedResourceVoters + +typedef GPB_ENUM(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_ContestedResourceVoters_FieldNumber) { + GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_ContestedResourceVoters_FieldNumber_VotersArray = 1, + GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_ContestedResourceVoters_FieldNumber_FinishedResults = 2, +}; + +GPB_FINAL @interface GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_ContestedResourceVoters : GPBMessage + +@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray *votersArray; +/** The number of items in @c votersArray without causing the array to be created. */ +@property(nonatomic, readonly) NSUInteger votersArray_Count; + +@property(nonatomic, readwrite) BOOL finishedResults; + +@end + +#pragma mark - GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_Voter + +typedef GPB_ENUM(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_Voter_FieldNumber) { + GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_Voter_FieldNumber_Identifier = 1, +}; + +GPB_FINAL @interface GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_Voter : GPBMessage + +@property(nonatomic, readwrite, copy, null_resettable) NSData *identifier; + +@end + NS_ASSUME_NONNULL_END CF_EXTERN_C_END diff --git a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.m b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.m index e5ece015ec..e39ca62bf0 100644 --- a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.m +++ b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.m @@ -36,6 +36,24 @@ GPBObjCClassDeclaration(GetConsensusParamsResponse_ConsensusParamsBlock); GPBObjCClassDeclaration(GetConsensusParamsResponse_ConsensusParamsEvidence); GPBObjCClassDeclaration(GetConsensusParamsResponse_GetConsensusParamsResponseV0); +GPBObjCClassDeclaration(GetContestedResourceVoteStateRequest); +GPBObjCClassDeclaration(GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0); +GPBObjCClassDeclaration(GetContestedResourceVoteStateResponse); +GPBObjCClassDeclaration(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0); +GPBObjCClassDeclaration(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Contender); +GPBObjCClassDeclaration(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_ContestedResourceContenders); +GPBObjCClassDeclaration(GetContestedResourceVoteStatusRequest); +GPBObjCClassDeclaration(GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0); +GPBObjCClassDeclaration(GetContestedResourceVoteStatusResponse); +GPBObjCClassDeclaration(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0); +GPBObjCClassDeclaration(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_ContestedResourceVoters); +GPBObjCClassDeclaration(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_Voter); +GPBObjCClassDeclaration(GetContestedResourcesRequest); +GPBObjCClassDeclaration(GetContestedResourcesRequest_GetContestedResourcesRequestV0); +GPBObjCClassDeclaration(GetContestedResourcesResponse); +GPBObjCClassDeclaration(GetContestedResourcesResponse_GetContestedResourcesResponseV0); +GPBObjCClassDeclaration(GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResource); +GPBObjCClassDeclaration(GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResources); GPBObjCClassDeclaration(GetDataContractHistoryRequest); GPBObjCClassDeclaration(GetDataContractHistoryRequest_GetDataContractHistoryRequestV0); GPBObjCClassDeclaration(GetDataContractHistoryResponse); @@ -6486,6 +6504,1191 @@ + (GPBDescriptor *)descriptor { @end +#pragma mark - GetContestedResourcesRequest + +@implementation GetContestedResourcesRequest + +@dynamic versionOneOfCase; +@dynamic v0; + +typedef struct GetContestedResourcesRequest__storage_ { + uint32_t _has_storage_[2]; + GetContestedResourcesRequest_GetContestedResourcesRequestV0 *v0; +} GetContestedResourcesRequest__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "v0", + .dataTypeSpecific.clazz = GPBObjCClass(GetContestedResourcesRequest_GetContestedResourcesRequestV0), + .number = GetContestedResourcesRequest_FieldNumber_V0, + .hasIndex = -1, + .offset = (uint32_t)offsetof(GetContestedResourcesRequest__storage_, v0), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetContestedResourcesRequest class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetContestedResourcesRequest__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + static const char *oneofs[] = { + "version", + }; + [localDescriptor setupOneofs:oneofs + count:(uint32_t)(sizeof(oneofs) / sizeof(char*)) + firstHasIndex:-1]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +void GetContestedResourcesRequest_ClearVersionOneOfCase(GetContestedResourcesRequest *message) { + GPBDescriptor *descriptor = [GetContestedResourcesRequest descriptor]; + GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:0]; + GPBClearOneof(message, oneof); +} +#pragma mark - GetContestedResourcesRequest_GetContestedResourcesRequestV0 + +@implementation GetContestedResourcesRequest_GetContestedResourcesRequestV0 + +@dynamic prove; +@dynamic resourcePathArray, resourcePathArray_Count; +@dynamic hasStartContestedResourceIdentifier, startContestedResourceIdentifier; +@dynamic hasCount, count; +@dynamic hasAscending, ascending; + +typedef struct GetContestedResourcesRequest_GetContestedResourcesRequestV0__storage_ { + uint32_t _has_storage_[1]; + uint32_t count; + NSMutableArray *resourcePathArray; + NSData *startContestedResourceIdentifier; +} GetContestedResourcesRequest_GetContestedResourcesRequestV0__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "prove", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourcesRequest_GetContestedResourcesRequestV0_FieldNumber_Prove, + .hasIndex = 0, + .offset = 1, // Stored in _has_storage_ to save space. + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeBool, + }, + { + .name = "resourcePathArray", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourcesRequest_GetContestedResourcesRequestV0_FieldNumber_ResourcePathArray, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GetContestedResourcesRequest_GetContestedResourcesRequestV0__storage_, resourcePathArray), + .flags = GPBFieldRepeated, + .dataType = GPBDataTypeBytes, + }, + { + .name = "startContestedResourceIdentifier", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourcesRequest_GetContestedResourcesRequestV0_FieldNumber_StartContestedResourceIdentifier, + .hasIndex = 2, + .offset = (uint32_t)offsetof(GetContestedResourcesRequest_GetContestedResourcesRequestV0__storage_, startContestedResourceIdentifier), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeBytes, + }, + { + .name = "count", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourcesRequest_GetContestedResourcesRequestV0_FieldNumber_Count, + .hasIndex = 3, + .offset = (uint32_t)offsetof(GetContestedResourcesRequest_GetContestedResourcesRequestV0__storage_, count), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeUInt32, + }, + { + .name = "ascending", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourcesRequest_GetContestedResourcesRequestV0_FieldNumber_Ascending, + .hasIndex = 4, + .offset = 5, // Stored in _has_storage_ to save space. + .flags = GPBFieldOptional, + .dataType = GPBDataTypeBool, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetContestedResourcesRequest_GetContestedResourcesRequestV0 class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetContestedResourcesRequest_GetContestedResourcesRequestV0__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + [localDescriptor setupContainingMessageClass:GPBObjCClass(GetContestedResourcesRequest)]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - GetContestedResourcesResponse + +@implementation GetContestedResourcesResponse + +@dynamic versionOneOfCase; +@dynamic v0; + +typedef struct GetContestedResourcesResponse__storage_ { + uint32_t _has_storage_[2]; + GetContestedResourcesResponse_GetContestedResourcesResponseV0 *v0; +} GetContestedResourcesResponse__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "v0", + .dataTypeSpecific.clazz = GPBObjCClass(GetContestedResourcesResponse_GetContestedResourcesResponseV0), + .number = GetContestedResourcesResponse_FieldNumber_V0, + .hasIndex = -1, + .offset = (uint32_t)offsetof(GetContestedResourcesResponse__storage_, v0), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetContestedResourcesResponse class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetContestedResourcesResponse__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + static const char *oneofs[] = { + "version", + }; + [localDescriptor setupOneofs:oneofs + count:(uint32_t)(sizeof(oneofs) / sizeof(char*)) + firstHasIndex:-1]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +void GetContestedResourcesResponse_ClearVersionOneOfCase(GetContestedResourcesResponse *message) { + GPBDescriptor *descriptor = [GetContestedResourcesResponse descriptor]; + GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:0]; + GPBClearOneof(message, oneof); +} +#pragma mark - GetContestedResourcesResponse_GetContestedResourcesResponseV0 + +@implementation GetContestedResourcesResponse_GetContestedResourcesResponseV0 + +@dynamic resultOneOfCase; +@dynamic contestedResources; +@dynamic proof; +@dynamic hasMetadata, metadata; + +typedef struct GetContestedResourcesResponse_GetContestedResourcesResponseV0__storage_ { + uint32_t _has_storage_[2]; + GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResources *contestedResources; + Proof *proof; + ResponseMetadata *metadata; +} GetContestedResourcesResponse_GetContestedResourcesResponseV0__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "contestedResources", + .dataTypeSpecific.clazz = GPBObjCClass(GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResources), + .number = GetContestedResourcesResponse_GetContestedResourcesResponseV0_FieldNumber_ContestedResources, + .hasIndex = -1, + .offset = (uint32_t)offsetof(GetContestedResourcesResponse_GetContestedResourcesResponseV0__storage_, contestedResources), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + { + .name = "proof", + .dataTypeSpecific.clazz = GPBObjCClass(Proof), + .number = GetContestedResourcesResponse_GetContestedResourcesResponseV0_FieldNumber_Proof, + .hasIndex = -1, + .offset = (uint32_t)offsetof(GetContestedResourcesResponse_GetContestedResourcesResponseV0__storage_, proof), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + { + .name = "metadata", + .dataTypeSpecific.clazz = GPBObjCClass(ResponseMetadata), + .number = GetContestedResourcesResponse_GetContestedResourcesResponseV0_FieldNumber_Metadata, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GetContestedResourcesResponse_GetContestedResourcesResponseV0__storage_, metadata), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetContestedResourcesResponse_GetContestedResourcesResponseV0 class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetContestedResourcesResponse_GetContestedResourcesResponseV0__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + static const char *oneofs[] = { + "result", + }; + [localDescriptor setupOneofs:oneofs + count:(uint32_t)(sizeof(oneofs) / sizeof(char*)) + firstHasIndex:-1]; + [localDescriptor setupContainingMessageClass:GPBObjCClass(GetContestedResourcesResponse)]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +void GetContestedResourcesResponse_GetContestedResourcesResponseV0_ClearResultOneOfCase(GetContestedResourcesResponse_GetContestedResourcesResponseV0 *message) { + GPBDescriptor *descriptor = [GetContestedResourcesResponse_GetContestedResourcesResponseV0 descriptor]; + GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:0]; + GPBClearOneof(message, oneof); +} +#pragma mark - GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResources + +@implementation GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResources + +@dynamic contestedResourcesArray, contestedResourcesArray_Count; +@dynamic finishedResults; + +typedef struct GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResources__storage_ { + uint32_t _has_storage_[1]; + NSMutableArray *contestedResourcesArray; +} GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResources__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "contestedResourcesArray", + .dataTypeSpecific.clazz = GPBObjCClass(GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResource), + .number = GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResources_FieldNumber_ContestedResourcesArray, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResources__storage_, contestedResourcesArray), + .flags = GPBFieldRepeated, + .dataType = GPBDataTypeMessage, + }, + { + .name = "finishedResults", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResources_FieldNumber_FinishedResults, + .hasIndex = 0, + .offset = 1, // Stored in _has_storage_ to save space. + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeBool, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResources class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResources__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + [localDescriptor setupContainingMessageClass:GPBObjCClass(GetContestedResourcesResponse_GetContestedResourcesResponseV0)]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResource + +@implementation GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResource + +@dynamic identifier; + +typedef struct GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResource__storage_ { + uint32_t _has_storage_[1]; + NSData *identifier; +} GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResource__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "identifier", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResource_FieldNumber_Identifier, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResource__storage_, identifier), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeBytes, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResource class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetContestedResourcesResponse_GetContestedResourcesResponseV0_ContestedResource__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + [localDescriptor setupContainingMessageClass:GPBObjCClass(GetContestedResourcesResponse_GetContestedResourcesResponseV0)]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - GetContestedResourceVoteStateRequest + +@implementation GetContestedResourceVoteStateRequest + +@dynamic versionOneOfCase; +@dynamic v0; + +typedef struct GetContestedResourceVoteStateRequest__storage_ { + uint32_t _has_storage_[2]; + GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0 *v0; +} GetContestedResourceVoteStateRequest__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "v0", + .dataTypeSpecific.clazz = GPBObjCClass(GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0), + .number = GetContestedResourceVoteStateRequest_FieldNumber_V0, + .hasIndex = -1, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStateRequest__storage_, v0), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetContestedResourceVoteStateRequest class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetContestedResourceVoteStateRequest__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + static const char *oneofs[] = { + "version", + }; + [localDescriptor setupOneofs:oneofs + count:(uint32_t)(sizeof(oneofs) / sizeof(char*)) + firstHasIndex:-1]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +void GetContestedResourceVoteStateRequest_ClearVersionOneOfCase(GetContestedResourceVoteStateRequest *message) { + GPBDescriptor *descriptor = [GetContestedResourceVoteStateRequest descriptor]; + GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:0]; + GPBClearOneof(message, oneof); +} +#pragma mark - GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0 + +@implementation GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0 + +@dynamic prove; +@dynamic resourcePathArray, resourcePathArray_Count; +@dynamic contestedResource; +@dynamic hasStartIdentifier, startIdentifier; +@dynamic hasCount, count; +@dynamic hasAscending, ascending; + +typedef struct GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0__storage_ { + uint32_t _has_storage_[1]; + uint32_t count; + NSMutableArray *resourcePathArray; + NSData *contestedResource; + NSData *startIdentifier; +} GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "prove", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0_FieldNumber_Prove, + .hasIndex = 0, + .offset = 1, // Stored in _has_storage_ to save space. + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeBool, + }, + { + .name = "resourcePathArray", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0_FieldNumber_ResourcePathArray, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0__storage_, resourcePathArray), + .flags = GPBFieldRepeated, + .dataType = GPBDataTypeBytes, + }, + { + .name = "contestedResource", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0_FieldNumber_ContestedResource, + .hasIndex = 2, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0__storage_, contestedResource), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeBytes, + }, + { + .name = "startIdentifier", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0_FieldNumber_StartIdentifier, + .hasIndex = 3, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0__storage_, startIdentifier), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeBytes, + }, + { + .name = "count", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0_FieldNumber_Count, + .hasIndex = 4, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0__storage_, count), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeUInt32, + }, + { + .name = "ascending", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0_FieldNumber_Ascending, + .hasIndex = 5, + .offset = 6, // Stored in _has_storage_ to save space. + .flags = GPBFieldOptional, + .dataType = GPBDataTypeBool, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0 class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + [localDescriptor setupContainingMessageClass:GPBObjCClass(GetContestedResourceVoteStateRequest)]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - GetContestedResourceVoteStateResponse + +@implementation GetContestedResourceVoteStateResponse + +@dynamic versionOneOfCase; +@dynamic v0; + +typedef struct GetContestedResourceVoteStateResponse__storage_ { + uint32_t _has_storage_[2]; + GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0 *v0; +} GetContestedResourceVoteStateResponse__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "v0", + .dataTypeSpecific.clazz = GPBObjCClass(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0), + .number = GetContestedResourceVoteStateResponse_FieldNumber_V0, + .hasIndex = -1, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStateResponse__storage_, v0), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetContestedResourceVoteStateResponse class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetContestedResourceVoteStateResponse__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + static const char *oneofs[] = { + "version", + }; + [localDescriptor setupOneofs:oneofs + count:(uint32_t)(sizeof(oneofs) / sizeof(char*)) + firstHasIndex:-1]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +void GetContestedResourceVoteStateResponse_ClearVersionOneOfCase(GetContestedResourceVoteStateResponse *message) { + GPBDescriptor *descriptor = [GetContestedResourceVoteStateResponse descriptor]; + GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:0]; + GPBClearOneof(message, oneof); +} +#pragma mark - GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0 + +@implementation GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0 + +@dynamic resultOneOfCase; +@dynamic contestedResourceContenders; +@dynamic proof; +@dynamic hasMetadata, metadata; + +typedef struct GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0__storage_ { + uint32_t _has_storage_[2]; + GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_ContestedResourceContenders *contestedResourceContenders; + Proof *proof; + ResponseMetadata *metadata; +} GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "contestedResourceContenders", + .dataTypeSpecific.clazz = GPBObjCClass(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_ContestedResourceContenders), + .number = GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_FieldNumber_ContestedResourceContenders, + .hasIndex = -1, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0__storage_, contestedResourceContenders), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + { + .name = "proof", + .dataTypeSpecific.clazz = GPBObjCClass(Proof), + .number = GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_FieldNumber_Proof, + .hasIndex = -1, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0__storage_, proof), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + { + .name = "metadata", + .dataTypeSpecific.clazz = GPBObjCClass(ResponseMetadata), + .number = GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_FieldNumber_Metadata, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0__storage_, metadata), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0 class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + static const char *oneofs[] = { + "result", + }; + [localDescriptor setupOneofs:oneofs + count:(uint32_t)(sizeof(oneofs) / sizeof(char*)) + firstHasIndex:-1]; + [localDescriptor setupContainingMessageClass:GPBObjCClass(GetContestedResourceVoteStateResponse)]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +void GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_ClearResultOneOfCase(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0 *message) { + GPBDescriptor *descriptor = [GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0 descriptor]; + GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:0]; + GPBClearOneof(message, oneof); +} +#pragma mark - GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_ContestedResourceContenders + +@implementation GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_ContestedResourceContenders + +@dynamic contendersArray, contendersArray_Count; +@dynamic finishedResults; + +typedef struct GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_ContestedResourceContenders__storage_ { + uint32_t _has_storage_[1]; + NSMutableArray *contendersArray; +} GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_ContestedResourceContenders__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "contendersArray", + .dataTypeSpecific.clazz = GPBObjCClass(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Contender), + .number = GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_ContestedResourceContenders_FieldNumber_ContendersArray, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_ContestedResourceContenders__storage_, contendersArray), + .flags = GPBFieldRepeated, + .dataType = GPBDataTypeMessage, + }, + { + .name = "finishedResults", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_ContestedResourceContenders_FieldNumber_FinishedResults, + .hasIndex = 0, + .offset = 1, // Stored in _has_storage_ to save space. + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeBool, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_ContestedResourceContenders class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_ContestedResourceContenders__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + [localDescriptor setupContainingMessageClass:GPBObjCClass(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0)]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Contender + +@implementation GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Contender + +@dynamic identifier; +@dynamic voteCount; + +typedef struct GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Contender__storage_ { + uint32_t _has_storage_[1]; + uint32_t voteCount; + NSData *identifier; +} GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Contender__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "identifier", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Contender_FieldNumber_Identifier, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Contender__storage_, identifier), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeBytes, + }, + { + .name = "voteCount", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Contender_FieldNumber_VoteCount, + .hasIndex = 1, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Contender__storage_, voteCount), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeUInt32, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Contender class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0_Contender__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + [localDescriptor setupContainingMessageClass:GPBObjCClass(GetContestedResourceVoteStateResponse_GetContestedResourceVoteStateResponseV0)]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - GetContestedResourceVoteStatusRequest + +@implementation GetContestedResourceVoteStatusRequest + +@dynamic versionOneOfCase; +@dynamic v0; + +typedef struct GetContestedResourceVoteStatusRequest__storage_ { + uint32_t _has_storage_[2]; + GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0 *v0; +} GetContestedResourceVoteStatusRequest__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "v0", + .dataTypeSpecific.clazz = GPBObjCClass(GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0), + .number = GetContestedResourceVoteStatusRequest_FieldNumber_V0, + .hasIndex = -1, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStatusRequest__storage_, v0), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetContestedResourceVoteStatusRequest class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetContestedResourceVoteStatusRequest__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + static const char *oneofs[] = { + "version", + }; + [localDescriptor setupOneofs:oneofs + count:(uint32_t)(sizeof(oneofs) / sizeof(char*)) + firstHasIndex:-1]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +void GetContestedResourceVoteStatusRequest_ClearVersionOneOfCase(GetContestedResourceVoteStatusRequest *message) { + GPBDescriptor *descriptor = [GetContestedResourceVoteStatusRequest descriptor]; + GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:0]; + GPBClearOneof(message, oneof); +} +#pragma mark - GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0 + +@implementation GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0 + +@dynamic prove; +@dynamic resourcePathArray, resourcePathArray_Count; +@dynamic resourceIdentifier; +@dynamic hasVoterIdentifier, voterIdentifier; +@dynamic hasCount, count; +@dynamic hasAscending, ascending; + +typedef struct GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0__storage_ { + uint32_t _has_storage_[1]; + uint32_t count; + NSMutableArray *resourcePathArray; + NSData *resourceIdentifier; + NSData *voterIdentifier; +} GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "prove", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0_FieldNumber_Prove, + .hasIndex = 0, + .offset = 1, // Stored in _has_storage_ to save space. + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeBool, + }, + { + .name = "resourcePathArray", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0_FieldNumber_ResourcePathArray, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0__storage_, resourcePathArray), + .flags = GPBFieldRepeated, + .dataType = GPBDataTypeBytes, + }, + { + .name = "resourceIdentifier", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0_FieldNumber_ResourceIdentifier, + .hasIndex = 2, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0__storage_, resourceIdentifier), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeBytes, + }, + { + .name = "voterIdentifier", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0_FieldNumber_VoterIdentifier, + .hasIndex = 3, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0__storage_, voterIdentifier), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeBytes, + }, + { + .name = "count", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0_FieldNumber_Count, + .hasIndex = 4, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0__storage_, count), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeUInt32, + }, + { + .name = "ascending", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0_FieldNumber_Ascending, + .hasIndex = 5, + .offset = 6, // Stored in _has_storage_ to save space. + .flags = GPBFieldOptional, + .dataType = GPBDataTypeBool, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0 class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetContestedResourceVoteStatusRequest_GetContestedResourceVoteStatusRequestV0__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + [localDescriptor setupContainingMessageClass:GPBObjCClass(GetContestedResourceVoteStatusRequest)]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - GetContestedResourceVoteStatusResponse + +@implementation GetContestedResourceVoteStatusResponse + +@dynamic versionOneOfCase; +@dynamic v0; + +typedef struct GetContestedResourceVoteStatusResponse__storage_ { + uint32_t _has_storage_[2]; + GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0 *v0; +} GetContestedResourceVoteStatusResponse__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "v0", + .dataTypeSpecific.clazz = GPBObjCClass(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0), + .number = GetContestedResourceVoteStatusResponse_FieldNumber_V0, + .hasIndex = -1, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStatusResponse__storage_, v0), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetContestedResourceVoteStatusResponse class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetContestedResourceVoteStatusResponse__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + static const char *oneofs[] = { + "version", + }; + [localDescriptor setupOneofs:oneofs + count:(uint32_t)(sizeof(oneofs) / sizeof(char*)) + firstHasIndex:-1]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +void GetContestedResourceVoteStatusResponse_ClearVersionOneOfCase(GetContestedResourceVoteStatusResponse *message) { + GPBDescriptor *descriptor = [GetContestedResourceVoteStatusResponse descriptor]; + GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:0]; + GPBClearOneof(message, oneof); +} +#pragma mark - GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0 + +@implementation GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0 + +@dynamic resultOneOfCase; +@dynamic contestedResourceVoters; +@dynamic proof; +@dynamic hasMetadata, metadata; + +typedef struct GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0__storage_ { + uint32_t _has_storage_[2]; + GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_ContestedResourceVoters *contestedResourceVoters; + Proof *proof; + ResponseMetadata *metadata; +} GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "contestedResourceVoters", + .dataTypeSpecific.clazz = GPBObjCClass(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_ContestedResourceVoters), + .number = GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_FieldNumber_ContestedResourceVoters, + .hasIndex = -1, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0__storage_, contestedResourceVoters), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + { + .name = "proof", + .dataTypeSpecific.clazz = GPBObjCClass(Proof), + .number = GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_FieldNumber_Proof, + .hasIndex = -1, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0__storage_, proof), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + { + .name = "metadata", + .dataTypeSpecific.clazz = GPBObjCClass(ResponseMetadata), + .number = GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_FieldNumber_Metadata, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0__storage_, metadata), + .flags = GPBFieldOptional, + .dataType = GPBDataTypeMessage, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0 class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + static const char *oneofs[] = { + "result", + }; + [localDescriptor setupOneofs:oneofs + count:(uint32_t)(sizeof(oneofs) / sizeof(char*)) + firstHasIndex:-1]; + [localDescriptor setupContainingMessageClass:GPBObjCClass(GetContestedResourceVoteStatusResponse)]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +void GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_ClearResultOneOfCase(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0 *message) { + GPBDescriptor *descriptor = [GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0 descriptor]; + GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:0]; + GPBClearOneof(message, oneof); +} +#pragma mark - GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_ContestedResourceVoters + +@implementation GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_ContestedResourceVoters + +@dynamic votersArray, votersArray_Count; +@dynamic finishedResults; + +typedef struct GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_ContestedResourceVoters__storage_ { + uint32_t _has_storage_[1]; + NSMutableArray *votersArray; +} GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_ContestedResourceVoters__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "votersArray", + .dataTypeSpecific.clazz = GPBObjCClass(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_Voter), + .number = GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_ContestedResourceVoters_FieldNumber_VotersArray, + .hasIndex = GPBNoHasBit, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_ContestedResourceVoters__storage_, votersArray), + .flags = GPBFieldRepeated, + .dataType = GPBDataTypeMessage, + }, + { + .name = "finishedResults", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_ContestedResourceVoters_FieldNumber_FinishedResults, + .hasIndex = 0, + .offset = 1, // Stored in _has_storage_ to save space. + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeBool, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_ContestedResourceVoters class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_ContestedResourceVoters__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + [localDescriptor setupContainingMessageClass:GPBObjCClass(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0)]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + +#pragma mark - GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_Voter + +@implementation GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_Voter + +@dynamic identifier; + +typedef struct GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_Voter__storage_ { + uint32_t _has_storage_[1]; + NSData *identifier; +} GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_Voter__storage_; + +// This method is threadsafe because it is initially called +// in +initialize for each subclass. ++ (GPBDescriptor *)descriptor { + static GPBDescriptor *descriptor = nil; + if (!descriptor) { + static GPBMessageFieldDescription fields[] = { + { + .name = "identifier", + .dataTypeSpecific.clazz = Nil, + .number = GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_Voter_FieldNumber_Identifier, + .hasIndex = 0, + .offset = (uint32_t)offsetof(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_Voter__storage_, identifier), + .flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldClearHasIvarOnZero), + .dataType = GPBDataTypeBytes, + }, + }; + GPBDescriptor *localDescriptor = + [GPBDescriptor allocDescriptorForClass:[GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_Voter class] + rootClass:[PlatformRoot class] + file:PlatformRoot_FileDescriptor() + fields:fields + fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription)) + storageSize:sizeof(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0_Voter__storage_) + flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)]; + [localDescriptor setupContainingMessageClass:GPBObjCClass(GetContestedResourceVoteStatusResponse_GetContestedResourceVoteStatusResponseV0)]; + #if defined(DEBUG) && DEBUG + NSAssert(descriptor == nil, @"Startup recursed!"); + #endif // DEBUG + descriptor = localDescriptor; + } + return descriptor; +} + +@end + #pragma clang diagnostic pop diff --git a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.h b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.h index 062e8b4944..c1cb5c9bba 100644 --- a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.h +++ b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.h @@ -18,6 +18,12 @@ @class BroadcastStateTransitionResponse; @class GetConsensusParamsRequest; @class GetConsensusParamsResponse; +@class GetContestedResourceVoteStateRequest; +@class GetContestedResourceVoteStateResponse; +@class GetContestedResourceVoteStatusRequest; +@class GetContestedResourceVoteStatusResponse; +@class GetContestedResourcesRequest; +@class GetContestedResourcesResponse; @class GetDataContractHistoryRequest; @class GetDataContractHistoryResponse; @class GetDataContractRequest; @@ -152,6 +158,18 @@ NS_ASSUME_NONNULL_BEGIN - (GRPCUnaryProtoCall *)getEpochsInfoWithMessage:(GetEpochsInfoRequest *)message responseHandler:(id)handler callOptions:(GRPCCallOptions *_Nullable)callOptions; +#pragma mark getContestedResources(GetContestedResourcesRequest) returns (GetContestedResourcesResponse) + +- (GRPCUnaryProtoCall *)getContestedResourcesWithMessage:(GetContestedResourcesRequest *)message responseHandler:(id)handler callOptions:(GRPCCallOptions *_Nullable)callOptions; + +#pragma mark getContestedResourceVoteState(GetContestedResourceVoteStateRequest) returns (GetContestedResourceVoteStateResponse) + +- (GRPCUnaryProtoCall *)getContestedResourceVoteStateWithMessage:(GetContestedResourceVoteStateRequest *)message responseHandler:(id)handler callOptions:(GRPCCallOptions *_Nullable)callOptions; + +#pragma mark getContestedResourceVoteStatus(GetContestedResourceVoteStatusRequest) returns (GetContestedResourceVoteStatusResponse) + +- (GRPCUnaryProtoCall *)getContestedResourceVoteStatusWithMessage:(GetContestedResourceVoteStatusRequest *)message responseHandler:(id)handler callOptions:(GRPCCallOptions *_Nullable)callOptions; + @end /** @@ -286,6 +304,27 @@ NS_ASSUME_NONNULL_BEGIN - (GRPCProtoCall *)RPCTogetEpochsInfoWithRequest:(GetEpochsInfoRequest *)request handler:(void(^)(GetEpochsInfoResponse *_Nullable response, NSError *_Nullable error))handler; +#pragma mark getContestedResources(GetContestedResourcesRequest) returns (GetContestedResourcesResponse) + +- (void)getContestedResourcesWithRequest:(GetContestedResourcesRequest *)request handler:(void(^)(GetContestedResourcesResponse *_Nullable response, NSError *_Nullable error))handler; + +- (GRPCProtoCall *)RPCTogetContestedResourcesWithRequest:(GetContestedResourcesRequest *)request handler:(void(^)(GetContestedResourcesResponse *_Nullable response, NSError *_Nullable error))handler; + + +#pragma mark getContestedResourceVoteState(GetContestedResourceVoteStateRequest) returns (GetContestedResourceVoteStateResponse) + +- (void)getContestedResourceVoteStateWithRequest:(GetContestedResourceVoteStateRequest *)request handler:(void(^)(GetContestedResourceVoteStateResponse *_Nullable response, NSError *_Nullable error))handler; + +- (GRPCProtoCall *)RPCTogetContestedResourceVoteStateWithRequest:(GetContestedResourceVoteStateRequest *)request handler:(void(^)(GetContestedResourceVoteStateResponse *_Nullable response, NSError *_Nullable error))handler; + + +#pragma mark getContestedResourceVoteStatus(GetContestedResourceVoteStatusRequest) returns (GetContestedResourceVoteStatusResponse) + +- (void)getContestedResourceVoteStatusWithRequest:(GetContestedResourceVoteStatusRequest *)request handler:(void(^)(GetContestedResourceVoteStatusResponse *_Nullable response, NSError *_Nullable error))handler; + +- (GRPCProtoCall *)RPCTogetContestedResourceVoteStatusWithRequest:(GetContestedResourceVoteStatusRequest *)request handler:(void(^)(GetContestedResourceVoteStatusResponse *_Nullable response, NSError *_Nullable error))handler; + + @end diff --git a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.m b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.m index 4d4611e93d..b59fb66d12 100644 --- a/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.m +++ b/packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.m @@ -430,5 +430,65 @@ - (GRPCUnaryProtoCall *)getEpochsInfoWithMessage:(GetEpochsInfoRequest *)message responseClass:[GetEpochsInfoResponse class]]; } +#pragma mark getContestedResources(GetContestedResourcesRequest) returns (GetContestedResourcesResponse) + +- (void)getContestedResourcesWithRequest:(GetContestedResourcesRequest *)request handler:(void(^)(GetContestedResourcesResponse *_Nullable response, NSError *_Nullable error))handler{ + [[self RPCTogetContestedResourcesWithRequest:request handler:handler] start]; +} +// Returns a not-yet-started RPC object. +- (GRPCProtoCall *)RPCTogetContestedResourcesWithRequest:(GetContestedResourcesRequest *)request handler:(void(^)(GetContestedResourcesResponse *_Nullable response, NSError *_Nullable error))handler{ + return [self RPCToMethod:@"getContestedResources" + requestsWriter:[GRXWriter writerWithValue:request] + responseClass:[GetContestedResourcesResponse class] + responsesWriteable:[GRXWriteable writeableWithSingleHandler:handler]]; +} +- (GRPCUnaryProtoCall *)getContestedResourcesWithMessage:(GetContestedResourcesRequest *)message responseHandler:(id)handler callOptions:(GRPCCallOptions *_Nullable)callOptions { + return [self RPCToMethod:@"getContestedResources" + message:message + responseHandler:handler + callOptions:callOptions + responseClass:[GetContestedResourcesResponse class]]; +} + +#pragma mark getContestedResourceVoteState(GetContestedResourceVoteStateRequest) returns (GetContestedResourceVoteStateResponse) + +- (void)getContestedResourceVoteStateWithRequest:(GetContestedResourceVoteStateRequest *)request handler:(void(^)(GetContestedResourceVoteStateResponse *_Nullable response, NSError *_Nullable error))handler{ + [[self RPCTogetContestedResourceVoteStateWithRequest:request handler:handler] start]; +} +// Returns a not-yet-started RPC object. +- (GRPCProtoCall *)RPCTogetContestedResourceVoteStateWithRequest:(GetContestedResourceVoteStateRequest *)request handler:(void(^)(GetContestedResourceVoteStateResponse *_Nullable response, NSError *_Nullable error))handler{ + return [self RPCToMethod:@"getContestedResourceVoteState" + requestsWriter:[GRXWriter writerWithValue:request] + responseClass:[GetContestedResourceVoteStateResponse class] + responsesWriteable:[GRXWriteable writeableWithSingleHandler:handler]]; +} +- (GRPCUnaryProtoCall *)getContestedResourceVoteStateWithMessage:(GetContestedResourceVoteStateRequest *)message responseHandler:(id)handler callOptions:(GRPCCallOptions *_Nullable)callOptions { + return [self RPCToMethod:@"getContestedResourceVoteState" + message:message + responseHandler:handler + callOptions:callOptions + responseClass:[GetContestedResourceVoteStateResponse class]]; +} + +#pragma mark getContestedResourceVoteStatus(GetContestedResourceVoteStatusRequest) returns (GetContestedResourceVoteStatusResponse) + +- (void)getContestedResourceVoteStatusWithRequest:(GetContestedResourceVoteStatusRequest *)request handler:(void(^)(GetContestedResourceVoteStatusResponse *_Nullable response, NSError *_Nullable error))handler{ + [[self RPCTogetContestedResourceVoteStatusWithRequest:request handler:handler] start]; +} +// Returns a not-yet-started RPC object. +- (GRPCProtoCall *)RPCTogetContestedResourceVoteStatusWithRequest:(GetContestedResourceVoteStatusRequest *)request handler:(void(^)(GetContestedResourceVoteStatusResponse *_Nullable response, NSError *_Nullable error))handler{ + return [self RPCToMethod:@"getContestedResourceVoteStatus" + requestsWriter:[GRXWriter writerWithValue:request] + responseClass:[GetContestedResourceVoteStatusResponse class] + responsesWriteable:[GRXWriteable writeableWithSingleHandler:handler]]; +} +- (GRPCUnaryProtoCall *)getContestedResourceVoteStatusWithMessage:(GetContestedResourceVoteStatusRequest *)message responseHandler:(id)handler callOptions:(GRPCCallOptions *_Nullable)callOptions { + return [self RPCToMethod:@"getContestedResourceVoteStatus" + message:message + responseHandler:handler + callOptions:callOptions + responseClass:[GetContestedResourceVoteStatusResponse class]]; +} + @end #endif diff --git a/packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py b/packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py index 36cc42d123..8d45d1ea92 100644 --- a/packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py +++ b/packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py @@ -22,7 +22,7 @@ syntax='proto3', serialized_options=None, create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x0eplatform.proto\x12\x19org.dash.platform.dapi.v0\x1a\x1egoogle/protobuf/wrappers.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x81\x01\n\x05Proof\x12\x15\n\rgrovedb_proof\x18\x01 \x01(\x0c\x12\x13\n\x0bquorum_hash\x18\x02 \x01(\x0c\x12\x11\n\tsignature\x18\x03 \x01(\x0c\x12\r\n\x05round\x18\x04 \x01(\r\x12\x15\n\rblock_id_hash\x18\x05 \x01(\x0c\x12\x13\n\x0bquorum_type\x18\x06 \x01(\r\"\x90\x01\n\x10ResponseMetadata\x12\x0e\n\x06height\x18\x01 \x01(\x04\x12 \n\x18\x63ore_chain_locked_height\x18\x02 \x01(\r\x12\r\n\x05\x65poch\x18\x03 \x01(\r\x12\x0f\n\x07time_ms\x18\x04 \x01(\x04\x12\x18\n\x10protocol_version\x18\x05 \x01(\r\x12\x10\n\x08\x63hain_id\x18\x06 \x01(\t\"L\n\x1dStateTransitionBroadcastError\x12\x0c\n\x04\x63ode\x18\x01 \x01(\r\x12\x0f\n\x07message\x18\x02 \x01(\t\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x0c\";\n\x1f\x42roadcastStateTransitionRequest\x12\x18\n\x10state_transition\x18\x01 \x01(\x0c\"\"\n BroadcastStateTransitionResponse\"\xa4\x01\n\x12GetIdentityRequest\x12P\n\x02v0\x18\x01 \x01(\x0b\x32\x42.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0H\x00\x1a\x31\n\x14GetIdentityRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xc0\x01\n\x19GetIdentityBalanceRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0H\x00\x1a\x38\n\x1bGetIdentityBalanceRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xec\x01\n$GetIdentityBalanceAndRevisionRequest\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0H\x00\x1a\x43\n&GetIdentityBalanceAndRevisionRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x9e\x02\n\x13GetIdentityResponse\x12R\n\x02v0\x18\x01 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0H\x00\x1a\xa7\x01\n\x15GetIdentityResponseV0\x12\x12\n\x08identity\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xad\x01\n\x14GetIdentitiesRequest\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0H\x00\x1a\x34\n\x16GetIdentitiesRequestV0\x12\x0b\n\x03ids\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xda\x04\n\x15GetIdentitiesResponse\x12V\n\x02v0\x18\x01 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0H\x00\x1a\x1e\n\rIdentityValue\x12\r\n\x05value\x18\x01 \x01(\x0c\x1ak\n\rIdentityEntry\x12\x0b\n\x03key\x18\x01 \x01(\x0c\x12M\n\x05value\x18\x02 \x01(\x0b\x32>.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue\x1a\x66\n\nIdentities\x12X\n\x10identity_entries\x18\x01 \x03(\x0b\x32>.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry\x1a\xe8\x01\n\x17GetIdentitiesResponseV0\x12Q\n\nidentities\x18\x01 \x01(\x0b\x32;.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentitiesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb9\x02\n\x1aGetIdentityBalanceResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0H\x00\x1a\xad\x01\n\x1cGetIdentityBalanceResponseV0\x12\x11\n\x07\x62\x61lance\x18\x01 \x01(\x04H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xa9\x04\n%GetIdentityBalanceAndRevisionResponse\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0H\x00\x1a\xfc\x02\n\'GetIdentityBalanceAndRevisionResponseV0\x12\x9b\x01\n\x14\x62\x61lance_and_revision\x18\x01 \x01(\x0b\x32{.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevisionH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x37\n\x12\x42\x61lanceAndRevision\x12\x0f\n\x07\x62\x61lance\x18\x01 \x01(\x04\x12\x10\n\x08revision\x18\x02 \x01(\x04\x42\x08\n\x06resultB\t\n\x07version\"\xd1\x01\n\x0eKeyRequestType\x12\x36\n\x08\x61ll_keys\x18\x01 \x01(\x0b\x32\".org.dash.platform.dapi.v0.AllKeysH\x00\x12@\n\rspecific_keys\x18\x02 \x01(\x0b\x32\'.org.dash.platform.dapi.v0.SpecificKeysH\x00\x12:\n\nsearch_key\x18\x03 \x01(\x0b\x32$.org.dash.platform.dapi.v0.SearchKeyH\x00\x42\t\n\x07request\"\t\n\x07\x41llKeys\"\x1f\n\x0cSpecificKeys\x12\x0f\n\x07key_ids\x18\x01 \x03(\r\"\xb6\x01\n\tSearchKey\x12I\n\x0bpurpose_map\x18\x01 \x03(\x0b\x32\x34.org.dash.platform.dapi.v0.SearchKey.PurposeMapEntry\x1a^\n\x0fPurposeMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\r\x12:\n\x05value\x18\x02 \x01(\x0b\x32+.org.dash.platform.dapi.v0.SecurityLevelMap:\x02\x38\x01\"\xbf\x02\n\x10SecurityLevelMap\x12]\n\x12security_level_map\x18\x01 \x03(\x0b\x32\x41.org.dash.platform.dapi.v0.SecurityLevelMap.SecurityLevelMapEntry\x1aw\n\x15SecurityLevelMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\r\x12M\n\x05value\x18\x02 \x01(\x0e\x32>.org.dash.platform.dapi.v0.SecurityLevelMap.KeyKindRequestType:\x02\x38\x01\"S\n\x12KeyKindRequestType\x12\x1f\n\x1b\x43URRENT_KEY_OF_KIND_REQUEST\x10\x00\x12\x1c\n\x18\x41LL_KEYS_OF_KIND_REQUEST\x10\x01\"\xda\x02\n\x16GetIdentityKeysRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0H\x00\x1a\xda\x01\n\x18GetIdentityKeysRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12?\n\x0crequest_type\x18\x02 \x01(\x0b\x32).org.dash.platform.dapi.v0.KeyRequestType\x12+\n\x05limit\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x04 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\t\n\x07version\"\x99\x03\n\x17GetIdentityKeysResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0H\x00\x1a\x96\x02\n\x19GetIdentityKeysResponseV0\x12\x61\n\x04keys\x18\x01 \x01(\x0b\x32Q.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.KeysH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1a\n\x04Keys\x12\x12\n\nkeys_bytes\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\x93\x06\n\x10GetProofsRequest\x12L\n\x02v0\x18\x01 \x01(\x0b\x32>.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0H\x00\x1a\xa5\x05\n\x12GetProofsRequestV0\x12\x62\n\nidentities\x18\x01 \x03(\x0b\x32N.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest\x12\x61\n\tcontracts\x18\x02 \x03(\x0b\x32N.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest\x12\x61\n\tdocuments\x18\x03 \x03(\x0b\x32N.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest\x1aw\n\x0f\x44ocumentRequest\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x15\n\rdocument_type\x18\x02 \x01(\t\x12#\n\x1b\x64ocument_type_keeps_history\x18\x03 \x01(\x08\x12\x13\n\x0b\x64ocument_id\x18\x04 \x01(\x0c\x1a\xc3\x01\n\x0fIdentityRequest\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12i\n\x0crequest_type\x18\x02 \x01(\x0e\x32S.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type\"0\n\x04Type\x12\x11\n\rFULL_IDENTITY\x10\x00\x12\x0b\n\x07\x42\x41LANCE\x10\x01\x12\x08\n\x04KEYS\x10\x02\x1a&\n\x0f\x43ontractRequest\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x42\t\n\x07version\"\x82\x02\n\x11GetProofsResponse\x12N\n\x02v0\x18\x01 \x01(\x0b\x32@.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0H\x00\x1a\x91\x01\n\x13GetProofsResponseV0\x12\x31\n\x05proof\x18\x01 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x02 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb4\x01\n\x16GetDataContractRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0H\x00\x1a\x35\n\x18GetDataContractRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xb3\x02\n\x17GetDataContractResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0H\x00\x1a\xb0\x01\n\x19GetDataContractResponseV0\x12\x17\n\rdata_contract\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb9\x01\n\x17GetDataContractsRequest\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0H\x00\x1a\x37\n\x19GetDataContractsRequestV0\x12\x0b\n\x03ids\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xcf\x04\n\x18GetDataContractsResponse\x12\\\n\x02v0\x18\x01 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0H\x00\x1a[\n\x11\x44\x61taContractEntry\x12\x12\n\nidentifier\x18\x01 \x01(\x0c\x12\x32\n\rdata_contract\x18\x02 \x01(\x0b\x32\x1b.google.protobuf.BytesValue\x1au\n\rDataContracts\x12\x64\n\x15\x64\x61ta_contract_entries\x18\x01 \x03(\x0b\x32\x45.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry\x1a\xf5\x01\n\x1aGetDataContractsResponseV0\x12[\n\x0e\x64\x61ta_contracts\x18\x01 \x01(\x0b\x32\x41.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc1\x02\n\x1dGetDataContractHistoryRequest\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0H\x00\x1a\xac\x01\n\x1fGetDataContractHistoryRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12+\n\x05limit\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\x13\n\x0bstart_at_ms\x18\x04 \x01(\x04\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\t\n\x07version\"\xae\x05\n\x1eGetDataContractHistoryResponse\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0H\x00\x1a\x96\x04\n GetDataContractHistoryResponseV0\x12\x8f\x01\n\x15\x64\x61ta_contract_history\x18\x01 \x01(\x0b\x32n.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x37\n\x18\x44\x61taContractHistoryEntry\x12\x0c\n\x04\x64\x61te\x18\x01 \x01(\x04\x12\r\n\x05value\x18\x02 \x01(\x0c\x1a\xaa\x01\n\x13\x44\x61taContractHistory\x12\x92\x01\n\x15\x64\x61ta_contract_entries\x18\x01 \x03(\x0b\x32s.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntryB\x08\n\x06resultB\t\n\x07version\"\xb2\x02\n\x13GetDocumentsRequest\x12R\n\x02v0\x18\x01 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0H\x00\x1a\xbb\x01\n\x15GetDocumentsRequestV0\x12\x18\n\x10\x64\x61ta_contract_id\x18\x01 \x01(\x0c\x12\x15\n\rdocument_type\x18\x02 \x01(\t\x12\r\n\x05where\x18\x03 \x01(\x0c\x12\x10\n\x08order_by\x18\x04 \x01(\x0c\x12\r\n\x05limit\x18\x05 \x01(\r\x12\x15\n\x0bstart_after\x18\x06 \x01(\x0cH\x00\x12\x12\n\x08start_at\x18\x07 \x01(\x0cH\x00\x12\r\n\x05prove\x18\x08 \x01(\x08\x42\x07\n\x05startB\t\n\x07version\"\x95\x03\n\x14GetDocumentsResponse\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0H\x00\x1a\x9b\x02\n\x16GetDocumentsResponseV0\x12\x65\n\tdocuments\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.DocumentsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1e\n\tDocuments\x12\x11\n\tdocuments\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\xff\x01\n%GetIdentitiesByPublicKeyHashesRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0H\x00\x1aS\n\'GetIdentitiesByPublicKeyHashesRequestV0\x12\x19\n\x11public_key_hashes\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xc6\x05\n&GetIdentitiesByPublicKeyHashesResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0H\x00\x1a\x61\n\x1aPublicKeyHashIdentityEntry\x12\x17\n\x0fpublic_key_hash\x18\x01 \x01(\x0c\x12*\n\x05value\x18\x02 \x01(\x0b\x32\x1b.google.protobuf.BytesValue\x1a\x95\x01\n\x1bIdentitiesByPublicKeyHashes\x12v\n\x10identity_entries\x18\x01 \x03(\x0b\x32\\.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry\x1a\x9b\x02\n(GetIdentitiesByPublicKeyHashesResponseV0\x12s\n\nidentities\x18\x01 \x01(\x0b\x32].org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xed\x01\n!GetIdentityByPublicKeyHashRequest\x12n\n\x02v0\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0H\x00\x1aM\n#GetIdentityByPublicKeyHashRequestV0\x12\x17\n\x0fpublic_key_hash\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xda\x02\n\"GetIdentityByPublicKeyHashResponse\x12p\n\x02v0\x18\x01 \x01(\x0b\x32\x62.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0H\x00\x1a\xb6\x01\n$GetIdentityByPublicKeyHashResponseV0\x12\x12\n\x08identity\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xfb\x01\n#WaitForStateTransitionResultRequest\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0H\x00\x1aU\n%WaitForStateTransitionResultRequestV0\x12\x1d\n\x15state_transition_hash\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x99\x03\n$WaitForStateTransitionResultResponse\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0H\x00\x1a\xef\x01\n&WaitForStateTransitionResultResponseV0\x12I\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x38.org.dash.platform.dapi.v0.StateTransitionBroadcastErrorH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc4\x01\n\x19GetConsensusParamsRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0H\x00\x1a<\n\x1bGetConsensusParamsRequestV0\x12\x0e\n\x06height\x18\x01 \x01(\x05\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x9c\x04\n\x1aGetConsensusParamsResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0H\x00\x1aP\n\x14\x43onsensusParamsBlock\x12\x11\n\tmax_bytes\x18\x01 \x01(\t\x12\x0f\n\x07max_gas\x18\x02 \x01(\t\x12\x14\n\x0ctime_iota_ms\x18\x03 \x01(\t\x1a\x62\n\x17\x43onsensusParamsEvidence\x12\x1a\n\x12max_age_num_blocks\x18\x01 \x01(\t\x12\x18\n\x10max_age_duration\x18\x02 \x01(\t\x12\x11\n\tmax_bytes\x18\x03 \x01(\t\x1a\xda\x01\n\x1cGetConsensusParamsResponseV0\x12Y\n\x05\x62lock\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock\x12_\n\x08\x65vidence\x18\x02 \x01(\x0b\x32M.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidenceB\t\n\x07version\"\xe4\x01\n%GetProtocolVersionUpgradeStateRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0H\x00\x1a\x38\n\'GetProtocolVersionUpgradeStateRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x42\t\n\x07version\"\xb5\x05\n&GetProtocolVersionUpgradeStateResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0H\x00\x1a\x85\x04\n(GetProtocolVersionUpgradeStateResponseV0\x12\x87\x01\n\x08versions\x18\x01 \x01(\x0b\x32s.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x96\x01\n\x08Versions\x12\x89\x01\n\x08versions\x18\x01 \x03(\x0b\x32w.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry\x1a:\n\x0cVersionEntry\x12\x16\n\x0eversion_number\x18\x01 \x01(\r\x12\x12\n\nvote_count\x18\x02 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xa3\x02\n*GetProtocolVersionUpgradeVoteStatusRequest\x12\x80\x01\n\x02v0\x18\x01 \x01(\x0b\x32r.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0H\x00\x1ag\n,GetProtocolVersionUpgradeVoteStatusRequestV0\x12\x19\n\x11start_pro_tx_hash\x18\x01 \x01(\x0c\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xef\x05\n+GetProtocolVersionUpgradeVoteStatusResponse\x12\x82\x01\n\x02v0\x18\x01 \x01(\x0b\x32t.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0H\x00\x1a\xaf\x04\n-GetProtocolVersionUpgradeVoteStatusResponseV0\x12\x98\x01\n\x08versions\x18\x01 \x01(\x0b\x32\x83\x01.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignalsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xaf\x01\n\x0eVersionSignals\x12\x9c\x01\n\x0fversion_signals\x18\x01 \x03(\x0b\x32\x82\x01.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal\x1a\x35\n\rVersionSignal\x12\x13\n\x0bpro_tx_hash\x18\x01 \x01(\x0c\x12\x0f\n\x07version\x18\x02 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xf5\x01\n\x14GetEpochsInfoRequest\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0H\x00\x1a|\n\x16GetEpochsInfoRequestV0\x12\x31\n\x0bstart_epoch\x18\x01 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x12\x11\n\tascending\x18\x03 \x01(\x08\x12\r\n\x05prove\x18\x04 \x01(\x08\x42\t\n\x07version\"\xf7\x04\n\x15GetEpochsInfoResponse\x12V\n\x02v0\x18\x01 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0H\x00\x1a\xfa\x03\n\x17GetEpochsInfoResponseV0\x12\x65\n\x06\x65pochs\x18\x01 \x01(\x0b\x32S.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfosH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1au\n\nEpochInfos\x12g\n\x0b\x65poch_infos\x18\x01 \x03(\x0b\x32R.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo\x1a\x84\x01\n\tEpochInfo\x12\x0e\n\x06number\x18\x01 \x01(\r\x12\x1a\n\x12\x66irst_block_height\x18\x02 \x01(\x04\x12\x1f\n\x17\x66irst_core_block_height\x18\x03 \x01(\r\x12\x12\n\nstart_time\x18\x04 \x01(\x04\x12\x16\n\x0e\x66\x65\x65_multiplier\x18\x05 \x01(\x01\x42\x08\n\x06resultB\t\n\x07version2\xc2\x13\n\x08Platform\x12\x93\x01\n\x18\x62roadcastStateTransition\x12:.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest\x1a;.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse\x12l\n\x0bgetIdentity\x12-.org.dash.platform.dapi.v0.GetIdentityRequest\x1a..org.dash.platform.dapi.v0.GetIdentityResponse\x12r\n\rgetIdentities\x12/.org.dash.platform.dapi.v0.GetIdentitiesRequest\x1a\x30.org.dash.platform.dapi.v0.GetIdentitiesResponse\x12x\n\x0fgetIdentityKeys\x12\x31.org.dash.platform.dapi.v0.GetIdentityKeysRequest\x1a\x32.org.dash.platform.dapi.v0.GetIdentityKeysResponse\x12\x81\x01\n\x12getIdentityBalance\x12\x34.org.dash.platform.dapi.v0.GetIdentityBalanceRequest\x1a\x35.org.dash.platform.dapi.v0.GetIdentityBalanceResponse\x12\xa2\x01\n\x1dgetIdentityBalanceAndRevision\x12?.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest\x1a@.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse\x12\x66\n\tgetProofs\x12+.org.dash.platform.dapi.v0.GetProofsRequest\x1a,.org.dash.platform.dapi.v0.GetProofsResponse\x12x\n\x0fgetDataContract\x12\x31.org.dash.platform.dapi.v0.GetDataContractRequest\x1a\x32.org.dash.platform.dapi.v0.GetDataContractResponse\x12\x8d\x01\n\x16getDataContractHistory\x12\x38.org.dash.platform.dapi.v0.GetDataContractHistoryRequest\x1a\x39.org.dash.platform.dapi.v0.GetDataContractHistoryResponse\x12{\n\x10getDataContracts\x12\x32.org.dash.platform.dapi.v0.GetDataContractsRequest\x1a\x33.org.dash.platform.dapi.v0.GetDataContractsResponse\x12o\n\x0cgetDocuments\x12..org.dash.platform.dapi.v0.GetDocumentsRequest\x1a/.org.dash.platform.dapi.v0.GetDocumentsResponse\x12\xa5\x01\n\x1egetIdentitiesByPublicKeyHashes\x12@.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest\x1a\x41.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse\x12\x99\x01\n\x1agetIdentityByPublicKeyHash\x12<.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest\x1a=.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse\x12\x9f\x01\n\x1cwaitForStateTransitionResult\x12>.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest\x1a?.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse\x12\x81\x01\n\x12getConsensusParams\x12\x34.org.dash.platform.dapi.v0.GetConsensusParamsRequest\x1a\x35.org.dash.platform.dapi.v0.GetConsensusParamsResponse\x12\xa5\x01\n\x1egetProtocolVersionUpgradeState\x12@.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest\x1a\x41.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse\x12\xb4\x01\n#getProtocolVersionUpgradeVoteStatus\x12\x45.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest\x1a\x46.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse\x12r\n\rgetEpochsInfo\x12/.org.dash.platform.dapi.v0.GetEpochsInfoRequest\x1a\x30.org.dash.platform.dapi.v0.GetEpochsInfoResponseb\x06proto3' + serialized_pb=b'\n\x0eplatform.proto\x12\x19org.dash.platform.dapi.v0\x1a\x1egoogle/protobuf/wrappers.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x81\x01\n\x05Proof\x12\x15\n\rgrovedb_proof\x18\x01 \x01(\x0c\x12\x13\n\x0bquorum_hash\x18\x02 \x01(\x0c\x12\x11\n\tsignature\x18\x03 \x01(\x0c\x12\r\n\x05round\x18\x04 \x01(\r\x12\x15\n\rblock_id_hash\x18\x05 \x01(\x0c\x12\x13\n\x0bquorum_type\x18\x06 \x01(\r\"\x90\x01\n\x10ResponseMetadata\x12\x0e\n\x06height\x18\x01 \x01(\x04\x12 \n\x18\x63ore_chain_locked_height\x18\x02 \x01(\r\x12\r\n\x05\x65poch\x18\x03 \x01(\r\x12\x0f\n\x07time_ms\x18\x04 \x01(\x04\x12\x18\n\x10protocol_version\x18\x05 \x01(\r\x12\x10\n\x08\x63hain_id\x18\x06 \x01(\t\"L\n\x1dStateTransitionBroadcastError\x12\x0c\n\x04\x63ode\x18\x01 \x01(\r\x12\x0f\n\x07message\x18\x02 \x01(\t\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x0c\";\n\x1f\x42roadcastStateTransitionRequest\x12\x18\n\x10state_transition\x18\x01 \x01(\x0c\"\"\n BroadcastStateTransitionResponse\"\xa4\x01\n\x12GetIdentityRequest\x12P\n\x02v0\x18\x01 \x01(\x0b\x32\x42.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0H\x00\x1a\x31\n\x14GetIdentityRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xc0\x01\n\x19GetIdentityBalanceRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0H\x00\x1a\x38\n\x1bGetIdentityBalanceRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xec\x01\n$GetIdentityBalanceAndRevisionRequest\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0H\x00\x1a\x43\n&GetIdentityBalanceAndRevisionRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x9e\x02\n\x13GetIdentityResponse\x12R\n\x02v0\x18\x01 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0H\x00\x1a\xa7\x01\n\x15GetIdentityResponseV0\x12\x12\n\x08identity\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xad\x01\n\x14GetIdentitiesRequest\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0H\x00\x1a\x34\n\x16GetIdentitiesRequestV0\x12\x0b\n\x03ids\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xda\x04\n\x15GetIdentitiesResponse\x12V\n\x02v0\x18\x01 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0H\x00\x1a\x1e\n\rIdentityValue\x12\r\n\x05value\x18\x01 \x01(\x0c\x1ak\n\rIdentityEntry\x12\x0b\n\x03key\x18\x01 \x01(\x0c\x12M\n\x05value\x18\x02 \x01(\x0b\x32>.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue\x1a\x66\n\nIdentities\x12X\n\x10identity_entries\x18\x01 \x03(\x0b\x32>.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry\x1a\xe8\x01\n\x17GetIdentitiesResponseV0\x12Q\n\nidentities\x18\x01 \x01(\x0b\x32;.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentitiesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb9\x02\n\x1aGetIdentityBalanceResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0H\x00\x1a\xad\x01\n\x1cGetIdentityBalanceResponseV0\x12\x11\n\x07\x62\x61lance\x18\x01 \x01(\x04H\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xa9\x04\n%GetIdentityBalanceAndRevisionResponse\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0H\x00\x1a\xfc\x02\n\'GetIdentityBalanceAndRevisionResponseV0\x12\x9b\x01\n\x14\x62\x61lance_and_revision\x18\x01 \x01(\x0b\x32{.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevisionH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x37\n\x12\x42\x61lanceAndRevision\x12\x0f\n\x07\x62\x61lance\x18\x01 \x01(\x04\x12\x10\n\x08revision\x18\x02 \x01(\x04\x42\x08\n\x06resultB\t\n\x07version\"\xd1\x01\n\x0eKeyRequestType\x12\x36\n\x08\x61ll_keys\x18\x01 \x01(\x0b\x32\".org.dash.platform.dapi.v0.AllKeysH\x00\x12@\n\rspecific_keys\x18\x02 \x01(\x0b\x32\'.org.dash.platform.dapi.v0.SpecificKeysH\x00\x12:\n\nsearch_key\x18\x03 \x01(\x0b\x32$.org.dash.platform.dapi.v0.SearchKeyH\x00\x42\t\n\x07request\"\t\n\x07\x41llKeys\"\x1f\n\x0cSpecificKeys\x12\x0f\n\x07key_ids\x18\x01 \x03(\r\"\xb6\x01\n\tSearchKey\x12I\n\x0bpurpose_map\x18\x01 \x03(\x0b\x32\x34.org.dash.platform.dapi.v0.SearchKey.PurposeMapEntry\x1a^\n\x0fPurposeMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\r\x12:\n\x05value\x18\x02 \x01(\x0b\x32+.org.dash.platform.dapi.v0.SecurityLevelMap:\x02\x38\x01\"\xbf\x02\n\x10SecurityLevelMap\x12]\n\x12security_level_map\x18\x01 \x03(\x0b\x32\x41.org.dash.platform.dapi.v0.SecurityLevelMap.SecurityLevelMapEntry\x1aw\n\x15SecurityLevelMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\r\x12M\n\x05value\x18\x02 \x01(\x0e\x32>.org.dash.platform.dapi.v0.SecurityLevelMap.KeyKindRequestType:\x02\x38\x01\"S\n\x12KeyKindRequestType\x12\x1f\n\x1b\x43URRENT_KEY_OF_KIND_REQUEST\x10\x00\x12\x1c\n\x18\x41LL_KEYS_OF_KIND_REQUEST\x10\x01\"\xda\x02\n\x16GetIdentityKeysRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0H\x00\x1a\xda\x01\n\x18GetIdentityKeysRequestV0\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12?\n\x0crequest_type\x18\x02 \x01(\x0b\x32).org.dash.platform.dapi.v0.KeyRequestType\x12+\n\x05limit\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x04 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\t\n\x07version\"\x99\x03\n\x17GetIdentityKeysResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0H\x00\x1a\x96\x02\n\x19GetIdentityKeysResponseV0\x12\x61\n\x04keys\x18\x01 \x01(\x0b\x32Q.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.KeysH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1a\n\x04Keys\x12\x12\n\nkeys_bytes\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\x93\x06\n\x10GetProofsRequest\x12L\n\x02v0\x18\x01 \x01(\x0b\x32>.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0H\x00\x1a\xa5\x05\n\x12GetProofsRequestV0\x12\x62\n\nidentities\x18\x01 \x03(\x0b\x32N.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest\x12\x61\n\tcontracts\x18\x02 \x03(\x0b\x32N.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest\x12\x61\n\tdocuments\x18\x03 \x03(\x0b\x32N.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest\x1aw\n\x0f\x44ocumentRequest\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x12\x15\n\rdocument_type\x18\x02 \x01(\t\x12#\n\x1b\x64ocument_type_keeps_history\x18\x03 \x01(\x08\x12\x13\n\x0b\x64ocument_id\x18\x04 \x01(\x0c\x1a\xc3\x01\n\x0fIdentityRequest\x12\x13\n\x0bidentity_id\x18\x01 \x01(\x0c\x12i\n\x0crequest_type\x18\x02 \x01(\x0e\x32S.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type\"0\n\x04Type\x12\x11\n\rFULL_IDENTITY\x10\x00\x12\x0b\n\x07\x42\x41LANCE\x10\x01\x12\x08\n\x04KEYS\x10\x02\x1a&\n\x0f\x43ontractRequest\x12\x13\n\x0b\x63ontract_id\x18\x01 \x01(\x0c\x42\t\n\x07version\"\x82\x02\n\x11GetProofsResponse\x12N\n\x02v0\x18\x01 \x01(\x0b\x32@.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0H\x00\x1a\x91\x01\n\x13GetProofsResponseV0\x12\x31\n\x05proof\x18\x01 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x02 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb4\x01\n\x16GetDataContractRequest\x12X\n\x02v0\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0H\x00\x1a\x35\n\x18GetDataContractRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xb3\x02\n\x17GetDataContractResponse\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0H\x00\x1a\xb0\x01\n\x19GetDataContractResponseV0\x12\x17\n\rdata_contract\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xb9\x01\n\x17GetDataContractsRequest\x12Z\n\x02v0\x18\x01 \x01(\x0b\x32L.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0H\x00\x1a\x37\n\x19GetDataContractsRequestV0\x12\x0b\n\x03ids\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xcf\x04\n\x18GetDataContractsResponse\x12\\\n\x02v0\x18\x01 \x01(\x0b\x32N.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0H\x00\x1a[\n\x11\x44\x61taContractEntry\x12\x12\n\nidentifier\x18\x01 \x01(\x0c\x12\x32\n\rdata_contract\x18\x02 \x01(\x0b\x32\x1b.google.protobuf.BytesValue\x1au\n\rDataContracts\x12\x64\n\x15\x64\x61ta_contract_entries\x18\x01 \x03(\x0b\x32\x45.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry\x1a\xf5\x01\n\x1aGetDataContractsResponseV0\x12[\n\x0e\x64\x61ta_contracts\x18\x01 \x01(\x0b\x32\x41.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc1\x02\n\x1dGetDataContractHistoryRequest\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0H\x00\x1a\xac\x01\n\x1fGetDataContractHistoryRequestV0\x12\n\n\x02id\x18\x01 \x01(\x0c\x12+\n\x05limit\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12,\n\x06offset\x18\x03 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\x13\n\x0bstart_at_ms\x18\x04 \x01(\x04\x12\r\n\x05prove\x18\x05 \x01(\x08\x42\t\n\x07version\"\xae\x05\n\x1eGetDataContractHistoryResponse\x12h\n\x02v0\x18\x01 \x01(\x0b\x32Z.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0H\x00\x1a\x96\x04\n GetDataContractHistoryResponseV0\x12\x8f\x01\n\x15\x64\x61ta_contract_history\x18\x01 \x01(\x0b\x32n.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x37\n\x18\x44\x61taContractHistoryEntry\x12\x0c\n\x04\x64\x61te\x18\x01 \x01(\x04\x12\r\n\x05value\x18\x02 \x01(\x0c\x1a\xaa\x01\n\x13\x44\x61taContractHistory\x12\x92\x01\n\x15\x64\x61ta_contract_entries\x18\x01 \x03(\x0b\x32s.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntryB\x08\n\x06resultB\t\n\x07version\"\xb2\x02\n\x13GetDocumentsRequest\x12R\n\x02v0\x18\x01 \x01(\x0b\x32\x44.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0H\x00\x1a\xbb\x01\n\x15GetDocumentsRequestV0\x12\x18\n\x10\x64\x61ta_contract_id\x18\x01 \x01(\x0c\x12\x15\n\rdocument_type\x18\x02 \x01(\t\x12\r\n\x05where\x18\x03 \x01(\x0c\x12\x10\n\x08order_by\x18\x04 \x01(\x0c\x12\r\n\x05limit\x18\x05 \x01(\r\x12\x15\n\x0bstart_after\x18\x06 \x01(\x0cH\x00\x12\x12\n\x08start_at\x18\x07 \x01(\x0cH\x00\x12\r\n\x05prove\x18\x08 \x01(\x08\x42\x07\n\x05startB\t\n\x07version\"\x95\x03\n\x14GetDocumentsResponse\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0H\x00\x1a\x9b\x02\n\x16GetDocumentsResponseV0\x12\x65\n\tdocuments\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.DocumentsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x1e\n\tDocuments\x12\x11\n\tdocuments\x18\x01 \x03(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\xff\x01\n%GetIdentitiesByPublicKeyHashesRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0H\x00\x1aS\n\'GetIdentitiesByPublicKeyHashesRequestV0\x12\x19\n\x11public_key_hashes\x18\x01 \x03(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xc6\x05\n&GetIdentitiesByPublicKeyHashesResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0H\x00\x1a\x61\n\x1aPublicKeyHashIdentityEntry\x12\x17\n\x0fpublic_key_hash\x18\x01 \x01(\x0c\x12*\n\x05value\x18\x02 \x01(\x0b\x32\x1b.google.protobuf.BytesValue\x1a\x95\x01\n\x1bIdentitiesByPublicKeyHashes\x12v\n\x10identity_entries\x18\x01 \x03(\x0b\x32\\.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry\x1a\x9b\x02\n(GetIdentitiesByPublicKeyHashesResponseV0\x12s\n\nidentities\x18\x01 \x01(\x0b\x32].org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xed\x01\n!GetIdentityByPublicKeyHashRequest\x12n\n\x02v0\x18\x01 \x01(\x0b\x32`.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0H\x00\x1aM\n#GetIdentityByPublicKeyHashRequestV0\x12\x17\n\x0fpublic_key_hash\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\xda\x02\n\"GetIdentityByPublicKeyHashResponse\x12p\n\x02v0\x18\x01 \x01(\x0b\x32\x62.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0H\x00\x1a\xb6\x01\n$GetIdentityByPublicKeyHashResponseV0\x12\x12\n\x08identity\x18\x01 \x01(\x0cH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xfb\x01\n#WaitForStateTransitionResultRequest\x12r\n\x02v0\x18\x01 \x01(\x0b\x32\x64.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0H\x00\x1aU\n%WaitForStateTransitionResultRequestV0\x12\x1d\n\x15state_transition_hash\x18\x01 \x01(\x0c\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x99\x03\n$WaitForStateTransitionResultResponse\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0H\x00\x1a\xef\x01\n&WaitForStateTransitionResultResponseV0\x12I\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x38.org.dash.platform.dapi.v0.StateTransitionBroadcastErrorH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadataB\x08\n\x06resultB\t\n\x07version\"\xc4\x01\n\x19GetConsensusParamsRequest\x12^\n\x02v0\x18\x01 \x01(\x0b\x32P.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0H\x00\x1a<\n\x1bGetConsensusParamsRequestV0\x12\x0e\n\x06height\x18\x01 \x01(\x05\x12\r\n\x05prove\x18\x02 \x01(\x08\x42\t\n\x07version\"\x9c\x04\n\x1aGetConsensusParamsResponse\x12`\n\x02v0\x18\x01 \x01(\x0b\x32R.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0H\x00\x1aP\n\x14\x43onsensusParamsBlock\x12\x11\n\tmax_bytes\x18\x01 \x01(\t\x12\x0f\n\x07max_gas\x18\x02 \x01(\t\x12\x14\n\x0ctime_iota_ms\x18\x03 \x01(\t\x1a\x62\n\x17\x43onsensusParamsEvidence\x12\x1a\n\x12max_age_num_blocks\x18\x01 \x01(\t\x12\x18\n\x10max_age_duration\x18\x02 \x01(\t\x12\x11\n\tmax_bytes\x18\x03 \x01(\t\x1a\xda\x01\n\x1cGetConsensusParamsResponseV0\x12Y\n\x05\x62lock\x18\x01 \x01(\x0b\x32J.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock\x12_\n\x08\x65vidence\x18\x02 \x01(\x0b\x32M.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidenceB\t\n\x07version\"\xe4\x01\n%GetProtocolVersionUpgradeStateRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0H\x00\x1a\x38\n\'GetProtocolVersionUpgradeStateRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x42\t\n\x07version\"\xb5\x05\n&GetProtocolVersionUpgradeStateResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0H\x00\x1a\x85\x04\n(GetProtocolVersionUpgradeStateResponseV0\x12\x87\x01\n\x08versions\x18\x01 \x01(\x0b\x32s.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\x96\x01\n\x08Versions\x12\x89\x01\n\x08versions\x18\x01 \x03(\x0b\x32w.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry\x1a:\n\x0cVersionEntry\x12\x16\n\x0eversion_number\x18\x01 \x01(\r\x12\x12\n\nvote_count\x18\x02 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xa3\x02\n*GetProtocolVersionUpgradeVoteStatusRequest\x12\x80\x01\n\x02v0\x18\x01 \x01(\x0b\x32r.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0H\x00\x1ag\n,GetProtocolVersionUpgradeVoteStatusRequestV0\x12\x19\n\x11start_pro_tx_hash\x18\x01 \x01(\x0c\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x12\r\n\x05prove\x18\x03 \x01(\x08\x42\t\n\x07version\"\xef\x05\n+GetProtocolVersionUpgradeVoteStatusResponse\x12\x82\x01\n\x02v0\x18\x01 \x01(\x0b\x32t.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0H\x00\x1a\xaf\x04\n-GetProtocolVersionUpgradeVoteStatusResponseV0\x12\x98\x01\n\x08versions\x18\x01 \x01(\x0b\x32\x83\x01.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignalsH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xaf\x01\n\x0eVersionSignals\x12\x9c\x01\n\x0fversion_signals\x18\x01 \x03(\x0b\x32\x82\x01.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal\x1a\x35\n\rVersionSignal\x12\x13\n\x0bpro_tx_hash\x18\x01 \x01(\x0c\x12\x0f\n\x07version\x18\x02 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\xf5\x01\n\x14GetEpochsInfoRequest\x12T\n\x02v0\x18\x01 \x01(\x0b\x32\x46.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0H\x00\x1a|\n\x16GetEpochsInfoRequestV0\x12\x31\n\x0bstart_epoch\x18\x01 \x01(\x0b\x32\x1c.google.protobuf.UInt32Value\x12\r\n\x05\x63ount\x18\x02 \x01(\r\x12\x11\n\tascending\x18\x03 \x01(\x08\x12\r\n\x05prove\x18\x04 \x01(\x08\x42\t\n\x07version\"\xf7\x04\n\x15GetEpochsInfoResponse\x12V\n\x02v0\x18\x01 \x01(\x0b\x32H.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0H\x00\x1a\xfa\x03\n\x17GetEpochsInfoResponseV0\x12\x65\n\x06\x65pochs\x18\x01 \x01(\x0b\x32S.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfosH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1au\n\nEpochInfos\x12g\n\x0b\x65poch_infos\x18\x01 \x03(\x0b\x32R.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo\x1a\x84\x01\n\tEpochInfo\x12\x0e\n\x06number\x18\x01 \x01(\r\x12\x1a\n\x12\x66irst_block_height\x18\x02 \x01(\x04\x12\x1f\n\x17\x66irst_core_block_height\x18\x03 \x01(\r\x12\x12\n\nstart_time\x18\x04 \x01(\x04\x12\x16\n\x0e\x66\x65\x65_multiplier\x18\x05 \x01(\x01\x42\x08\n\x06resultB\t\n\x07version\"\xf6\x02\n\x1cGetContestedResourcesRequest\x12\x64\n\x02v0\x18\x01 \x01(\x0b\x32V.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0H\x00\x1a\xe4\x01\n\x1eGetContestedResourcesRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x12\x15\n\rresource_path\x18\x02 \x03(\x0c\x12\x30\n#start_contested_resource_identifier\x18\x03 \x01(\x0cH\x00\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x04 \x01(\rH\x01\x88\x01\x01\x12\x16\n\tascending\x18\x05 \x01(\x08H\x02\x88\x01\x01\x42&\n$_start_contested_resource_identifierB\x08\n\x06_countB\x0c\n\n_ascendingB\t\n\x07version\"\xa3\x05\n\x1dGetContestedResourcesResponse\x12\x66\n\x02v0\x18\x01 \x01(\x0b\x32X.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0H\x00\x1a\x8e\x04\n\x1fGetContestedResourcesResponseV0\x12\x8a\x01\n\x13\x63ontested_resources\x18\x01 \x01(\x0b\x32k.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResourcesH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xb8\x01\n\x12\x43ontestedResources\x12\x87\x01\n\x13\x63ontested_resources\x18\x01 \x03(\x0b\x32j.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource\x12\x18\n\x10\x66inished_results\x18\x02 \x01(\x08\x1a\'\n\x11\x43ontestedResource\x12\x12\n\nidentifier\x18\x01 \x01(\x0c\x42\x08\n\x06resultB\t\n\x07version\"\x8c\x03\n$GetContestedResourceVoteStateRequest\x12t\n\x02v0\x18\x01 \x01(\x0b\x32\x66.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0H\x00\x1a\xe2\x01\n&GetContestedResourceVoteStateRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x12\x15\n\rresource_path\x18\x02 \x03(\x0c\x12\x1a\n\x12\x63ontested_resource\x18\x03 \x01(\x0c\x12\x1d\n\x10start_identifier\x18\x04 \x01(\x0cH\x00\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x05 \x01(\rH\x01\x88\x01\x01\x12\x16\n\tascending\x18\x06 \x01(\x08H\x02\x88\x01\x01\x42\x13\n\x11_start_identifierB\x08\n\x06_countB\x0c\n\n_ascendingB\t\n\x07version\"\xfb\x05\n%GetContestedResourceVoteStateResponse\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0H\x00\x1a\xce\x04\n\'GetContestedResourceVoteStateResponseV0\x12\xae\x01\n\x1d\x63ontested_resource_contenders\x18\x01 \x01(\x0b\x32\x84\x01.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContendersH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xc0\x01\n\x1b\x43ontestedResourceContenders\x12\x86\x01\n\ncontenders\x18\x01 \x03(\x0b\x32r.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender\x12\x18\n\x10\x66inished_results\x18\x02 \x01(\x08\x1a\x33\n\tContender\x12\x12\n\nidentifier\x18\x01 \x01(\x0c\x12\x12\n\nvote_count\x18\x02 \x01(\rB\x08\n\x06resultB\t\n\x07version\"\x91\x03\n%GetContestedResourceVoteStatusRequest\x12v\n\x02v0\x18\x01 \x01(\x0b\x32h.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0H\x00\x1a\xe4\x01\n\'GetContestedResourceVoteStatusRequestV0\x12\r\n\x05prove\x18\x01 \x01(\x08\x12\x15\n\rresource_path\x18\x02 \x03(\x0c\x12\x1b\n\x13resource_identifier\x18\x03 \x01(\x0c\x12\x1d\n\x10voter_identifier\x18\x04 \x01(\x0cH\x00\x88\x01\x01\x12\x12\n\x05\x63ount\x18\x05 \x01(\rH\x01\x88\x01\x01\x12\x16\n\tascending\x18\x06 \x01(\x08H\x02\x88\x01\x01\x42\x13\n\x11_voter_identifierB\x08\n\x06_countB\x0c\n\n_ascendingB\t\n\x07version\"\xd7\x05\n&GetContestedResourceVoteStatusResponse\x12x\n\x02v0\x18\x01 \x01(\x0b\x32j.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0H\x00\x1a\xa7\x04\n(GetContestedResourceVoteStatusResponseV0\x12\xa8\x01\n\x19\x63ontested_resource_voters\x18\x01 \x01(\x0b\x32\x82\x01.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVotersH\x00\x12\x31\n\x05proof\x18\x02 \x01(\x0b\x32 .org.dash.platform.dapi.v0.ProofH\x00\x12=\n\x08metadata\x18\x03 \x01(\x0b\x32+.org.dash.platform.dapi.v0.ResponseMetadata\x1a\xb6\x01\n\x17\x43ontestedResourceVoters\x12\x80\x01\n\x06voters\x18\x01 \x03(\x0b\x32p.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter\x12\x18\n\x10\x66inished_results\x18\x02 \x01(\x08\x1a\x1b\n\x05Voter\x12\x12\n\nidentifier\x18\x01 \x01(\x0c\x42\x08\n\x06resultB\t\n\x07version2\x9c\x17\n\x08Platform\x12\x93\x01\n\x18\x62roadcastStateTransition\x12:.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest\x1a;.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse\x12l\n\x0bgetIdentity\x12-.org.dash.platform.dapi.v0.GetIdentityRequest\x1a..org.dash.platform.dapi.v0.GetIdentityResponse\x12r\n\rgetIdentities\x12/.org.dash.platform.dapi.v0.GetIdentitiesRequest\x1a\x30.org.dash.platform.dapi.v0.GetIdentitiesResponse\x12x\n\x0fgetIdentityKeys\x12\x31.org.dash.platform.dapi.v0.GetIdentityKeysRequest\x1a\x32.org.dash.platform.dapi.v0.GetIdentityKeysResponse\x12\x81\x01\n\x12getIdentityBalance\x12\x34.org.dash.platform.dapi.v0.GetIdentityBalanceRequest\x1a\x35.org.dash.platform.dapi.v0.GetIdentityBalanceResponse\x12\xa2\x01\n\x1dgetIdentityBalanceAndRevision\x12?.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest\x1a@.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse\x12\x66\n\tgetProofs\x12+.org.dash.platform.dapi.v0.GetProofsRequest\x1a,.org.dash.platform.dapi.v0.GetProofsResponse\x12x\n\x0fgetDataContract\x12\x31.org.dash.platform.dapi.v0.GetDataContractRequest\x1a\x32.org.dash.platform.dapi.v0.GetDataContractResponse\x12\x8d\x01\n\x16getDataContractHistory\x12\x38.org.dash.platform.dapi.v0.GetDataContractHistoryRequest\x1a\x39.org.dash.platform.dapi.v0.GetDataContractHistoryResponse\x12{\n\x10getDataContracts\x12\x32.org.dash.platform.dapi.v0.GetDataContractsRequest\x1a\x33.org.dash.platform.dapi.v0.GetDataContractsResponse\x12o\n\x0cgetDocuments\x12..org.dash.platform.dapi.v0.GetDocumentsRequest\x1a/.org.dash.platform.dapi.v0.GetDocumentsResponse\x12\xa5\x01\n\x1egetIdentitiesByPublicKeyHashes\x12@.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest\x1a\x41.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse\x12\x99\x01\n\x1agetIdentityByPublicKeyHash\x12<.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest\x1a=.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse\x12\x9f\x01\n\x1cwaitForStateTransitionResult\x12>.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest\x1a?.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse\x12\x81\x01\n\x12getConsensusParams\x12\x34.org.dash.platform.dapi.v0.GetConsensusParamsRequest\x1a\x35.org.dash.platform.dapi.v0.GetConsensusParamsResponse\x12\xa5\x01\n\x1egetProtocolVersionUpgradeState\x12@.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest\x1a\x41.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse\x12\xb4\x01\n#getProtocolVersionUpgradeVoteStatus\x12\x45.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest\x1a\x46.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse\x12r\n\rgetEpochsInfo\x12/.org.dash.platform.dapi.v0.GetEpochsInfoRequest\x1a\x30.org.dash.platform.dapi.v0.GetEpochsInfoResponse\x12\x8a\x01\n\x15getContestedResources\x12\x37.org.dash.platform.dapi.v0.GetContestedResourcesRequest\x1a\x38.org.dash.platform.dapi.v0.GetContestedResourcesResponse\x12\xa2\x01\n\x1dgetContestedResourceVoteState\x12?.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest\x1a@.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse\x12\xa5\x01\n\x1egetContestedResourceVoteStatus\x12@.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest\x1a\x41.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponseb\x06proto3' , dependencies=[google_dot_protobuf_dot_wrappers__pb2.DESCRIPTOR,google_dot_protobuf_dot_struct__pb2.DESCRIPTOR,google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,]) @@ -4261,6 +4261,828 @@ serialized_end=14540, ) + +_GETCONTESTEDRESOURCESREQUEST_GETCONTESTEDRESOURCESREQUESTV0 = _descriptor.Descriptor( + name='GetContestedResourcesRequestV0', + full_name='org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='prove', full_name='org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prove', index=0, + number=1, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='resource_path', full_name='org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.resource_path', index=1, + number=2, type=12, cpp_type=9, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='start_contested_resource_identifier', full_name='org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.start_contested_resource_identifier', index=2, + number=3, type=12, cpp_type=9, label=1, + has_default_value=False, default_value=b"", + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='count', full_name='org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.count', index=3, + number=4, type=13, cpp_type=3, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='ascending', full_name='org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.ascending', index=4, + number=5, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='_start_contested_resource_identifier', full_name='org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0._start_contested_resource_identifier', + index=0, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + _descriptor.OneofDescriptor( + name='_count', full_name='org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0._count', + index=1, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + _descriptor.OneofDescriptor( + name='_ascending', full_name='org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0._ascending', + index=2, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + ], + serialized_start=14678, + serialized_end=14906, +) + +_GETCONTESTEDRESOURCESREQUEST = _descriptor.Descriptor( + name='GetContestedResourcesRequest', + full_name='org.dash.platform.dapi.v0.GetContestedResourcesRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='v0', full_name='org.dash.platform.dapi.v0.GetContestedResourcesRequest.v0', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[_GETCONTESTEDRESOURCESREQUEST_GETCONTESTEDRESOURCESREQUESTV0, ], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='version', full_name='org.dash.platform.dapi.v0.GetContestedResourcesRequest.version', + index=0, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + ], + serialized_start=14543, + serialized_end=14917, +) + + +_GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0_CONTESTEDRESOURCES = _descriptor.Descriptor( + name='ContestedResources', + full_name='org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='contested_resources', full_name='org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.contested_resources', index=0, + number=1, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='finished_results', full_name='org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.finished_results', index=1, + number=2, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=15349, + serialized_end=15533, +) + +_GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0_CONTESTEDRESOURCE = _descriptor.Descriptor( + name='ContestedResource', + full_name='org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='identifier', full_name='org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.identifier', index=0, + number=1, type=12, cpp_type=9, label=1, + has_default_value=False, default_value=b"", + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=15535, + serialized_end=15574, +) + +_GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0 = _descriptor.Descriptor( + name='GetContestedResourcesResponseV0', + full_name='org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='contested_resources', full_name='org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.contested_resources', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='proof', full_name='org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.proof', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='metadata', full_name='org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.metadata', index=2, + number=3, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[_GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0_CONTESTEDRESOURCES, _GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0_CONTESTEDRESOURCE, ], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='result', full_name='org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.result', + index=0, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + ], + serialized_start=15058, + serialized_end=15584, +) + +_GETCONTESTEDRESOURCESRESPONSE = _descriptor.Descriptor( + name='GetContestedResourcesResponse', + full_name='org.dash.platform.dapi.v0.GetContestedResourcesResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='v0', full_name='org.dash.platform.dapi.v0.GetContestedResourcesResponse.v0', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[_GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0, ], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='version', full_name='org.dash.platform.dapi.v0.GetContestedResourcesResponse.version', + index=0, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + ], + serialized_start=14920, + serialized_end=15595, +) + + +_GETCONTESTEDRESOURCEVOTESTATEREQUEST_GETCONTESTEDRESOURCEVOTESTATEREQUESTV0 = _descriptor.Descriptor( + name='GetContestedResourceVoteStateRequestV0', + full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='prove', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prove', index=0, + number=1, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='resource_path', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.resource_path', index=1, + number=2, type=12, cpp_type=9, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='contested_resource', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.contested_resource', index=2, + number=3, type=12, cpp_type=9, label=1, + has_default_value=False, default_value=b"", + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='start_identifier', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.start_identifier', index=3, + number=4, type=12, cpp_type=9, label=1, + has_default_value=False, default_value=b"", + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='count', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.count', index=4, + number=5, type=13, cpp_type=3, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='ascending', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.ascending', index=5, + number=6, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='_start_identifier', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0._start_identifier', + index=0, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + _descriptor.OneofDescriptor( + name='_count', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0._count', + index=1, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + _descriptor.OneofDescriptor( + name='_ascending', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0._ascending', + index=2, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + ], + serialized_start=15757, + serialized_end=15983, +) + +_GETCONTESTEDRESOURCEVOTESTATEREQUEST = _descriptor.Descriptor( + name='GetContestedResourceVoteStateRequest', + full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='v0', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.v0', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[_GETCONTESTEDRESOURCEVOTESTATEREQUEST_GETCONTESTEDRESOURCEVOTESTATEREQUESTV0, ], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='version', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.version', + index=0, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + ], + serialized_start=15598, + serialized_end=15994, +) + + +_GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0_CONTESTEDRESOURCECONTENDERS = _descriptor.Descriptor( + name='ContestedResourceContenders', + full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='contenders', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.contenders', index=0, + number=1, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='finished_results', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.finished_results', index=1, + number=2, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=16494, + serialized_end=16686, +) + +_GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0_CONTENDER = _descriptor.Descriptor( + name='Contender', + full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='identifier', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.identifier', index=0, + number=1, type=12, cpp_type=9, label=1, + has_default_value=False, default_value=b"", + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='vote_count', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.vote_count', index=1, + number=2, type=13, cpp_type=3, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=16688, + serialized_end=16739, +) + +_GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0 = _descriptor.Descriptor( + name='GetContestedResourceVoteStateResponseV0', + full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='contested_resource_contenders', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.contested_resource_contenders', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='proof', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.proof', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='metadata', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.metadata', index=2, + number=3, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[_GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0_CONTESTEDRESOURCECONTENDERS, _GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0_CONTENDER, ], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='result', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.result', + index=0, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + ], + serialized_start=16159, + serialized_end=16749, +) + +_GETCONTESTEDRESOURCEVOTESTATERESPONSE = _descriptor.Descriptor( + name='GetContestedResourceVoteStateResponse', + full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='v0', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.v0', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[_GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0, ], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='version', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.version', + index=0, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + ], + serialized_start=15997, + serialized_end=16760, +) + + +_GETCONTESTEDRESOURCEVOTESTATUSREQUEST_GETCONTESTEDRESOURCEVOTESTATUSREQUESTV0 = _descriptor.Descriptor( + name='GetContestedResourceVoteStatusRequestV0', + full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='prove', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prove', index=0, + number=1, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='resource_path', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.resource_path', index=1, + number=2, type=12, cpp_type=9, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='resource_identifier', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.resource_identifier', index=2, + number=3, type=12, cpp_type=9, label=1, + has_default_value=False, default_value=b"", + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='voter_identifier', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.voter_identifier', index=3, + number=4, type=12, cpp_type=9, label=1, + has_default_value=False, default_value=b"", + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='count', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.count', index=4, + number=5, type=13, cpp_type=3, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='ascending', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.ascending', index=5, + number=6, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='_voter_identifier', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0._voter_identifier', + index=0, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + _descriptor.OneofDescriptor( + name='_count', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0._count', + index=1, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + _descriptor.OneofDescriptor( + name='_ascending', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0._ascending', + index=2, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + ], + serialized_start=16925, + serialized_end=17153, +) + +_GETCONTESTEDRESOURCEVOTESTATUSREQUEST = _descriptor.Descriptor( + name='GetContestedResourceVoteStatusRequest', + full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='v0', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.v0', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[_GETCONTESTEDRESOURCEVOTESTATUSREQUEST_GETCONTESTEDRESOURCEVOTESTATUSREQUESTV0, ], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='version', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.version', + index=0, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + ], + serialized_start=16763, + serialized_end=17164, +) + + +_GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0_CONTESTEDRESOURCEVOTERS = _descriptor.Descriptor( + name='ContestedResourceVoters', + full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='voters', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.voters', index=0, + number=1, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='finished_results', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.finished_results', index=1, + number=2, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=17662, + serialized_end=17844, +) + +_GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0_VOTER = _descriptor.Descriptor( + name='Voter', + full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='identifier', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.identifier', index=0, + number=1, type=12, cpp_type=9, label=1, + has_default_value=False, default_value=b"", + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=17846, + serialized_end=17873, +) + +_GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0 = _descriptor.Descriptor( + name='GetContestedResourceVoteStatusResponseV0', + full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='contested_resource_voters', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.contested_resource_voters', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='proof', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.proof', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='metadata', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.metadata', index=2, + number=3, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[_GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0_CONTESTEDRESOURCEVOTERS, _GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0_VOTER, ], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='result', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.result', + index=0, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + ], + serialized_start=17332, + serialized_end=17883, +) + +_GETCONTESTEDRESOURCEVOTESTATUSRESPONSE = _descriptor.Descriptor( + name='GetContestedResourceVoteStatusResponse', + full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='v0', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.v0', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[_GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0, ], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='version', full_name='org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.version', + index=0, containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[]), + ], + serialized_start=17167, + serialized_end=17894, +) + _GETIDENTITYREQUEST_GETIDENTITYREQUESTV0.containing_type = _GETIDENTITYREQUEST _GETIDENTITYREQUEST.fields_by_name['v0'].message_type = _GETIDENTITYREQUEST_GETIDENTITYREQUESTV0 _GETIDENTITYREQUEST.oneofs_by_name['version'].fields.append( @@ -4638,6 +5460,99 @@ _GETEPOCHSINFORESPONSE.oneofs_by_name['version'].fields.append( _GETEPOCHSINFORESPONSE.fields_by_name['v0']) _GETEPOCHSINFORESPONSE.fields_by_name['v0'].containing_oneof = _GETEPOCHSINFORESPONSE.oneofs_by_name['version'] +_GETCONTESTEDRESOURCESREQUEST_GETCONTESTEDRESOURCESREQUESTV0.containing_type = _GETCONTESTEDRESOURCESREQUEST +_GETCONTESTEDRESOURCESREQUEST_GETCONTESTEDRESOURCESREQUESTV0.oneofs_by_name['_start_contested_resource_identifier'].fields.append( + _GETCONTESTEDRESOURCESREQUEST_GETCONTESTEDRESOURCESREQUESTV0.fields_by_name['start_contested_resource_identifier']) +_GETCONTESTEDRESOURCESREQUEST_GETCONTESTEDRESOURCESREQUESTV0.fields_by_name['start_contested_resource_identifier'].containing_oneof = _GETCONTESTEDRESOURCESREQUEST_GETCONTESTEDRESOURCESREQUESTV0.oneofs_by_name['_start_contested_resource_identifier'] +_GETCONTESTEDRESOURCESREQUEST_GETCONTESTEDRESOURCESREQUESTV0.oneofs_by_name['_count'].fields.append( + _GETCONTESTEDRESOURCESREQUEST_GETCONTESTEDRESOURCESREQUESTV0.fields_by_name['count']) +_GETCONTESTEDRESOURCESREQUEST_GETCONTESTEDRESOURCESREQUESTV0.fields_by_name['count'].containing_oneof = _GETCONTESTEDRESOURCESREQUEST_GETCONTESTEDRESOURCESREQUESTV0.oneofs_by_name['_count'] +_GETCONTESTEDRESOURCESREQUEST_GETCONTESTEDRESOURCESREQUESTV0.oneofs_by_name['_ascending'].fields.append( + _GETCONTESTEDRESOURCESREQUEST_GETCONTESTEDRESOURCESREQUESTV0.fields_by_name['ascending']) +_GETCONTESTEDRESOURCESREQUEST_GETCONTESTEDRESOURCESREQUESTV0.fields_by_name['ascending'].containing_oneof = _GETCONTESTEDRESOURCESREQUEST_GETCONTESTEDRESOURCESREQUESTV0.oneofs_by_name['_ascending'] +_GETCONTESTEDRESOURCESREQUEST.fields_by_name['v0'].message_type = _GETCONTESTEDRESOURCESREQUEST_GETCONTESTEDRESOURCESREQUESTV0 +_GETCONTESTEDRESOURCESREQUEST.oneofs_by_name['version'].fields.append( + _GETCONTESTEDRESOURCESREQUEST.fields_by_name['v0']) +_GETCONTESTEDRESOURCESREQUEST.fields_by_name['v0'].containing_oneof = _GETCONTESTEDRESOURCESREQUEST.oneofs_by_name['version'] +_GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0_CONTESTEDRESOURCES.fields_by_name['contested_resources'].message_type = _GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0_CONTESTEDRESOURCE +_GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0_CONTESTEDRESOURCES.containing_type = _GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0 +_GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0_CONTESTEDRESOURCE.containing_type = _GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0 +_GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0.fields_by_name['contested_resources'].message_type = _GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0_CONTESTEDRESOURCES +_GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0.fields_by_name['proof'].message_type = _PROOF +_GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0.fields_by_name['metadata'].message_type = _RESPONSEMETADATA +_GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0.containing_type = _GETCONTESTEDRESOURCESRESPONSE +_GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0.oneofs_by_name['result'].fields.append( + _GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0.fields_by_name['contested_resources']) +_GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0.fields_by_name['contested_resources'].containing_oneof = _GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0.oneofs_by_name['result'] +_GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0.oneofs_by_name['result'].fields.append( + _GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0.fields_by_name['proof']) +_GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0.fields_by_name['proof'].containing_oneof = _GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0.oneofs_by_name['result'] +_GETCONTESTEDRESOURCESRESPONSE.fields_by_name['v0'].message_type = _GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0 +_GETCONTESTEDRESOURCESRESPONSE.oneofs_by_name['version'].fields.append( + _GETCONTESTEDRESOURCESRESPONSE.fields_by_name['v0']) +_GETCONTESTEDRESOURCESRESPONSE.fields_by_name['v0'].containing_oneof = _GETCONTESTEDRESOURCESRESPONSE.oneofs_by_name['version'] +_GETCONTESTEDRESOURCEVOTESTATEREQUEST_GETCONTESTEDRESOURCEVOTESTATEREQUESTV0.containing_type = _GETCONTESTEDRESOURCEVOTESTATEREQUEST +_GETCONTESTEDRESOURCEVOTESTATEREQUEST_GETCONTESTEDRESOURCEVOTESTATEREQUESTV0.oneofs_by_name['_start_identifier'].fields.append( + _GETCONTESTEDRESOURCEVOTESTATEREQUEST_GETCONTESTEDRESOURCEVOTESTATEREQUESTV0.fields_by_name['start_identifier']) +_GETCONTESTEDRESOURCEVOTESTATEREQUEST_GETCONTESTEDRESOURCEVOTESTATEREQUESTV0.fields_by_name['start_identifier'].containing_oneof = _GETCONTESTEDRESOURCEVOTESTATEREQUEST_GETCONTESTEDRESOURCEVOTESTATEREQUESTV0.oneofs_by_name['_start_identifier'] +_GETCONTESTEDRESOURCEVOTESTATEREQUEST_GETCONTESTEDRESOURCEVOTESTATEREQUESTV0.oneofs_by_name['_count'].fields.append( + _GETCONTESTEDRESOURCEVOTESTATEREQUEST_GETCONTESTEDRESOURCEVOTESTATEREQUESTV0.fields_by_name['count']) +_GETCONTESTEDRESOURCEVOTESTATEREQUEST_GETCONTESTEDRESOURCEVOTESTATEREQUESTV0.fields_by_name['count'].containing_oneof = _GETCONTESTEDRESOURCEVOTESTATEREQUEST_GETCONTESTEDRESOURCEVOTESTATEREQUESTV0.oneofs_by_name['_count'] +_GETCONTESTEDRESOURCEVOTESTATEREQUEST_GETCONTESTEDRESOURCEVOTESTATEREQUESTV0.oneofs_by_name['_ascending'].fields.append( + _GETCONTESTEDRESOURCEVOTESTATEREQUEST_GETCONTESTEDRESOURCEVOTESTATEREQUESTV0.fields_by_name['ascending']) +_GETCONTESTEDRESOURCEVOTESTATEREQUEST_GETCONTESTEDRESOURCEVOTESTATEREQUESTV0.fields_by_name['ascending'].containing_oneof = _GETCONTESTEDRESOURCEVOTESTATEREQUEST_GETCONTESTEDRESOURCEVOTESTATEREQUESTV0.oneofs_by_name['_ascending'] +_GETCONTESTEDRESOURCEVOTESTATEREQUEST.fields_by_name['v0'].message_type = _GETCONTESTEDRESOURCEVOTESTATEREQUEST_GETCONTESTEDRESOURCEVOTESTATEREQUESTV0 +_GETCONTESTEDRESOURCEVOTESTATEREQUEST.oneofs_by_name['version'].fields.append( + _GETCONTESTEDRESOURCEVOTESTATEREQUEST.fields_by_name['v0']) +_GETCONTESTEDRESOURCEVOTESTATEREQUEST.fields_by_name['v0'].containing_oneof = _GETCONTESTEDRESOURCEVOTESTATEREQUEST.oneofs_by_name['version'] +_GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0_CONTESTEDRESOURCECONTENDERS.fields_by_name['contenders'].message_type = _GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0_CONTENDER +_GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0_CONTESTEDRESOURCECONTENDERS.containing_type = _GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0 +_GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0_CONTENDER.containing_type = _GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0 +_GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0.fields_by_name['contested_resource_contenders'].message_type = _GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0_CONTESTEDRESOURCECONTENDERS +_GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0.fields_by_name['proof'].message_type = _PROOF +_GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0.fields_by_name['metadata'].message_type = _RESPONSEMETADATA +_GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0.containing_type = _GETCONTESTEDRESOURCEVOTESTATERESPONSE +_GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0.oneofs_by_name['result'].fields.append( + _GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0.fields_by_name['contested_resource_contenders']) +_GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0.fields_by_name['contested_resource_contenders'].containing_oneof = _GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0.oneofs_by_name['result'] +_GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0.oneofs_by_name['result'].fields.append( + _GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0.fields_by_name['proof']) +_GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0.fields_by_name['proof'].containing_oneof = _GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0.oneofs_by_name['result'] +_GETCONTESTEDRESOURCEVOTESTATERESPONSE.fields_by_name['v0'].message_type = _GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0 +_GETCONTESTEDRESOURCEVOTESTATERESPONSE.oneofs_by_name['version'].fields.append( + _GETCONTESTEDRESOURCEVOTESTATERESPONSE.fields_by_name['v0']) +_GETCONTESTEDRESOURCEVOTESTATERESPONSE.fields_by_name['v0'].containing_oneof = _GETCONTESTEDRESOURCEVOTESTATERESPONSE.oneofs_by_name['version'] +_GETCONTESTEDRESOURCEVOTESTATUSREQUEST_GETCONTESTEDRESOURCEVOTESTATUSREQUESTV0.containing_type = _GETCONTESTEDRESOURCEVOTESTATUSREQUEST +_GETCONTESTEDRESOURCEVOTESTATUSREQUEST_GETCONTESTEDRESOURCEVOTESTATUSREQUESTV0.oneofs_by_name['_voter_identifier'].fields.append( + _GETCONTESTEDRESOURCEVOTESTATUSREQUEST_GETCONTESTEDRESOURCEVOTESTATUSREQUESTV0.fields_by_name['voter_identifier']) +_GETCONTESTEDRESOURCEVOTESTATUSREQUEST_GETCONTESTEDRESOURCEVOTESTATUSREQUESTV0.fields_by_name['voter_identifier'].containing_oneof = _GETCONTESTEDRESOURCEVOTESTATUSREQUEST_GETCONTESTEDRESOURCEVOTESTATUSREQUESTV0.oneofs_by_name['_voter_identifier'] +_GETCONTESTEDRESOURCEVOTESTATUSREQUEST_GETCONTESTEDRESOURCEVOTESTATUSREQUESTV0.oneofs_by_name['_count'].fields.append( + _GETCONTESTEDRESOURCEVOTESTATUSREQUEST_GETCONTESTEDRESOURCEVOTESTATUSREQUESTV0.fields_by_name['count']) +_GETCONTESTEDRESOURCEVOTESTATUSREQUEST_GETCONTESTEDRESOURCEVOTESTATUSREQUESTV0.fields_by_name['count'].containing_oneof = _GETCONTESTEDRESOURCEVOTESTATUSREQUEST_GETCONTESTEDRESOURCEVOTESTATUSREQUESTV0.oneofs_by_name['_count'] +_GETCONTESTEDRESOURCEVOTESTATUSREQUEST_GETCONTESTEDRESOURCEVOTESTATUSREQUESTV0.oneofs_by_name['_ascending'].fields.append( + _GETCONTESTEDRESOURCEVOTESTATUSREQUEST_GETCONTESTEDRESOURCEVOTESTATUSREQUESTV0.fields_by_name['ascending']) +_GETCONTESTEDRESOURCEVOTESTATUSREQUEST_GETCONTESTEDRESOURCEVOTESTATUSREQUESTV0.fields_by_name['ascending'].containing_oneof = _GETCONTESTEDRESOURCEVOTESTATUSREQUEST_GETCONTESTEDRESOURCEVOTESTATUSREQUESTV0.oneofs_by_name['_ascending'] +_GETCONTESTEDRESOURCEVOTESTATUSREQUEST.fields_by_name['v0'].message_type = _GETCONTESTEDRESOURCEVOTESTATUSREQUEST_GETCONTESTEDRESOURCEVOTESTATUSREQUESTV0 +_GETCONTESTEDRESOURCEVOTESTATUSREQUEST.oneofs_by_name['version'].fields.append( + _GETCONTESTEDRESOURCEVOTESTATUSREQUEST.fields_by_name['v0']) +_GETCONTESTEDRESOURCEVOTESTATUSREQUEST.fields_by_name['v0'].containing_oneof = _GETCONTESTEDRESOURCEVOTESTATUSREQUEST.oneofs_by_name['version'] +_GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0_CONTESTEDRESOURCEVOTERS.fields_by_name['voters'].message_type = _GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0_VOTER +_GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0_CONTESTEDRESOURCEVOTERS.containing_type = _GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0 +_GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0_VOTER.containing_type = _GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0 +_GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0.fields_by_name['contested_resource_voters'].message_type = _GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0_CONTESTEDRESOURCEVOTERS +_GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0.fields_by_name['proof'].message_type = _PROOF +_GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0.fields_by_name['metadata'].message_type = _RESPONSEMETADATA +_GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0.containing_type = _GETCONTESTEDRESOURCEVOTESTATUSRESPONSE +_GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0.oneofs_by_name['result'].fields.append( + _GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0.fields_by_name['contested_resource_voters']) +_GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0.fields_by_name['contested_resource_voters'].containing_oneof = _GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0.oneofs_by_name['result'] +_GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0.oneofs_by_name['result'].fields.append( + _GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0.fields_by_name['proof']) +_GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0.fields_by_name['proof'].containing_oneof = _GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0.oneofs_by_name['result'] +_GETCONTESTEDRESOURCEVOTESTATUSRESPONSE.fields_by_name['v0'].message_type = _GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0 +_GETCONTESTEDRESOURCEVOTESTATUSRESPONSE.oneofs_by_name['version'].fields.append( + _GETCONTESTEDRESOURCEVOTESTATUSRESPONSE.fields_by_name['v0']) +_GETCONTESTEDRESOURCEVOTESTATUSRESPONSE.fields_by_name['v0'].containing_oneof = _GETCONTESTEDRESOURCEVOTESTATUSRESPONSE.oneofs_by_name['version'] DESCRIPTOR.message_types_by_name['Proof'] = _PROOF DESCRIPTOR.message_types_by_name['ResponseMetadata'] = _RESPONSEMETADATA DESCRIPTOR.message_types_by_name['StateTransitionBroadcastError'] = _STATETRANSITIONBROADCASTERROR @@ -4682,6 +5597,12 @@ DESCRIPTOR.message_types_by_name['GetProtocolVersionUpgradeVoteStatusResponse'] = _GETPROTOCOLVERSIONUPGRADEVOTESTATUSRESPONSE DESCRIPTOR.message_types_by_name['GetEpochsInfoRequest'] = _GETEPOCHSINFOREQUEST DESCRIPTOR.message_types_by_name['GetEpochsInfoResponse'] = _GETEPOCHSINFORESPONSE +DESCRIPTOR.message_types_by_name['GetContestedResourcesRequest'] = _GETCONTESTEDRESOURCESREQUEST +DESCRIPTOR.message_types_by_name['GetContestedResourcesResponse'] = _GETCONTESTEDRESOURCESRESPONSE +DESCRIPTOR.message_types_by_name['GetContestedResourceVoteStateRequest'] = _GETCONTESTEDRESOURCEVOTESTATEREQUEST +DESCRIPTOR.message_types_by_name['GetContestedResourceVoteStateResponse'] = _GETCONTESTEDRESOURCEVOTESTATERESPONSE +DESCRIPTOR.message_types_by_name['GetContestedResourceVoteStatusRequest'] = _GETCONTESTEDRESOURCEVOTESTATUSREQUEST +DESCRIPTOR.message_types_by_name['GetContestedResourceVoteStatusResponse'] = _GETCONTESTEDRESOURCEVOTESTATUSRESPONSE _sym_db.RegisterFileDescriptor(DESCRIPTOR) Proof = _reflection.GeneratedProtocolMessageType('Proof', (_message.Message,), { @@ -5464,6 +6385,144 @@ _sym_db.RegisterMessage(GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos) _sym_db.RegisterMessage(GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo) +GetContestedResourcesRequest = _reflection.GeneratedProtocolMessageType('GetContestedResourcesRequest', (_message.Message,), { + + 'GetContestedResourcesRequestV0' : _reflection.GeneratedProtocolMessageType('GetContestedResourcesRequestV0', (_message.Message,), { + 'DESCRIPTOR' : _GETCONTESTEDRESOURCESREQUEST_GETCONTESTEDRESOURCESREQUESTV0, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0) + }) + , + 'DESCRIPTOR' : _GETCONTESTEDRESOURCESREQUEST, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetContestedResourcesRequest) + }) +_sym_db.RegisterMessage(GetContestedResourcesRequest) +_sym_db.RegisterMessage(GetContestedResourcesRequest.GetContestedResourcesRequestV0) + +GetContestedResourcesResponse = _reflection.GeneratedProtocolMessageType('GetContestedResourcesResponse', (_message.Message,), { + + 'GetContestedResourcesResponseV0' : _reflection.GeneratedProtocolMessageType('GetContestedResourcesResponseV0', (_message.Message,), { + + 'ContestedResources' : _reflection.GeneratedProtocolMessageType('ContestedResources', (_message.Message,), { + 'DESCRIPTOR' : _GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0_CONTESTEDRESOURCES, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources) + }) + , + + 'ContestedResource' : _reflection.GeneratedProtocolMessageType('ContestedResource', (_message.Message,), { + 'DESCRIPTOR' : _GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0_CONTESTEDRESOURCE, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource) + }) + , + 'DESCRIPTOR' : _GETCONTESTEDRESOURCESRESPONSE_GETCONTESTEDRESOURCESRESPONSEV0, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0) + }) + , + 'DESCRIPTOR' : _GETCONTESTEDRESOURCESRESPONSE, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetContestedResourcesResponse) + }) +_sym_db.RegisterMessage(GetContestedResourcesResponse) +_sym_db.RegisterMessage(GetContestedResourcesResponse.GetContestedResourcesResponseV0) +_sym_db.RegisterMessage(GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources) +_sym_db.RegisterMessage(GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource) + +GetContestedResourceVoteStateRequest = _reflection.GeneratedProtocolMessageType('GetContestedResourceVoteStateRequest', (_message.Message,), { + + 'GetContestedResourceVoteStateRequestV0' : _reflection.GeneratedProtocolMessageType('GetContestedResourceVoteStateRequestV0', (_message.Message,), { + 'DESCRIPTOR' : _GETCONTESTEDRESOURCEVOTESTATEREQUEST_GETCONTESTEDRESOURCEVOTESTATEREQUESTV0, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0) + }) + , + 'DESCRIPTOR' : _GETCONTESTEDRESOURCEVOTESTATEREQUEST, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest) + }) +_sym_db.RegisterMessage(GetContestedResourceVoteStateRequest) +_sym_db.RegisterMessage(GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0) + +GetContestedResourceVoteStateResponse = _reflection.GeneratedProtocolMessageType('GetContestedResourceVoteStateResponse', (_message.Message,), { + + 'GetContestedResourceVoteStateResponseV0' : _reflection.GeneratedProtocolMessageType('GetContestedResourceVoteStateResponseV0', (_message.Message,), { + + 'ContestedResourceContenders' : _reflection.GeneratedProtocolMessageType('ContestedResourceContenders', (_message.Message,), { + 'DESCRIPTOR' : _GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0_CONTESTEDRESOURCECONTENDERS, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders) + }) + , + + 'Contender' : _reflection.GeneratedProtocolMessageType('Contender', (_message.Message,), { + 'DESCRIPTOR' : _GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0_CONTENDER, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender) + }) + , + 'DESCRIPTOR' : _GETCONTESTEDRESOURCEVOTESTATERESPONSE_GETCONTESTEDRESOURCEVOTESTATERESPONSEV0, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0) + }) + , + 'DESCRIPTOR' : _GETCONTESTEDRESOURCEVOTESTATERESPONSE, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse) + }) +_sym_db.RegisterMessage(GetContestedResourceVoteStateResponse) +_sym_db.RegisterMessage(GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0) +_sym_db.RegisterMessage(GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders) +_sym_db.RegisterMessage(GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender) + +GetContestedResourceVoteStatusRequest = _reflection.GeneratedProtocolMessageType('GetContestedResourceVoteStatusRequest', (_message.Message,), { + + 'GetContestedResourceVoteStatusRequestV0' : _reflection.GeneratedProtocolMessageType('GetContestedResourceVoteStatusRequestV0', (_message.Message,), { + 'DESCRIPTOR' : _GETCONTESTEDRESOURCEVOTESTATUSREQUEST_GETCONTESTEDRESOURCEVOTESTATUSREQUESTV0, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0) + }) + , + 'DESCRIPTOR' : _GETCONTESTEDRESOURCEVOTESTATUSREQUEST, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest) + }) +_sym_db.RegisterMessage(GetContestedResourceVoteStatusRequest) +_sym_db.RegisterMessage(GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0) + +GetContestedResourceVoteStatusResponse = _reflection.GeneratedProtocolMessageType('GetContestedResourceVoteStatusResponse', (_message.Message,), { + + 'GetContestedResourceVoteStatusResponseV0' : _reflection.GeneratedProtocolMessageType('GetContestedResourceVoteStatusResponseV0', (_message.Message,), { + + 'ContestedResourceVoters' : _reflection.GeneratedProtocolMessageType('ContestedResourceVoters', (_message.Message,), { + 'DESCRIPTOR' : _GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0_CONTESTEDRESOURCEVOTERS, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters) + }) + , + + 'Voter' : _reflection.GeneratedProtocolMessageType('Voter', (_message.Message,), { + 'DESCRIPTOR' : _GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0_VOTER, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter) + }) + , + 'DESCRIPTOR' : _GETCONTESTEDRESOURCEVOTESTATUSRESPONSE_GETCONTESTEDRESOURCEVOTESTATUSRESPONSEV0, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0) + }) + , + 'DESCRIPTOR' : _GETCONTESTEDRESOURCEVOTESTATUSRESPONSE, + '__module__' : 'platform_pb2' + # @@protoc_insertion_point(class_scope:org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse) + }) +_sym_db.RegisterMessage(GetContestedResourceVoteStatusResponse) +_sym_db.RegisterMessage(GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0) +_sym_db.RegisterMessage(GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters) +_sym_db.RegisterMessage(GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter) + _SEARCHKEY_PURPOSEMAPENTRY._options = None _SECURITYLEVELMAP_SECURITYLEVELMAPENTRY._options = None @@ -5475,8 +6534,8 @@ index=0, serialized_options=None, create_key=_descriptor._internal_create_key, - serialized_start=14543, - serialized_end=17041, + serialized_start=17897, + serialized_end=20869, methods=[ _descriptor.MethodDescriptor( name='broadcastStateTransition', @@ -5658,6 +6717,36 @@ serialized_options=None, create_key=_descriptor._internal_create_key, ), + _descriptor.MethodDescriptor( + name='getContestedResources', + full_name='org.dash.platform.dapi.v0.Platform.getContestedResources', + index=18, + containing_service=None, + input_type=_GETCONTESTEDRESOURCESREQUEST, + output_type=_GETCONTESTEDRESOURCESRESPONSE, + serialized_options=None, + create_key=_descriptor._internal_create_key, + ), + _descriptor.MethodDescriptor( + name='getContestedResourceVoteState', + full_name='org.dash.platform.dapi.v0.Platform.getContestedResourceVoteState', + index=19, + containing_service=None, + input_type=_GETCONTESTEDRESOURCEVOTESTATEREQUEST, + output_type=_GETCONTESTEDRESOURCEVOTESTATERESPONSE, + serialized_options=None, + create_key=_descriptor._internal_create_key, + ), + _descriptor.MethodDescriptor( + name='getContestedResourceVoteStatus', + full_name='org.dash.platform.dapi.v0.Platform.getContestedResourceVoteStatus', + index=20, + containing_service=None, + input_type=_GETCONTESTEDRESOURCEVOTESTATUSREQUEST, + output_type=_GETCONTESTEDRESOURCEVOTESTATUSRESPONSE, + serialized_options=None, + create_key=_descriptor._internal_create_key, + ), ]) _sym_db.RegisterServiceDescriptor(_PLATFORM) diff --git a/packages/dapi-grpc/clients/platform/v0/python/platform_pb2_grpc.py b/packages/dapi-grpc/clients/platform/v0/python/platform_pb2_grpc.py index a28f5122e3..7022cabab0 100644 --- a/packages/dapi-grpc/clients/platform/v0/python/platform_pb2_grpc.py +++ b/packages/dapi-grpc/clients/platform/v0/python/platform_pb2_grpc.py @@ -104,6 +104,21 @@ def __init__(self, channel): request_serializer=platform__pb2.GetEpochsInfoRequest.SerializeToString, response_deserializer=platform__pb2.GetEpochsInfoResponse.FromString, ) + self.getContestedResources = channel.unary_unary( + '/org.dash.platform.dapi.v0.Platform/getContestedResources', + request_serializer=platform__pb2.GetContestedResourcesRequest.SerializeToString, + response_deserializer=platform__pb2.GetContestedResourcesResponse.FromString, + ) + self.getContestedResourceVoteState = channel.unary_unary( + '/org.dash.platform.dapi.v0.Platform/getContestedResourceVoteState', + request_serializer=platform__pb2.GetContestedResourceVoteStateRequest.SerializeToString, + response_deserializer=platform__pb2.GetContestedResourceVoteStateResponse.FromString, + ) + self.getContestedResourceVoteStatus = channel.unary_unary( + '/org.dash.platform.dapi.v0.Platform/getContestedResourceVoteStatus', + request_serializer=platform__pb2.GetContestedResourceVoteStatusRequest.SerializeToString, + response_deserializer=platform__pb2.GetContestedResourceVoteStatusResponse.FromString, + ) class PlatformServicer(object): @@ -217,6 +232,24 @@ def getEpochsInfo(self, request, context): context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') + def getContestedResources(self, request, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def getContestedResourceVoteState(self, request, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def getContestedResourceVoteStatus(self, request, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + def add_PlatformServicer_to_server(servicer, server): rpc_method_handlers = { @@ -310,6 +343,21 @@ def add_PlatformServicer_to_server(servicer, server): request_deserializer=platform__pb2.GetEpochsInfoRequest.FromString, response_serializer=platform__pb2.GetEpochsInfoResponse.SerializeToString, ), + 'getContestedResources': grpc.unary_unary_rpc_method_handler( + servicer.getContestedResources, + request_deserializer=platform__pb2.GetContestedResourcesRequest.FromString, + response_serializer=platform__pb2.GetContestedResourcesResponse.SerializeToString, + ), + 'getContestedResourceVoteState': grpc.unary_unary_rpc_method_handler( + servicer.getContestedResourceVoteState, + request_deserializer=platform__pb2.GetContestedResourceVoteStateRequest.FromString, + response_serializer=platform__pb2.GetContestedResourceVoteStateResponse.SerializeToString, + ), + 'getContestedResourceVoteStatus': grpc.unary_unary_rpc_method_handler( + servicer.getContestedResourceVoteStatus, + request_deserializer=platform__pb2.GetContestedResourceVoteStatusRequest.FromString, + response_serializer=platform__pb2.GetContestedResourceVoteStatusResponse.SerializeToString, + ), } generic_handler = grpc.method_handlers_generic_handler( 'org.dash.platform.dapi.v0.Platform', rpc_method_handlers) @@ -625,3 +673,54 @@ def getEpochsInfo(request, platform__pb2.GetEpochsInfoResponse.FromString, options, channel_credentials, insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def getContestedResources(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/org.dash.platform.dapi.v0.Platform/getContestedResources', + platform__pb2.GetContestedResourcesRequest.SerializeToString, + platform__pb2.GetContestedResourcesResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def getContestedResourceVoteState(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/org.dash.platform.dapi.v0.Platform/getContestedResourceVoteState', + platform__pb2.GetContestedResourceVoteStateRequest.SerializeToString, + platform__pb2.GetContestedResourceVoteStateResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def getContestedResourceVoteStatus(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/org.dash.platform.dapi.v0.Platform/getContestedResourceVoteStatus', + platform__pb2.GetContestedResourceVoteStatusRequest.SerializeToString, + platform__pb2.GetContestedResourceVoteStatusResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts b/packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts index 9ff5ae3c99..3d754cc195 100644 --- a/packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts +++ b/packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts @@ -3051,3 +3051,598 @@ export namespace GetEpochsInfoResponse { } } +export class GetContestedResourcesRequest extends jspb.Message { + hasV0(): boolean; + clearV0(): void; + getV0(): GetContestedResourcesRequest.GetContestedResourcesRequestV0 | undefined; + setV0(value?: GetContestedResourcesRequest.GetContestedResourcesRequestV0): void; + + getVersionCase(): GetContestedResourcesRequest.VersionCase; + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetContestedResourcesRequest.AsObject; + static toObject(includeInstance: boolean, msg: GetContestedResourcesRequest): GetContestedResourcesRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetContestedResourcesRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetContestedResourcesRequest; + static deserializeBinaryFromReader(message: GetContestedResourcesRequest, reader: jspb.BinaryReader): GetContestedResourcesRequest; +} + +export namespace GetContestedResourcesRequest { + export type AsObject = { + v0?: GetContestedResourcesRequest.GetContestedResourcesRequestV0.AsObject, + } + + export class GetContestedResourcesRequestV0 extends jspb.Message { + getProve(): boolean; + setProve(value: boolean): void; + + clearResourcePathList(): void; + getResourcePathList(): Array; + getResourcePathList_asU8(): Array; + getResourcePathList_asB64(): Array; + setResourcePathList(value: Array): void; + addResourcePath(value: Uint8Array | string, index?: number): Uint8Array | string; + + hasStartContestedResourceIdentifier(): boolean; + clearStartContestedResourceIdentifier(): void; + getStartContestedResourceIdentifier(): Uint8Array | string; + getStartContestedResourceIdentifier_asU8(): Uint8Array; + getStartContestedResourceIdentifier_asB64(): string; + setStartContestedResourceIdentifier(value: Uint8Array | string): void; + + hasCount(): boolean; + clearCount(): void; + getCount(): number; + setCount(value: number): void; + + hasAscending(): boolean; + clearAscending(): void; + getAscending(): boolean; + setAscending(value: boolean): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetContestedResourcesRequestV0.AsObject; + static toObject(includeInstance: boolean, msg: GetContestedResourcesRequestV0): GetContestedResourcesRequestV0.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetContestedResourcesRequestV0, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetContestedResourcesRequestV0; + static deserializeBinaryFromReader(message: GetContestedResourcesRequestV0, reader: jspb.BinaryReader): GetContestedResourcesRequestV0; + } + + export namespace GetContestedResourcesRequestV0 { + export type AsObject = { + prove: boolean, + resourcePathList: Array, + startContestedResourceIdentifier: Uint8Array | string, + count: number, + ascending: boolean, + } + } + + export enum VersionCase { + VERSION_NOT_SET = 0, + V0 = 1, + } +} + +export class GetContestedResourcesResponse extends jspb.Message { + hasV0(): boolean; + clearV0(): void; + getV0(): GetContestedResourcesResponse.GetContestedResourcesResponseV0 | undefined; + setV0(value?: GetContestedResourcesResponse.GetContestedResourcesResponseV0): void; + + getVersionCase(): GetContestedResourcesResponse.VersionCase; + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetContestedResourcesResponse.AsObject; + static toObject(includeInstance: boolean, msg: GetContestedResourcesResponse): GetContestedResourcesResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetContestedResourcesResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetContestedResourcesResponse; + static deserializeBinaryFromReader(message: GetContestedResourcesResponse, reader: jspb.BinaryReader): GetContestedResourcesResponse; +} + +export namespace GetContestedResourcesResponse { + export type AsObject = { + v0?: GetContestedResourcesResponse.GetContestedResourcesResponseV0.AsObject, + } + + export class GetContestedResourcesResponseV0 extends jspb.Message { + hasContestedResources(): boolean; + clearContestedResources(): void; + getContestedResources(): GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources | undefined; + setContestedResources(value?: GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources): void; + + hasProof(): boolean; + clearProof(): void; + getProof(): Proof | undefined; + setProof(value?: Proof): void; + + hasMetadata(): boolean; + clearMetadata(): void; + getMetadata(): ResponseMetadata | undefined; + setMetadata(value?: ResponseMetadata): void; + + getResultCase(): GetContestedResourcesResponseV0.ResultCase; + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetContestedResourcesResponseV0.AsObject; + static toObject(includeInstance: boolean, msg: GetContestedResourcesResponseV0): GetContestedResourcesResponseV0.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetContestedResourcesResponseV0, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetContestedResourcesResponseV0; + static deserializeBinaryFromReader(message: GetContestedResourcesResponseV0, reader: jspb.BinaryReader): GetContestedResourcesResponseV0; + } + + export namespace GetContestedResourcesResponseV0 { + export type AsObject = { + contestedResources?: GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.AsObject, + proof?: Proof.AsObject, + metadata?: ResponseMetadata.AsObject, + } + + export class ContestedResources extends jspb.Message { + clearContestedResourcesList(): void; + getContestedResourcesList(): Array; + setContestedResourcesList(value: Array): void; + addContestedResources(value?: GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource, index?: number): GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource; + + getFinishedResults(): boolean; + setFinishedResults(value: boolean): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ContestedResources.AsObject; + static toObject(includeInstance: boolean, msg: ContestedResources): ContestedResources.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: ContestedResources, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ContestedResources; + static deserializeBinaryFromReader(message: ContestedResources, reader: jspb.BinaryReader): ContestedResources; + } + + export namespace ContestedResources { + export type AsObject = { + contestedResourcesList: Array, + finishedResults: boolean, + } + } + + export class ContestedResource extends jspb.Message { + getIdentifier(): Uint8Array | string; + getIdentifier_asU8(): Uint8Array; + getIdentifier_asB64(): string; + setIdentifier(value: Uint8Array | string): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ContestedResource.AsObject; + static toObject(includeInstance: boolean, msg: ContestedResource): ContestedResource.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: ContestedResource, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ContestedResource; + static deserializeBinaryFromReader(message: ContestedResource, reader: jspb.BinaryReader): ContestedResource; + } + + export namespace ContestedResource { + export type AsObject = { + identifier: Uint8Array | string, + } + } + + export enum ResultCase { + RESULT_NOT_SET = 0, + CONTESTED_RESOURCES = 1, + PROOF = 2, + } + } + + export enum VersionCase { + VERSION_NOT_SET = 0, + V0 = 1, + } +} + +export class GetContestedResourceVoteStateRequest extends jspb.Message { + hasV0(): boolean; + clearV0(): void; + getV0(): GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0 | undefined; + setV0(value?: GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0): void; + + getVersionCase(): GetContestedResourceVoteStateRequest.VersionCase; + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetContestedResourceVoteStateRequest.AsObject; + static toObject(includeInstance: boolean, msg: GetContestedResourceVoteStateRequest): GetContestedResourceVoteStateRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetContestedResourceVoteStateRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetContestedResourceVoteStateRequest; + static deserializeBinaryFromReader(message: GetContestedResourceVoteStateRequest, reader: jspb.BinaryReader): GetContestedResourceVoteStateRequest; +} + +export namespace GetContestedResourceVoteStateRequest { + export type AsObject = { + v0?: GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.AsObject, + } + + export class GetContestedResourceVoteStateRequestV0 extends jspb.Message { + getProve(): boolean; + setProve(value: boolean): void; + + clearResourcePathList(): void; + getResourcePathList(): Array; + getResourcePathList_asU8(): Array; + getResourcePathList_asB64(): Array; + setResourcePathList(value: Array): void; + addResourcePath(value: Uint8Array | string, index?: number): Uint8Array | string; + + getContestedResource(): Uint8Array | string; + getContestedResource_asU8(): Uint8Array; + getContestedResource_asB64(): string; + setContestedResource(value: Uint8Array | string): void; + + hasStartIdentifier(): boolean; + clearStartIdentifier(): void; + getStartIdentifier(): Uint8Array | string; + getStartIdentifier_asU8(): Uint8Array; + getStartIdentifier_asB64(): string; + setStartIdentifier(value: Uint8Array | string): void; + + hasCount(): boolean; + clearCount(): void; + getCount(): number; + setCount(value: number): void; + + hasAscending(): boolean; + clearAscending(): void; + getAscending(): boolean; + setAscending(value: boolean): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetContestedResourceVoteStateRequestV0.AsObject; + static toObject(includeInstance: boolean, msg: GetContestedResourceVoteStateRequestV0): GetContestedResourceVoteStateRequestV0.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetContestedResourceVoteStateRequestV0, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetContestedResourceVoteStateRequestV0; + static deserializeBinaryFromReader(message: GetContestedResourceVoteStateRequestV0, reader: jspb.BinaryReader): GetContestedResourceVoteStateRequestV0; + } + + export namespace GetContestedResourceVoteStateRequestV0 { + export type AsObject = { + prove: boolean, + resourcePathList: Array, + contestedResource: Uint8Array | string, + startIdentifier: Uint8Array | string, + count: number, + ascending: boolean, + } + } + + export enum VersionCase { + VERSION_NOT_SET = 0, + V0 = 1, + } +} + +export class GetContestedResourceVoteStateResponse extends jspb.Message { + hasV0(): boolean; + clearV0(): void; + getV0(): GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0 | undefined; + setV0(value?: GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0): void; + + getVersionCase(): GetContestedResourceVoteStateResponse.VersionCase; + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetContestedResourceVoteStateResponse.AsObject; + static toObject(includeInstance: boolean, msg: GetContestedResourceVoteStateResponse): GetContestedResourceVoteStateResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetContestedResourceVoteStateResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetContestedResourceVoteStateResponse; + static deserializeBinaryFromReader(message: GetContestedResourceVoteStateResponse, reader: jspb.BinaryReader): GetContestedResourceVoteStateResponse; +} + +export namespace GetContestedResourceVoteStateResponse { + export type AsObject = { + v0?: GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.AsObject, + } + + export class GetContestedResourceVoteStateResponseV0 extends jspb.Message { + hasContestedResourceContenders(): boolean; + clearContestedResourceContenders(): void; + getContestedResourceContenders(): GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders | undefined; + setContestedResourceContenders(value?: GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders): void; + + hasProof(): boolean; + clearProof(): void; + getProof(): Proof | undefined; + setProof(value?: Proof): void; + + hasMetadata(): boolean; + clearMetadata(): void; + getMetadata(): ResponseMetadata | undefined; + setMetadata(value?: ResponseMetadata): void; + + getResultCase(): GetContestedResourceVoteStateResponseV0.ResultCase; + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetContestedResourceVoteStateResponseV0.AsObject; + static toObject(includeInstance: boolean, msg: GetContestedResourceVoteStateResponseV0): GetContestedResourceVoteStateResponseV0.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetContestedResourceVoteStateResponseV0, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetContestedResourceVoteStateResponseV0; + static deserializeBinaryFromReader(message: GetContestedResourceVoteStateResponseV0, reader: jspb.BinaryReader): GetContestedResourceVoteStateResponseV0; + } + + export namespace GetContestedResourceVoteStateResponseV0 { + export type AsObject = { + contestedResourceContenders?: GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.AsObject, + proof?: Proof.AsObject, + metadata?: ResponseMetadata.AsObject, + } + + export class ContestedResourceContenders extends jspb.Message { + clearContendersList(): void; + getContendersList(): Array; + setContendersList(value: Array): void; + addContenders(value?: GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender, index?: number): GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender; + + getFinishedResults(): boolean; + setFinishedResults(value: boolean): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ContestedResourceContenders.AsObject; + static toObject(includeInstance: boolean, msg: ContestedResourceContenders): ContestedResourceContenders.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: ContestedResourceContenders, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ContestedResourceContenders; + static deserializeBinaryFromReader(message: ContestedResourceContenders, reader: jspb.BinaryReader): ContestedResourceContenders; + } + + export namespace ContestedResourceContenders { + export type AsObject = { + contendersList: Array, + finishedResults: boolean, + } + } + + export class Contender extends jspb.Message { + getIdentifier(): Uint8Array | string; + getIdentifier_asU8(): Uint8Array; + getIdentifier_asB64(): string; + setIdentifier(value: Uint8Array | string): void; + + getVoteCount(): number; + setVoteCount(value: number): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): Contender.AsObject; + static toObject(includeInstance: boolean, msg: Contender): Contender.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: Contender, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): Contender; + static deserializeBinaryFromReader(message: Contender, reader: jspb.BinaryReader): Contender; + } + + export namespace Contender { + export type AsObject = { + identifier: Uint8Array | string, + voteCount: number, + } + } + + export enum ResultCase { + RESULT_NOT_SET = 0, + CONTESTED_RESOURCE_CONTENDERS = 1, + PROOF = 2, + } + } + + export enum VersionCase { + VERSION_NOT_SET = 0, + V0 = 1, + } +} + +export class GetContestedResourceVoteStatusRequest extends jspb.Message { + hasV0(): boolean; + clearV0(): void; + getV0(): GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0 | undefined; + setV0(value?: GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0): void; + + getVersionCase(): GetContestedResourceVoteStatusRequest.VersionCase; + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetContestedResourceVoteStatusRequest.AsObject; + static toObject(includeInstance: boolean, msg: GetContestedResourceVoteStatusRequest): GetContestedResourceVoteStatusRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetContestedResourceVoteStatusRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetContestedResourceVoteStatusRequest; + static deserializeBinaryFromReader(message: GetContestedResourceVoteStatusRequest, reader: jspb.BinaryReader): GetContestedResourceVoteStatusRequest; +} + +export namespace GetContestedResourceVoteStatusRequest { + export type AsObject = { + v0?: GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.AsObject, + } + + export class GetContestedResourceVoteStatusRequestV0 extends jspb.Message { + getProve(): boolean; + setProve(value: boolean): void; + + clearResourcePathList(): void; + getResourcePathList(): Array; + getResourcePathList_asU8(): Array; + getResourcePathList_asB64(): Array; + setResourcePathList(value: Array): void; + addResourcePath(value: Uint8Array | string, index?: number): Uint8Array | string; + + getResourceIdentifier(): Uint8Array | string; + getResourceIdentifier_asU8(): Uint8Array; + getResourceIdentifier_asB64(): string; + setResourceIdentifier(value: Uint8Array | string): void; + + hasVoterIdentifier(): boolean; + clearVoterIdentifier(): void; + getVoterIdentifier(): Uint8Array | string; + getVoterIdentifier_asU8(): Uint8Array; + getVoterIdentifier_asB64(): string; + setVoterIdentifier(value: Uint8Array | string): void; + + hasCount(): boolean; + clearCount(): void; + getCount(): number; + setCount(value: number): void; + + hasAscending(): boolean; + clearAscending(): void; + getAscending(): boolean; + setAscending(value: boolean): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetContestedResourceVoteStatusRequestV0.AsObject; + static toObject(includeInstance: boolean, msg: GetContestedResourceVoteStatusRequestV0): GetContestedResourceVoteStatusRequestV0.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetContestedResourceVoteStatusRequestV0, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetContestedResourceVoteStatusRequestV0; + static deserializeBinaryFromReader(message: GetContestedResourceVoteStatusRequestV0, reader: jspb.BinaryReader): GetContestedResourceVoteStatusRequestV0; + } + + export namespace GetContestedResourceVoteStatusRequestV0 { + export type AsObject = { + prove: boolean, + resourcePathList: Array, + resourceIdentifier: Uint8Array | string, + voterIdentifier: Uint8Array | string, + count: number, + ascending: boolean, + } + } + + export enum VersionCase { + VERSION_NOT_SET = 0, + V0 = 1, + } +} + +export class GetContestedResourceVoteStatusResponse extends jspb.Message { + hasV0(): boolean; + clearV0(): void; + getV0(): GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0 | undefined; + setV0(value?: GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0): void; + + getVersionCase(): GetContestedResourceVoteStatusResponse.VersionCase; + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetContestedResourceVoteStatusResponse.AsObject; + static toObject(includeInstance: boolean, msg: GetContestedResourceVoteStatusResponse): GetContestedResourceVoteStatusResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetContestedResourceVoteStatusResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetContestedResourceVoteStatusResponse; + static deserializeBinaryFromReader(message: GetContestedResourceVoteStatusResponse, reader: jspb.BinaryReader): GetContestedResourceVoteStatusResponse; +} + +export namespace GetContestedResourceVoteStatusResponse { + export type AsObject = { + v0?: GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.AsObject, + } + + export class GetContestedResourceVoteStatusResponseV0 extends jspb.Message { + hasContestedResourceVoters(): boolean; + clearContestedResourceVoters(): void; + getContestedResourceVoters(): GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters | undefined; + setContestedResourceVoters(value?: GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters): void; + + hasProof(): boolean; + clearProof(): void; + getProof(): Proof | undefined; + setProof(value?: Proof): void; + + hasMetadata(): boolean; + clearMetadata(): void; + getMetadata(): ResponseMetadata | undefined; + setMetadata(value?: ResponseMetadata): void; + + getResultCase(): GetContestedResourceVoteStatusResponseV0.ResultCase; + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): GetContestedResourceVoteStatusResponseV0.AsObject; + static toObject(includeInstance: boolean, msg: GetContestedResourceVoteStatusResponseV0): GetContestedResourceVoteStatusResponseV0.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: GetContestedResourceVoteStatusResponseV0, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): GetContestedResourceVoteStatusResponseV0; + static deserializeBinaryFromReader(message: GetContestedResourceVoteStatusResponseV0, reader: jspb.BinaryReader): GetContestedResourceVoteStatusResponseV0; + } + + export namespace GetContestedResourceVoteStatusResponseV0 { + export type AsObject = { + contestedResourceVoters?: GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.AsObject, + proof?: Proof.AsObject, + metadata?: ResponseMetadata.AsObject, + } + + export class ContestedResourceVoters extends jspb.Message { + clearVotersList(): void; + getVotersList(): Array; + setVotersList(value: Array): void; + addVoters(value?: GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter, index?: number): GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter; + + getFinishedResults(): boolean; + setFinishedResults(value: boolean): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ContestedResourceVoters.AsObject; + static toObject(includeInstance: boolean, msg: ContestedResourceVoters): ContestedResourceVoters.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: ContestedResourceVoters, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ContestedResourceVoters; + static deserializeBinaryFromReader(message: ContestedResourceVoters, reader: jspb.BinaryReader): ContestedResourceVoters; + } + + export namespace ContestedResourceVoters { + export type AsObject = { + votersList: Array, + finishedResults: boolean, + } + } + + export class Voter extends jspb.Message { + getIdentifier(): Uint8Array | string; + getIdentifier_asU8(): Uint8Array; + getIdentifier_asB64(): string; + setIdentifier(value: Uint8Array | string): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): Voter.AsObject; + static toObject(includeInstance: boolean, msg: Voter): Voter.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: Voter, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): Voter; + static deserializeBinaryFromReader(message: Voter, reader: jspb.BinaryReader): Voter; + } + + export namespace Voter { + export type AsObject = { + identifier: Uint8Array | string, + } + } + + export enum ResultCase { + RESULT_NOT_SET = 0, + CONTESTED_RESOURCE_VOTERS = 1, + PROOF = 2, + } + } + + export enum VersionCase { + VERSION_NOT_SET = 0, + V0 = 1, + } +} + diff --git a/packages/dapi-grpc/clients/platform/v0/web/platform_pb.js b/packages/dapi-grpc/clients/platform/v0/web/platform_pb.js index 9d6d3e76cf..3f9e383688 100644 --- a/packages/dapi-grpc/clients/platform/v0/web/platform_pb.js +++ b/packages/dapi-grpc/clients/platform/v0/web/platform_pb.js @@ -32,6 +32,33 @@ goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.Co goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.VersionCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.VersionCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ResultCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.VersionCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.VersionCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ResultCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.VersionCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.VersionCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ResultCase', null, { proto }); +goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.VersionCase', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0', null, { proto }); goog.exportSymbol('proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.VersionCase', null, { proto }); @@ -2297,6 +2324,4590 @@ if (goog.DEBUG && !COMPILED) { */ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.displayName = 'proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo'; } +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.repeatedFields_, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.repeatedFields_, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.repeatedFields_, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.repeatedFields_, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.repeatedFields_, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.oneofGroups_); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.repeatedFields_, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.displayName = 'proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter'; +} + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.Proof.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.Proof} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.Proof.toObject = function(includeInstance, msg) { + var f, obj = { + grovedbProof: msg.getGrovedbProof_asB64(), + quorumHash: msg.getQuorumHash_asB64(), + signature: msg.getSignature_asB64(), + round: jspb.Message.getFieldWithDefault(msg, 4, 0), + blockIdHash: msg.getBlockIdHash_asB64(), + quorumType: jspb.Message.getFieldWithDefault(msg, 6, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.Proof.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.Proof; + return proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.Proof} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setGrovedbProof(value); + break; + case 2: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setQuorumHash(value); + break; + case 3: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setSignature(value); + break; + case 4: + var value = /** @type {number} */ (reader.readUint32()); + msg.setRound(value); + break; + case 5: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setBlockIdHash(value); + break; + case 6: + var value = /** @type {number} */ (reader.readUint32()); + msg.setQuorumType(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.Proof} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getGrovedbProof_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } + f = message.getQuorumHash_asU8(); + if (f.length > 0) { + writer.writeBytes( + 2, + f + ); + } + f = message.getSignature_asU8(); + if (f.length > 0) { + writer.writeBytes( + 3, + f + ); + } + f = message.getRound(); + if (f !== 0) { + writer.writeUint32( + 4, + f + ); + } + f = message.getBlockIdHash_asU8(); + if (f.length > 0) { + writer.writeBytes( + 5, + f + ); + } + f = message.getQuorumType(); + if (f !== 0) { + writer.writeUint32( + 6, + f + ); + } +}; + + +/** + * optional bytes grovedb_proof = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getGrovedbProof = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes grovedb_proof = 1; + * This is a type-conversion wrapper around `getGrovedbProof()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getGrovedbProof_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getGrovedbProof())); +}; + + +/** + * optional bytes grovedb_proof = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getGrovedbProof()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getGrovedbProof_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getGrovedbProof())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.setGrovedbProof = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + +/** + * optional bytes quorum_hash = 2; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getQuorumHash = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * optional bytes quorum_hash = 2; + * This is a type-conversion wrapper around `getQuorumHash()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getQuorumHash_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getQuorumHash())); +}; + + +/** + * optional bytes quorum_hash = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getQuorumHash()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getQuorumHash_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getQuorumHash())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.setQuorumHash = function(value) { + return jspb.Message.setProto3BytesField(this, 2, value); +}; + + +/** + * optional bytes signature = 3; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getSignature = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * optional bytes signature = 3; + * This is a type-conversion wrapper around `getSignature()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getSignature_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getSignature())); +}; + + +/** + * optional bytes signature = 3; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getSignature()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getSignature_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getSignature())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.setSignature = function(value) { + return jspb.Message.setProto3BytesField(this, 3, value); +}; + + +/** + * optional uint32 round = 4; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getRound = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.setRound = function(value) { + return jspb.Message.setProto3IntField(this, 4, value); +}; + + +/** + * optional bytes block_id_hash = 5; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getBlockIdHash = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, "")); +}; + + +/** + * optional bytes block_id_hash = 5; + * This is a type-conversion wrapper around `getBlockIdHash()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getBlockIdHash_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getBlockIdHash())); +}; + + +/** + * optional bytes block_id_hash = 5; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getBlockIdHash()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getBlockIdHash_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getBlockIdHash())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.setBlockIdHash = function(value) { + return jspb.Message.setProto3BytesField(this, 5, value); +}; + + +/** + * optional uint32 quorum_type = 6; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.getQuorumType = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 6, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + */ +proto.org.dash.platform.dapi.v0.Proof.prototype.setQuorumType = function(value) { + return jspb.Message.setProto3IntField(this, 6, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.ResponseMetadata} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject = function(includeInstance, msg) { + var f, obj = { + height: jspb.Message.getFieldWithDefault(msg, 1, 0), + coreChainLockedHeight: jspb.Message.getFieldWithDefault(msg, 2, 0), + epoch: jspb.Message.getFieldWithDefault(msg, 3, 0), + timeMs: jspb.Message.getFieldWithDefault(msg, 4, 0), + protocolVersion: jspb.Message.getFieldWithDefault(msg, 5, 0), + chainId: jspb.Message.getFieldWithDefault(msg, 6, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + return proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.ResponseMetadata} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readUint64()); + msg.setHeight(value); + break; + case 2: + var value = /** @type {number} */ (reader.readUint32()); + msg.setCoreChainLockedHeight(value); + break; + case 3: + var value = /** @type {number} */ (reader.readUint32()); + msg.setEpoch(value); + break; + case 4: + var value = /** @type {number} */ (reader.readUint64()); + msg.setTimeMs(value); + break; + case 5: + var value = /** @type {number} */ (reader.readUint32()); + msg.setProtocolVersion(value); + break; + case 6: + var value = /** @type {string} */ (reader.readString()); + msg.setChainId(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.ResponseMetadata} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getHeight(); + if (f !== 0) { + writer.writeUint64( + 1, + f + ); + } + f = message.getCoreChainLockedHeight(); + if (f !== 0) { + writer.writeUint32( + 2, + f + ); + } + f = message.getEpoch(); + if (f !== 0) { + writer.writeUint32( + 3, + f + ); + } + f = message.getTimeMs(); + if (f !== 0) { + writer.writeUint64( + 4, + f + ); + } + f = message.getProtocolVersion(); + if (f !== 0) { + writer.writeUint32( + 5, + f + ); + } + f = message.getChainId(); + if (f.length > 0) { + writer.writeString( + 6, + f + ); + } +}; + + +/** + * optional uint64 height = 1; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getHeight = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setHeight = function(value) { + return jspb.Message.setProto3IntField(this, 1, value); +}; + + +/** + * optional uint32 core_chain_locked_height = 2; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getCoreChainLockedHeight = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setCoreChainLockedHeight = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); +}; + + +/** + * optional uint32 epoch = 3; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getEpoch = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setEpoch = function(value) { + return jspb.Message.setProto3IntField(this, 3, value); +}; + + +/** + * optional uint64 time_ms = 4; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getTimeMs = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setTimeMs = function(value) { + return jspb.Message.setProto3IntField(this, 4, value); +}; + + +/** + * optional uint32 protocol_version = 5; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getProtocolVersion = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setProtocolVersion = function(value) { + return jspb.Message.setProto3IntField(this, 5, value); +}; + + +/** + * optional string chain_id = 6; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getChainId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, "")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this + */ +proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setChainId = function(value) { + return jspb.Message.setProto3StringField(this, 6, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.toObject = function(includeInstance, msg) { + var f, obj = { + code: jspb.Message.getFieldWithDefault(msg, 1, 0), + message: jspb.Message.getFieldWithDefault(msg, 2, ""), + data: msg.getData_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError; + return proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readUint32()); + msg.setCode(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setMessage(value); + break; + case 3: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setData(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getCode(); + if (f !== 0) { + writer.writeUint32( + 1, + f + ); + } + f = message.getMessage(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getData_asU8(); + if (f.length > 0) { + writer.writeBytes( + 3, + f + ); + } +}; + + +/** + * optional uint32 code = 1; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.getCode = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} returns this + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.setCode = function(value) { + return jspb.Message.setProto3IntField(this, 1, value); +}; + + +/** + * optional string message = 2; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.getMessage = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} returns this + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.setMessage = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional bytes data = 3; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.getData = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * optional bytes data = 3; + * This is a type-conversion wrapper around `getData()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.getData_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getData())); +}; + + +/** + * optional bytes data = 3; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getData()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.getData_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getData())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} returns this + */ +proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.setData = function(value) { + return jspb.Message.setProto3BytesField(this, 3, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.toObject = function(includeInstance, msg) { + var f, obj = { + stateTransition: msg.getStateTransition_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest; + return proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setStateTransition(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStateTransition_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } +}; + + +/** + * optional bytes state_transition = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.getStateTransition = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes state_transition = 1; + * This is a type-conversion wrapper around `getStateTransition()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.getStateTransition_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getStateTransition())); +}; + + +/** + * optional bytes state_transition = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getStateTransition()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.getStateTransition_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getStateTransition())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} returns this + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.setStateTransition = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse; + return proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentityRequest.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityRequest.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityRequest; + return proto.org.dash.platform.dapi.v0.GetIdentityRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentityRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.serializeBinaryToWriter + ); + } +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.toObject = function(includeInstance, msg) { + var f, obj = { + id: msg.getId_asB64(), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0; + return proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setId(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getId_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 2, + f + ); + } +}; + + +/** + * optional bytes id = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes id = 1; + * This is a type-conversion wrapper around `getId()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.getId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getId())); +}; + + +/** + * optional bytes id = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getId()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.getId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getId())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.setId = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + +/** + * optional bool prove = 2; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); +}; + + +/** + * optional GetIdentityRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest; + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.serializeBinaryToWriter + ); + } +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.toObject = function(includeInstance, msg) { + var f, obj = { + id: msg.getId_asB64(), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0; + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setId(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getId_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 2, + f + ); + } +}; + + +/** + * optional bytes id = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes id = 1; + * This is a type-conversion wrapper around `getId()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.getId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getId())); +}; + + +/** + * optional bytes id = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getId()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.getId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getId())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.setId = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + +/** + * optional bool prove = 2; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); +}; + + +/** + * optional GetIdentityBalanceRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest; + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.serializeBinaryToWriter + ); + } +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.toObject = function(includeInstance, msg) { + var f, obj = { + id: msg.getId_asB64(), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0; + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setId(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getId_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 2, + f + ); + } +}; + + +/** + * optional bytes id = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes id = 1; + * This is a type-conversion wrapper around `getId()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.getId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getId())); +}; + + +/** + * optional bytes id = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getId()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.getId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getId())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.setId = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + +/** + * optional bool prove = 2; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); +}; + + +/** + * optional GetIdentityBalanceAndRevisionRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentityResponse.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityResponse.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityResponse; + return proto.org.dash.platform.dapi.v0.GetIdentityResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentityResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.serializeBinaryToWriter + ); + } +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.oneofGroups_ = [[1,2]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + IDENTITY: 1, + PROOF: 2 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.ResultCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.toObject = function(includeInstance, msg) { + var f, obj = { + identity: msg.getIdentity_asB64(), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0; + return proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setIdentity(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeBytes( + 1, + f + ); + } + f = message.getProof(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + ); + } + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + ); + } +}; + + +/** + * optional bytes identity = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getIdentity = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes identity = 1; + * This is a type-conversion wrapper around `getIdentity()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getIdentity_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getIdentity())); +}; + + +/** + * optional bytes identity = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getIdentity()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getIdentity_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getIdentity())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.setIdentity = function(value) { + return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.clearIdentity = function() { + return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.oneofGroups_[0], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.hasIdentity = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional GetIdentityResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityResponse.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesRequest; + return proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.serializeBinaryToWriter + ); + } +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.repeatedFields_ = [1]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.toObject = function(includeInstance, msg) { + var f, obj = { + idsList: msg.getIdsList_asB64(), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0; + return proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.addIds(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getIdsList_asU8(); + if (f.length > 0) { + writer.writeRepeatedBytes( + 1, + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 2, + f + ); + } +}; + + +/** + * repeated bytes ids = 1; + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.getIdsList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); +}; + + +/** + * repeated bytes ids = 1; + * This is a type-conversion wrapper around `getIdsList()` + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.getIdsList_asB64 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsB64( + this.getIdsList())); +}; + + +/** + * repeated bytes ids = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getIdsList()` + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.getIdsList_asU8 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsU8( + this.getIdsList())); +}; + + +/** + * @param {!(Array|Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.setIdsList = function(value) { + return jspb.Message.setField(this, 1, value || []); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.addIds = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 1, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.clearIdsList = function() { + return this.setIdsList([]); +}; + + +/** + * optional bool prove = 2; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); +}; + + +/** + * optional GetIdentitiesRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse; + return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.serializeBinaryToWriter + ); + } +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.toObject = function(includeInstance, msg) { + var f, obj = { + value: msg.getValue_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue; + return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setValue(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getValue_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } +}; + + +/** + * optional bytes value = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.getValue = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes value = 1; + * This is a type-conversion wrapper around `getValue()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.getValue_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getValue())); +}; + + +/** + * optional bytes value = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getValue()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.getValue_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getValue())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.setValue = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.toObject = function(includeInstance, msg) { + var f, obj = { + key: msg.getKey_asB64(), + value: (f = msg.getValue()) && proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry; + return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setKey(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.deserializeBinaryFromReader); + msg.setValue(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getKey_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } + f = message.getValue(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.serializeBinaryToWriter + ); + } +}; + + +/** + * optional bytes key = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.getKey = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes key = 1; + * This is a type-conversion wrapper around `getKey()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.getKey_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getKey())); +}; + + +/** + * optional bytes key = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getKey()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.getKey_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getKey())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.setKey = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + +/** + * optional IdentityValue value = 2; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.getValue = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue, 2)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.setValue = function(value) { + return jspb.Message.setWrapperField(this, 2, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.clearValue = function() { + return this.setValue(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.hasValue = function() { + return jspb.Message.getField(this, 2) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.repeatedFields_ = [1]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.toObject = function(includeInstance, msg) { + var f, obj = { + identityEntriesList: jspb.Message.toObjectList(msg.getIdentityEntriesList(), + proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.toObject, includeInstance) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities; + return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.deserializeBinaryFromReader); + msg.addIdentityEntries(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getIdentityEntriesList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.serializeBinaryToWriter + ); + } +}; + + +/** + * repeated IdentityEntry identity_entries = 1; + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.getIdentityEntriesList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry, 1)); +}; + + +/** + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.setIdentityEntriesList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); +}; + + +/** + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry=} opt_value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.addIdentityEntries = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.clearIdentityEntriesList = function() { + return this.setIdentityEntriesList([]); +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.oneofGroups_ = [[1,2]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + IDENTITIES: 1, + PROOF: 2 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.ResultCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.toObject = function(includeInstance, msg) { + var f, obj = { + identities: (f = msg.getIdentities()) && proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.toObject(includeInstance, f), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0; + return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.deserializeBinaryFromReader); + msg.setIdentities(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getIdentities(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.serializeBinaryToWriter + ); + } + f = message.getProof(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + ); + } + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + ); + } +}; + + +/** + * optional Identities identities = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.getIdentities = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.setIdentities = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.clearIdentities = function() { + return this.setIdentities(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.hasIdentities = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional GetIdentitiesResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.oneofGroups_[0])); +}; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse; + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.serializeBinaryToWriter + ); + } +}; + + + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.oneofGroups_ = [[1,2]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + BALANCE: 1, + PROOF: 2 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.ResultCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.oneofGroups_[0])); +}; @@ -2313,8 +6924,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.Proof.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.toObject(opt_includeInstance, this); }; @@ -2323,18 +6934,15 @@ proto.org.dash.platform.dapi.v0.Proof.prototype.toObject = function(opt_includeI * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.Proof} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.Proof.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - grovedbProof: msg.getGrovedbProof_asB64(), - quorumHash: msg.getQuorumHash_asB64(), - signature: msg.getSignature_asB64(), - round: jspb.Message.getFieldWithDefault(msg, 4, 0), - blockIdHash: msg.getBlockIdHash_asB64(), - quorumType: jspb.Message.getFieldWithDefault(msg, 6, 0) + balance: jspb.Message.getFieldWithDefault(msg, 1, 0), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; if (includeInstance) { @@ -2348,23 +6956,23 @@ proto.org.dash.platform.dapi.v0.Proof.toObject = function(includeInstance, msg) /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.Proof} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} */ -proto.org.dash.platform.dapi.v0.Proof.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.Proof; - return proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0; + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.Proof} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.Proof} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} */ -proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -2372,28 +6980,18 @@ proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader = function(msg var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setGrovedbProof(value); + var value = /** @type {number} */ (reader.readUint64()); + msg.setBalance(value); break; case 2: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setQuorumHash(value); + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); break; case 3: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setSignature(value); - break; - case 4: - var value = /** @type {number} */ (reader.readUint32()); - msg.setRound(value); - break; - case 5: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setBlockIdHash(value); - break; - case 6: - var value = /** @type {number} */ (reader.readUint32()); - msg.setQuorumType(value); + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); break; default: reader.skipField(); @@ -2408,9 +7006,9 @@ proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader = function(msg * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -2418,261 +7016,350 @@ proto.org.dash.platform.dapi.v0.Proof.prototype.serializeBinary = function() { /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.Proof} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getGrovedbProof_asU8(); - if (f.length > 0) { - writer.writeBytes( + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeUint64( 1, f ); } - f = message.getQuorumHash_asU8(); - if (f.length > 0) { - writer.writeBytes( + f = message.getProof(); + if (f != null) { + writer.writeMessage( 2, - f + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter ); } - f = message.getSignature_asU8(); - if (f.length > 0) { - writer.writeBytes( + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( 3, - f - ); - } - f = message.getRound(); - if (f !== 0) { - writer.writeUint32( - 4, - f - ); - } - f = message.getBlockIdHash_asU8(); - if (f.length > 0) { - writer.writeBytes( - 5, - f - ); - } - f = message.getQuorumType(); - if (f !== 0) { - writer.writeUint32( - 6, - f + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter ); } }; /** - * optional bytes grovedb_proof = 1; - * @return {string} + * optional uint64 balance = 1; + * @return {number} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getGrovedbProof = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.getBalance = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); }; /** - * optional bytes grovedb_proof = 1; - * This is a type-conversion wrapper around `getGrovedbProof()` - * @return {string} + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getGrovedbProof_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getGrovedbProof())); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.setBalance = function(value) { + return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.oneofGroups_[0], value); }; /** - * optional bytes grovedb_proof = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getGrovedbProof()` - * @return {!Uint8Array} + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getGrovedbProof_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getGrovedbProof())); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.clearBalance = function() { + return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.oneofGroups_[0], undefined); }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.setGrovedbProof = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.hasBalance = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); }; /** - * optional bytes quorum_hash = 2; - * @return {string} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getQuorumHash = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); }; /** - * optional bytes quorum_hash = 2; - * This is a type-conversion wrapper around `getQuorumHash()` - * @return {string} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getQuorumHash_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getQuorumHash())); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; }; /** - * optional bytes quorum_hash = 2; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getQuorumHash()` - * @return {!Uint8Array} + * optional GetIdentityBalanceResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getQuorumHash_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getQuorumHash())); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0, 1)); }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this - */ -proto.org.dash.platform.dapi.v0.Proof.prototype.setQuorumHash = function(value) { - return jspb.Message.setProto3BytesField(this, 2, value); + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.oneofGroups_[0], value); }; /** - * optional bytes signature = 3; - * @return {string} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} returns this */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getSignature = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * optional bytes signature = 3; - * This is a type-conversion wrapper around `getSignature()` - * @return {string} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getSignature_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getSignature())); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; + /** - * optional bytes signature = 3; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getSignature()` - * @return {!Uint8Array} + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getSignature_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getSignature())); -}; +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.oneofGroups_ = [[1]]; +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.setSignature = function(value) { - return jspb.Message.setProto3BytesField(this, 3, value); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.oneofGroups_[0])); }; + +if (jspb.Message.GENERATE_TO_OBJECT) { /** - * optional uint32 round = 4; - * @return {number} + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getRound = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.toObject(opt_includeInstance, this); }; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.Proof.prototype.setRound = function(value) { - return jspb.Message.setProto3IntField(this, 4, value); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; }; +} /** - * optional bytes block_id_hash = 5; - * @return {string} + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getBlockIdHash = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, "")); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse; + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.deserializeBinaryFromReader(msg, reader); }; /** - * optional bytes block_id_hash = 5; - * This is a type-conversion wrapper around `getBlockIdHash()` - * @return {string} + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getBlockIdHash_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getBlockIdHash())); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; }; /** - * optional bytes block_id_hash = 5; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getBlockIdHash()` + * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getBlockIdHash_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getBlockIdHash())); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.Proof.prototype.setBlockIdHash = function(value) { - return jspb.Message.setProto3BytesField(this, 5, value); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.serializeBinaryToWriter + ); + } }; + /** - * optional uint32 quorum_type = 6; - * @return {number} + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const */ -proto.org.dash.platform.dapi.v0.Proof.prototype.getQuorumType = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 6, 0)); -}; - +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.oneofGroups_ = [[1,2]]; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.Proof} returns this + * @enum {number} */ -proto.org.dash.platform.dapi.v0.Proof.prototype.setQuorumType = function(value) { - return jspb.Message.setProto3IntField(this, 6, value); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + BALANCE_AND_REVISION: 1, + PROOF: 2 }; - +/** + * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.ResultCase} + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.oneofGroups_[0])); +}; @@ -2689,8 +7376,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.toObject(opt_includeInstance, this); }; @@ -2699,18 +7386,15 @@ proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.toObject = function(o * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.ResponseMetadata} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - height: jspb.Message.getFieldWithDefault(msg, 1, 0), - coreChainLockedHeight: jspb.Message.getFieldWithDefault(msg, 2, 0), - epoch: jspb.Message.getFieldWithDefault(msg, 3, 0), - timeMs: jspb.Message.getFieldWithDefault(msg, 4, 0), - protocolVersion: jspb.Message.getFieldWithDefault(msg, 5, 0), - chainId: jspb.Message.getFieldWithDefault(msg, 6, "") + balanceAndRevision: (f = msg.getBalanceAndRevision()) && proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.toObject(includeInstance, f), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; if (includeInstance) { @@ -2724,23 +7408,23 @@ proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject = function(includeInst /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.ResponseMetadata; - return proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0; + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.ResponseMetadata} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -2748,28 +7432,19 @@ proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader = f var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {number} */ (reader.readUint64()); - msg.setHeight(value); + var value = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.deserializeBinaryFromReader); + msg.setBalanceAndRevision(value); break; case 2: - var value = /** @type {number} */ (reader.readUint32()); - msg.setCoreChainLockedHeight(value); + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); break; case 3: - var value = /** @type {number} */ (reader.readUint32()); - msg.setEpoch(value); - break; - case 4: - var value = /** @type {number} */ (reader.readUint64()); - msg.setTimeMs(value); - break; - case 5: - var value = /** @type {number} */ (reader.readUint32()); - msg.setProtocolVersion(value); - break; - case 6: - var value = /** @type {string} */ (reader.readString()); - msg.setChainId(value); + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); break; default: reader.skipField(); @@ -2784,9 +7459,9 @@ proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader = f * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -2794,165 +7469,39 @@ proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.serializeBinary = fun /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.ResponseMetadata} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getHeight(); - if (f !== 0) { - writer.writeUint64( + f = message.getBalanceAndRevision(); + if (f != null) { + writer.writeMessage( 1, - f + f, + proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.serializeBinaryToWriter ); } - f = message.getCoreChainLockedHeight(); - if (f !== 0) { - writer.writeUint32( + f = message.getProof(); + if (f != null) { + writer.writeMessage( 2, - f + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter ); } - f = message.getEpoch(); - if (f !== 0) { - writer.writeUint32( + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( 3, - f - ); - } - f = message.getTimeMs(); - if (f !== 0) { - writer.writeUint64( - 4, - f - ); - } - f = message.getProtocolVersion(); - if (f !== 0) { - writer.writeUint32( - 5, - f - ); - } - f = message.getChainId(); - if (f.length > 0) { - writer.writeString( - 6, - f + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter ); } }; -/** - * optional uint64 height = 1; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getHeight = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setHeight = function(value) { - return jspb.Message.setProto3IntField(this, 1, value); -}; - - -/** - * optional uint32 core_chain_locked_height = 2; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getCoreChainLockedHeight = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setCoreChainLockedHeight = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); -}; - - -/** - * optional uint32 epoch = 3; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getEpoch = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setEpoch = function(value) { - return jspb.Message.setProto3IntField(this, 3, value); -}; - - -/** - * optional uint64 time_ms = 4; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getTimeMs = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setTimeMs = function(value) { - return jspb.Message.setProto3IntField(this, 4, value); -}; - - -/** - * optional uint32 protocol_version = 5; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getProtocolVersion = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setProtocolVersion = function(value) { - return jspb.Message.setProto3IntField(this, 5, value); -}; - - -/** - * optional string chain_id = 6; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.getChainId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, "")); -}; - - -/** - * @param {string} value - * @return {!proto.org.dash.platform.dapi.v0.ResponseMetadata} returns this - */ -proto.org.dash.platform.dapi.v0.ResponseMetadata.prototype.setChainId = function(value) { - return jspb.Message.setProto3StringField(this, 6, value); -}; - - @@ -2969,8 +7518,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.toObject(opt_includeInstance, this); }; @@ -2979,15 +7528,14 @@ proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.toObject * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.toObject = function(includeInstance, msg) { var f, obj = { - code: jspb.Message.getFieldWithDefault(msg, 1, 0), - message: jspb.Message.getFieldWithDefault(msg, 2, ""), - data: msg.getData_asB64() + balance: jspb.Message.getFieldWithDefault(msg, 1, 0), + revision: jspb.Message.getFieldWithDefault(msg, 2, 0) }; if (includeInstance) { @@ -3001,23 +7549,23 @@ proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.toObject = functio /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError; - return proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision; + return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -3025,16 +7573,12 @@ proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.deserializeBinaryF var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {number} */ (reader.readUint32()); - msg.setCode(value); + var value = /** @type {number} */ (reader.readUint64()); + msg.setBalance(value); break; case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setMessage(value); - break; - case 3: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setData(value); + var value = /** @type {number} */ (reader.readUint64()); + msg.setRevision(value); break; default: reader.skipField(); @@ -3049,9 +7593,9 @@ proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.deserializeBinaryF * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -3059,30 +7603,23 @@ proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.serializ /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getCode(); - if (f !== 0) { - writer.writeUint32( - 1, - f - ); - } - f = message.getMessage(); - if (f.length > 0) { - writer.writeString( - 2, + f = message.getBalance(); + if (f !== 0) { + writer.writeUint64( + 1, f ); } - f = message.getData_asU8(); - if (f.length > 0) { - writer.writeBytes( - 3, + f = message.getRevision(); + if (f !== 0) { + writer.writeUint64( + 2, f ); } @@ -3090,240 +7627,219 @@ proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.serializeBinaryToW /** - * optional uint32 code = 1; + * optional uint64 balance = 1; * @return {number} */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.getCode = function() { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.getBalance = function() { return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); }; /** * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} returns this */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.setCode = function(value) { +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.setBalance = function(value) { return jspb.Message.setProto3IntField(this, 1, value); }; /** - * optional string message = 2; - * @return {string} + * optional uint64 revision = 2; + * @return {number} */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.getMessage = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.getRevision = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); }; /** - * @param {string} value - * @return {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} returns this + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} returns this */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.setMessage = function(value) { - return jspb.Message.setProto3StringField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.setRevision = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); }; /** - * optional bytes data = 3; - * @return {string} + * optional BalanceAndRevision balance_and_revision = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.getData = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.getBalanceAndRevision = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision, 1)); }; /** - * optional bytes data = 3; - * This is a type-conversion wrapper around `getData()` - * @return {string} + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.setBalanceAndRevision = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.getData_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getData())); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.clearBalanceAndRevision = function() { + return this.setBalanceAndRevision(undefined); }; /** - * optional bytes data = 3; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getData()` - * @return {!Uint8Array} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.getData_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getData())); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.hasBalanceAndRevision = function() { + return jspb.Message.getField(this, 1) != null; }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} returns this + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.prototype.setData = function(value) { - return jspb.Message.setProto3BytesField(this, 3, value); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; +/** + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.oneofGroups_[0], value); +}; + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); +}; -if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.toObject = function(includeInstance, msg) { - var f, obj = { - stateTransition: msg.getStateTransition_asB64() - }; +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +}; - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; + +/** + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest; - return proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setStateTransition(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; }; /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * optional GetIdentityBalanceAndRevisionResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0, 1)); }; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getStateTransition_asU8(); - if (f.length > 0) { - writer.writeBytes( - 1, - f - ); - } + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.oneofGroups_[0], value); }; /** - * optional bytes state_transition = 1; - * @return {string} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} returns this */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.getStateTransition = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * optional bytes state_transition = 1; - * This is a type-conversion wrapper around `getStateTransition()` - * @return {string} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.getStateTransition_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getStateTransition())); +proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; + /** - * optional bytes state_transition = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getStateTransition()` - * @return {!Uint8Array} + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.getStateTransition_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getStateTransition())); +proto.org.dash.platform.dapi.v0.KeyRequestType.oneofGroups_ = [[1,2,3]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.KeyRequestType.RequestCase = { + REQUEST_NOT_SET: 0, + ALL_KEYS: 1, + SPECIFIC_KEYS: 2, + SEARCH_KEY: 3 }; - /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest} returns this + * @return {proto.org.dash.platform.dapi.v0.KeyRequestType.RequestCase} */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionRequest.prototype.setStateTransition = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.getRequestCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.KeyRequestType.RequestCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.KeyRequestType.oneofGroups_[0])); }; - - if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. @@ -3337,8 +7853,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.KeyRequestType.toObject(opt_includeInstance, this); }; @@ -3347,13 +7863,15 @@ proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.prototype.toObj * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.KeyRequestType} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.KeyRequestType.toObject = function(includeInstance, msg) { var f, obj = { - + allKeys: (f = msg.getAllKeys()) && proto.org.dash.platform.dapi.v0.AllKeys.toObject(includeInstance, f), + specificKeys: (f = msg.getSpecificKeys()) && proto.org.dash.platform.dapi.v0.SpecificKeys.toObject(includeInstance, f), + searchKey: (f = msg.getSearchKey()) && proto.org.dash.platform.dapi.v0.SearchKey.toObject(includeInstance, f) }; if (includeInstance) { @@ -3367,29 +7885,44 @@ proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.toObject = func /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse} + * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.KeyRequestType.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse; - return proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.KeyRequestType; + return proto.org.dash.platform.dapi.v0.KeyRequestType.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.KeyRequestType} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse} + * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.KeyRequestType.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.AllKeys; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.AllKeys.deserializeBinaryFromReader); + msg.setAllKeys(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.SpecificKeys; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.SpecificKeys.deserializeBinaryFromReader); + msg.setSpecificKeys(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.SearchKey; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.SearchKey.deserializeBinaryFromReader); + msg.setSearchKey(value); + break; default: reader.skipField(); break; @@ -3403,9 +7936,9 @@ proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.deserializeBina * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.KeyRequestType.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -3413,43 +7946,153 @@ proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.prototype.seria /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse} message + * @param {!proto.org.dash.platform.dapi.v0.KeyRequestType} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.BroadcastStateTransitionResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.KeyRequestType.serializeBinaryToWriter = function(message, writer) { var f = undefined; + f = message.getAllKeys(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.AllKeys.serializeBinaryToWriter + ); + } + f = message.getSpecificKeys(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.SpecificKeys.serializeBinaryToWriter + ); + } + f = message.getSearchKey(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.SearchKey.serializeBinaryToWriter + ); + } }; +/** + * optional AllKeys all_keys = 1; + * @return {?proto.org.dash.platform.dapi.v0.AllKeys} + */ +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.getAllKeys = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.AllKeys} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.AllKeys, 1)); +}; + /** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const + * @param {?proto.org.dash.platform.dapi.v0.AllKeys|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this +*/ +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.setAllKeys = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.KeyRequestType.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.clearAllKeys = function() { + return this.setAllKeys(undefined); +}; + /** - * @enum {number} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.hasAllKeys = function() { + return jspb.Message.getField(this, 1) != null; }; + /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityRequest.VersionCase} + * optional SpecificKeys specific_keys = 2; + * @return {?proto.org.dash.platform.dapi.v0.SpecificKeys} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.getSpecificKeys = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.SpecificKeys} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.SpecificKeys, 2)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.SpecificKeys|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this +*/ +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.setSpecificKeys = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.KeyRequestType.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this + */ +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.clearSpecificKeys = function() { + return this.setSpecificKeys(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.hasSpecificKeys = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional SearchKey search_key = 3; + * @return {?proto.org.dash.platform.dapi.v0.SearchKey} + */ +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.getSearchKey = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.SearchKey} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.SearchKey, 3)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.SearchKey|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this +*/ +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.setSearchKey = function(value) { + return jspb.Message.setOneofWrapperField(this, 3, proto.org.dash.platform.dapi.v0.KeyRequestType.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this + */ +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.clearSearchKey = function() { + return this.setSearchKey(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.hasSearchKey = function() { + return jspb.Message.getField(this, 3) != null; }; + + if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. @@ -3463,8 +8106,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.AllKeys.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.AllKeys.toObject(opt_includeInstance, this); }; @@ -3473,13 +8116,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.toObject = function * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.AllKeys} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.AllKeys.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.toObject(includeInstance, f) + }; if (includeInstance) { @@ -3493,34 +8136,29 @@ proto.org.dash.platform.dapi.v0.GetIdentityRequest.toObject = function(includeIn /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} + * @return {!proto.org.dash.platform.dapi.v0.AllKeys} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.AllKeys.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityRequest; - return proto.org.dash.platform.dapi.v0.GetIdentityRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.AllKeys; + return proto.org.dash.platform.dapi.v0.AllKeys.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.AllKeys} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} + * @return {!proto.org.dash.platform.dapi.v0.AllKeys} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.AllKeys.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { - case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.deserializeBinaryFromReader); - msg.setV0(value); - break; default: reader.skipField(); break; @@ -3534,9 +8172,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityRequest.deserializeBinaryFromReader = * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.AllKeys.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.AllKeys.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -3544,24 +8182,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.serializeBinary = f /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} message + * @param {!proto.org.dash.platform.dapi.v0.AllKeys} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.AllKeys.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getV0(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.serializeBinaryToWriter - ); - } }; +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.org.dash.platform.dapi.v0.SpecificKeys.repeatedFields_ = [1]; + if (jspb.Message.GENERATE_TO_OBJECT) { @@ -3577,8 +8214,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.SpecificKeys.toObject(opt_includeInstance, this); }; @@ -3587,14 +8224,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototyp * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.SpecificKeys} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.SpecificKeys.toObject = function(includeInstance, msg) { var f, obj = { - id: msg.getId_asB64(), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + keyIdsList: (f = jspb.Message.getRepeatedField(msg, 1)) == null ? undefined : f }; if (includeInstance) { @@ -3608,23 +8244,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.toObject /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.SpecificKeys} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.SpecificKeys.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0; - return proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.SpecificKeys; + return proto.org.dash.platform.dapi.v0.SpecificKeys.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.SpecificKeys} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.SpecificKeys} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.SpecificKeys.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -3632,12 +8268,10 @@ proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.deserial var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setId(value); - break; - case 2: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); + var values = /** @type {!Array} */ (reader.isDelimited() ? reader.readPackedUint32() : [reader.readUint32()]); + for (var i = 0; i < values.length; i++) { + msg.addKeyIds(values[i]); + } break; default: reader.skipField(); @@ -3652,9 +8286,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.deserial * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.SpecificKeys.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -3662,152 +8296,60 @@ proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototyp /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.SpecificKeys} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.SpecificKeys.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getId_asU8(); + f = message.getKeyIdsList(); if (f.length > 0) { - writer.writeBytes( + writer.writePackedUint32( 1, f ); } - f = message.getProve(); - if (f) { - writer.writeBool( - 2, - f - ); - } -}; - - -/** - * optional bytes id = 1; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.getId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * optional bytes id = 1; - * This is a type-conversion wrapper around `getId()` - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.getId_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getId())); -}; - - -/** - * optional bytes id = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getId()` - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.getId_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getId())); -}; - - -/** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.setId = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); -}; - - -/** - * optional bool prove = 2; - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); }; /** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} returns this + * repeated uint32 key_ids = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 2, value); +proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.getKeyIdsList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); }; /** - * optional GetIdentityRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.SpecificKeys} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0, 1)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityRequest.GetIdentityRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.setKeyIdsList = function(value) { + return jspb.Message.setField(this, 1, value || []); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityRequest} returns this + * @param {number} value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.SpecificKeys} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.clearV0 = function() { - return this.setV0(undefined); +proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.addKeyIds = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 1, value, opt_index); }; /** - * Returns whether this field is set. - * @return {boolean} + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.SpecificKeys} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityRequest.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.clearKeyIdsList = function() { + return this.setKeyIdsList([]); }; -/** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.oneofGroups_ = [[1]]; - -/** - * @enum {number} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 -}; - -/** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.VersionCase} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.oneofGroups_[0])); -}; - if (jspb.Message.GENERATE_TO_OBJECT) { @@ -3823,8 +8365,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.SearchKey.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.SearchKey.toObject(opt_includeInstance, this); }; @@ -3833,13 +8375,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.toObject = f * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.SearchKey} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.SearchKey.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.toObject(includeInstance, f) + purposeMapMap: (f = msg.getPurposeMapMap()) ? f.toObject(includeInstance, proto.org.dash.platform.dapi.v0.SecurityLevelMap.toObject) : [] }; if (includeInstance) { @@ -3853,23 +8395,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.toObject = function(in /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} + * @return {!proto.org.dash.platform.dapi.v0.SearchKey} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.SearchKey.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest; - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.SearchKey; + return proto.org.dash.platform.dapi.v0.SearchKey.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.SearchKey} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} + * @return {!proto.org.dash.platform.dapi.v0.SearchKey} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.SearchKey.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -3877,9 +8419,10 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.deserializeBinaryFromR var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.deserializeBinaryFromReader); - msg.setV0(value); + var value = msg.getPurposeMapMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readUint32, jspb.BinaryReader.prototype.readMessage, proto.org.dash.platform.dapi.v0.SecurityLevelMap.deserializeBinaryFromReader, 0, new proto.org.dash.platform.dapi.v0.SecurityLevelMap()); + }); break; default: reader.skipField(); @@ -3894,9 +8437,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.deserializeBinaryFromR * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.SearchKey.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.SearchKey.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -3904,23 +8447,41 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.serializeBin /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} message + * @param {!proto.org.dash.platform.dapi.v0.SearchKey} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.SearchKey.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getV0(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.serializeBinaryToWriter - ); + f = message.getPurposeMapMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(1, writer, jspb.BinaryWriter.prototype.writeUint32, jspb.BinaryWriter.prototype.writeMessage, proto.org.dash.platform.dapi.v0.SecurityLevelMap.serializeBinaryToWriter); } }; +/** + * map purpose_map = 1; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.org.dash.platform.dapi.v0.SearchKey.prototype.getPurposeMapMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 1, opt_noLazyCreate, + proto.org.dash.platform.dapi.v0.SecurityLevelMap)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.org.dash.platform.dapi.v0.SearchKey} returns this + */ +proto.org.dash.platform.dapi.v0.SearchKey.prototype.clearPurposeMapMap = function() { + this.getPurposeMapMap().clear(); + return this;}; + + @@ -3937,8 +8498,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.SecurityLevelMap.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.SecurityLevelMap.toObject(opt_includeInstance, this); }; @@ -3947,14 +8508,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequ * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.SecurityLevelMap.toObject = function(includeInstance, msg) { var f, obj = { - id: msg.getId_asB64(), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + securityLevelMapMap: (f = msg.getSecurityLevelMapMap()) ? f.toObject(includeInstance, undefined) : [] }; if (includeInstance) { @@ -3968,23 +8528,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequ /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0; - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.SecurityLevelMap.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.SecurityLevelMap; + return proto.org.dash.platform.dapi.v0.SecurityLevelMap.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.SecurityLevelMap.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -3992,12 +8552,10 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequ var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setId(value); - break; - case 2: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); + var value = msg.getSecurityLevelMapMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readUint32, jspb.BinaryReader.prototype.readEnum, null, 0, 0); + }); break; default: reader.skipField(); @@ -4012,9 +8570,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequ * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.SecurityLevelMap.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.SecurityLevelMap.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -4022,124 +8580,47 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequ /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.SecurityLevelMap.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getId_asU8(); - if (f.length > 0) { - writer.writeBytes( - 1, - f - ); - } - f = message.getProve(); - if (f) { - writer.writeBool( - 2, - f - ); + f = message.getSecurityLevelMapMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(1, writer, jspb.BinaryWriter.prototype.writeUint32, jspb.BinaryWriter.prototype.writeEnum); } }; /** - * optional bytes id = 1; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.getId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * optional bytes id = 1; - * This is a type-conversion wrapper around `getId()` - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.getId_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getId())); -}; - - -/** - * optional bytes id = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getId()` - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.getId_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getId())); -}; - - -/** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.setId = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); -}; - - -/** - * optional bool prove = 2; - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); -}; - - -/** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 2, value); -}; - - -/** - * optional GetIdentityBalanceRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} + * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0, 1)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.GetIdentityBalanceRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.SecurityLevelMap.KeyKindRequestType = { + CURRENT_KEY_OF_KIND_REQUEST: 0, + ALL_KEYS_OF_KIND_REQUEST: 1 }; - /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest} returns this + * map security_level_map = 1; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.clearV0 = function() { - return this.setV0(undefined); +proto.org.dash.platform.dapi.v0.SecurityLevelMap.prototype.getSecurityLevelMapMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 1, opt_noLazyCreate, + null)); }; /** - * Returns whether this field is set. - * @return {boolean} + * Clears values from the map. The map will be non-null. + * @return {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; -}; +proto.org.dash.platform.dapi.v0.SecurityLevelMap.prototype.clearSecurityLevelMapMap = function() { + this.getSecurityLevelMapMap().clear(); + return this;}; @@ -4151,21 +8632,21 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceRequest.prototype.hasV0 = func * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.oneofGroups_[0])); }; @@ -4183,8 +8664,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.toObject(opt_includeInstance, this); }; @@ -4193,13 +8674,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.t * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -4213,23 +8694,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.toObject = /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest; - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest; + return proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -4237,8 +8718,8 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.deserialize var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -4254,9 +8735,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.deserialize * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -4264,18 +8745,18 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.s /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.serializeBinaryToWriter ); } }; @@ -4297,8 +8778,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.toObject(opt_includeInstance, this); }; @@ -4307,14 +8788,17 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentity * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - id: msg.getId_asB64(), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + identityId: msg.getIdentityId_asB64(), + requestType: (f = msg.getRequestType()) && proto.org.dash.platform.dapi.v0.KeyRequestType.toObject(includeInstance, f), + limit: (f = msg.getLimit()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), + offset: (f = msg.getOffset()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 5, false) }; if (includeInstance) { @@ -4328,23 +8812,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentity /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0; - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0; + return proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -4353,9 +8837,24 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentity switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setId(value); + msg.setIdentityId(value); break; case 2: + var value = new proto.org.dash.platform.dapi.v0.KeyRequestType; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.KeyRequestType.deserializeBinaryFromReader); + msg.setRequestType(value); + break; + case 3: + var value = new google_protobuf_wrappers_pb.UInt32Value; + reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); + msg.setLimit(value); + break; + case 4: + var value = new google_protobuf_wrappers_pb.UInt32Value; + reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); + msg.setOffset(value); + break; + case 5: var value = /** @type {boolean} */ (reader.readBool()); msg.setProve(value); break; @@ -4372,9 +8871,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentity * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -4382,23 +8881,47 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentity /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getId_asU8(); + f = message.getIdentityId_asU8(); if (f.length > 0) { writer.writeBytes( 1, f ); } + f = message.getRequestType(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.KeyRequestType.serializeBinaryToWriter + ); + } + f = message.getLimit(); + if (f != null) { + writer.writeMessage( + 3, + f, + google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter + ); + } + f = message.getOffset(); + if (f != null) { + writer.writeMessage( + 4, + f, + google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter + ); + } f = message.getProve(); if (f) { writer.writeBool( - 2, + 5, f ); } @@ -4406,90 +8929,109 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentity /** - * optional bytes id = 1; + * optional bytes identity_id = 1; * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.getId = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getIdentityId = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * optional bytes id = 1; - * This is a type-conversion wrapper around `getId()` + * optional bytes identity_id = 1; + * This is a type-conversion wrapper around `getIdentityId()` * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.getId_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getIdentityId_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getId())); + this.getIdentityId())); }; /** - * optional bytes id = 1; + * optional bytes identity_id = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getId()` + * This is a type-conversion wrapper around `getIdentityId()` * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.getId_asU8 = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getIdentityId_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getId())); + this.getIdentityId())); }; /** * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.setId = function(value) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.setIdentityId = function(value) { return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional bool prove = 2; - * @return {boolean} + * optional KeyRequestType request_type = 2; + * @return {?proto.org.dash.platform.dapi.v0.KeyRequestType} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getRequestType = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.KeyRequestType} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.KeyRequestType, 2)); }; /** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.KeyRequestType|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.setRequestType = function(value) { + return jspb.Message.setWrapperField(this, 2, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.clearRequestType = function() { + return this.setRequestType(undefined); }; /** - * optional GetIdentityBalanceAndRevisionRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.hasRequestType = function() { + return jspb.Message.getField(this, 2) != null; }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.GetIdentityBalanceAndRevisionRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} returns this + * optional google.protobuf.UInt32Value limit = 3; + * @return {?proto.google.protobuf.UInt32Value} + */ +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getLimit = function() { + return /** @type{?proto.google.protobuf.UInt32Value} */ ( + jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 3)); +}; + + +/** + * @param {?proto.google.protobuf.UInt32Value|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.setLimit = function(value) { + return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.clearV0 = function() { - return this.setV0(undefined); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.clearLimit = function() { + return this.setLimit(undefined); }; @@ -4497,147 +9039,100 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.c * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionRequest.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.hasLimit = function() { + return jspb.Message.getField(this, 3) != null; }; - /** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const + * optional google.protobuf.UInt32Value offset = 4; + * @return {?proto.google.protobuf.UInt32Value} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getOffset = function() { + return /** @type{?proto.google.protobuf.UInt32Value} */ ( + jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 4)); +}; + /** - * @enum {number} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 + * @param {?proto.google.protobuf.UInt32Value|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.setOffset = function(value) { + return jspb.Message.setWrapperField(this, 4, value); }; + /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityResponse.VersionCase} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.clearOffset = function() { + return this.setOffset(undefined); }; - -if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.hasOffset = function() { + return jspb.Message.getField(this, 4) != null; }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional bool prove = 5; + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.toObject = function(includeInstance, msg) { - var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.toObject(includeInstance, f) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 5, false)); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityResponse; - return proto.org.dash.platform.dapi.v0.GetIdentityResponse.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 5, value); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} + * optional GetIdentityKeysRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.deserializeBinaryFromReader); - msg.setV0(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0, 1)); }; /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getV0(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.serializeBinaryToWriter - ); - } +proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; @@ -4650,22 +9145,21 @@ proto.org.dash.platform.dapi.v0.GetIdentityResponse.serializeBinaryToWriter = fu * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.ResultCase = { - RESULT_NOT_SET: 0, - IDENTITY: 1, - PROOF: 2 +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.ResultCase} + * @return {proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.oneofGroups_[0])); }; @@ -4683,8 +9177,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.toObject(opt_includeInstance, this); }; @@ -4693,15 +9187,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.protot * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.toObject = function(includeInstance, msg) { var f, obj = { - identity: msg.getIdentity_asB64(), - proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), - metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -4715,23 +9207,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.toObje /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0; - return proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse; + return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -4739,18 +9231,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.deseri var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setIdentity(value); - break; - case 2: - var value = new proto.org.dash.platform.dapi.v0.Proof; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); - msg.setProof(value); - break; - case 3: - var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); - msg.setMetadata(value); + var value = new proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.deserializeBinaryFromReader); + msg.setV0(value); break; default: reader.skipField(); @@ -4765,9 +9248,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.deseri * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -4775,206 +9258,20 @@ proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.protot /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 1)); - if (f != null) { - writer.writeBytes( - 1, - f - ); - } - f = message.getProof(); - if (f != null) { - writer.writeMessage( - 2, - f, - proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter - ); - } - f = message.getMetadata(); + f = message.getV0(); if (f != null) { writer.writeMessage( - 3, - f, - proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter - ); - } -}; - - -/** - * optional bytes identity = 1; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getIdentity = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * optional bytes identity = 1; - * This is a type-conversion wrapper around `getIdentity()` - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getIdentity_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getIdentity())); -}; - - -/** - * optional bytes identity = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getIdentity()` - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getIdentity_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getIdentity())); -}; - - -/** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.setIdentity = function(value) { - return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.oneofGroups_[0], value); -}; - - -/** - * Clears the field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.clearIdentity = function() { - return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.oneofGroups_[0], undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.hasIdentity = function() { - return jspb.Message.getField(this, 1) != null; -}; - - -/** - * optional Proof proof = 2; - * @return {?proto.org.dash.platform.dapi.v0.Proof} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getProof = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.oneofGroups_[0], value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.clearProof = function() { - return this.setProof(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.hasProof = function() { - return jspb.Message.getField(this, 2) != null; -}; - - -/** - * optional ResponseMetadata metadata = 3; - * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.getMetadata = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.setMetadata = function(value) { - return jspb.Message.setWrapperField(this, 3, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.clearMetadata = function() { - return this.setMetadata(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0.prototype.hasMetadata = function() { - return jspb.Message.getField(this, 3) != null; -}; - - -/** - * optional GetIdentityResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0, 1)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityResponse.GetIdentityResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityResponse.oneofGroups_[0], value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityResponse} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.clearV0 = function() { - return this.setV0(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; + 1, + f, + proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.serializeBinaryToWriter + ); + } }; @@ -4987,21 +9284,22 @@ proto.org.dash.platform.dapi.v0.GetIdentityResponse.prototype.hasV0 = function() * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + KEYS: 1, + PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.oneofGroups_[0])); }; @@ -5019,8 +9317,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.toObject(opt_includeInstance, this); }; @@ -5029,13 +9327,15 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.toObject = functi * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.toObject(includeInstance, f) + keys: (f = msg.getKeys()) && proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.toObject(includeInstance, f), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; if (includeInstance) { @@ -5049,23 +9349,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.toObject = function(include /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesRequest; - return proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0; + return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -5073,9 +9373,19 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.deserializeBinaryFromReader var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.deserializeBinaryFromReader); - msg.setV0(value); + var value = new proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.deserializeBinaryFromReader); + msg.setKeys(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); break; default: reader.skipField(); @@ -5090,9 +9400,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.deserializeBinaryFromReader * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -5100,18 +9410,34 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.serializeBinary = /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getV0(); + f = message.getKeys(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.serializeBinaryToWriter + ); + } + f = message.getProof(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + ); + } + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter ); } }; @@ -5123,7 +9449,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.serializeBinaryToWriter = f * @private {!Array} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.repeatedFields_ = [1]; @@ -5140,8 +9466,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.toObject(opt_includeInstance, this); }; @@ -5150,14 +9476,13 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prot * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.toObject = function(includeInstance, msg) { var f, obj = { - idsList: msg.getIdsList_asB64(), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + keysBytesList: msg.getKeysBytesList_asB64() }; if (includeInstance) { @@ -5171,23 +9496,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.toOb /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0; - return proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys; + return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -5196,11 +9521,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.dese switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.addIds(value); - break; - case 2: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); + msg.addKeysBytes(value); break; default: reader.skipField(); @@ -5215,9 +9536,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.dese * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -5225,132 +9546,218 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prot /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getIdsList_asU8(); + f = message.getKeysBytesList_asU8(); if (f.length > 0) { writer.writeRepeatedBytes( 1, f ); } - f = message.getProve(); - if (f) { - writer.writeBool( - 2, - f - ); - } }; /** - * repeated bytes ids = 1; + * repeated bytes keys_bytes = 1; * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.getIdsList = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.getKeysBytesList = function() { return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); }; /** - * repeated bytes ids = 1; - * This is a type-conversion wrapper around `getIdsList()` + * repeated bytes keys_bytes = 1; + * This is a type-conversion wrapper around `getKeysBytesList()` * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.getIdsList_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.getKeysBytesList_asB64 = function() { return /** @type {!Array} */ (jspb.Message.bytesListAsB64( - this.getIdsList())); + this.getKeysBytesList())); }; /** - * repeated bytes ids = 1; + * repeated bytes keys_bytes = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getIdsList()` + * This is a type-conversion wrapper around `getKeysBytesList()` * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.getIdsList_asU8 = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.getKeysBytesList_asU8 = function() { return /** @type {!Array} */ (jspb.Message.bytesListAsU8( - this.getIdsList())); + this.getKeysBytesList())); }; /** * @param {!(Array|Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.setIdsList = function(value) { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.setKeysBytesList = function(value) { return jspb.Message.setField(this, 1, value || []); }; /** - * @param {!(string|Uint8Array)} value - * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} returns this + * @param {!(string|Uint8Array)} value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.addKeysBytes = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 1, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.clearKeysBytesList = function() { + return this.setKeysBytesList([]); +}; + + +/** + * optional Keys keys = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} + */ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.getKeys = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.setKeys = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.clearKeys = function() { + return this.setKeys(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.hasKeys = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.addIds = function(value, opt_index) { - return jspb.Message.addToRepeatedField(this, 1, value, opt_index); +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; /** - * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.clearIdsList = function() { - return this.setIdsList([]); + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); }; /** - * optional bool prove = 2; - * @return {boolean} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); }; /** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; }; /** - * optional GetIdentitiesRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} + * optional GetIdentityKeysResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.GetIdentitiesRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -5359,7 +9766,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.clearV0 = functio * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -5373,21 +9780,21 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesRequest.prototype.hasV0 = function( * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetProofsRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetProofsRequest.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetProofsRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetProofsRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProofsRequest.oneofGroups_[0])); }; @@ -5405,8 +9812,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProofsRequest.toObject(opt_includeInstance, this); }; @@ -5415,13 +9822,13 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.toObject = funct * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -5435,23 +9842,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.toObject = function(includ /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse; - return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProofsRequest; + return proto.org.dash.platform.dapi.v0.GetProofsRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -5459,8 +9866,8 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.deserializeBinaryFromReade var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -5476,9 +9883,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.deserializeBinaryFromReade * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProofsRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -5486,24 +9893,31 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.serializeBinary /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.serializeBinaryToWriter ); } }; +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.repeatedFields_ = [1,2,3]; + if (jspb.Message.GENERATE_TO_OBJECT) { @@ -5519,8 +9933,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.toObject(opt_includeInstance, this); }; @@ -5529,13 +9943,18 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.to * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - value: msg.getValue_asB64() + identitiesList: jspb.Message.toObjectList(msg.getIdentitiesList(), + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.toObject, includeInstance), + contractsList: jspb.Message.toObjectList(msg.getContractsList(), + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.toObject, includeInstance), + documentsList: jspb.Message.toObjectList(msg.getDocumentsList(), + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.toObject, includeInstance) }; if (includeInstance) { @@ -5549,23 +9968,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.toObject = f /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue; - return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0; + return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -5573,8 +9992,19 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.deserializeB var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setValue(value); + var value = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.deserializeBinaryFromReader); + msg.addIdentities(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.deserializeBinaryFromReader); + msg.addContracts(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.deserializeBinaryFromReader); + msg.addDocuments(value); break; default: reader.skipField(); @@ -5589,9 +10019,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.deserializeB * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -5599,61 +10029,36 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.se /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} message + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getValue_asU8(); + f = message.getIdentitiesList(); if (f.length > 0) { - writer.writeBytes( + writer.writeRepeatedMessage( 1, - f + f, + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.serializeBinaryToWriter + ); + } + f = message.getContractsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.serializeBinaryToWriter + ); + } + f = message.getDocumentsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.serializeBinaryToWriter ); } -}; - - -/** - * optional bytes value = 1; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.getValue = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * optional bytes value = 1; - * This is a type-conversion wrapper around `getValue()` - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.getValue_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getValue())); -}; - - -/** - * optional bytes value = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getValue()` - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.getValue_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getValue())); -}; - - -/** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.prototype.setValue = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); }; @@ -5673,8 +10078,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.toObject(opt_includeInstance, this); }; @@ -5683,14 +10088,16 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.to * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.toObject = function(includeInstance, msg) { var f, obj = { - key: msg.getKey_asB64(), - value: (f = msg.getValue()) && proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.toObject(includeInstance, f) + contractId: msg.getContractId_asB64(), + documentType: jspb.Message.getFieldWithDefault(msg, 2, ""), + documentTypeKeepsHistory: jspb.Message.getBooleanFieldWithDefault(msg, 3, false), + documentId: msg.getDocumentId_asB64() }; if (includeInstance) { @@ -5704,23 +10111,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.toObject = f /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry; - return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest; + return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -5729,12 +10136,19 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.deserializeB switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setKey(value); + msg.setContractId(value); break; case 2: - var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.deserializeBinaryFromReader); - msg.setValue(value); + var value = /** @type {string} */ (reader.readString()); + msg.setDocumentType(value); + break; + case 3: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setDocumentTypeKeepsHistory(value); + break; + case 4: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setDocumentId(value); break; default: reader.skipField(); @@ -5749,9 +10163,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.deserializeB * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -5759,116 +10173,163 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.se /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} message + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getKey_asU8(); + f = message.getContractId_asU8(); if (f.length > 0) { writer.writeBytes( 1, f ); } - f = message.getValue(); - if (f != null) { - writer.writeMessage( + f = message.getDocumentType(); + if (f.length > 0) { + writer.writeString( 2, - f, - proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue.serializeBinaryToWriter + f + ); + } + f = message.getDocumentTypeKeepsHistory(); + if (f) { + writer.writeBool( + 3, + f + ); + } + f = message.getDocumentId_asU8(); + if (f.length > 0) { + writer.writeBytes( + 4, + f ); } }; /** - * optional bytes key = 1; + * optional bytes contract_id = 1; * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.getKey = function() { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getContractId = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * optional bytes key = 1; - * This is a type-conversion wrapper around `getKey()` + * optional bytes contract_id = 1; + * This is a type-conversion wrapper around `getContractId()` * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.getKey_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getContractId_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getKey())); + this.getContractId())); }; /** - * optional bytes key = 1; + * optional bytes contract_id = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getKey()` + * This is a type-conversion wrapper around `getContractId()` * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.getKey_asU8 = function() { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getContractId_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getKey())); + this.getContractId())); }; /** * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.setKey = function(value) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.setContractId = function(value) { return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional IdentityValue value = 2; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} + * optional string document_type = 2; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.getValue = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue, 2)); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getDocumentType = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityValue|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.setValue = function(value) { - return jspb.Message.setWrapperField(this, 2, value); + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} returns this + */ +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.setDocumentType = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} returns this + * optional bool document_type_keeps_history = 3; + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.clearValue = function() { - return this.setValue(undefined); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getDocumentTypeKeepsHistory = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 3, false)); }; /** - * Returns whether this field is set. - * @return {boolean} + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.prototype.hasValue = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.setDocumentTypeKeepsHistory = function(value) { + return jspb.Message.setProto3BooleanField(this, 3, value); }; +/** + * optional bytes document_id = 4; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getDocumentId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + /** - * List of repeated fields within this message type. - * @private {!Array} - * @const + * optional bytes document_id = 4; + * This is a type-conversion wrapper around `getDocumentId()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getDocumentId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getDocumentId())); +}; + + +/** + * optional bytes document_id = 4; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getDocumentId()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getDocumentId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getDocumentId())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} returns this + */ +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.setDocumentId = function(value) { + return jspb.Message.setProto3BytesField(this, 4, value); +}; + + @@ -5885,8 +10346,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.toObject(opt_includeInstance, this); }; @@ -5895,14 +10356,14 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.toObj * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.toObject = function(includeInstance, msg) { var f, obj = { - identityEntriesList: jspb.Message.toObjectList(msg.getIdentityEntriesList(), - proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.toObject, includeInstance) + identityId: msg.getIdentityId_asB64(), + requestType: jspb.Message.getFieldWithDefault(msg, 2, 0) }; if (includeInstance) { @@ -5916,23 +10377,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.toObject = func /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities; - return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest; + return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -5940,9 +10401,12 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.deserializeBina var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.deserializeBinaryFromReader); - msg.addIdentityEntries(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setIdentityId(value); + break; + case 2: + var value = /** @type {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type} */ (reader.readEnum()); + msg.setRequestType(value); break; default: reader.skipField(); @@ -5957,9 +10421,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.deserializeBina * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -5967,90 +10431,101 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.seria /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} message + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getIdentityEntriesList(); + f = message.getIdentityId_asU8(); if (f.length > 0) { - writer.writeRepeatedMessage( + writer.writeBytes( 1, - f, - proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry.serializeBinaryToWriter + f + ); + } + f = message.getRequestType(); + if (f !== 0.0) { + writer.writeEnum( + 2, + f ); } }; /** - * repeated IdentityEntry identity_entries = 1; - * @return {!Array} + * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.getIdentityEntriesList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry, 1)); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type = { + FULL_IDENTITY: 0, + BALANCE: 1, + KEYS: 2 }; - /** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.setIdentityEntriesList = function(value) { - return jspb.Message.setRepeatedWrapperField(this, 1, value); + * optional bytes identity_id = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.getIdentityId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry=} opt_value - * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry} + * optional bytes identity_id = 1; + * This is a type-conversion wrapper around `getIdentityId()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.addIdentityEntries = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.IdentityEntry, opt_index); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.getIdentityId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getIdentityId())); }; /** - * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} returns this + * optional bytes identity_id = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getIdentityId()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.prototype.clearIdentityEntriesList = function() { - return this.setIdentityEntriesList([]); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.getIdentityId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getIdentityId())); }; - /** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.setIdentityId = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + /** - * @enum {number} + * optional Type request_type = 2; + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.ResultCase = { - RESULT_NOT_SET: 0, - IDENTITIES: 1, - PROOF: 2 +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.getRequestType = function() { + return /** @type {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); }; + /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.ResultCase} + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.setRequestType = function(value) { + return jspb.Message.setProto3EnumField(this, 2, value); }; + + if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. @@ -6064,8 +10539,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.toObject(opt_includeInstance, this); }; @@ -6074,15 +10549,13 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.pr * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.toObject = function(includeInstance, msg) { var f, obj = { - identities: (f = msg.getIdentities()) && proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.toObject(includeInstance, f), - proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), - metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + contractId: msg.getContractId_asB64() }; if (includeInstance) { @@ -6096,23 +10569,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.to /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0; - return proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest; + return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -6120,19 +10593,8 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.de var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.deserializeBinaryFromReader); - msg.setIdentities(value); - break; - case 2: - var value = new proto.org.dash.platform.dapi.v0.Proof; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); - msg.setProof(value); - break; - case 3: - var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); - msg.setMetadata(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setContractId(value); break; default: reader.skipField(); @@ -6147,9 +10609,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.de * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -6157,174 +10619,202 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.pr /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getIdentities(); - if (f != null) { - writer.writeMessage( + f = message.getContractId_asU8(); + if (f.length > 0) { + writer.writeBytes( 1, - f, - proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities.serializeBinaryToWriter - ); - } - f = message.getProof(); - if (f != null) { - writer.writeMessage( - 2, - f, - proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter - ); - } - f = message.getMetadata(); - if (f != null) { - writer.writeMessage( - 3, - f, - proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + f ); } }; /** - * optional Identities identities = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} + * optional bytes contract_id = 1; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.getIdentities = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities, 1)); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.getContractId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.Identities|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this + * optional bytes contract_id = 1; + * This is a type-conversion wrapper around `getContractId()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.getContractId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getContractId())); +}; + + +/** + * optional bytes contract_id = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getContractId()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.getContractId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getContractId())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} returns this + */ +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.setContractId = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; + + +/** + * repeated IdentityRequest identities = 1; + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.getIdentitiesList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest, 1)); +}; + + +/** + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.setIdentities = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.setIdentitiesList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest=} opt_value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.clearIdentities = function() { - return this.setIdentities(undefined); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.addIdentities = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest, opt_index); }; /** - * Returns whether this field is set. - * @return {boolean} + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.hasIdentities = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.clearIdentitiesList = function() { + return this.setIdentitiesList([]); }; /** - * optional Proof proof = 2; - * @return {?proto.org.dash.platform.dapi.v0.Proof} + * repeated ContractRequest contracts = 2; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.getProof = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.getContractsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest, 2)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.setContractsList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 2, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest=} opt_value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.clearProof = function() { - return this.setProof(undefined); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.addContracts = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 2, opt_value, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest, opt_index); }; /** - * Returns whether this field is set. - * @return {boolean} + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.hasProof = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.clearContractsList = function() { + return this.setContractsList([]); }; /** - * optional ResponseMetadata metadata = 3; - * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + * repeated DocumentRequest documents = 3; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.getMetadata = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.getDocumentsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest, 3)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.setMetadata = function(value) { - return jspb.Message.setWrapperField(this, 3, value); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.setDocumentsList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 3, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} returns this + * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest=} opt_value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.clearMetadata = function() { - return this.setMetadata(undefined); +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.addDocuments = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 3, opt_value, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest, opt_index); }; /** - * Returns whether this field is set. - * @return {boolean} + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0.prototype.hasMetadata = function() { - return jspb.Message.getField(this, 3) != null; +proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.clearDocumentsList = function() { + return this.setDocumentsList([]); }; /** - * optional GetIdentitiesResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} + * optional GetProofsRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.GetIdentitiesResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProofsRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -6333,7 +10823,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.clearV0 = functi * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -6347,21 +10837,21 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesResponse.prototype.hasV0 = function * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetProofsResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetProofsResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetProofsResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetProofsResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProofsResponse.oneofGroups_[0])); }; @@ -6379,8 +10869,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProofsResponse.toObject(opt_includeInstance, this); }; @@ -6389,13 +10879,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.toObject = * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProofsResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -6409,23 +10899,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.toObject = function(i /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProofsResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse; - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProofsResponse; + return proto.org.dash.platform.dapi.v0.GetProofsResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProofsResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -6433,8 +10923,8 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.deserializeBinaryFrom var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -6450,9 +10940,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.deserializeBinaryFrom * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProofsResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -6460,18 +10950,18 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.serializeBi /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProofsResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.serializeBinaryToWriter ); } }; @@ -6486,22 +10976,21 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.serializeBinaryToWrit * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.ResultCase = { +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.ResultCase = { RESULT_NOT_SET: 0, - BALANCE: 1, - PROOF: 2 + PROOF: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.ResultCase} + * @return {proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.oneofGroups_[0])); }; @@ -6519,8 +11008,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.toObject(opt_includeInstance, this); }; @@ -6529,13 +11018,12 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceRes * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - balance: jspb.Message.getFieldWithDefault(msg, 1, 0), proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; @@ -6551,23 +11039,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceRes /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0; - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0; + return proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -6575,15 +11063,11 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceRes var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {number} */ (reader.readUint64()); - msg.setBalance(value); - break; - case 2: var value = new proto.org.dash.platform.dapi.v0.Proof; reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); msg.setProof(value); break; - case 3: + case 2: var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); msg.setMetadata(value); @@ -6601,9 +11085,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceRes * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -6611,23 +11095,16 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceRes /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = /** @type {number} */ (jspb.Message.getField(message, 1)); - if (f != null) { - writer.writeUint64( - 1, - f - ); - } f = message.getProof(); if (f != null) { writer.writeMessage( - 2, + 1, f, proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter ); @@ -6635,7 +11112,7 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceRes f = message.getMetadata(); if (f != null) { writer.writeMessage( - 3, + 2, f, proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter ); @@ -6644,140 +11121,30 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceRes /** - * optional uint64 balance = 1; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.getBalance = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.setBalance = function(value) { - return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.oneofGroups_[0], value); -}; - - -/** - * Clears the field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.clearBalance = function() { - return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.oneofGroups_[0], undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.hasBalance = function() { - return jspb.Message.getField(this, 1) != null; -}; - - -/** - * optional Proof proof = 2; + * optional Proof proof = 1; * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.getProof = function() { +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.getProof = function() { return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 1)); }; /** * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.oneofGroups_[0], value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.clearProof = function() { - return this.setProof(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.hasProof = function() { - return jspb.Message.getField(this, 2) != null; -}; - - -/** - * optional ResponseMetadata metadata = 3; - * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.getMetadata = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.setMetadata = function(value) { - return jspb.Message.setWrapperField(this, 3, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.clearMetadata = function() { - return this.setMetadata(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0.prototype.hasMetadata = function() { - return jspb.Message.getField(this, 3) != null; -}; - - -/** - * optional GetIdentityBalanceResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0, 1)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.GetIdentityBalanceResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.clearV0 = function() { - return this.setV0(undefined); +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); }; @@ -6785,147 +11152,82 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.clearV0 = f * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.hasProof = function() { return jspb.Message.getField(this, 1) != null; }; - -/** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.oneofGroups_ = [[1]]; - /** - * @enum {number} + * optional ResponseMetadata metadata = 2; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 2)); }; + /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.VersionCase} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.oneofGroups_[0])); + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 2, value); }; - -if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.toObject = function(includeInstance, msg) { - var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.toObject(includeInstance, f) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; +proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 2) != null; }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} + * optional GetProofsResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse; - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0, 1)); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.deserializeBinaryFromReader); - msg.setV0(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; + * @param {?proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProofsResponse.oneofGroups_[0], value); }; /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getV0(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.serializeBinaryToWriter - ); - } +proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; @@ -6938,22 +11240,21 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.serializeB * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetDataContractRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.ResultCase = { - RESULT_NOT_SET: 0, - BALANCE_AND_REVISION: 1, - PROOF: 2 +proto.org.dash.platform.dapi.v0.GetDataContractRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.ResultCase} + * @return {proto.org.dash.platform.dapi.v0.GetDataContractRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractRequest.oneofGroups_[0])); }; @@ -6971,8 +11272,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractRequest.toObject(opt_includeInstance, this); }; @@ -6981,15 +11282,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractRequest.toObject = function(includeInstance, msg) { var f, obj = { - balanceAndRevision: (f = msg.getBalanceAndRevision()) && proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.toObject(includeInstance, f), - proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), - metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -7003,23 +11302,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0; - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractRequest; + return proto.org.dash.platform.dapi.v0.GetDataContractRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -7027,19 +11326,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.deserializeBinaryFromReader); - msg.setBalanceAndRevision(value); - break; - case 2: - var value = new proto.org.dash.platform.dapi.v0.Proof; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); - msg.setProof(value); - break; - case 3: - var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); - msg.setMetadata(value); + var value = new proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.deserializeBinaryFromReader); + msg.setV0(value); break; default: reader.skipField(); @@ -7054,9 +11343,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -7064,34 +11353,18 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getBalanceAndRevision(); + f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.serializeBinaryToWriter - ); - } - f = message.getProof(); - if (f != null) { - writer.writeMessage( - 2, - f, - proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter - ); - } - f = message.getMetadata(); - if (f != null) { - writer.writeMessage( - 3, - f, - proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.serializeBinaryToWriter ); } }; @@ -7113,8 +11386,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.toObject(opt_includeInstance, this); }; @@ -7123,14 +11396,14 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - balance: jspb.Message.getFieldWithDefault(msg, 1, 0), - revision: jspb.Message.getFieldWithDefault(msg, 2, 0) + id: msg.getId_asB64(), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) }; if (includeInstance) { @@ -7144,23 +11417,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision; - return proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0; + return proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -7168,12 +11441,12 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {number} */ (reader.readUint64()); - msg.setBalance(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setId(value); break; case 2: - var value = /** @type {number} */ (reader.readUint64()); - msg.setRevision(value); + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); break; default: reader.skipField(); @@ -7188,9 +11461,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -7198,22 +11471,22 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getBalance(); - if (f !== 0) { - writer.writeUint64( + f = message.getId_asU8(); + if (f.length > 0) { + writer.writeBytes( 1, f ); } - f = message.getRevision(); - if (f !== 0) { - writer.writeUint64( + f = message.getProve(); + if (f) { + writer.writeBool( 2, f ); @@ -7222,103 +11495,90 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit /** - * optional uint64 balance = 1; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.getBalance = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} returns this + * optional bytes id = 1; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.setBalance = function(value) { - return jspb.Message.setProto3IntField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * optional uint64 revision = 2; - * @return {number} + * optional bytes id = 1; + * This is a type-conversion wrapper around `getId()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.getRevision = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.getId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getId())); }; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} returns this + * optional bytes id = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getId()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision.prototype.setRevision = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.getId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getId())); }; /** - * optional BalanceAndRevision balance_and_revision = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.getBalanceAndRevision = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision, 1)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.BalanceAndRevision|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.setBalanceAndRevision = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.setId = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this + * optional bool prove = 2; + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.clearBalanceAndRevision = function() { - return this.setBalanceAndRevision(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); }; /** - * Returns whether this field is set. - * @return {boolean} + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.hasBalanceAndRevision = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); }; /** - * optional Proof proof = 2; - * @return {?proto.org.dash.platform.dapi.v0.Proof} + * optional GetDataContractRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.getProof = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.clearProof = function() { - return this.setProof(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.clearV0 = function() { + return this.setV0(undefined); }; @@ -7326,82 +11586,147 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentit * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.hasProof = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; + /** - * optional ResponseMetadata metadata = 3; - * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.getMetadata = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); -}; +proto.org.dash.platform.dapi.v0.GetDataContractResponse.oneofGroups_ = [[1]]; +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetDataContractResponse.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; /** - * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.setMetadata = function(value) { - return jspb.Message.setWrapperField(this, 3, value); + * @return {proto.org.dash.platform.dapi.v0.GetDataContractResponse.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractResponse.oneofGroups_[0])); }; + +if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} returns this + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.clearMetadata = function() { - return this.setMetadata(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractResponse.toObject(opt_includeInstance, this); }; /** - * Returns whether this field is set. - * @return {boolean} + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0.prototype.hasMetadata = function() { - return jspb.Message.getField(this, 3) != null; +proto.org.dash.platform.dapi.v0.GetDataContractResponse.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; }; +} /** - * optional GetIdentityBalanceAndRevisionResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractResponse; + return proto.org.dash.platform.dapi.v0.GetDataContractResponse.deserializeBinaryFromReader(msg, reader); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.GetIdentityBalanceAndRevisionResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.oneofGroups_[0], value); + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} + */ +proto.org.dash.platform.dapi.v0.GetDataContractResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse} returns this + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.clearV0 = function() { - return this.setV0(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetDataContractResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); }; /** - * Returns whether this field is set. - * @return {boolean} + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetDataContractResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.serializeBinaryToWriter + ); + } }; @@ -7414,23 +11739,22 @@ proto.org.dash.platform.dapi.v0.GetIdentityBalanceAndRevisionResponse.prototype. * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.KeyRequestType.oneofGroups_ = [[1,2,3]]; +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.RequestCase = { - REQUEST_NOT_SET: 0, - ALL_KEYS: 1, - SPECIFIC_KEYS: 2, - SEARCH_KEY: 3 +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + DATA_CONTRACT: 1, + PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.KeyRequestType.RequestCase} + * @return {proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.getRequestCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.KeyRequestType.RequestCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.KeyRequestType.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.oneofGroups_[0])); }; @@ -7448,8 +11772,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.KeyRequestType.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.toObject(opt_includeInstance, this); }; @@ -7458,15 +11782,15 @@ proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.toObject = function(opt * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.KeyRequestType} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.KeyRequestType.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - allKeys: (f = msg.getAllKeys()) && proto.org.dash.platform.dapi.v0.AllKeys.toObject(includeInstance, f), - specificKeys: (f = msg.getSpecificKeys()) && proto.org.dash.platform.dapi.v0.SpecificKeys.toObject(includeInstance, f), - searchKey: (f = msg.getSearchKey()) && proto.org.dash.platform.dapi.v0.SearchKey.toObject(includeInstance, f) + dataContract: msg.getDataContract_asB64(), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; if (includeInstance) { @@ -7480,23 +11804,23 @@ proto.org.dash.platform.dapi.v0.KeyRequestType.toObject = function(includeInstan /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.KeyRequestType; - return proto.org.dash.platform.dapi.v0.KeyRequestType.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0; + return proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.KeyRequestType} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -7504,19 +11828,18 @@ proto.org.dash.platform.dapi.v0.KeyRequestType.deserializeBinaryFromReader = fun var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.AllKeys; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.AllKeys.deserializeBinaryFromReader); - msg.setAllKeys(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setDataContract(value); break; case 2: - var value = new proto.org.dash.platform.dapi.v0.SpecificKeys; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.SpecificKeys.deserializeBinaryFromReader); - msg.setSpecificKeys(value); + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); break; case 3: - var value = new proto.org.dash.platform.dapi.v0.SearchKey; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.SearchKey.deserializeBinaryFromReader); - msg.setSearchKey(value); + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); break; default: reader.skipField(); @@ -7531,9 +11854,9 @@ proto.org.dash.platform.dapi.v0.KeyRequestType.deserializeBinaryFromReader = fun * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.KeyRequestType.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -7541,64 +11864,86 @@ proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.serializeBinary = funct /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.KeyRequestType} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.KeyRequestType.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getAllKeys(); + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 1)); if (f != null) { - writer.writeMessage( + writer.writeBytes( 1, - f, - proto.org.dash.platform.dapi.v0.AllKeys.serializeBinaryToWriter + f ); } - f = message.getSpecificKeys(); + f = message.getProof(); if (f != null) { writer.writeMessage( 2, f, - proto.org.dash.platform.dapi.v0.SpecificKeys.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter ); } - f = message.getSearchKey(); + f = message.getMetadata(); if (f != null) { writer.writeMessage( 3, f, - proto.org.dash.platform.dapi.v0.SearchKey.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter ); } }; /** - * optional AllKeys all_keys = 1; - * @return {?proto.org.dash.platform.dapi.v0.AllKeys} + * optional bytes data_contract = 1; + * @return {string} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.getAllKeys = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.AllKeys} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.AllKeys, 1)); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getDataContract = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * @param {?proto.org.dash.platform.dapi.v0.AllKeys|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this -*/ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.setAllKeys = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.KeyRequestType.oneofGroups_[0], value); + * optional bytes data_contract = 1; + * This is a type-conversion wrapper around `getDataContract()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getDataContract_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getDataContract())); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this + * optional bytes data_contract = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getDataContract()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.clearAllKeys = function() { - return this.setAllKeys(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getDataContract_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getDataContract())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.setDataContract = function(value) { + return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.clearDataContract = function() { + return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.oneofGroups_[0], undefined); }; @@ -7606,36 +11951,36 @@ proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.clearAllKeys = function * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.hasAllKeys = function() { +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.hasDataContract = function() { return jspb.Message.getField(this, 1) != null; }; /** - * optional SpecificKeys specific_keys = 2; - * @return {?proto.org.dash.platform.dapi.v0.SpecificKeys} + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.getSpecificKeys = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.SpecificKeys} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.SpecificKeys, 2)); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.SpecificKeys|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.setSpecificKeys = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.KeyRequestType.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.clearSpecificKeys = function() { - return this.setSpecificKeys(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); }; @@ -7643,36 +11988,36 @@ proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.clearSpecificKeys = fun * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.hasSpecificKeys = function() { +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.hasProof = function() { return jspb.Message.getField(this, 2) != null; }; /** - * optional SearchKey search_key = 3; - * @return {?proto.org.dash.platform.dapi.v0.SearchKey} + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.getSearchKey = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.SearchKey} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.SearchKey, 3)); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.SearchKey|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.setSearchKey = function(value) { - return jspb.Message.setOneofWrapperField(this, 3, proto.org.dash.platform.dapi.v0.KeyRequestType.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.KeyRequestType} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.clearSearchKey = function() { - return this.setSearchKey(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); }; @@ -7680,119 +12025,73 @@ proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.clearSearchKey = functi * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.KeyRequestType.prototype.hasSearchKey = function() { +proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.hasMetadata = function() { return jspb.Message.getField(this, 3) != null; }; - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.org.dash.platform.dapi.v0.AllKeys.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.AllKeys.toObject(opt_includeInstance, this); -}; - - /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.AllKeys} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional GetDataContractResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} */ -proto.org.dash.platform.dapi.v0.AllKeys.toObject = function(includeInstance, msg) { - var f, obj = { - - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; +proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0, 1)); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.AllKeys} - */ -proto.org.dash.platform.dapi.v0.AllKeys.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.AllKeys; - return proto.org.dash.platform.dapi.v0.AllKeys.deserializeBinaryFromReader(msg, reader); + * @param {?proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractResponse.oneofGroups_[0], value); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.AllKeys} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.AllKeys} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} returns this */ -proto.org.dash.platform.dapi.v0.AllKeys.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.AllKeys.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.AllKeys.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; + /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.AllKeys} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const */ -proto.org.dash.platform.dapi.v0.AllKeys.serializeBinaryToWriter = function(message, writer) { - var f = undefined; -}; - +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.oneofGroups_ = [[1]]; +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; /** - * List of repeated fields within this message type. - * @private {!Array} - * @const + * @return {proto.org.dash.platform.dapi.v0.GetDataContractsRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.SpecificKeys.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractsRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractsRequest.oneofGroups_[0])); +}; @@ -7809,8 +12108,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.SpecificKeys.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractsRequest.toObject(opt_includeInstance, this); }; @@ -7819,13 +12118,13 @@ proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.toObject = function(opt_i * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.SpecificKeys} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.SpecificKeys.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.toObject = function(includeInstance, msg) { var f, obj = { - keyIdsList: (f = jspb.Message.getRepeatedField(msg, 1)) == null ? undefined : f + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -7839,23 +12138,23 @@ proto.org.dash.platform.dapi.v0.SpecificKeys.toObject = function(includeInstance /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.SpecificKeys} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} */ -proto.org.dash.platform.dapi.v0.SpecificKeys.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.SpecificKeys; - return proto.org.dash.platform.dapi.v0.SpecificKeys.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsRequest; + return proto.org.dash.platform.dapi.v0.GetDataContractsRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.SpecificKeys} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.SpecificKeys} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} */ -proto.org.dash.platform.dapi.v0.SpecificKeys.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -7863,10 +12162,9 @@ proto.org.dash.platform.dapi.v0.SpecificKeys.deserializeBinaryFromReader = funct var field = reader.getFieldNumber(); switch (field) { case 1: - var values = /** @type {!Array} */ (reader.isDelimited() ? reader.readPackedUint32() : [reader.readUint32()]); - for (var i = 0; i < values.length; i++) { - msg.addKeyIds(values[i]); - } + var value = new proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.deserializeBinaryFromReader); + msg.setV0(value); break; default: reader.skipField(); @@ -7881,9 +12179,9 @@ proto.org.dash.platform.dapi.v0.SpecificKeys.deserializeBinaryFromReader = funct * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.SpecificKeys.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractsRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -7891,59 +12189,30 @@ proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.serializeBinary = functio /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.SpecificKeys} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.SpecificKeys.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getKeyIdsList(); - if (f.length > 0) { - writer.writePackedUint32( + f = message.getV0(); + if (f != null) { + writer.writeMessage( 1, - f + f, + proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.serializeBinaryToWriter ); } }; -/** - * repeated uint32 key_ids = 1; - * @return {!Array} - */ -proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.getKeyIdsList = function() { - return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); -}; - - -/** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.SpecificKeys} returns this - */ -proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.setKeyIdsList = function(value) { - return jspb.Message.setField(this, 1, value || []); -}; - - -/** - * @param {number} value - * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.SpecificKeys} returns this - */ -proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.addKeyIds = function(value, opt_index) { - return jspb.Message.addToRepeatedField(this, 1, value, opt_index); -}; - /** - * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.SpecificKeys} returns this + * List of repeated fields within this message type. + * @private {!Array} + * @const */ -proto.org.dash.platform.dapi.v0.SpecificKeys.prototype.clearKeyIdsList = function() { - return this.setKeyIdsList([]); -}; - - +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.repeatedFields_ = [1]; @@ -7960,8 +12229,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.SearchKey.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.SearchKey.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.toObject(opt_includeInstance, this); }; @@ -7970,13 +12239,14 @@ proto.org.dash.platform.dapi.v0.SearchKey.prototype.toObject = function(opt_incl * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.SearchKey} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.SearchKey.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - purposeMapMap: (f = msg.getPurposeMapMap()) ? f.toObject(includeInstance, proto.org.dash.platform.dapi.v0.SecurityLevelMap.toObject) : [] + idsList: msg.getIdsList_asB64(), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) }; if (includeInstance) { @@ -7990,23 +12260,23 @@ proto.org.dash.platform.dapi.v0.SearchKey.toObject = function(includeInstance, m /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.SearchKey} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} */ -proto.org.dash.platform.dapi.v0.SearchKey.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.SearchKey; - return proto.org.dash.platform.dapi.v0.SearchKey.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0; + return proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.SearchKey} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.SearchKey} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} */ -proto.org.dash.platform.dapi.v0.SearchKey.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -8014,10 +12284,12 @@ proto.org.dash.platform.dapi.v0.SearchKey.deserializeBinaryFromReader = function var field = reader.getFieldNumber(); switch (field) { case 1: - var value = msg.getPurposeMapMap(); - reader.readMessage(value, function(message, reader) { - jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readUint32, jspb.BinaryReader.prototype.readMessage, proto.org.dash.platform.dapi.v0.SecurityLevelMap.deserializeBinaryFromReader, 0, new proto.org.dash.platform.dapi.v0.SecurityLevelMap()); - }); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.addIds(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); break; default: reader.skipField(); @@ -8032,9 +12304,9 @@ proto.org.dash.platform.dapi.v0.SearchKey.deserializeBinaryFromReader = function * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.SearchKey.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.SearchKey.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -8042,180 +12314,143 @@ proto.org.dash.platform.dapi.v0.SearchKey.prototype.serializeBinary = function() /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.SearchKey} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.SearchKey.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getPurposeMapMap(true); - if (f && f.getLength() > 0) { - f.serializeBinary(1, writer, jspb.BinaryWriter.prototype.writeUint32, jspb.BinaryWriter.prototype.writeMessage, proto.org.dash.platform.dapi.v0.SecurityLevelMap.serializeBinaryToWriter); + f = message.getIdsList_asU8(); + if (f.length > 0) { + writer.writeRepeatedBytes( + 1, + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 2, + f + ); } }; /** - * map purpose_map = 1; - * @param {boolean=} opt_noLazyCreate Do not create the map if - * empty, instead returning `undefined` - * @return {!jspb.Map} + * repeated bytes ids = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.SearchKey.prototype.getPurposeMapMap = function(opt_noLazyCreate) { - return /** @type {!jspb.Map} */ ( - jspb.Message.getMapField(this, 1, opt_noLazyCreate, - proto.org.dash.platform.dapi.v0.SecurityLevelMap)); +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.getIdsList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); }; /** - * Clears values from the map. The map will be non-null. - * @return {!proto.org.dash.platform.dapi.v0.SearchKey} returns this + * repeated bytes ids = 1; + * This is a type-conversion wrapper around `getIdsList()` + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.SearchKey.prototype.clearPurposeMapMap = function() { - this.getPurposeMapMap().clear(); - return this;}; - +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.getIdsList_asB64 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsB64( + this.getIdsList())); +}; +/** + * repeated bytes ids = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getIdsList()` + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.getIdsList_asU8 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsU8( + this.getIdsList())); +}; -if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} + * @param {!(Array|Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.SecurityLevelMap.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.SecurityLevelMap.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.setIdsList = function(value) { + return jspb.Message.setField(this, 1, value || []); }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * @param {!(string|Uint8Array)} value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.SecurityLevelMap.toObject = function(includeInstance, msg) { - var f, obj = { - securityLevelMapMap: (f = msg.getSecurityLevelMapMap()) ? f.toObject(includeInstance, undefined) : [] - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.addIds = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 1, value, opt_index); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.SecurityLevelMap.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.SecurityLevelMap; - return proto.org.dash.platform.dapi.v0.SecurityLevelMap.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.clearIdsList = function() { + return this.setIdsList([]); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} + * optional bool prove = 2; + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.SecurityLevelMap.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = msg.getSecurityLevelMapMap(); - reader.readMessage(value, function(message, reader) { - jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readUint32, jspb.BinaryReader.prototype.readEnum, null, 0, 0); - }); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); }; /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.SecurityLevelMap.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.SecurityLevelMap.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); }; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional GetDataContractsRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} */ -proto.org.dash.platform.dapi.v0.SecurityLevelMap.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getSecurityLevelMapMap(true); - if (f && f.getLength() > 0) { - f.serializeBinary(1, writer, jspb.BinaryWriter.prototype.writeUint32, jspb.BinaryWriter.prototype.writeEnum); - } +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0, 1)); }; /** - * @enum {number} - */ -proto.org.dash.platform.dapi.v0.SecurityLevelMap.KeyKindRequestType = { - CURRENT_KEY_OF_KIND_REQUEST: 0, - ALL_KEYS_OF_KIND_REQUEST: 1 + * @param {?proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractsRequest.oneofGroups_[0], value); }; + /** - * map security_level_map = 1; - * @param {boolean=} opt_noLazyCreate Do not create the map if - * empty, instead returning `undefined` - * @return {!jspb.Map} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} returns this */ -proto.org.dash.platform.dapi.v0.SecurityLevelMap.prototype.getSecurityLevelMapMap = function(opt_noLazyCreate) { - return /** @type {!jspb.Map} */ ( - jspb.Message.getMapField(this, 1, opt_noLazyCreate, - null)); +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * Clears values from the map. The map will be non-null. - * @return {!proto.org.dash.platform.dapi.v0.SecurityLevelMap} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.SecurityLevelMap.prototype.clearSecurityLevelMapMap = function() { - this.getSecurityLevelMapMap().clear(); - return this;}; +proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; @@ -8227,21 +12462,21 @@ proto.org.dash.platform.dapi.v0.SecurityLevelMap.prototype.clearSecurityLevelMap * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetDataContractsResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractsResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.oneofGroups_[0])); }; @@ -8259,8 +12494,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.toObject(opt_includeInstance, this); }; @@ -8269,13 +12504,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.toObject = func * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -8289,23 +12524,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.toObject = function(inclu /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest; - return proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse; + return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -8313,8 +12548,8 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.deserializeBinaryFromRead var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -8330,9 +12565,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.deserializeBinaryFromRead * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractsResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -8340,18 +12575,18 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.serializeBinary /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.serializeBinaryToWriter ); } }; @@ -8373,8 +12608,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.toObject(opt_includeInstance, this); }; @@ -8383,17 +12618,14 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.toObject = function(includeInstance, msg) { var f, obj = { - identityId: msg.getIdentityId_asB64(), - requestType: (f = msg.getRequestType()) && proto.org.dash.platform.dapi.v0.KeyRequestType.toObject(includeInstance, f), - limit: (f = msg.getLimit()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), - offset: (f = msg.getOffset()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 5, false) + identifier: msg.getIdentifier_asB64(), + dataContract: (f = msg.getDataContract()) && google_protobuf_wrappers_pb.BytesValue.toObject(includeInstance, f) }; if (includeInstance) { @@ -8407,23 +12639,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0. /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0; - return proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry; + return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -8432,26 +12664,12 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0. switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setIdentityId(value); + msg.setIdentifier(value); break; case 2: - var value = new proto.org.dash.platform.dapi.v0.KeyRequestType; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.KeyRequestType.deserializeBinaryFromReader); - msg.setRequestType(value); - break; - case 3: - var value = new google_protobuf_wrappers_pb.UInt32Value; - reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); - msg.setLimit(value); - break; - case 4: - var value = new google_protobuf_wrappers_pb.UInt32Value; - reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); - msg.setOffset(value); - break; - case 5: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); + var value = new google_protobuf_wrappers_pb.BytesValue; + reader.readMessage(value,google_protobuf_wrappers_pb.BytesValue.deserializeBinaryFromReader); + msg.setDataContract(value); break; default: reader.skipField(); @@ -8466,9 +12684,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0. * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -8476,120 +12694,97 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0. /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getIdentityId_asU8(); - if (f.length > 0) { - writer.writeBytes( - 1, - f - ); - } - f = message.getRequestType(); - if (f != null) { - writer.writeMessage( - 2, - f, - proto.org.dash.platform.dapi.v0.KeyRequestType.serializeBinaryToWriter - ); - } - f = message.getLimit(); - if (f != null) { - writer.writeMessage( - 3, - f, - google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getIdentifier_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f ); } - f = message.getOffset(); + f = message.getDataContract(); if (f != null) { writer.writeMessage( - 4, + 2, f, - google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter - ); - } - f = message.getProve(); - if (f) { - writer.writeBool( - 5, - f + google_protobuf_wrappers_pb.BytesValue.serializeBinaryToWriter ); } }; /** - * optional bytes identity_id = 1; + * optional bytes identifier = 1; * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getIdentityId = function() { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.getIdentifier = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * optional bytes identity_id = 1; - * This is a type-conversion wrapper around `getIdentityId()` + * optional bytes identifier = 1; + * This is a type-conversion wrapper around `getIdentifier()` * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getIdentityId_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.getIdentifier_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getIdentityId())); + this.getIdentifier())); }; /** - * optional bytes identity_id = 1; + * optional bytes identifier = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getIdentityId()` + * This is a type-conversion wrapper around `getIdentifier()` * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getIdentityId_asU8 = function() { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.getIdentifier_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getIdentityId())); + this.getIdentifier())); }; /** * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.setIdentityId = function(value) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.setIdentifier = function(value) { return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional KeyRequestType request_type = 2; - * @return {?proto.org.dash.platform.dapi.v0.KeyRequestType} + * optional google.protobuf.BytesValue data_contract = 2; + * @return {?proto.google.protobuf.BytesValue} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getRequestType = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.KeyRequestType} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.KeyRequestType, 2)); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.getDataContract = function() { + return /** @type{?proto.google.protobuf.BytesValue} */ ( + jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.BytesValue, 2)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.KeyRequestType|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this + * @param {?proto.google.protobuf.BytesValue|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.setRequestType = function(value) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.setDataContract = function(value) { return jspb.Message.setWrapperField(this, 2, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.clearRequestType = function() { - return this.setRequestType(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.clearDataContract = function() { + return this.setDataContract(undefined); }; @@ -8597,137 +12792,168 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0. * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.hasRequestType = function() { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.hasDataContract = function() { return jspb.Message.getField(this, 2) != null; }; -/** - * optional google.protobuf.UInt32Value limit = 3; - * @return {?proto.google.protobuf.UInt32Value} - */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getLimit = function() { - return /** @type{?proto.google.protobuf.UInt32Value} */ ( - jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 3)); -}; - - -/** - * @param {?proto.google.protobuf.UInt32Value|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.setLimit = function(value) { - return jspb.Message.setWrapperField(this, 3, value); -}; - /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this + * List of repeated fields within this message type. + * @private {!Array} + * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.clearLimit = function() { - return this.setLimit(undefined); -}; +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.repeatedFields_ = [1]; + +if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Returns whether this field is set. - * @return {boolean} + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.hasLimit = function() { - return jspb.Message.getField(this, 3) != null; +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.toObject(opt_includeInstance, this); }; /** - * optional google.protobuf.UInt32Value offset = 4; - * @return {?proto.google.protobuf.UInt32Value} + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getOffset = function() { - return /** @type{?proto.google.protobuf.UInt32Value} */ ( - jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 4)); -}; - +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.toObject = function(includeInstance, msg) { + var f, obj = { + dataContractEntriesList: jspb.Message.toObjectList(msg.getDataContractEntriesList(), + proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.toObject, includeInstance) + }; -/** - * @param {?proto.google.protobuf.UInt32Value|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.setOffset = function(value) { - return jspb.Message.setWrapperField(this, 4, value); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; }; +} /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.clearOffset = function() { - return this.setOffset(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts; + return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.deserializeBinaryFromReader(msg, reader); }; /** - * Returns whether this field is set. - * @return {boolean} + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.hasOffset = function() { - return jspb.Message.getField(this, 4) != null; +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.deserializeBinaryFromReader); + msg.addDataContractEntries(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; }; /** - * optional bool prove = 5; - * @return {boolean} + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 5, false)); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); }; /** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} returns this + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 5, value); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getDataContractEntriesList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.serializeBinaryToWriter + ); + } }; /** - * optional GetIdentityKeysRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} + * repeated DataContractEntry data_contract_entries = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.getDataContractEntriesList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.GetIdentityKeysRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} returns this + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.setDataContractEntriesList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest} returns this + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry=} opt_value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.clearV0 = function() { - return this.setV0(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.addDataContractEntries = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry, opt_index); }; /** - * Returns whether this field is set. - * @return {boolean} + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.clearDataContractEntriesList = function() { + return this.setDataContractEntriesList([]); }; @@ -8740,21 +12966,22 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysRequest.prototype.hasV0 = functio * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.oneofGroups_ = [[1,2]]; /** - * @enum {number} - */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + DATA_CONTRACTS: 1, + PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.oneofGroups_[0])); }; @@ -8772,8 +12999,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.toObject(opt_includeInstance, this); }; @@ -8782,13 +13009,15 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.toObject = fun * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.toObject(includeInstance, f) + dataContracts: (f = msg.getDataContracts()) && proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.toObject(includeInstance, f), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; if (includeInstance) { @@ -8802,23 +13031,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.toObject = function(incl /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse; - return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0; + return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -8826,9 +13055,19 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.deserializeBinaryFromRea var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.deserializeBinaryFromReader); - msg.setV0(value); + var value = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.deserializeBinaryFromReader); + msg.setDataContracts(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); break; default: reader.skipField(); @@ -8843,9 +13082,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.deserializeBinaryFromRea * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -8853,23 +13092,187 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.serializeBinar /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getV0(); + f = message.getDataContracts(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.serializeBinaryToWriter + ); + } + f = message.getProof(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + ); + } + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter ); } }; +/** + * optional DataContracts data_contracts = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.getDataContracts = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.setDataContracts = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.clearDataContracts = function() { + return this.setDataContracts(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.hasDataContracts = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional GetDataContractsResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} returns this + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.clearV0 = function() { + return this.setV0(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + /** * Oneof group definitions for this message. Each group defines the field @@ -8879,22 +13282,21 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.serializeBinaryToWriter * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.ResultCase = { - RESULT_NOT_SET: 0, - KEYS: 1, - PROOF: 2 +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.ResultCase} + * @return {proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.oneofGroups_[0])); }; @@ -8912,8 +13314,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.toObject(opt_includeInstance, this); }; @@ -8922,15 +13324,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.toObject = function(includeInstance, msg) { - var f, obj = { - keys: (f = msg.getKeys()) && proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.toObject(includeInstance, f), - proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), - metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -8944,23 +13344,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0; - return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest; + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -8968,19 +13368,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.deserializeBinaryFromReader); - msg.setKeys(value); - break; - case 2: - var value = new proto.org.dash.platform.dapi.v0.Proof; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); - msg.setProof(value); - break; - case 3: - var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); - msg.setMetadata(value); + var value = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.deserializeBinaryFromReader); + msg.setV0(value); break; default: reader.skipField(); @@ -8995,9 +13385,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -9005,47 +13395,24 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getKeys(); + f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.serializeBinaryToWriter - ); - } - f = message.getProof(); - if (f != null) { - writer.writeMessage( - 2, - f, - proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter - ); - } - f = message.getMetadata(); - if (f != null) { - writer.writeMessage( - 3, - f, - proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.serializeBinaryToWriter ); } }; -/** - * List of repeated fields within this message type. - * @private {!Array} - * @const - */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.repeatedFields_ = [1]; - if (jspb.Message.GENERATE_TO_OBJECT) { @@ -9061,8 +13428,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.toObject(opt_includeInstance, this); }; @@ -9071,13 +13438,17 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - keysBytesList: msg.getKeysBytesList_asB64() + id: msg.getId_asB64(), + limit: (f = msg.getLimit()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), + offset: (f = msg.getOffset()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), + startAtMs: jspb.Message.getFieldWithDefault(msg, 4, 0), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 5, false) }; if (includeInstance) { @@ -9091,23 +13462,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys; - return proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0; + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -9116,7 +13487,25 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.addKeysBytes(value); + msg.setId(value); + break; + case 2: + var value = new google_protobuf_wrappers_pb.UInt32Value; + reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); + msg.setLimit(value); + break; + case 3: + var value = new google_protobuf_wrappers_pb.UInt32Value; + reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); + msg.setOffset(value); + break; + case 4: + var value = /** @type {number} */ (reader.readUint64()); + msg.setStartAtMs(value); + break; + case 5: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); break; default: reader.skipField(); @@ -9131,9 +13520,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -9141,108 +13530,119 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getKeysBytesList_asU8(); + f = message.getId_asU8(); if (f.length > 0) { - writer.writeRepeatedBytes( + writer.writeBytes( 1, f ); } + f = message.getLimit(); + if (f != null) { + writer.writeMessage( + 2, + f, + google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter + ); + } + f = message.getOffset(); + if (f != null) { + writer.writeMessage( + 3, + f, + google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter + ); + } + f = message.getStartAtMs(); + if (f !== 0) { + writer.writeUint64( + 4, + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 5, + f + ); + } }; /** - * repeated bytes keys_bytes = 1; - * @return {!Array} + * optional bytes id = 1; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.getKeysBytesList = function() { - return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * repeated bytes keys_bytes = 1; - * This is a type-conversion wrapper around `getKeysBytesList()` - * @return {!Array} + * optional bytes id = 1; + * This is a type-conversion wrapper around `getId()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.getKeysBytesList_asB64 = function() { - return /** @type {!Array} */ (jspb.Message.bytesListAsB64( - this.getKeysBytesList())); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getId())); }; /** - * repeated bytes keys_bytes = 1; + * optional bytes id = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getKeysBytesList()` - * @return {!Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.getKeysBytesList_asU8 = function() { - return /** @type {!Array} */ (jspb.Message.bytesListAsU8( - this.getKeysBytesList())); -}; - - -/** - * @param {!(Array|Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} returns this + * This is a type-conversion wrapper around `getId()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.setKeysBytesList = function(value) { - return jspb.Message.setField(this, 1, value || []); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getId())); }; /** * @param {!(string|Uint8Array)} value - * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.addKeysBytes = function(value, opt_index) { - return jspb.Message.addToRepeatedField(this, 1, value, opt_index); -}; - - -/** - * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys.prototype.clearKeysBytesList = function() { - return this.setKeysBytesList([]); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.setId = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional Keys keys = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} + * optional google.protobuf.UInt32Value limit = 2; + * @return {?proto.google.protobuf.UInt32Value} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.getKeys = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys, 1)); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getLimit = function() { + return /** @type{?proto.google.protobuf.UInt32Value} */ ( + jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 2)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.Keys|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this + * @param {?proto.google.protobuf.UInt32Value|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.setKeys = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.setLimit = function(value) { + return jspb.Message.setWrapperField(this, 2, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.clearKeys = function() { - return this.setKeys(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.clearLimit = function() { + return this.setLimit(undefined); }; @@ -9250,36 +13650,36 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.hasKeys = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.hasLimit = function() { + return jspb.Message.getField(this, 2) != null; }; /** - * optional Proof proof = 2; - * @return {?proto.org.dash.platform.dapi.v0.Proof} + * optional google.protobuf.UInt32Value offset = 3; + * @return {?proto.google.protobuf.UInt32Value} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.getProof = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getOffset = function() { + return /** @type{?proto.google.protobuf.UInt32Value} */ ( + jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 3)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this + * @param {?proto.google.protobuf.UInt32Value|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.setOffset = function(value) { + return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.clearProof = function() { - return this.setProof(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.clearOffset = function() { + return this.setOffset(undefined); }; @@ -9287,72 +13687,71 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.hasProof = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.hasOffset = function() { + return jspb.Message.getField(this, 3) != null; }; /** - * optional ResponseMetadata metadata = 3; - * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + * optional uint64 start_at_ms = 4; + * @return {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.getMetadata = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getStartAtMs = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.setMetadata = function(value) { - return jspb.Message.setWrapperField(this, 3, value); + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.setStartAtMs = function(value) { + return jspb.Message.setProto3IntField(this, 4, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} returns this + * optional bool prove = 5; + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.clearMetadata = function() { - return this.setMetadata(undefined); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 5, false)); }; /** - * Returns whether this field is set. - * @return {boolean} + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0.prototype.hasMetadata = function() { - return jspb.Message.getField(this, 3) != null; +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 5, value); }; /** - * optional GetIdentityKeysResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} + * optional GetDataContractHistoryRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.GetIdentityKeysResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -9361,7 +13760,7 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.clearV0 = func * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -9375,21 +13774,21 @@ proto.org.dash.platform.dapi.v0.GetIdentityKeysResponse.prototype.hasV0 = functi * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetProofsRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetProofsRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProofsRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.oneofGroups_[0])); }; @@ -9407,8 +13806,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProofsRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.toObject(opt_includeInstance, this); }; @@ -9417,13 +13816,13 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.toObject = function(o * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -9437,23 +13836,23 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.toObject = function(includeInst /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProofsRequest; - return proto.org.dash.platform.dapi.v0.GetProofsRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse; + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -9461,8 +13860,8 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.deserializeBinaryFromReader = f var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -9478,9 +13877,9 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.deserializeBinaryFromReader = f * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProofsRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -9488,176 +13887,50 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.serializeBinary = fun /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.serializeBinaryToWriter - ); - } -}; - - - -/** - * List of repeated fields within this message type. - * @private {!Array} - * @const - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.repeatedFields_ = [1,2,3]; - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.toObject = function(includeInstance, msg) { - var f, obj = { - identitiesList: jspb.Message.toObjectList(msg.getIdentitiesList(), - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.toObject, includeInstance), - contractsList: jspb.Message.toObjectList(msg.getContractsList(), - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.toObject, includeInstance), - documentsList: jspb.Message.toObjectList(msg.getDocumentsList(), - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.toObject, includeInstance) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0; - return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.deserializeBinaryFromReader); - msg.addIdentities(value); - break; - case 2: - var value = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.deserializeBinaryFromReader); - msg.addContracts(value); - break; - case 3: - var value = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.deserializeBinaryFromReader); - msg.addDocuments(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getIdentitiesList(); - if (f.length > 0) { - writer.writeRepeatedMessage( - 1, - f, - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.serializeBinaryToWriter - ); - } - f = message.getContractsList(); - if (f.length > 0) { - writer.writeRepeatedMessage( - 2, - f, - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.serializeBinaryToWriter - ); - } - f = message.getDocumentsList(); - if (f.length > 0) { - writer.writeRepeatedMessage( - 3, - f, - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.serializeBinaryToWriter ); } }; +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.oneofGroups_ = [[1,2]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + DATA_CONTRACT_HISTORY: 1, + PROOF: 2 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.ResultCase} + */ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.oneofGroups_[0])); +}; + if (jspb.Message.GENERATE_TO_OBJECT) { @@ -9673,8 +13946,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.toObject(opt_includeInstance, this); }; @@ -9683,16 +13956,15 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequ * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - contractId: msg.getContractId_asB64(), - documentType: jspb.Message.getFieldWithDefault(msg, 2, ""), - documentTypeKeepsHistory: jspb.Message.getBooleanFieldWithDefault(msg, 3, false), - documentId: msg.getDocumentId_asB64() + dataContractHistory: (f = msg.getDataContractHistory()) && proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.toObject(includeInstance, f), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; if (includeInstance) { @@ -9706,23 +13978,23 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequ /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest; - return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0; + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -9730,20 +14002,19 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequ var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setContractId(value); + var value = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.deserializeBinaryFromReader); + msg.setDataContractHistory(value); break; case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setDocumentType(value); + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); break; case 3: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setDocumentTypeKeepsHistory(value); - break; - case 4: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setDocumentId(value); + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); break; default: reader.skipField(); @@ -9758,9 +14029,9 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequ * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -9768,163 +14039,39 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequ /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getContractId_asU8(); - if (f.length > 0) { - writer.writeBytes( + f = message.getDataContractHistory(); + if (f != null) { + writer.writeMessage( 1, - f + f, + proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.serializeBinaryToWriter ); } - f = message.getDocumentType(); - if (f.length > 0) { - writer.writeString( + f = message.getProof(); + if (f != null) { + writer.writeMessage( 2, - f + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter ); } - f = message.getDocumentTypeKeepsHistory(); - if (f) { - writer.writeBool( + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( 3, - f - ); - } - f = message.getDocumentId_asU8(); - if (f.length > 0) { - writer.writeBytes( - 4, - f + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter ); } }; -/** - * optional bytes contract_id = 1; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getContractId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * optional bytes contract_id = 1; - * This is a type-conversion wrapper around `getContractId()` - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getContractId_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getContractId())); -}; - - -/** - * optional bytes contract_id = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getContractId()` - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getContractId_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getContractId())); -}; - - -/** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} returns this - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.setContractId = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); -}; - - -/** - * optional string document_type = 2; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getDocumentType = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); -}; - - -/** - * @param {string} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} returns this - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.setDocumentType = function(value) { - return jspb.Message.setProto3StringField(this, 2, value); -}; - - -/** - * optional bool document_type_keeps_history = 3; - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getDocumentTypeKeepsHistory = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 3, false)); -}; - - -/** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} returns this - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.setDocumentTypeKeepsHistory = function(value) { - return jspb.Message.setProto3BooleanField(this, 3, value); -}; - - -/** - * optional bytes document_id = 4; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getDocumentId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); -}; - - -/** - * optional bytes document_id = 4; - * This is a type-conversion wrapper around `getDocumentId()` - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getDocumentId_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getDocumentId())); -}; - - -/** - * optional bytes document_id = 4; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getDocumentId()` - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.getDocumentId_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getDocumentId())); -}; - - -/** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} returns this - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest.prototype.setDocumentId = function(value) { - return jspb.Message.setProto3BytesField(this, 4, value); -}; - - @@ -9941,8 +14088,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.toObject(opt_includeInstance, this); }; @@ -9951,14 +14098,14 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequ * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.toObject = function(includeInstance, msg) { var f, obj = { - identityId: msg.getIdentityId_asB64(), - requestType: jspb.Message.getFieldWithDefault(msg, 2, 0) + date: jspb.Message.getFieldWithDefault(msg, 1, 0), + value: msg.getValue_asB64() }; if (includeInstance) { @@ -9972,23 +14119,23 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequ /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest; - return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry; + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -9996,12 +14143,12 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequ var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setIdentityId(value); + var value = /** @type {number} */ (reader.readUint64()); + msg.setDate(value); break; case 2: - var value = /** @type {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type} */ (reader.readEnum()); - msg.setRequestType(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setValue(value); break; default: reader.skipField(); @@ -10016,9 +14163,9 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequ * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -10026,22 +14173,22 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequ /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getIdentityId_asU8(); - if (f.length > 0) { - writer.writeBytes( + f = message.getDate(); + if (f !== 0) { + writer.writeUint64( 1, f ); } - f = message.getRequestType(); - if (f !== 0.0) { - writer.writeEnum( + f = message.getValue_asU8(); + if (f.length > 0) { + writer.writeBytes( 2, f ); @@ -10050,74 +14197,72 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequ /** - * @enum {number} + * optional uint64 date = 1; + * @return {number} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type = { - FULL_IDENTITY: 0, - BALANCE: 1, - KEYS: 2 +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.getDate = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); }; + /** - * optional bytes identity_id = 1; + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} returns this + */ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.setDate = function(value) { + return jspb.Message.setProto3IntField(this, 1, value); +}; + + +/** + * optional bytes value = 2; * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.getIdentityId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.getValue = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** - * optional bytes identity_id = 1; - * This is a type-conversion wrapper around `getIdentityId()` + * optional bytes value = 2; + * This is a type-conversion wrapper around `getValue()` * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.getIdentityId_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.getValue_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getIdentityId())); + this.getValue())); }; /** - * optional bytes identity_id = 1; + * optional bytes value = 2; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getIdentityId()` + * This is a type-conversion wrapper around `getValue()` * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.getIdentityId_asU8 = function() { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.getValue_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getIdentityId())); + this.getValue())); }; /** * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.setIdentityId = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.setValue = function(value) { + return jspb.Message.setProto3BytesField(this, 2, value); }; -/** - * optional Type request_type = 2; - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type} - */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.getRequestType = function() { - return /** @type {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); -}; - /** - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.Type} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} returns this + * List of repeated fields within this message type. + * @private {!Array} + * @const */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest.prototype.setRequestType = function(value) { - return jspb.Message.setProto3EnumField(this, 2, value); -}; - - +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.repeatedFields_ = [1]; @@ -10134,8 +14279,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.toObject(opt_includeInstance, this); }; @@ -10144,13 +14289,14 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequ * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.toObject = function(includeInstance, msg) { var f, obj = { - contractId: msg.getContractId_asB64() + dataContractEntriesList: jspb.Message.toObjectList(msg.getDataContractEntriesList(), + proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.toObject, includeInstance) }; if (includeInstance) { @@ -10164,23 +14310,23 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequ /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest; - return proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory; + return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -10188,8 +14334,9 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequ var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setContractId(value); + var value = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.deserializeBinaryFromReader); + msg.addDataContractEntries(value); break; default: reader.skipField(); @@ -10204,9 +14351,9 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequ * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -10214,212 +14361,345 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequ /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getContractId_asU8(); + f = message.getDataContractEntriesList(); if (f.length > 0) { - writer.writeBytes( + writer.writeRepeatedMessage( 1, - f + f, + proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.serializeBinaryToWriter ); } }; /** - * optional bytes contract_id = 1; - * @return {string} + * repeated DataContractHistoryEntry data_contract_entries = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.getContractId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.getDataContractEntriesList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry, 1)); }; /** - * optional bytes contract_id = 1; - * This is a type-conversion wrapper around `getContractId()` - * @return {string} + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.setDataContractEntriesList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); +}; + + +/** + * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry=} opt_value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.getContractId_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getContractId())); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.addDataContractEntries = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} returns this + */ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.clearDataContractEntriesList = function() { + return this.setDataContractEntriesList([]); +}; + + +/** + * optional DataContractHistory data_contract_history = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} + */ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.getDataContractHistory = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.setDataContractHistory = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.clearDataContractHistory = function() { + return this.setDataContractHistory(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.hasDataContractHistory = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.oneofGroups_[0], value); }; /** - * optional bytes contract_id = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getContractId()` - * @return {!Uint8Array} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.getContractId_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getContractId())); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest.prototype.setContractId = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; }; /** - * repeated IdentityRequest identities = 1; - * @return {!Array} + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.getIdentitiesList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest, 1)); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; /** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.setIdentitiesList = function(value) { - return jspb.Message.setRepeatedWrapperField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); }; /** - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest=} opt_value - * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.addIdentities = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.IdentityRequest, opt_index); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); }; /** - * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.clearIdentitiesList = function() { - return this.setIdentitiesList([]); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; }; /** - * repeated ContractRequest contracts = 2; - * @return {!Array} + * optional GetDataContractHistoryResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.getContractsList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest, 2)); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0, 1)); }; /** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.setContractsList = function(value) { - return jspb.Message.setRepeatedWrapperField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.oneofGroups_[0], value); }; /** - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest=} opt_value - * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.addContracts = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 2, opt_value, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.ContractRequest, opt_index); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.clearContractsList = function() { - return this.setContractsList([]); +proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; + /** - * repeated DocumentRequest documents = 3; - * @return {!Array} + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.getDocumentsList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest, 3)); -}; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.oneofGroups_ = [[1]]; +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; /** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.setDocumentsList = function(value) { - return jspb.Message.setRepeatedWrapperField(this, 3, value); + * @return {proto.org.dash.platform.dapi.v0.GetDocumentsRequest.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentsRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.oneofGroups_[0])); }; + +if (jspb.Message.GENERATE_TO_OBJECT) { /** - * @param {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest=} opt_value - * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest} + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.addDocuments = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 3, opt_value, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.DocumentRequest, opt_index); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentsRequest.toObject(opt_includeInstance, this); }; /** - * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} returns this + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0.prototype.clearDocumentsList = function() { - return this.setDocumentsList([]); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; }; +} /** - * optional GetProofsRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentsRequest; + return proto.org.dash.platform.dapi.v0.GetDocumentsRequest.deserializeBinaryFromReader(msg, reader); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetProofsRequest.GetProofsRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest} returns this -*/ -proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProofsRequest.oneofGroups_[0], value); + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsRequest} returns this + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.clearV0 = function() { - return this.setV0(undefined); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetDocumentsRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); }; /** - * Returns whether this field is set. - * @return {boolean} + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.serializeBinaryToWriter + ); + } }; @@ -10432,21 +14712,22 @@ proto.org.dash.platform.dapi.v0.GetProofsRequest.prototype.hasV0 = function() { * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_ = [[6,7]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.StartCase = { + START_NOT_SET: 0, + START_AFTER: 6, + START_AT: 7 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetProofsResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.StartCase} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetProofsResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProofsResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.StartCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_[0])); }; @@ -10464,8 +14745,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProofsResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.toObject(opt_includeInstance, this); }; @@ -10474,13 +14755,20 @@ proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.toObject = function( * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.toObject(includeInstance, f) + dataContractId: msg.getDataContractId_asB64(), + documentType: jspb.Message.getFieldWithDefault(msg, 2, ""), + where: msg.getWhere_asB64(), + orderBy: msg.getOrderBy_asB64(), + limit: jspb.Message.getFieldWithDefault(msg, 5, 0), + startAfter: msg.getStartAfter_asB64(), + startAt: msg.getStartAt_asB64(), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 8, false) }; if (includeInstance) { @@ -10494,23 +14782,23 @@ proto.org.dash.platform.dapi.v0.GetProofsResponse.toObject = function(includeIns /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProofsResponse; - return proto.org.dash.platform.dapi.v0.GetProofsResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0; + return proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -10518,9 +14806,36 @@ proto.org.dash.platform.dapi.v0.GetProofsResponse.deserializeBinaryFromReader = var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.deserializeBinaryFromReader); - msg.setV0(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setDataContractId(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setDocumentType(value); + break; + case 3: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setWhere(value); + break; + case 4: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setOrderBy(value); + break; + case 5: + var value = /** @type {number} */ (reader.readUint32()); + msg.setLimit(value); + break; + case 6: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setStartAfter(value); + break; + case 7: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setStartAt(value); + break; + case 8: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); break; default: reader.skipField(); @@ -10535,9 +14850,9 @@ proto.org.dash.platform.dapi.v0.GetProofsResponse.deserializeBinaryFromReader = * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProofsResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -10545,238 +14860,281 @@ proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.serializeBinary = fu /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getV0(); - if (f != null) { - writer.writeMessage( + f = message.getDataContractId_asU8(); + if (f.length > 0) { + writer.writeBytes( 1, - f, - proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.serializeBinaryToWriter + f + ); + } + f = message.getDocumentType(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getWhere_asU8(); + if (f.length > 0) { + writer.writeBytes( + 3, + f + ); + } + f = message.getOrderBy_asU8(); + if (f.length > 0) { + writer.writeBytes( + 4, + f + ); + } + f = message.getLimit(); + if (f !== 0) { + writer.writeUint32( + 5, + f + ); + } + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 6)); + if (f != null) { + writer.writeBytes( + 6, + f + ); + } + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 7)); + if (f != null) { + writer.writeBytes( + 7, + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 8, + f ); } }; +/** + * optional bytes data_contract_id = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getDataContractId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes data_contract_id = 1; + * This is a type-conversion wrapper around `getDataContractId()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getDataContractId_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getDataContractId())); +}; + /** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const + * optional bytes data_contract_id = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getDataContractId()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getDataContractId_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getDataContractId())); +}; + /** - * @enum {number} + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.ResultCase = { - RESULT_NOT_SET: 0, - PROOF: 1 +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setDataContractId = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); }; + /** - * @return {proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.ResultCase} + * optional string document_type = 2; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getDocumentType = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setDocumentType = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + -if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} + * optional bytes where = 3; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getWhere = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional bytes where = 3; + * This is a type-conversion wrapper around `getWhere()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.toObject = function(includeInstance, msg) { - var f, obj = { - proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), - metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) - }; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getWhere_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getWhere())); +}; - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; + +/** + * optional bytes where = 3; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getWhere()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getWhere_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getWhere())); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0; - return proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setWhere = function(value) { + return jspb.Message.setProto3BytesField(this, 3, value); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} + * optional bytes order_by = 4; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getOrderBy = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** + * optional bytes order_by = 4; + * This is a type-conversion wrapper around `getOrderBy()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.org.dash.platform.dapi.v0.Proof; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); - msg.setProof(value); - break; - case 2: - var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); - msg.setMetadata(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getOrderBy_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getOrderBy())); }; /** - * Serializes the message to binary data (in protobuf wire format). + * optional bytes order_by = 4; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getOrderBy()` * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getOrderBy_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getOrderBy())); }; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getProof(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter - ); - } - f = message.getMetadata(); - if (f != null) { - writer.writeMessage( - 2, - f, - proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter - ); - } +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setOrderBy = function(value) { + return jspb.Message.setProto3BytesField(this, 4, value); }; /** - * optional Proof proof = 1; - * @return {?proto.org.dash.platform.dapi.v0.Proof} + * optional uint32 limit = 5; + * @return {number} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.getProof = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 1)); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getLimit = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.oneofGroups_[0], value); + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setLimit = function(value) { + return jspb.Message.setProto3IntField(this, 5, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} returns this + * optional bytes start_after = 6; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.clearProof = function() { - return this.setProof(undefined); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAfter = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, "")); }; /** - * Returns whether this field is set. - * @return {boolean} + * optional bytes start_after = 6; + * This is a type-conversion wrapper around `getStartAfter()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.hasProof = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAfter_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getStartAfter())); }; /** - * optional ResponseMetadata metadata = 2; - * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + * optional bytes start_after = 6; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getStartAfter()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.getMetadata = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 2)); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAfter_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getStartAfter())); }; /** - * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.setMetadata = function(value) { - return jspb.Message.setWrapperField(this, 2, value); + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setStartAfter = function(value) { + return jspb.Message.setOneofField(this, 6, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_[0], value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} returns this + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.clearMetadata = function() { - return this.setMetadata(undefined); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.clearStartAfter = function() { + return jspb.Message.setOneofField(this, 6, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_[0], undefined); }; @@ -10784,187 +15142,151 @@ proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype. * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0.prototype.hasMetadata = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.hasStartAfter = function() { + return jspb.Message.getField(this, 6) != null; }; /** - * optional GetProofsResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} + * optional bytes start_at = 7; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAt = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 7, "")); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetProofsResponse.GetProofsResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse} returns this -*/ -proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProofsResponse.oneofGroups_[0], value); + * optional bytes start_at = 7; + * This is a type-conversion wrapper around `getStartAt()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAt_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getStartAt())); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProofsResponse} returns this + * optional bytes start_at = 7; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getStartAt()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.clearV0 = function() { - return this.setV0(undefined); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAt_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getStartAt())); }; /** - * Returns whether this field is set. - * @return {boolean} + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProofsResponse.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setStartAt = function(value) { + return jspb.Message.setOneofField(this, 7, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_[0], value); }; - /** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.clearStartAt = function() { + return jspb.Message.setOneofField(this, 7, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_[0], undefined); +}; + /** - * @enum {number} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.hasStartAt = function() { + return jspb.Message.getField(this, 7) != null; }; + /** - * @return {proto.org.dash.platform.dapi.v0.GetDataContractRequest.VersionCase} + * optional bool prove = 8; + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 8, false)); }; - -if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 8, value); }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional GetDocumentsRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.toObject = function(includeInstance, msg) { - var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.toObject(includeInstance, f) - }; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0, 1)); +}; - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.oneofGroups_[0], value); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractRequest; - return proto.org.dash.platform.dapi.v0.GetDataContractRequest.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.deserializeBinaryFromReader); - msg.setV0(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; + /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.oneofGroups_ = [[1]]; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getV0(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.serializeBinaryToWriter - ); - } +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 }; - +/** + * @return {proto.org.dash.platform.dapi.v0.GetDocumentsResponse.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentsResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.oneofGroups_[0])); +}; @@ -10981,8 +15303,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.toObject(opt_includeInstance, this); }; @@ -10991,14 +15313,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.toObject = function(includeInstance, msg) { var f, obj = { - id: msg.getId_asB64(), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -11012,23 +15333,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0. /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0; - return proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentsResponse; + return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -11036,12 +15357,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0. var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setId(value); - break; - case 2: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); + var value = new proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.deserializeBinaryFromReader); + msg.setV0(value); break; default: reader.skipField(); @@ -11056,9 +15374,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0. * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDocumentsResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -11066,126 +15384,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0. /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getId_asU8(); - if (f.length > 0) { - writer.writeBytes( + f = message.getV0(); + if (f != null) { + writer.writeMessage( 1, - f - ); - } - f = message.getProve(); - if (f) { - writer.writeBool( - 2, - f + f, + proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.serializeBinaryToWriter ); } }; -/** - * optional bytes id = 1; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.getId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * optional bytes id = 1; - * This is a type-conversion wrapper around `getId()` - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.getId_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getId())); -}; - - -/** - * optional bytes id = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getId()` - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.getId_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getId())); -}; - - -/** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.setId = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); -}; - - -/** - * optional bool prove = 2; - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); -}; - - -/** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 2, value); -}; - - -/** - * optional GetDataContractRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} - */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0, 1)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.GetDataContractRequest.GetDataContractRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} returns this -*/ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractRequest.oneofGroups_[0], value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractRequest} returns this - */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.clearV0 = function() { - return this.setV0(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; -}; - - /** * Oneof group definitions for this message. Each group defines the field @@ -11195,21 +15410,22 @@ proto.org.dash.platform.dapi.v0.GetDataContractRequest.prototype.hasV0 = functio * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + DOCUMENTS: 1, + PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetDataContractResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.oneofGroups_[0])); }; @@ -11226,9 +15442,9 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @return {!Object} - */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractResponse.toObject(opt_includeInstance, this); + */ +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.toObject(opt_includeInstance, this); }; @@ -11237,13 +15453,15 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.toObject = fun * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.toObject(includeInstance, f) + documents: (f = msg.getDocuments()) && proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.toObject(includeInstance, f), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; if (includeInstance) { @@ -11257,23 +15475,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.toObject = function(incl /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractResponse; - return proto.org.dash.platform.dapi.v0.GetDataContractResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0; + return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -11281,9 +15499,19 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.deserializeBinaryFromRea var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.deserializeBinaryFromReader); - msg.setV0(value); + var value = new proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.deserializeBinaryFromReader); + msg.setDocuments(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); break; default: reader.skipField(); @@ -11298,9 +15526,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.deserializeBinaryFromRea * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -11308,18 +15536,34 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.serializeBinar /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getV0(); + f = message.getDocuments(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.serializeBinaryToWriter + ); + } + f = message.getProof(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + ); + } + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter ); } }; @@ -11327,30 +15571,11 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.serializeBinaryToWriter /** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} + * List of repeated fields within this message type. + * @private {!Array} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.oneofGroups_ = [[1,2]]; - -/** - * @enum {number} - */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.ResultCase = { - RESULT_NOT_SET: 0, - DATA_CONTRACT: 1, - PROOF: 2 -}; - -/** - * @return {proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.ResultCase} - */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.oneofGroups_[0])); -}; +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.repeatedFields_ = [1]; @@ -11367,8 +15592,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.toObject(opt_includeInstance, this); }; @@ -11377,15 +15602,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.toObject = function(includeInstance, msg) { var f, obj = { - dataContract: msg.getDataContract_asB64(), - proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), - metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + documentsList: msg.getDocumentsList_asB64() }; if (includeInstance) { @@ -11399,23 +15622,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0; - return proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents; + return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -11424,17 +15647,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setDataContract(value); - break; - case 2: - var value = new proto.org.dash.platform.dapi.v0.Proof; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); - msg.setProof(value); - break; - case 3: - var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); - msg.setMetadata(value); + msg.addDocuments(value); break; default: reader.skipField(); @@ -11449,9 +15662,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -11459,86 +15672,108 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 1)); - if (f != null) { - writer.writeBytes( + f = message.getDocumentsList_asU8(); + if (f.length > 0) { + writer.writeRepeatedBytes( 1, f ); } - f = message.getProof(); - if (f != null) { - writer.writeMessage( - 2, - f, - proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter - ); - } - f = message.getMetadata(); - if (f != null) { - writer.writeMessage( - 3, - f, - proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter - ); - } }; /** - * optional bytes data_contract = 1; - * @return {string} + * repeated bytes documents = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getDataContract = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.getDocumentsList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); }; /** - * optional bytes data_contract = 1; - * This is a type-conversion wrapper around `getDataContract()` - * @return {string} + * repeated bytes documents = 1; + * This is a type-conversion wrapper around `getDocumentsList()` + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getDataContract_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getDataContract())); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.getDocumentsList_asB64 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsB64( + this.getDocumentsList())); }; /** - * optional bytes data_contract = 1; + * repeated bytes documents = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getDataContract()` - * @return {!Uint8Array} + * This is a type-conversion wrapper around `getDocumentsList()` + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getDataContract_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getDataContract())); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.getDocumentsList_asU8 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsU8( + this.getDocumentsList())); +}; + + +/** + * @param {!(Array|Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.setDocumentsList = function(value) { + return jspb.Message.setField(this, 1, value || []); }; /** * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.setDataContract = function(value) { - return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.addDocuments = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 1, value, opt_index); }; /** - * Clears the field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.clearDataContract = function() { - return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.oneofGroups_[0], undefined); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.clearDocumentsList = function() { + return this.setDocumentsList([]); +}; + + +/** + * optional Documents documents = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} + */ +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.getDocuments = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.setDocuments = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.clearDocuments = function() { + return this.setDocuments(undefined); }; @@ -11546,7 +15781,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.hasDataContract = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.hasDocuments = function() { return jspb.Message.getField(this, 1) != null; }; @@ -11555,7 +15790,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV * optional Proof proof = 2; * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getProof = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.getProof = function() { return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; @@ -11563,18 +15798,18 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV /** * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.clearProof = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.clearProof = function() { return this.setProof(undefined); }; @@ -11583,7 +15818,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.hasProof = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.hasProof = function() { return jspb.Message.getField(this, 2) != null; }; @@ -11592,7 +15827,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV * optional ResponseMetadata metadata = 3; * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.getMetadata = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.getMetadata = function() { return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; @@ -11600,18 +15835,18 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV /** * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.setMetadata = function(value) { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.setMetadata = function(value) { return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.clearMetadata = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.clearMetadata = function() { return this.setMetadata(undefined); }; @@ -11620,35 +15855,35 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0.prototype.hasMetadata = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.hasMetadata = function() { return jspb.Message.getField(this, 3) != null; }; /** - * optional GetDataContractResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} + * optional GetDocumentsResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetDataContractResponse.GetDataContractResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -11657,7 +15892,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.clearV0 = func * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -11671,21 +15906,21 @@ proto.org.dash.platform.dapi.v0.GetDataContractResponse.prototype.hasV0 = functi * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetDataContractsRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractsRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractsRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.oneofGroups_[0])); }; @@ -11703,8 +15938,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractsRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.toObject(opt_includeInstance, this); }; @@ -11713,13 +15948,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.toObject = fun * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -11733,23 +15968,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.toObject = function(incl /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsRequest; - return proto.org.dash.platform.dapi.v0.GetDataContractsRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest; + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -11757,8 +15992,8 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.deserializeBinaryFromRea var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -11774,9 +16009,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.deserializeBinaryFromRea * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractsRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -11784,18 +16019,18 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.serializeBinar /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.serializeBinaryToWriter ); } }; @@ -11807,7 +16042,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.serializeBinaryToWriter * @private {!Array} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.repeatedFields_ = [1]; @@ -11824,8 +16059,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.toObject(opt_includeInstance, this); }; @@ -11834,13 +16069,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - idsList: msg.getIdsList_asB64(), + publicKeyHashesList: msg.getPublicKeyHashesList_asB64(), prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) }; @@ -11855,23 +16090,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0; - return proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0; + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -11880,7 +16115,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.addIds(value); + msg.addPublicKeyHashes(value); break; case 2: var value = /** @type {boolean} */ (reader.readBool()); @@ -11899,9 +16134,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -11909,13 +16144,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getIdsList_asU8(); + f = message.getPublicKeyHashesList_asU8(); if (f.length > 0) { writer.writeRepeatedBytes( 1, @@ -11933,43 +16168,43 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV /** - * repeated bytes ids = 1; + * repeated bytes public_key_hashes = 1; * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.getIdsList = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.getPublicKeyHashesList = function() { return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); }; /** - * repeated bytes ids = 1; - * This is a type-conversion wrapper around `getIdsList()` + * repeated bytes public_key_hashes = 1; + * This is a type-conversion wrapper around `getPublicKeyHashesList()` * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.getIdsList_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.getPublicKeyHashesList_asB64 = function() { return /** @type {!Array} */ (jspb.Message.bytesListAsB64( - this.getIdsList())); + this.getPublicKeyHashesList())); }; /** - * repeated bytes ids = 1; + * repeated bytes public_key_hashes = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getIdsList()` + * This is a type-conversion wrapper around `getPublicKeyHashesList()` * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.getIdsList_asU8 = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.getPublicKeyHashesList_asU8 = function() { return /** @type {!Array} */ (jspb.Message.bytesListAsU8( - this.getIdsList())); + this.getPublicKeyHashesList())); }; /** * @param {!(Array|Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.setIdsList = function(value) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.setPublicKeyHashesList = function(value) { return jspb.Message.setField(this, 1, value || []); }; @@ -11977,19 +16212,19 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV /** * @param {!(string|Uint8Array)} value * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.addIds = function(value, opt_index) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.addPublicKeyHashes = function(value, opt_index) { return jspb.Message.addToRepeatedField(this, 1, value, opt_index); }; /** * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.clearIdsList = function() { - return this.setIdsList([]); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.clearPublicKeyHashesList = function() { + return this.setPublicKeyHashesList([]); }; @@ -11997,44 +16232,44 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV * optional bool prove = 2; * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.getProve = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.getProve = function() { return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); }; /** * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0.prototype.setProve = function(value) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.setProve = function(value) { return jspb.Message.setProto3BooleanField(this, 2, value); }; /** - * optional GetDataContractsRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} + * optional GetIdentitiesByPublicKeyHashesRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetDataContractsRequest.GetDataContractsRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractsRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -12043,7 +16278,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.clearV0 = func * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -12057,21 +16292,21 @@ proto.org.dash.platform.dapi.v0.GetDataContractsRequest.prototype.hasV0 = functi * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetDataContractsResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractsResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.oneofGroups_[0])); }; @@ -12089,8 +16324,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.toObject(opt_includeInstance, this); }; @@ -12099,13 +16334,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.toObject = fu * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -12119,23 +16354,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.toObject = function(inc /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse; - return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse; + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -12143,8 +16378,8 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.deserializeBinaryFromRe var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -12160,9 +16395,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.deserializeBinaryFromRe * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractsResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -12170,18 +16405,18 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.serializeBina /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.serializeBinaryToWriter ); } }; @@ -12203,8 +16438,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.toObject(opt_includeInstance, this); }; @@ -12213,14 +16448,14 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.proto * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.toObject = function(includeInstance, msg) { var f, obj = { - identifier: msg.getIdentifier_asB64(), - dataContract: (f = msg.getDataContract()) && google_protobuf_wrappers_pb.BytesValue.toObject(includeInstance, f) + publicKeyHash: msg.getPublicKeyHash_asB64(), + value: (f = msg.getValue()) && google_protobuf_wrappers_pb.BytesValue.toObject(includeInstance, f) }; if (includeInstance) { @@ -12234,23 +16469,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.toObj /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry; - return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry; + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -12259,12 +16494,12 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.deser switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setIdentifier(value); + msg.setPublicKeyHash(value); break; case 2: var value = new google_protobuf_wrappers_pb.BytesValue; reader.readMessage(value,google_protobuf_wrappers_pb.BytesValue.deserializeBinaryFromReader); - msg.setDataContract(value); + msg.setValue(value); break; default: reader.skipField(); @@ -12279,9 +16514,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.deser * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -12289,20 +16524,20 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.proto /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getIdentifier_asU8(); + f = message.getPublicKeyHash_asU8(); if (f.length > 0) { writer.writeBytes( 1, f ); } - f = message.getDataContract(); + f = message.getValue(); if (f != null) { writer.writeMessage( 2, @@ -12314,52 +16549,52 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.seria /** - * optional bytes identifier = 1; + * optional bytes public_key_hash = 1; * @return {string} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.getIdentifier = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.getPublicKeyHash = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * optional bytes identifier = 1; - * This is a type-conversion wrapper around `getIdentifier()` + * optional bytes public_key_hash = 1; + * This is a type-conversion wrapper around `getPublicKeyHash()` * @return {string} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.getIdentifier_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.getPublicKeyHash_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getIdentifier())); + this.getPublicKeyHash())); }; /** - * optional bytes identifier = 1; + * optional bytes public_key_hash = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getIdentifier()` + * This is a type-conversion wrapper around `getPublicKeyHash()` * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.getIdentifier_asU8 = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.getPublicKeyHash_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getIdentifier())); + this.getPublicKeyHash())); }; /** * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.setIdentifier = function(value) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.setPublicKeyHash = function(value) { return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional google.protobuf.BytesValue data_contract = 2; + * optional google.protobuf.BytesValue value = 2; * @return {?proto.google.protobuf.BytesValue} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.getDataContract = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.getValue = function() { return /** @type{?proto.google.protobuf.BytesValue} */ ( jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.BytesValue, 2)); }; @@ -12367,19 +16602,19 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.proto /** * @param {?proto.google.protobuf.BytesValue|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.setDataContract = function(value) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.setValue = function(value) { return jspb.Message.setWrapperField(this, 2, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.clearDataContract = function() { - return this.setDataContract(undefined); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.clearValue = function() { + return this.setValue(undefined); }; @@ -12387,7 +16622,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.proto * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.prototype.hasDataContract = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.hasValue = function() { return jspb.Message.getField(this, 2) != null; }; @@ -12398,7 +16633,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.proto * @private {!Array} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.repeatedFields_ = [1]; @@ -12415,8 +16650,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.toObject(opt_includeInstance, this); }; @@ -12425,14 +16660,14 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.toObject = function(includeInstance, msg) { var f, obj = { - dataContractEntriesList: jspb.Message.toObjectList(msg.getDataContractEntriesList(), - proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.toObject, includeInstance) + identityEntriesList: jspb.Message.toObjectList(msg.getIdentityEntriesList(), + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.toObject, includeInstance) }; if (includeInstance) { @@ -12446,23 +16681,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.toObject /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts; - return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes; + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -12470,9 +16705,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.deseriali var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.deserializeBinaryFromReader); - msg.addDataContractEntries(value); + var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.deserializeBinaryFromReader); + msg.addIdentityEntries(value); break; default: reader.skipField(); @@ -12487,9 +16722,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.deseriali * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -12497,58 +16732,58 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getDataContractEntriesList(); + f = message.getIdentityEntriesList(); if (f.length > 0) { writer.writeRepeatedMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.serializeBinaryToWriter ); } }; /** - * repeated DataContractEntry data_contract_entries = 1; - * @return {!Array} + * repeated PublicKeyHashIdentityEntry identity_entries = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.getDataContractEntriesList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry, 1)); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.getIdentityEntriesList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry, 1)); }; /** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} returns this + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.setDataContractEntriesList = function(value) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.setIdentityEntriesList = function(value) { return jspb.Message.setRepeatedWrapperField(this, 1, value); }; /** - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry=} opt_value + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry=} opt_value * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.addDataContractEntries = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContractEntry, opt_index); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.addIdentityEntries = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry, opt_index); }; /** * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype.clearDataContractEntriesList = function() { - return this.setDataContractEntriesList([]); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.clearIdentityEntriesList = function() { + return this.setIdentityEntriesList([]); }; @@ -12561,22 +16796,22 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.prototype * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.ResultCase = { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.ResultCase = { RESULT_NOT_SET: 0, - DATA_CONTRACTS: 1, + IDENTITIES: 1, PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.ResultCase} + * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.oneofGroups_[0])); }; @@ -12594,8 +16829,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.toObject(opt_includeInstance, this); }; @@ -12604,13 +16839,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - dataContracts: (f = msg.getDataContracts()) && proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.toObject(includeInstance, f), + identities: (f = msg.getIdentities()) && proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.toObject(includeInstance, f), proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; @@ -12626,23 +16861,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0; - return proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0; + return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -12650,9 +16885,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.deserializeBinaryFromReader); - msg.setDataContracts(value); + var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.deserializeBinaryFromReader); + msg.setIdentities(value); break; case 2: var value = new proto.org.dash.platform.dapi.v0.Proof; @@ -12677,9 +16912,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -12687,18 +16922,18 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getDataContracts(); + f = message.getIdentities(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.serializeBinaryToWriter ); } f = message.getProof(); @@ -12721,30 +16956,30 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons /** - * optional DataContracts data_contracts = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} + * optional IdentitiesByPublicKeyHashes identities = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.getDataContracts = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts, 1)); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.getIdentities = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.DataContracts|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.setDataContracts = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.setIdentities = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.clearDataContracts = function() { - return this.setDataContracts(undefined); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.clearIdentities = function() { + return this.setIdentities(undefined); }; @@ -12752,7 +16987,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.hasDataContracts = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.hasIdentities = function() { return jspb.Message.getField(this, 1) != null; }; @@ -12761,7 +16996,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons * optional Proof proof = 2; * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.getProof = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.getProof = function() { return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; @@ -12769,18 +17004,18 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons /** * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.clearProof = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.clearProof = function() { return this.setProof(undefined); }; @@ -12789,7 +17024,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.hasProof = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.hasProof = function() { return jspb.Message.getField(this, 2) != null; }; @@ -12798,7 +17033,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons * optional ResponseMetadata metadata = 3; * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.getMetadata = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.getMetadata = function() { return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; @@ -12806,18 +17041,18 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons /** * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.setMetadata = function(value) { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.setMetadata = function(value) { return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.clearMetadata = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.clearMetadata = function() { return this.setMetadata(undefined); }; @@ -12826,35 +17061,35 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsRespons * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0.prototype.hasMetadata = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.hasMetadata = function() { return jspb.Message.getField(this, 3) != null; }; /** - * optional GetDataContractsResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} + * optional GetIdentitiesByPublicKeyHashesResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetDataContractsResponse.GetDataContractsResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractsResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractsResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -12863,7 +17098,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.clearV0 = fun * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -12877,21 +17112,21 @@ proto.org.dash.platform.dapi.v0.GetDataContractsResponse.prototype.hasV0 = funct * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.oneofGroups_[0])); }; @@ -12909,8 +17144,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.toObject(opt_includeInstance, this); }; @@ -12919,13 +17154,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.toObject * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -12939,23 +17174,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.toObject = functio /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest; - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest; + return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -12963,8 +17198,8 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.deserializeBinaryF var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -12980,9 +17215,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.deserializeBinaryF * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -12990,18 +17225,18 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.serializ /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.serializeBinaryToWriter ); } }; @@ -13023,8 +17258,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.toObject(opt_includeInstance, this); }; @@ -13033,17 +17268,14 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHis * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - id: msg.getId_asB64(), - limit: (f = msg.getLimit()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), - offset: (f = msg.getOffset()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), - startAtMs: jspb.Message.getFieldWithDefault(msg, 4, 0), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 5, false) + publicKeyHash: msg.getPublicKeyHash_asB64(), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) }; if (includeInstance) { @@ -13057,23 +17289,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHis /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0; - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0; + return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -13082,23 +17314,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHis switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setId(value); + msg.setPublicKeyHash(value); break; case 2: - var value = new google_protobuf_wrappers_pb.UInt32Value; - reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); - msg.setLimit(value); - break; - case 3: - var value = new google_protobuf_wrappers_pb.UInt32Value; - reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); - msg.setOffset(value); - break; - case 4: - var value = /** @type {number} */ (reader.readUint64()); - msg.setStartAtMs(value); - break; - case 5: var value = /** @type {boolean} */ (reader.readBool()); msg.setProve(value); break; @@ -13115,9 +17333,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHis * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -13125,46 +17343,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHis /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getId_asU8(); + f = message.getPublicKeyHash_asU8(); if (f.length > 0) { writer.writeBytes( 1, f ); } - f = message.getLimit(); - if (f != null) { - writer.writeMessage( - 2, - f, - google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter - ); - } - f = message.getOffset(); - if (f != null) { - writer.writeMessage( - 3, - f, - google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter - ); - } - f = message.getStartAtMs(); - if (f !== 0) { - writer.writeUint64( - 4, - f - ); - } f = message.getProve(); if (f) { writer.writeBool( - 5, + 2, f ); } @@ -13172,181 +17367,89 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHis /** - * optional bytes id = 1; + * optional bytes public_key_hash = 1; * @return {string} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getId = function() { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.getPublicKeyHash = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * optional bytes id = 1; - * This is a type-conversion wrapper around `getId()` + * optional bytes public_key_hash = 1; + * This is a type-conversion wrapper around `getPublicKeyHash()` * @return {string} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getId_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.getPublicKeyHash_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getId())); + this.getPublicKeyHash())); }; /** - * optional bytes id = 1; + * optional bytes public_key_hash = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getId()` + * This is a type-conversion wrapper around `getPublicKeyHash()` * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getId_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getId())); -}; - - -/** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.setId = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); -}; - - -/** - * optional google.protobuf.UInt32Value limit = 2; - * @return {?proto.google.protobuf.UInt32Value} - */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getLimit = function() { - return /** @type{?proto.google.protobuf.UInt32Value} */ ( - jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 2)); -}; - - -/** - * @param {?proto.google.protobuf.UInt32Value|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.setLimit = function(value) { - return jspb.Message.setWrapperField(this, 2, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.clearLimit = function() { - return this.setLimit(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.hasLimit = function() { - return jspb.Message.getField(this, 2) != null; -}; - - -/** - * optional google.protobuf.UInt32Value offset = 3; - * @return {?proto.google.protobuf.UInt32Value} - */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getOffset = function() { - return /** @type{?proto.google.protobuf.UInt32Value} */ ( - jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 3)); -}; - - -/** - * @param {?proto.google.protobuf.UInt32Value|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.setOffset = function(value) { - return jspb.Message.setWrapperField(this, 3, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.clearOffset = function() { - return this.setOffset(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.hasOffset = function() { - return jspb.Message.getField(this, 3) != null; -}; - - -/** - * optional uint64 start_at_ms = 4; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getStartAtMs = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.getPublicKeyHash_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getPublicKeyHash())); }; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.setStartAtMs = function(value) { - return jspb.Message.setProto3IntField(this, 4, value); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.setPublicKeyHash = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional bool prove = 5; + * optional bool prove = 2; * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 5, false)); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); }; /** * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 5, value); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); }; /** - * optional GetDataContractHistoryRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} + * optional GetIdentityByPublicKeyHashRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.GetDataContractHistoryRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -13355,7 +17458,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.clearV0 * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -13369,21 +17472,21 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryRequest.prototype.hasV0 = * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.oneofGroups_[0])); }; @@ -13401,8 +17504,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.toObject(opt_includeInstance, this); }; @@ -13411,13 +17514,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.toObjec * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -13431,23 +17534,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.toObject = functi /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse; - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse; + return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -13455,8 +17558,8 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.deserializeBinary var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -13472,9 +17575,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.deserializeBinary * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -13482,18 +17585,18 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.seriali /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.serializeBinaryToWriter ); } }; @@ -13508,22 +17611,22 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.serializeBinaryTo * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.ResultCase = { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.ResultCase = { RESULT_NOT_SET: 0, - DATA_CONTRACT_HISTORY: 1, + IDENTITY: 1, PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.ResultCase} + * @return {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.oneofGroups_[0])); }; @@ -13541,8 +17644,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.toObject(opt_includeInstance, this); }; @@ -13551,13 +17654,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - dataContractHistory: (f = msg.getDataContractHistory()) && proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.toObject(includeInstance, f), + identity: msg.getIdentity_asB64(), proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; @@ -13573,23 +17676,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0; - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0; + return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -13597,9 +17700,8 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.deserializeBinaryFromReader); - msg.setDataContractHistory(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setIdentity(value); break; case 2: var value = new proto.org.dash.platform.dapi.v0.Proof; @@ -13624,9 +17726,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -13634,18 +17736,17 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getDataContractHistory(); + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 1)); if (f != null) { - writer.writeMessage( + writer.writeBytes( 1, - f, - proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.serializeBinaryToWriter + f ); } f = message.getProof(); @@ -13667,197 +17768,202 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi }; +/** + * optional bytes identity = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getIdentity = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; - -if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} + * optional bytes identity = 1; + * This is a type-conversion wrapper around `getIdentity()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getIdentity_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getIdentity())); }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional bytes identity = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getIdentity()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.toObject = function(includeInstance, msg) { - var f, obj = { - date: jspb.Message.getFieldWithDefault(msg, 1, 0), - value: msg.getValue_asB64() - }; +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getIdentity_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getIdentity())); +}; - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.setIdentity = function(value) { + return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.oneofGroups_[0], value); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry; - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.clearIdentity = function() { + return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.oneofGroups_[0], undefined); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {number} */ (reader.readUint64()); - msg.setDate(value); - break; - case 2: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setValue(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.hasIdentity = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} + */ +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); }; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getDate(); - if (f !== 0) { - writer.writeUint64( - 1, - f - ); - } - f = message.getValue_asU8(); - if (f.length > 0) { - writer.writeBytes( - 2, - f - ); - } +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; }; /** - * optional uint64 date = 1; - * @return {number} + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.getDate = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} returns this + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.setDate = function(value) { - return jspb.Message.setProto3IntField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); }; /** - * optional bytes value = 2; - * @return {string} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.getValue = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; }; /** - * optional bytes value = 2; - * This is a type-conversion wrapper around `getValue()` - * @return {string} + * optional GetIdentityByPublicKeyHashResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.getValue_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getValue())); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0, 1)); }; /** - * optional bytes value = 2; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getValue()` - * @return {!Uint8Array} + * @param {?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.getValue_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getValue())); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.prototype.setValue = function(value) { - return jspb.Message.setProto3BytesField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; /** - * List of repeated fields within this message type. - * @private {!Array} + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.oneofGroups_ = [[1]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.VersionCase} + */ +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.oneofGroups_[0])); +}; @@ -13874,8 +17980,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.toObject(opt_includeInstance, this); }; @@ -13884,14 +17990,13 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.toObject = function(includeInstance, msg) { var f, obj = { - dataContractEntriesList: jspb.Message.toObjectList(msg.getDataContractEntriesList(), - proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.toObject, includeInstance) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -13905,23 +18010,23 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory; - return proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest; + return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -13929,9 +18034,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.deserializeBinaryFromReader); - msg.addDataContractEntries(value); + var value = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.deserializeBinaryFromReader); + msg.setV0(value); break; default: reader.skipField(); @@ -13946,9 +18051,9 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -13956,196 +18061,231 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHi /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} message + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getDataContractEntriesList(); - if (f.length > 0) { - writer.writeRepeatedMessage( + f = message.getV0(); + if (f != null) { + writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.serializeBinaryToWriter ); } }; -/** - * repeated DataContractHistoryEntry data_contract_entries = 1; - * @return {!Array} - */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.getDataContractEntriesList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry, 1)); -}; - - -/** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} returns this -*/ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.setDataContractEntriesList = function(value) { - return jspb.Message.setRepeatedWrapperField(this, 1, value); -}; - -/** - * @param {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry=} opt_value - * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry} - */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.addDataContractEntries = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistoryEntry, opt_index); -}; +if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} returns this + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory.prototype.clearDataContractEntriesList = function() { - return this.setDataContractEntriesList([]); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.toObject(opt_includeInstance, this); }; /** - * optional DataContractHistory data_contract_history = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.getDataContractHistory = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory, 1)); -}; - +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.toObject = function(includeInstance, msg) { + var f, obj = { + stateTransitionHash: msg.getStateTransitionHash_asB64(), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + }; -/** - * @param {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.DataContractHistory|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.setDataContractHistory = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.oneofGroups_[0], value); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; }; +} /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.clearDataContractHistory = function() { - return this.setDataContractHistory(undefined); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0; + return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.deserializeBinaryFromReader(msg, reader); }; /** - * Returns whether this field is set. - * @return {boolean} + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.hasDataContractHistory = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setStateTransitionHash(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; }; /** - * optional Proof proof = 2; - * @return {?proto.org.dash.platform.dapi.v0.Proof} + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.getProof = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); }; /** - * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.oneofGroups_[0], value); + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStateTransitionHash_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 2, + f + ); + } }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this + * optional bytes state_transition_hash = 1; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.clearProof = function() { - return this.setProof(undefined); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.getStateTransitionHash = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * Returns whether this field is set. - * @return {boolean} + * optional bytes state_transition_hash = 1; + * This is a type-conversion wrapper around `getStateTransitionHash()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.hasProof = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.getStateTransitionHash_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getStateTransitionHash())); }; /** - * optional ResponseMetadata metadata = 3; - * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + * optional bytes state_transition_hash = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getStateTransitionHash()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.getMetadata = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.getStateTransitionHash_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getStateTransitionHash())); }; /** - * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.setMetadata = function(value) { - return jspb.Message.setWrapperField(this, 3, value); + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.setStateTransitionHash = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} returns this + * optional bool prove = 2; + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.clearMetadata = function() { - return this.setMetadata(undefined); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); }; /** - * Returns whether this field is set. - * @return {boolean} + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0.prototype.hasMetadata = function() { - return jspb.Message.getField(this, 3) != null; +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); }; /** - * optional GetDataContractHistoryResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} + * optional WaitForStateTransitionResultRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0, 1)); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.GetDataContractHistoryResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -14154,7 +18294,7 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.clearV0 * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -14168,21 +18308,21 @@ proto.org.dash.platform.dapi.v0.GetDataContractHistoryResponse.prototype.hasV0 = * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetDocumentsRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentsRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.oneofGroups_[0])); }; @@ -14200,8 +18340,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDocumentsRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.toObject(opt_includeInstance, this); }; @@ -14210,13 +18350,13 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.toObject = functio * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -14230,23 +18370,23 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.toObject = function(includeI /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDocumentsRequest; - return proto.org.dash.platform.dapi.v0.GetDocumentsRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse; + return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -14254,8 +18394,8 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.deserializeBinaryFromReader var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -14271,9 +18411,9 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.deserializeBinaryFromReader * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDocumentsRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -14281,18 +18421,18 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.serializeBinary = /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} message + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.serializeBinaryToWriter ); } }; @@ -14307,22 +18447,22 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.serializeBinaryToWriter = fu * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_ = [[6,7]]; +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.StartCase = { - START_NOT_SET: 0, - START_AFTER: 6, - START_AT: 7 +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + ERROR: 1, + PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.StartCase} + * @return {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.StartCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.oneofGroups_[0])); }; @@ -14340,8 +18480,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.toObject(opt_includeInstance, this); }; @@ -14350,20 +18490,15 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.protot * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - dataContractId: msg.getDataContractId_asB64(), - documentType: jspb.Message.getFieldWithDefault(msg, 2, ""), - where: msg.getWhere_asB64(), - orderBy: msg.getOrderBy_asB64(), - limit: jspb.Message.getFieldWithDefault(msg, 5, 0), - startAfter: msg.getStartAfter_asB64(), - startAt: msg.getStartAt_asB64(), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 8, false) + error: (f = msg.getError()) && proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.toObject(includeInstance, f), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; if (includeInstance) { @@ -14377,23 +18512,23 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.toObje /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0; - return proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0; + return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -14401,36 +18536,19 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.deseri var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setDataContractId(value); + var value = new proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.deserializeBinaryFromReader); + msg.setError(value); break; case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setDocumentType(value); + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); break; case 3: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setWhere(value); - break; - case 4: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setOrderBy(value); - break; - case 5: - var value = /** @type {number} */ (reader.readUint32()); - msg.setLimit(value); - break; - case 6: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setStartAfter(value); - break; - case 7: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setStartAt(value); - break; - case 8: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); break; default: reader.skipField(); @@ -14445,9 +18563,9 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.deseri * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -14455,395 +18573,510 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.protot /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getDataContractId_asU8(); - if (f.length > 0) { - writer.writeBytes( + f = message.getError(); + if (f != null) { + writer.writeMessage( 1, - f - ); - } - f = message.getDocumentType(); - if (f.length > 0) { - writer.writeString( - 2, - f - ); - } - f = message.getWhere_asU8(); - if (f.length > 0) { - writer.writeBytes( - 3, - f - ); - } - f = message.getOrderBy_asU8(); - if (f.length > 0) { - writer.writeBytes( - 4, - f - ); - } - f = message.getLimit(); - if (f !== 0) { - writer.writeUint32( - 5, - f + f, + proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.serializeBinaryToWriter ); } - f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 6)); + f = message.getProof(); if (f != null) { - writer.writeBytes( - 6, - f + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter ); } - f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 7)); + f = message.getMetadata(); if (f != null) { - writer.writeBytes( - 7, - f - ); - } - f = message.getProve(); - if (f) { - writer.writeBool( - 8, - f + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter ); } }; /** - * optional bytes data_contract_id = 1; - * @return {string} + * optional StateTransitionBroadcastError error = 1; + * @return {?proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getDataContractId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.getError = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError, 1)); }; /** - * optional bytes data_contract_id = 1; - * This is a type-conversion wrapper around `getDataContractId()` - * @return {string} + * @param {?proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.setError = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getDataContractId_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getDataContractId())); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.clearError = function() { + return this.setError(undefined); }; /** - * optional bytes data_contract_id = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getDataContractId()` - * @return {!Uint8Array} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getDataContractId_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getDataContractId())); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.hasError = function() { + return jspb.Message.getField(this, 1) != null; }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setDataContractId = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; /** - * optional string document_type = 2; - * @return {string} + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getDocumentType = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); }; /** - * @param {string} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setDocumentType = function(value) { - return jspb.Message.setProto3StringField(this, 2, value); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; }; /** - * optional bytes where = 3; - * @return {string} + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getWhere = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; /** - * optional bytes where = 3; - * This is a type-conversion wrapper around `getWhere()` - * @return {string} + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getWhere_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getWhere())); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); }; /** - * optional bytes where = 3; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getWhere()` - * @return {!Uint8Array} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getWhere_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getWhere())); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + * optional WaitForStateTransitionResultResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setWhere = function(value) { - return jspb.Message.setProto3BytesField(this, 3, value); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0, 1)); }; /** - * optional bytes order_by = 4; - * @return {string} + * @param {?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} returns this +*/ +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getOrderBy = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * optional bytes order_by = 4; - * This is a type-conversion wrapper around `getOrderBy()` - * @return {string} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getOrderBy_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getOrderBy())); +proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; + /** - * optional bytes order_by = 4; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getOrderBy()` - * @return {!Uint8Array} + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getOrderBy_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getOrderBy())); -}; +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.oneofGroups_ = [[1]]; +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 +}; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + * @return {proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setOrderBy = function(value) { - return jspb.Message.setProto3BytesField(this, 4, value); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.oneofGroups_[0])); }; + +if (jspb.Message.GENERATE_TO_OBJECT) { /** - * optional uint32 limit = 5; - * @return {number} + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getLimit = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.toObject(opt_includeInstance, this); }; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setLimit = function(value) { - return jspb.Message.setProto3IntField(this, 5, value); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.toObject = function(includeInstance, msg) { + var f, obj = { + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; }; +} /** - * optional bytes start_after = 6; - * @return {string} + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAfter = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, "")); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest; + return proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.deserializeBinaryFromReader(msg, reader); }; /** - * optional bytes start_after = 6; - * This is a type-conversion wrapper around `getStartAfter()` - * @return {string} + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAfter_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getStartAfter())); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.deserializeBinaryFromReader); + msg.setV0(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; }; /** - * optional bytes start_after = 6; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getStartAfter()` + * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAfter_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getStartAfter())); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setStartAfter = function(value) { - return jspb.Message.setOneofField(this, 6, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getV0(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.serializeBinaryToWriter + ); + } }; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Clears the field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.clearStartAfter = function() { - return jspb.Message.setOneofField(this, 6, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_[0], undefined); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.toObject(opt_includeInstance, this); }; /** - * Returns whether this field is set. - * @return {boolean} + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.hasStartAfter = function() { - return jspb.Message.getField(this, 6) != null; +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.toObject = function(includeInstance, msg) { + var f, obj = { + height: jspb.Message.getFieldWithDefault(msg, 1, 0), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; }; +} /** - * optional bytes start_at = 7; - * @return {string} + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAt = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 7, "")); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0; + return proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.deserializeBinaryFromReader(msg, reader); }; /** - * optional bytes start_at = 7; - * This is a type-conversion wrapper around `getStartAt()` - * @return {string} + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAt_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getStartAt())); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setHeight(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; }; /** - * optional bytes start_at = 7; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getStartAt()` + * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getStartAt_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getStartAt())); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setStartAt = function(value) { - return jspb.Message.setOneofField(this, 7, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getHeight(); + if (f !== 0) { + writer.writeInt32( + 1, + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 2, + f + ); + } }; /** - * Clears the field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + * optional int32 height = 1; + * @return {number} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.clearStartAt = function() { - return jspb.Message.setOneofField(this, 7, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.oneofGroups_[0], undefined); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.getHeight = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); }; /** - * Returns whether this field is set. - * @return {boolean} + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.hasStartAt = function() { - return jspb.Message.getField(this, 7) != null; +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.setHeight = function(value) { + return jspb.Message.setProto3IntField(this, 1, value); }; /** - * optional bool prove = 8; + * optional bool prove = 2; * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 8, false)); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); }; /** * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 8, value); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); }; /** - * optional GetDocumentsRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} + * optional GetConsensusParamsRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetDocumentsRequest.GetDocumentsRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDocumentsRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -14852,7 +19085,7 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.clearV0 = function * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -14866,21 +19099,21 @@ proto.org.dash.platform.dapi.v0.GetDocumentsRequest.prototype.hasV0 = function() * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetDocumentsResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentsResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.oneofGroups_[0])); }; @@ -14898,8 +19131,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.toObject(opt_includeInstance, this); }; @@ -14908,13 +19141,13 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.toObject = functi * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -14928,23 +19161,23 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.toObject = function(include /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDocumentsResponse; - return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse; + return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -14952,8 +19185,8 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.deserializeBinaryFromReader var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -14969,9 +19202,9 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.deserializeBinaryFromReader * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDocumentsResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -14979,50 +19212,24 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.serializeBinary = /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.serializeBinaryToWriter ); } }; -/** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const - */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.oneofGroups_ = [[1,2]]; - -/** - * @enum {number} - */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.ResultCase = { - RESULT_NOT_SET: 0, - DOCUMENTS: 1, - PROOF: 2 -}; - -/** - * @return {proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.ResultCase} - */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.oneofGroups_[0])); -}; - if (jspb.Message.GENERATE_TO_OBJECT) { @@ -15038,8 +19245,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.toObject(opt_includeInstance, this); }; @@ -15048,15 +19255,15 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prot * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.toObject = function(includeInstance, msg) { var f, obj = { - documents: (f = msg.getDocuments()) && proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.toObject(includeInstance, f), - proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), - metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + maxBytes: jspb.Message.getFieldWithDefault(msg, 1, ""), + maxGas: jspb.Message.getFieldWithDefault(msg, 2, ""), + timeIotaMs: jspb.Message.getFieldWithDefault(msg, 3, "") }; if (includeInstance) { @@ -15070,23 +19277,23 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.toOb /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0; - return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock; + return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -15094,19 +19301,16 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.dese var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.deserializeBinaryFromReader); - msg.setDocuments(value); + var value = /** @type {string} */ (reader.readString()); + msg.setMaxBytes(value); break; case 2: - var value = new proto.org.dash.platform.dapi.v0.Proof; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); - msg.setProof(value); + var value = /** @type {string} */ (reader.readString()); + msg.setMaxGas(value); break; case 3: - var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); - msg.setMetadata(value); + var value = /** @type {string} */ (reader.readString()); + msg.setTimeIotaMs(value); break; default: reader.skipField(); @@ -15121,9 +19325,9 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.dese * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -15131,46 +19335,90 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prot /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getDocuments(); - if (f != null) { - writer.writeMessage( + f = message.getMaxBytes(); + if (f.length > 0) { + writer.writeString( 1, - f, - proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.serializeBinaryToWriter + f ); } - f = message.getProof(); - if (f != null) { - writer.writeMessage( + f = message.getMaxGas(); + if (f.length > 0) { + writer.writeString( 2, - f, - proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + f ); } - f = message.getMetadata(); - if (f != null) { - writer.writeMessage( + f = message.getTimeIotaMs(); + if (f.length > 0) { + writer.writeString( 3, - f, - proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + f ); } }; +/** + * optional string max_bytes = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.getMaxBytes = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} returns this + */ +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.setMaxBytes = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string max_gas = 2; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.getMaxGas = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} returns this + */ +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.setMaxGas = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional string time_iota_ms = 3; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.getTimeIotaMs = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + /** - * List of repeated fields within this message type. - * @private {!Array} - * @const + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.setTimeIotaMs = function(value) { + return jspb.Message.setProto3StringField(this, 3, value); +}; + + @@ -15187,8 +19435,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.toObject(opt_includeInstance, this); }; @@ -15197,13 +19445,15 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Docu * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.toObject = function(includeInstance, msg) { var f, obj = { - documentsList: msg.getDocumentsList_asB64() + maxAgeNumBlocks: jspb.Message.getFieldWithDefault(msg, 1, ""), + maxAgeDuration: jspb.Message.getFieldWithDefault(msg, 2, ""), + maxBytes: jspb.Message.getFieldWithDefault(msg, 3, "") }; if (includeInstance) { @@ -15217,23 +19467,23 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Docu /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents; - return proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence; + return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -15241,8 +19491,16 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Docu var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.addDocuments(value); + var value = /** @type {string} */ (reader.readString()); + msg.setMaxAgeNumBlocks(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setMaxAgeDuration(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setMaxBytes(value); break; default: reader.skipField(); @@ -15257,9 +19515,9 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Docu * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -15267,145 +19525,243 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Docu /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} message + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getDocumentsList_asU8(); + f = message.getMaxAgeNumBlocks(); if (f.length > 0) { - writer.writeRepeatedBytes( + writer.writeString( 1, f ); } + f = message.getMaxAgeDuration(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getMaxBytes(); + if (f.length > 0) { + writer.writeString( + 3, + f + ); + } }; /** - * repeated bytes documents = 1; - * @return {!Array} + * optional string max_age_num_blocks = 1; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.getDocumentsList = function() { - return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.getMaxAgeNumBlocks = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * repeated bytes documents = 1; - * This is a type-conversion wrapper around `getDocumentsList()` - * @return {!Array} + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.getDocumentsList_asB64 = function() { - return /** @type {!Array} */ (jspb.Message.bytesListAsB64( - this.getDocumentsList())); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.setMaxAgeNumBlocks = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); }; /** - * repeated bytes documents = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getDocumentsList()` - * @return {!Array} + * optional string max_age_duration = 2; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.getDocumentsList_asU8 = function() { - return /** @type {!Array} */ (jspb.Message.bytesListAsU8( - this.getDocumentsList())); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.getMaxAgeDuration = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** - * @param {!(Array|Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} returns this + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.setDocumentsList = function(value) { - return jspb.Message.setField(this, 1, value || []); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.setMaxAgeDuration = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); }; /** - * @param {!(string|Uint8Array)} value - * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} returns this + * optional string max_bytes = 3; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.addDocuments = function(value, opt_index) { - return jspb.Message.addToRepeatedField(this, 1, value, opt_index); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.getMaxBytes = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); }; /** - * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} returns this + * @param {string} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents.prototype.clearDocumentsList = function() { - return this.setDocumentsList([]); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.setMaxBytes = function(value) { + return jspb.Message.setProto3StringField(this, 3, value); }; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { /** - * optional Documents documents = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.getDocuments = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents, 1)); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.toObject(opt_includeInstance, this); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.Documents|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.setDocuments = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.oneofGroups_[0], value); + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.toObject = function(includeInstance, msg) { + var f, obj = { + block: (f = msg.getBlock()) && proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.toObject(includeInstance, f), + evidence: (f = msg.getEvidence()) && proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; }; +} /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.clearDocuments = function() { - return this.setDocuments(undefined); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0; + return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.deserializeBinaryFromReader(msg, reader); }; /** - * Returns whether this field is set. - * @return {boolean} + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.hasDocuments = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.deserializeBinaryFromReader); + msg.setBlock(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.deserializeBinaryFromReader); + msg.setEvidence(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getBlock(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.serializeBinaryToWriter + ); + } + f = message.getEvidence(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.serializeBinaryToWriter + ); + } }; /** - * optional Proof proof = 2; - * @return {?proto.org.dash.platform.dapi.v0.Proof} + * optional ConsensusParamsBlock block = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.getProof = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.getBlock = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.setBlock = function(value) { + return jspb.Message.setWrapperField(this, 1, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.clearProof = function() { - return this.setProof(undefined); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.clearBlock = function() { + return this.setBlock(undefined); }; @@ -15413,36 +19769,36 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prot * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.hasProof = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.hasBlock = function() { + return jspb.Message.getField(this, 1) != null; }; /** - * optional ResponseMetadata metadata = 3; - * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + * optional ConsensusParamsEvidence evidence = 2; + * @return {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.getMetadata = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.getEvidence = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence, 2)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.setMetadata = function(value) { - return jspb.Message.setWrapperField(this, 3, value); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.setEvidence = function(value) { + return jspb.Message.setWrapperField(this, 2, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.clearMetadata = function() { - return this.setMetadata(undefined); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.clearEvidence = function() { + return this.setEvidence(undefined); }; @@ -15450,35 +19806,35 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prot * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0.prototype.hasMetadata = function() { - return jspb.Message.getField(this, 3) != null; +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.hasEvidence = function() { + return jspb.Message.getField(this, 2) != null; }; /** - * optional GetDocumentsResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} + * optional GetConsensusParamsResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetDocumentsResponse.GetDocumentsResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetDocumentsResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetDocumentsResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -15487,7 +19843,7 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.clearV0 = functio * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -15501,21 +19857,21 @@ proto.org.dash.platform.dapi.v0.GetDocumentsResponse.prototype.hasV0 = function( * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.oneofGroups_[0])); }; @@ -15533,8 +19889,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.toObject(opt_includeInstance, this); }; @@ -15543,13 +19899,13 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -15563,23 +19919,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.toObject = /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest; - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -15587,8 +19943,8 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.deserializ var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -15604,9 +19960,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.deserializ * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -15614,31 +19970,24 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype. /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.serializeBinaryToWriter ); } }; -/** - * List of repeated fields within this message type. - * @private {!Array} - * @const - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.repeatedFields_ = [1]; - if (jspb.Message.GENERATE_TO_OBJECT) { @@ -15654,8 +20003,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.toObject(opt_includeInstance, this); }; @@ -15664,14 +20013,13 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentit * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - publicKeyHashesList: msg.getPublicKeyHashesList_asB64(), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + prove: jspb.Message.getBooleanFieldWithDefault(msg, 1, false) }; if (includeInstance) { @@ -15685,23 +20033,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentit /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0; - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -15709,10 +20057,6 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentit var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.addPublicKeyHashes(value); - break; - case 2: var value = /** @type {boolean} */ (reader.readBool()); msg.setProve(value); break; @@ -15729,9 +20073,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentit * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -15739,132 +20083,64 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentit /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getPublicKeyHashesList_asU8(); - if (f.length > 0) { - writer.writeRepeatedBytes( - 1, - f - ); - } f = message.getProve(); if (f) { writer.writeBool( - 2, - f - ); - } -}; - - -/** - * repeated bytes public_key_hashes = 1; - * @return {!Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.getPublicKeyHashesList = function() { - return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); -}; - - -/** - * repeated bytes public_key_hashes = 1; - * This is a type-conversion wrapper around `getPublicKeyHashesList()` - * @return {!Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.getPublicKeyHashesList_asB64 = function() { - return /** @type {!Array} */ (jspb.Message.bytesListAsB64( - this.getPublicKeyHashesList())); -}; - - -/** - * repeated bytes public_key_hashes = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getPublicKeyHashesList()` - * @return {!Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.getPublicKeyHashesList_asU8 = function() { - return /** @type {!Array} */ (jspb.Message.bytesListAsU8( - this.getPublicKeyHashesList())); -}; - - -/** - * @param {!(Array|Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.setPublicKeyHashesList = function(value) { - return jspb.Message.setField(this, 1, value || []); -}; - - -/** - * @param {!(string|Uint8Array)} value - * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.addPublicKeyHashes = function(value, opt_index) { - return jspb.Message.addToRepeatedField(this, 1, value, opt_index); -}; - - -/** - * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.clearPublicKeyHashesList = function() { - return this.setPublicKeyHashesList([]); + 1, + f + ); + } }; /** - * optional bool prove = 2; + * optional bool prove = 1; * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 1, false)); }; /** * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 1, value); }; /** - * optional GetIdentitiesByPublicKeyHashesRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} + * optional GetProtocolVersionUpgradeStateRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.GetIdentitiesByPublicKeyHashesRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -15873,7 +20149,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype. * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -15887,21 +20163,21 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesRequest.prototype. * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.oneofGroups_[0])); }; @@ -15919,8 +20195,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.toObject(opt_includeInstance, this); }; @@ -15929,13 +20205,13 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -15949,23 +20225,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.toObject /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse; - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -15973,8 +20249,8 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.deseriali var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -15990,9 +20266,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.deseriali * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -16000,24 +20276,50 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.serializeBinaryToWriter ); } }; +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.oneofGroups_ = [[1,2]]; + +/** + * @enum {number} + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + VERSIONS: 1, + PROOF: 2 +}; + +/** + * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.ResultCase} + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.oneofGroups_[0])); +}; + if (jspb.Message.GENERATE_TO_OBJECT) { @@ -16033,8 +20335,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.toObject(opt_includeInstance, this); }; @@ -16043,14 +20345,15 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKey * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - publicKeyHash: msg.getPublicKeyHash_asB64(), - value: (f = msg.getValue()) && google_protobuf_wrappers_pb.BytesValue.toObject(includeInstance, f) + versions: (f = msg.getVersions()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.toObject(includeInstance, f), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; if (includeInstance) { @@ -16064,23 +20367,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKey /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry; - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -16088,137 +20391,73 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKey var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setPublicKeyHash(value); + var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.deserializeBinaryFromReader); + msg.setVersions(value); break; case 2: - var value = new google_protobuf_wrappers_pb.BytesValue; - reader.readMessage(value,google_protobuf_wrappers_pb.BytesValue.deserializeBinaryFromReader); - msg.setValue(value); + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); break; default: reader.skipField(); break; } } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getPublicKeyHash_asU8(); - if (f.length > 0) { - writer.writeBytes( - 1, - f - ); - } - f = message.getValue(); - if (f != null) { - writer.writeMessage( - 2, - f, - google_protobuf_wrappers_pb.BytesValue.serializeBinaryToWriter - ); - } -}; - - -/** - * optional bytes public_key_hash = 1; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.getPublicKeyHash = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * optional bytes public_key_hash = 1; - * This is a type-conversion wrapper around `getPublicKeyHash()` - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.getPublicKeyHash_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getPublicKeyHash())); -}; - - -/** - * optional bytes public_key_hash = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getPublicKeyHash()` - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.getPublicKeyHash_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getPublicKeyHash())); -}; - - -/** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.setPublicKeyHash = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); -}; - - -/** - * optional google.protobuf.BytesValue value = 2; - * @return {?proto.google.protobuf.BytesValue} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.getValue = function() { - return /** @type{?proto.google.protobuf.BytesValue} */ ( - jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.BytesValue, 2)); -}; - - -/** - * @param {?proto.google.protobuf.BytesValue|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.setValue = function(value) { - return jspb.Message.setWrapperField(this, 2, value); + return msg; }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} returns this + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.clearValue = function() { - return this.setValue(undefined); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); }; /** - * Returns whether this field is set. - * @return {boolean} + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.prototype.hasValue = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getVersions(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.serializeBinaryToWriter + ); + } + f = message.getProof(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + ); + } + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + ); + } }; @@ -16228,7 +20467,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKey * @private {!Array} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.repeatedFields_ = [1]; @@ -16245,8 +20484,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.toObject(opt_includeInstance, this); }; @@ -16255,14 +20494,14 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.Identitie * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.toObject = function(includeInstance, msg) { var f, obj = { - identityEntriesList: jspb.Message.toObjectList(msg.getIdentityEntriesList(), - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.toObject, includeInstance) + versionsList: jspb.Message.toObjectList(msg.getVersionsList(), + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.toObject, includeInstance) }; if (includeInstance) { @@ -16276,23 +20515,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.Identitie /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes; - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -16300,9 +20539,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.Identitie var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.deserializeBinaryFromReader); - msg.addIdentityEntries(value); + var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.deserializeBinaryFromReader); + msg.addVersions(value); break; default: reader.skipField(); @@ -16317,9 +20556,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.Identitie * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -16327,88 +20566,62 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.Identitie /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} message + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getIdentityEntriesList(); + f = message.getVersionsList(); if (f.length > 0) { writer.writeRepeatedMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.serializeBinaryToWriter ); } }; /** - * repeated PublicKeyHashIdentityEntry identity_entries = 1; - * @return {!Array} + * repeated VersionEntry versions = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.getIdentityEntriesList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry, 1)); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.getVersionsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry, 1)); }; /** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} returns this + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.setIdentityEntriesList = function(value) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.setVersionsList = function(value) { return jspb.Message.setRepeatedWrapperField(this, 1, value); }; /** - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry=} opt_value + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry=} opt_value * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.addIdentityEntries = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.PublicKeyHashIdentityEntry, opt_index); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.addVersions = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry, opt_index); }; /** * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.prototype.clearIdentityEntriesList = function() { - return this.setIdentityEntriesList([]); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.clearVersionsList = function() { + return this.setVersionsList([]); }; -/** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.oneofGroups_ = [[1,2]]; - -/** - * @enum {number} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.ResultCase = { - RESULT_NOT_SET: 0, - IDENTITIES: 1, - PROOF: 2 -}; - -/** - * @return {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.ResultCase} - */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.oneofGroups_[0])); -}; - if (jspb.Message.GENERATE_TO_OBJECT) { @@ -16424,8 +20637,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.toObject(opt_includeInstance, this); }; @@ -16434,15 +20647,14 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.toObject = function(includeInstance, msg) { var f, obj = { - identities: (f = msg.getIdentities()) && proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.toObject(includeInstance, f), - proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), - metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + versionNumber: jspb.Message.getFieldWithDefault(msg, 1, 0), + voteCount: jspb.Message.getFieldWithDefault(msg, 2, 0) }; if (includeInstance) { @@ -16456,23 +20668,23 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0; - return proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -16480,19 +20692,12 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.deserializeBinaryFromReader); - msg.setIdentities(value); + var value = /** @type {number} */ (reader.readUint32()); + msg.setVersionNumber(value); break; case 2: - var value = new proto.org.dash.platform.dapi.v0.Proof; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); - msg.setProof(value); - break; - case 3: - var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); - msg.setMetadata(value); + var value = /** @type {number} */ (reader.readUint32()); + msg.setVoteCount(value); break; default: reader.skipField(); @@ -16507,9 +20712,9 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -16517,64 +20722,90 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getIdentities(); - if (f != null) { - writer.writeMessage( + f = message.getVersionNumber(); + if (f !== 0) { + writer.writeUint32( 1, - f, - proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes.serializeBinaryToWriter + f ); } - f = message.getProof(); - if (f != null) { - writer.writeMessage( + f = message.getVoteCount(); + if (f !== 0) { + writer.writeUint32( 2, - f, - proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter - ); - } - f = message.getMetadata(); - if (f != null) { - writer.writeMessage( - 3, - f, - proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + f ); } }; /** - * optional IdentitiesByPublicKeyHashes identities = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} + * optional uint32 version_number = 1; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.getVersionNumber = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} returns this + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.setVersionNumber = function(value) { + return jspb.Message.setProto3IntField(this, 1, value); +}; + + +/** + * optional uint32 vote_count = 2; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.getVoteCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} returns this + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.setVoteCount = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); +}; + + +/** + * optional Versions versions = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.getIdentities = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes, 1)); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.getVersions = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.IdentitiesByPublicKeyHashes|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.setIdentities = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.setVersions = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.clearIdentities = function() { - return this.setIdentities(undefined); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.clearVersions = function() { + return this.setVersions(undefined); }; @@ -16582,7 +20813,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.hasIdentities = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.hasVersions = function() { return jspb.Message.getField(this, 1) != null; }; @@ -16591,7 +20822,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti * optional Proof proof = 2; * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.getProof = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.getProof = function() { return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; @@ -16599,18 +20830,18 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti /** * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.clearProof = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.clearProof = function() { return this.setProof(undefined); }; @@ -16619,7 +20850,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.hasProof = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.hasProof = function() { return jspb.Message.getField(this, 2) != null; }; @@ -16628,7 +20859,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti * optional ResponseMetadata metadata = 3; * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.getMetadata = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.getMetadata = function() { return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; @@ -16636,18 +20867,18 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti /** * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.setMetadata = function(value) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.setMetadata = function(value) { return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.clearMetadata = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.clearMetadata = function() { return this.setMetadata(undefined); }; @@ -16656,35 +20887,35 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdenti * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0.prototype.hasMetadata = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.hasMetadata = function() { return jspb.Message.getField(this, 3) != null; }; /** - * optional GetIdentitiesByPublicKeyHashesResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} + * optional GetProtocolVersionUpgradeStateResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.GetIdentitiesByPublicKeyHashesResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -16693,7 +20924,7 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -16707,21 +20938,21 @@ proto.org.dash.platform.dapi.v0.GetIdentitiesByPublicKeyHashesResponse.prototype * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.oneofGroups_[0])); }; @@ -16739,8 +20970,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.toObject(opt_includeInstance, this); }; @@ -16749,13 +20980,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.toOb * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -16769,23 +21000,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.toObject = fun /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest; - return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -16793,8 +21024,8 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.deserializeBin var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -16810,9 +21041,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.deserializeBin * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -16820,18 +21051,18 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.seri /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.serializeBinaryToWriter ); } }; @@ -16853,8 +21084,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.toObject(opt_includeInstance, this); }; @@ -16863,14 +21094,15 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByP * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - publicKeyHash: msg.getPublicKeyHash_asB64(), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + startProTxHash: msg.getStartProTxHash_asB64(), + count: jspb.Message.getFieldWithDefault(msg, 2, 0), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 3, false) }; if (includeInstance) { @@ -16884,23 +21116,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByP /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0; - return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -16909,9 +21141,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByP switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setPublicKeyHash(value); + msg.setStartProTxHash(value); break; case 2: + var value = /** @type {number} */ (reader.readUint32()); + msg.setCount(value); + break; + case 3: var value = /** @type {boolean} */ (reader.readBool()); msg.setProve(value); break; @@ -16928,9 +21164,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByP * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -16938,23 +21174,30 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByP /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getPublicKeyHash_asU8(); + f = message.getStartProTxHash_asU8(); if (f.length > 0) { writer.writeBytes( 1, f ); } + f = message.getCount(); + if (f !== 0) { + writer.writeUint32( + 2, + f + ); + } f = message.getProve(); if (f) { writer.writeBool( - 2, + 3, f ); } @@ -16962,89 +21205,107 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByP /** - * optional bytes public_key_hash = 1; + * optional bytes start_pro_tx_hash = 1; * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.getPublicKeyHash = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.getStartProTxHash = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * optional bytes public_key_hash = 1; - * This is a type-conversion wrapper around `getPublicKeyHash()` + * optional bytes start_pro_tx_hash = 1; + * This is a type-conversion wrapper around `getStartProTxHash()` * @return {string} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.getPublicKeyHash_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.getStartProTxHash_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getPublicKeyHash())); + this.getStartProTxHash())); }; /** - * optional bytes public_key_hash = 1; + * optional bytes start_pro_tx_hash = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getPublicKeyHash()` + * This is a type-conversion wrapper around `getStartProTxHash()` * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.getPublicKeyHash_asU8 = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.getStartProTxHash_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getPublicKeyHash())); + this.getStartProTxHash())); }; /** * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.setPublicKeyHash = function(value) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.setStartProTxHash = function(value) { return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional bool prove = 2; + * optional uint32 count = 2; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.getCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.setCount = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); +}; + + +/** + * optional bool prove = 3; * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 3, false)); }; /** * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 3, value); }; /** - * optional GetIdentityByPublicKeyHashRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} + * optional GetProtocolVersionUpgradeVoteStatusRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.GetIdentityByPublicKeyHashRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -17053,7 +21314,7 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.clea * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -17067,21 +21328,21 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashRequest.prototype.hasV * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.oneofGroups_[0])); }; @@ -17099,8 +21360,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.toObject(opt_includeInstance, this); }; @@ -17109,13 +21370,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.toO * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -17129,23 +21390,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.toObject = fu /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse; - return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -17153,8 +21414,8 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.deserializeBi var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -17170,9 +21431,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.deserializeBi * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -17180,18 +21441,18 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.ser /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.serializeBinaryToWriter ); } }; @@ -17206,22 +21467,22 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.serializeBina * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.ResultCase = { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.ResultCase = { RESULT_NOT_SET: 0, - IDENTITY: 1, + VERSIONS: 1, PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.ResultCase} + * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.oneofGroups_[0])); }; @@ -17239,8 +21500,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.toObject(opt_includeInstance, this); }; @@ -17249,13 +21510,13 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityBy * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - identity: msg.getIdentity_asB64(), + versions: (f = msg.getVersions()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.toObject(includeInstance, f), proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; @@ -17271,23 +21532,23 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityBy /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0; - return proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -17295,8 +21556,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityBy var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setIdentity(value); + var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.deserializeBinaryFromReader); + msg.setVersions(value); break; case 2: var value = new proto.org.dash.platform.dapi.v0.Proof; @@ -17321,9 +21583,9 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityBy * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -17331,17 +21593,18 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityBy /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 1)); + f = message.getVersions(); if (f != null) { - writer.writeBytes( + writer.writeMessage( 1, - f + f, + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.serializeBinaryToWriter ); } f = message.getProof(); @@ -17363,203 +21626,167 @@ proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityBy }; -/** - * optional bytes identity = 1; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getIdentity = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * optional bytes identity = 1; - * This is a type-conversion wrapper around `getIdentity()` - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getIdentity_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getIdentity())); -}; - - -/** - * optional bytes identity = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getIdentity()` - * @return {!Uint8Array} - */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getIdentity_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getIdentity())); -}; - /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this + * List of repeated fields within this message type. + * @private {!Array} + * @const */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.setIdentity = function(value) { - return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.oneofGroups_[0], value); -}; - +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.repeatedFields_ = [1]; -/** - * Clears the field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.clearIdentity = function() { - return jspb.Message.setOneofField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.oneofGroups_[0], undefined); -}; +if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Returns whether this field is set. - * @return {boolean} + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.hasIdentity = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.toObject(opt_includeInstance, this); }; /** - * optional Proof proof = 2; - * @return {?proto.org.dash.platform.dapi.v0.Proof} + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getProof = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.oneofGroups_[0], value); -}; - +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.toObject = function(includeInstance, msg) { + var f, obj = { + versionSignalsList: jspb.Message.toObjectList(msg.getVersionSignalsList(), + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.toObject, includeInstance) + }; -/** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.clearProof = function() { - return this.setProof(undefined); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; }; +} /** - * Returns whether this field is set. - * @return {boolean} + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.hasProof = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.deserializeBinaryFromReader(msg, reader); }; /** - * optional ResponseMetadata metadata = 3; - * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.getMetadata = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.setMetadata = function(value) { - return jspb.Message.setWrapperField(this, 3, value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.deserializeBinaryFromReader); + msg.addVersionSignals(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} returns this + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.clearMetadata = function() { - return this.setMetadata(undefined); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); }; /** - * Returns whether this field is set. - * @return {boolean} + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0.prototype.hasMetadata = function() { - return jspb.Message.getField(this, 3) != null; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getVersionSignalsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 1, + f, + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.serializeBinaryToWriter + ); + } }; /** - * optional GetIdentityByPublicKeyHashResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} + * repeated VersionSignal version_signals = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.getVersionSignalsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.GetIdentityByPublicKeyHashResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} returns this + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.setVersionSignalsList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse} returns this + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal=} opt_value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.clearV0 = function() { - return this.setV0(undefined); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.addVersionSignals = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal, opt_index); }; /** - * Returns whether this field is set. - * @return {boolean} + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} returns this */ -proto.org.dash.platform.dapi.v0.GetIdentityByPublicKeyHashResponse.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.clearVersionSignalsList = function() { + return this.setVersionSignalsList([]); }; -/** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const - */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.oneofGroups_ = [[1]]; - -/** - * @enum {number} - */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 -}; - -/** - * @return {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.VersionCase} - */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.oneofGroups_[0])); -}; - if (jspb.Message.GENERATE_TO_OBJECT) { @@ -17575,8 +21802,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.toObject(opt_includeInstance, this); }; @@ -17585,13 +21812,14 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.to * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.toObject(includeInstance, f) + proTxHash: msg.getProTxHash_asB64(), + version: jspb.Message.getFieldWithDefault(msg, 2, 0) }; if (includeInstance) { @@ -17605,23 +21833,23 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.toObject = f /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest; - return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal; + return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -17629,9 +21857,12 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.deserializeB var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.deserializeBinaryFromReader); - msg.setV0(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setProTxHash(value); + break; + case 2: + var value = /** @type {number} */ (reader.readUint32()); + msg.setVersion(value); break; default: reader.skipField(); @@ -17646,9 +21877,9 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.deserializeB * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -17656,231 +21887,224 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.se /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getV0(); - if (f != null) { - writer.writeMessage( + f = message.getProTxHash_asU8(); + if (f.length > 0) { + writer.writeBytes( 1, - f, - proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.serializeBinaryToWriter + f + ); + } + f = message.getVersion(); + if (f !== 0) { + writer.writeUint32( + 2, + f ); } }; +/** + * optional bytes pro_tx_hash = 1; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.getProTxHash = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + +/** + * optional bytes pro_tx_hash = 1; + * This is a type-conversion wrapper around `getProTxHash()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.getProTxHash_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getProTxHash())); +}; -if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} + * optional bytes pro_tx_hash = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getProTxHash()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.getProTxHash_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getProTxHash())); }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.toObject = function(includeInstance, msg) { - var f, obj = { - stateTransitionHash: msg.getStateTransitionHash_asB64(), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) - }; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.setProTxHash = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); +}; - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; + +/** + * optional uint32 version = 2; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.getVersion = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0; - return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.setVersion = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); +}; + + +/** + * optional VersionSignals versions = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.getVersions = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.setVersions = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.clearVersions = function() { + return this.setVersions(undefined); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setStateTransitionHash(value); - break; - case 2: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.hasVersions = function() { + return jspb.Message.getField(this, 1) != null; }; /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getStateTransitionHash_asU8(); - if (f.length > 0) { - writer.writeBytes( - 1, - f - ); - } - f = message.getProve(); - if (f) { - writer.writeBool( - 2, - f - ); - } + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.oneofGroups_[0], value); }; /** - * optional bytes state_transition_hash = 1; - * @return {string} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.getStateTransitionHash = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); }; /** - * optional bytes state_transition_hash = 1; - * This is a type-conversion wrapper around `getStateTransitionHash()` - * @return {string} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.getStateTransitionHash_asB64 = function() { - return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getStateTransitionHash())); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; }; /** - * optional bytes state_transition_hash = 1; - * Note that Uint8Array is not supported on all browsers. - * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getStateTransitionHash()` - * @return {!Uint8Array} + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.getStateTransitionHash_asU8 = function() { - return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getStateTransitionHash())); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; /** - * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.setStateTransitionHash = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); }; /** - * optional bool prove = 2; - * @return {boolean} + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); }; /** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; }; /** - * optional WaitForStateTransitionResultRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} + * optional GetProtocolVersionUpgradeVoteStatusResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.WaitForStateTransitionResultRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -17889,7 +22113,7 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.cl * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -17903,21 +22127,21 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultRequest.prototype.ha * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.oneofGroups_[0])); }; @@ -17935,8 +22159,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.toObject(opt_includeInstance, this); }; @@ -17945,13 +22169,13 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.t * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -17965,23 +22189,23 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.toObject = /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse; - return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest; + return proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -17989,8 +22213,8 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.deserialize var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -18006,9 +22230,9 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.deserialize * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -18016,50 +22240,24 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.s /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.serializeBinaryToWriter ); } }; -/** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const - */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.oneofGroups_ = [[1,2]]; - -/** - * @enum {number} - */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.ResultCase = { - RESULT_NOT_SET: 0, - ERROR: 1, - PROOF: 2 -}; - -/** - * @return {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.ResultCase} - */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.oneofGroups_[0])); -}; - if (jspb.Message.GENERATE_TO_OBJECT) { @@ -18075,8 +22273,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.toObject(opt_includeInstance, this); }; @@ -18085,15 +22283,16 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStat * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - error: (f = msg.getError()) && proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.toObject(includeInstance, f), - proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), - metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) + startEpoch: (f = msg.getStartEpoch()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), + count: jspb.Message.getFieldWithDefault(msg, 2, 0), + ascending: jspb.Message.getBooleanFieldWithDefault(msg, 3, false), + prove: jspb.Message.getBooleanFieldWithDefault(msg, 4, false) }; if (includeInstance) { @@ -18107,23 +22306,23 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStat /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0; - return proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0; + return proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -18131,19 +22330,21 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStat var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.deserializeBinaryFromReader); - msg.setError(value); + var value = new google_protobuf_wrappers_pb.UInt32Value; + reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); + msg.setStartEpoch(value); break; case 2: - var value = new proto.org.dash.platform.dapi.v0.Proof; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); - msg.setProof(value); + var value = /** @type {number} */ (reader.readUint32()); + msg.setCount(value); break; case 3: - var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); - msg.setMetadata(value); + var value = /** @type {boolean} */ (reader.readBool()); + msg.setAscending(value); + break; + case 4: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); break; default: reader.skipField(); @@ -18158,9 +22359,9 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStat * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -18168,64 +22369,69 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStat /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getError(); + f = message.getStartEpoch(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError.serializeBinaryToWriter + google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter ); } - f = message.getProof(); - if (f != null) { - writer.writeMessage( + f = message.getCount(); + if (f !== 0) { + writer.writeUint32( 2, - f, - proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + f ); } - f = message.getMetadata(); - if (f != null) { - writer.writeMessage( + f = message.getAscending(); + if (f) { + writer.writeBool( 3, - f, - proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter + f + ); + } + f = message.getProve(); + if (f) { + writer.writeBool( + 4, + f ); } }; /** - * optional StateTransitionBroadcastError error = 1; - * @return {?proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} + * optional google.protobuf.UInt32Value start_epoch = 1; + * @return {?proto.google.protobuf.UInt32Value} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.getError = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError, 1)); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.getStartEpoch = function() { + return /** @type{?proto.google.protobuf.UInt32Value} */ ( + jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.StateTransitionBroadcastError|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this + * @param {?proto.google.protobuf.UInt32Value|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.setError = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.setStartEpoch = function(value) { + return jspb.Message.setWrapperField(this, 1, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.clearError = function() { - return this.setError(undefined); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.clearStartEpoch = function() { + return this.setStartEpoch(undefined); }; @@ -18233,261 +22439,127 @@ proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStat * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.hasError = function() { +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.hasStartEpoch = function() { return jspb.Message.getField(this, 1) != null; }; /** - * optional Proof proof = 2; - * @return {?proto.org.dash.platform.dapi.v0.Proof} + * optional uint32 count = 2; + * @return {number} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.getProof = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.getCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.clearProof = function() { - return this.setProof(undefined); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.setCount = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); }; /** - * Returns whether this field is set. + * optional bool ascending = 3; * @return {boolean} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.hasProof = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.getAscending = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 3, false)); }; /** - * optional ResponseMetadata metadata = 3; - * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.getMetadata = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this -*/ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.setMetadata = function(value) { - return jspb.Message.setWrapperField(this, 3, value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.setAscending = function(value) { + return jspb.Message.setProto3BooleanField(this, 3, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} returns this + * optional bool prove = 4; + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.clearMetadata = function() { - return this.setMetadata(undefined); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 4, false)); }; /** - * Returns whether this field is set. - * @return {boolean} + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0.prototype.hasMetadata = function() { - return jspb.Message.getField(this, 3) != null; +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 4, value); }; /** - * optional WaitForStateTransitionResultResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} + * optional GetEpochsInfoRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.WaitForStateTransitionResultResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} returns this */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse} returns this - */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.clearV0 = function() { - return this.setV0(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.WaitForStateTransitionResultResponse.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; -}; - - - -/** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.oneofGroups_ = [[1]]; - -/** - * @enum {number} - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 -}; - -/** - * @return {proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.VersionCase} - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.oneofGroups_[0])); -}; - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.toObject = function(includeInstance, msg) { - var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.toObject(includeInstance, f) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest; - return proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.clearV0 = function() { + return this.setV0(undefined); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.deserializeBinaryFromReader); - msg.setV0(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.hasV0 = function() { + return jspb.Message.getField(this, 1) != null; }; + /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.oneofGroups_ = [[1]]; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getV0(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.serializeBinaryToWriter - ); - } +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.VersionCase = { + VERSION_NOT_SET: 0, + V0: 1 }; - +/** + * @return {proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.VersionCase} + */ +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.oneofGroups_[0])); +}; @@ -18504,8 +22576,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.toObject(opt_includeInstance, this); }; @@ -18514,14 +22586,13 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequ * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.toObject = function(includeInstance, msg) { var f, obj = { - height: jspb.Message.getFieldWithDefault(msg, 1, 0), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -18535,23 +22606,23 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequ /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0; - return proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse; + return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -18559,12 +22630,9 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequ var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {number} */ (reader.readInt32()); - msg.setHeight(value); - break; - case 2: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); + var value = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.deserializeBinaryFromReader); + msg.setV0(value); break; default: reader.skipField(); @@ -18579,9 +22647,9 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequ * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -18589,102 +22657,23 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequ /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getHeight(); - if (f !== 0) { - writer.writeInt32( + f = message.getV0(); + if (f != null) { + writer.writeMessage( 1, - f - ); - } - f = message.getProve(); - if (f) { - writer.writeBool( - 2, - f + f, + proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.serializeBinaryToWriter ); } }; -/** - * optional int32 height = 1; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.getHeight = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.setHeight = function(value) { - return jspb.Message.setProto3IntField(this, 1, value); -}; - - -/** - * optional bool prove = 2; - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); -}; - - -/** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} returns this - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 2, value); -}; - - -/** - * optional GetConsensusParamsRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0, 1)); -}; - - -/** - * @param {?proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.GetConsensusParamsRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} returns this -*/ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.oneofGroups_[0], value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest} returns this - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.clearV0 = function() { - return this.setV0(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.hasV0 = function() { - return jspb.Message.getField(this, 1) != null; -}; - - /** * Oneof group definitions for this message. Each group defines the field @@ -18694,21 +22683,22 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsRequest.prototype.hasV0 = func * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.VersionCase = { - VERSION_NOT_SET: 0, - V0: 1 +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.ResultCase = { + RESULT_NOT_SET: 0, + EPOCHS: 1, + PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.oneofGroups_[0])); }; @@ -18726,8 +22716,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.toObject(opt_includeInstance, this); }; @@ -18736,13 +22726,15 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.toObject = * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.toObject(includeInstance, f) + epochs: (f = msg.getEpochs()) && proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.toObject(includeInstance, f), + proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), + metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; if (includeInstance) { @@ -18756,33 +22748,43 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.toObject = function(i /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse; - return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0; + return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.deserializeBinaryFromReader); - msg.setV0(value); + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.deserializeBinaryFromReader); + msg.setEpochs(value); + break; + case 2: + var value = new proto.org.dash.platform.dapi.v0.Proof; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.Proof.deserializeBinaryFromReader); + msg.setProof(value); + break; + case 3: + var value = new proto.org.dash.platform.dapi.v0.ResponseMetadata; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.ResponseMetadata.deserializeBinaryFromReader); + msg.setMetadata(value); break; default: reader.skipField(); @@ -18797,9 +22799,9 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.deserializeBinaryFrom * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -18807,24 +22809,47 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.serializeBi /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getV0(); + f = message.getEpochs(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.serializeBinaryToWriter + ); + } + f = message.getProof(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.org.dash.platform.dapi.v0.Proof.serializeBinaryToWriter + ); + } + f = message.getMetadata(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.org.dash.platform.dapi.v0.ResponseMetadata.serializeBinaryToWriter ); } }; +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.repeatedFields_ = [1]; + if (jspb.Message.GENERATE_TO_OBJECT) { @@ -18840,8 +22865,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.toObject(opt_includeInstance, this); }; @@ -18850,15 +22875,14 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.toObject = function(includeInstance, msg) { var f, obj = { - maxBytes: jspb.Message.getFieldWithDefault(msg, 1, ""), - maxGas: jspb.Message.getFieldWithDefault(msg, 2, ""), - timeIotaMs: jspb.Message.getFieldWithDefault(msg, 3, "") + epochInfosList: jspb.Message.toObjectList(msg.getEpochInfosList(), + proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.toObject, includeInstance) }; if (includeInstance) { @@ -18872,23 +22896,23 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock. /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock; - return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos; + return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -18896,16 +22920,9 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock. var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setMaxBytes(value); - break; - case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setMaxGas(value); - break; - case 3: - var value = /** @type {string} */ (reader.readString()); - msg.setTimeIotaMs(value); + var value = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.deserializeBinaryFromReader); + msg.addEpochInfos(value); break; default: reader.skipField(); @@ -18920,9 +22937,9 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock. * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -18930,87 +22947,58 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock. /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} message + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getMaxBytes(); + f = message.getEpochInfosList(); if (f.length > 0) { - writer.writeString( + writer.writeRepeatedMessage( 1, - f - ); - } - f = message.getMaxGas(); - if (f.length > 0) { - writer.writeString( - 2, - f - ); - } - f = message.getTimeIotaMs(); - if (f.length > 0) { - writer.writeString( - 3, - f + f, + proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.serializeBinaryToWriter ); } }; /** - * optional string max_bytes = 1; - * @return {string} - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.getMaxBytes = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} returns this - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.setMaxBytes = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - -/** - * optional string max_gas = 2; - * @return {string} + * repeated EpochInfo epoch_infos = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.getMaxGas = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.getEpochInfosList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo, 1)); }; /** - * @param {string} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} returns this - */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.setMaxGas = function(value) { - return jspb.Message.setProto3StringField(this, 2, value); + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} returns this +*/ +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.setEpochInfosList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); }; /** - * optional string time_iota_ms = 3; - * @return {string} + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo=} opt_value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.getTimeIotaMs = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.addEpochInfos = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo, opt_index); }; /** - * @param {string} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} returns this + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.prototype.setTimeIotaMs = function(value) { - return jspb.Message.setProto3StringField(this, 3, value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.clearEpochInfosList = function() { + return this.setEpochInfosList([]); }; @@ -19030,8 +23018,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.toObject(opt_includeInstance, this); }; @@ -19040,15 +23028,17 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEviden * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.toObject = function(includeInstance, msg) { var f, obj = { - maxAgeNumBlocks: jspb.Message.getFieldWithDefault(msg, 1, ""), - maxAgeDuration: jspb.Message.getFieldWithDefault(msg, 2, ""), - maxBytes: jspb.Message.getFieldWithDefault(msg, 3, "") + number: jspb.Message.getFieldWithDefault(msg, 1, 0), + firstBlockHeight: jspb.Message.getFieldWithDefault(msg, 2, 0), + firstCoreBlockHeight: jspb.Message.getFieldWithDefault(msg, 3, 0), + startTime: jspb.Message.getFieldWithDefault(msg, 4, 0), + feeMultiplier: jspb.Message.getFloatingPointFieldWithDefault(msg, 5, 0.0) }; if (includeInstance) { @@ -19062,23 +23052,23 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEviden /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence; - return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo; + return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -19086,16 +23076,24 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEviden var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setMaxAgeNumBlocks(value); + var value = /** @type {number} */ (reader.readUint32()); + msg.setNumber(value); break; case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setMaxAgeDuration(value); + var value = /** @type {number} */ (reader.readUint64()); + msg.setFirstBlockHeight(value); break; case 3: - var value = /** @type {string} */ (reader.readString()); - msg.setMaxBytes(value); + var value = /** @type {number} */ (reader.readUint32()); + msg.setFirstCoreBlockHeight(value); + break; + case 4: + var value = /** @type {number} */ (reader.readUint64()); + msg.setStartTime(value); + break; + case 5: + var value = /** @type {number} */ (reader.readDouble()); + msg.setFeeMultiplier(value); break; default: reader.skipField(); @@ -19110,9 +23108,9 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEviden * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -19120,243 +23118,202 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEviden /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} message + * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getMaxAgeNumBlocks(); - if (f.length > 0) { - writer.writeString( + f = message.getNumber(); + if (f !== 0) { + writer.writeUint32( 1, f ); } - f = message.getMaxAgeDuration(); - if (f.length > 0) { - writer.writeString( + f = message.getFirstBlockHeight(); + if (f !== 0) { + writer.writeUint64( 2, f ); } - f = message.getMaxBytes(); - if (f.length > 0) { - writer.writeString( + f = message.getFirstCoreBlockHeight(); + if (f !== 0) { + writer.writeUint32( 3, f ); } + f = message.getStartTime(); + if (f !== 0) { + writer.writeUint64( + 4, + f + ); + } + f = message.getFeeMultiplier(); + if (f !== 0.0) { + writer.writeDouble( + 5, + f + ); + } }; /** - * optional string max_age_num_blocks = 1; - * @return {string} + * optional uint32 number = 1; + * @return {number} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.getMaxAgeNumBlocks = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getNumber = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); }; /** - * @param {string} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} returns this + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.setMaxAgeNumBlocks = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setNumber = function(value) { + return jspb.Message.setProto3IntField(this, 1, value); }; /** - * optional string max_age_duration = 2; - * @return {string} + * optional uint64 first_block_height = 2; + * @return {number} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.getMaxAgeDuration = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getFirstBlockHeight = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); }; /** - * @param {string} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} returns this + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.setMaxAgeDuration = function(value) { - return jspb.Message.setProto3StringField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setFirstBlockHeight = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); }; /** - * optional string max_bytes = 3; - * @return {string} + * optional uint32 first_core_block_height = 3; + * @return {number} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.getMaxBytes = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getFirstCoreBlockHeight = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); }; /** - * @param {string} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} returns this + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.prototype.setMaxBytes = function(value) { - return jspb.Message.setProto3StringField(this, 3, value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setFirstCoreBlockHeight = function(value) { + return jspb.Message.setProto3IntField(this, 3, value); }; +/** + * optional uint64 start_time = 4; + * @return {number} + */ +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getStartTime = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +}; - -if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setStartTime = function(value) { + return jspb.Message.setProto3IntField(this, 4, value); }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional double fee_multiplier = 5; + * @return {number} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.toObject = function(includeInstance, msg) { - var f, obj = { - block: (f = msg.getBlock()) && proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.toObject(includeInstance, f), - evidence: (f = msg.getEvidence()) && proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.toObject(includeInstance, f) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getFeeMultiplier = function() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 5, 0.0)); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0; - return proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setFeeMultiplier = function(value) { + return jspb.Message.setProto3FloatField(this, 5, value); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} + * optional EpochInfos epochs = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.deserializeBinaryFromReader); - msg.setBlock(value); - break; - case 2: - var value = new proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.deserializeBinaryFromReader); - msg.setEvidence(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.getEpochs = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos, 1)); }; /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * @param {?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this +*/ +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.setEpochs = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.clearEpochs = function() { + return this.setEpochs(undefined); }; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getBlock(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock.serializeBinaryToWriter - ); - } - f = message.getEvidence(); - if (f != null) { - writer.writeMessage( - 2, - f, - proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence.serializeBinaryToWriter - ); - } +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.hasEpochs = function() { + return jspb.Message.getField(this, 1) != null; }; /** - * optional ConsensusParamsBlock block = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} + * optional Proof proof = 2; + * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.getBlock = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock, 1)); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.getProof = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsBlock|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.setBlock = function(value) { - return jspb.Message.setWrapperField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.clearBlock = function() { - return this.setBlock(undefined); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.clearProof = function() { + return this.setProof(undefined); }; @@ -19364,36 +23321,36 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsRes * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.hasBlock = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.hasProof = function() { + return jspb.Message.getField(this, 2) != null; }; /** - * optional ConsensusParamsEvidence evidence = 2; - * @return {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} + * optional ResponseMetadata metadata = 3; + * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.getEvidence = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence, 2)); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.getMetadata = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.ConsensusParamsEvidence|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.setEvidence = function(value) { - return jspb.Message.setWrapperField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.setMetadata = function(value) { + return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.clearEvidence = function() { - return this.setEvidence(undefined); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.clearMetadata = function() { + return this.setMetadata(undefined); }; @@ -19401,35 +23358,35 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsRes * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0.prototype.hasEvidence = function() { - return jspb.Message.getField(this, 2) != null; +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.hasMetadata = function() { + return jspb.Message.getField(this, 3) != null; }; /** - * optional GetConsensusParamsResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} + * optional GetEpochsInfoResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.GetConsensusParamsResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -19438,7 +23395,7 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.clearV0 = f * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -19452,21 +23409,21 @@ proto.org.dash.platform.dapi.v0.GetConsensusParamsResponse.prototype.hasV0 = fun * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.oneofGroups_[0])); }; @@ -19484,8 +23441,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.toObject(opt_includeInstance, this); }; @@ -19494,13 +23451,13 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -19514,23 +23471,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.toObject = /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest; + return proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -19538,8 +23495,8 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.deserializ var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -19555,9 +23512,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.deserializ * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -19565,24 +23522,31 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype. /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.serializeBinaryToWriter ); } }; +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.repeatedFields_ = [2]; + if (jspb.Message.GENERATE_TO_OBJECT) { @@ -19598,144 +23562,385 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.toObject = function(includeInstance, msg) { + var f, obj = { + prove: jspb.Message.getBooleanFieldWithDefault(msg, 1, false), + resourcePathList: msg.getResourcePathList_asB64(), + startContestedResourceIdentifier: msg.getStartContestedResourceIdentifier_asB64(), + count: jspb.Message.getFieldWithDefault(msg, 4, 0), + ascending: jspb.Message.getBooleanFieldWithDefault(msg, 5, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0; + return proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); + break; + case 2: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.addResourcePath(value); + break; + case 3: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setStartContestedResourceIdentifier(value); + break; + case 4: + var value = /** @type {number} */ (reader.readUint32()); + msg.setCount(value); + break; + case 5: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setAscending(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getProve(); + if (f) { + writer.writeBool( + 1, + f + ); + } + f = message.getResourcePathList_asU8(); + if (f.length > 0) { + writer.writeRepeatedBytes( + 2, + f + ); + } + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeBytes( + 3, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeUint32( + 4, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 5)); + if (f != null) { + writer.writeBool( + 5, + f + ); + } +}; + + +/** + * optional bool prove = 1; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 1, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 1, value); +}; + + +/** + * repeated bytes resource_path = 2; + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.getResourcePathList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); +}; + + +/** + * repeated bytes resource_path = 2; + * This is a type-conversion wrapper around `getResourcePathList()` + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.getResourcePathList_asB64 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsB64( + this.getResourcePathList())); +}; + + +/** + * repeated bytes resource_path = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getResourcePathList()` + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.getResourcePathList_asU8 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsU8( + this.getResourcePathList())); +}; + + +/** + * @param {!(Array|Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.setResourcePathList = function(value) { + return jspb.Message.setField(this, 2, value || []); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.addResourcePath = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 2, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.clearResourcePathList = function() { + return this.setResourcePathList([]); +}; + + +/** + * optional bytes start_contested_resource_identifier = 3; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.getStartContestedResourceIdentifier = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * optional bytes start_contested_resource_identifier = 3; + * This is a type-conversion wrapper around `getStartContestedResourceIdentifier()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.getStartContestedResourceIdentifier_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getStartContestedResourceIdentifier())); +}; + + +/** + * optional bytes start_contested_resource_identifier = 3; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getStartContestedResourceIdentifier()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.getStartContestedResourceIdentifier_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getStartContestedResourceIdentifier())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.setStartContestedResourceIdentifier = function(value) { + return jspb.Message.setField(this, 3, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.clearStartContestedResourceIdentifier = function() { + return jspb.Message.setField(this, 3, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.hasStartContestedResourceIdentifier = function() { + return jspb.Message.getField(this, 3) != null; }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional uint32 count = 4; + * @return {number} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.toObject = function(includeInstance, msg) { - var f, obj = { - prove: jspb.Message.getBooleanFieldWithDefault(msg, 1, false) - }; +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.getCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +}; - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; + +/** + * @param {number} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.setCount = function(value) { + return jspb.Message.setField(this, 4, value); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.clearCount = function() { + return jspb.Message.setField(this, 4, undefined); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.hasCount = function() { + return jspb.Message.getField(this, 4) != null; }; /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * optional bool ascending = 5; + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.getAscending = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 5, false)); }; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getProve(); - if (f) { - writer.writeBool( - 1, - f - ); - } +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.setAscending = function(value) { + return jspb.Message.setField(this, 5, value); }; /** - * optional bool prove = 1; - * @return {boolean} + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 1, false)); +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.clearAscending = function() { + return jspb.Message.setField(this, 5, undefined); }; /** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0.prototype.hasAscending = function() { + return jspb.Message.getField(this, 5) != null; }; /** - * optional GetProtocolVersionUpgradeStateRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} + * optional GetContestedResourcesRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.GetProtocolVersionUpgradeStateRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.GetContestedResourcesRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -19744,7 +23949,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype. * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -19758,21 +23963,21 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateRequest.prototype. * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.oneofGroups_[0])); }; @@ -19790,8 +23995,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.toObject(opt_includeInstance, this); }; @@ -19800,13 +24005,13 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -19820,23 +24025,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.toObject /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse; + return proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -19844,8 +24049,8 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.deseriali var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -19861,9 +24066,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.deseriali * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -19871,18 +24076,18 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.serializeBinaryToWriter ); } }; @@ -19897,22 +24102,22 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.serialize * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.ResultCase = { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ResultCase = { RESULT_NOT_SET: 0, - VERSIONS: 1, + CONTESTED_RESOURCES: 1, PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.ResultCase} + * @return {proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.oneofGroups_[0])); }; @@ -19930,8 +24135,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.toObject(opt_includeInstance, this); }; @@ -19940,13 +24145,13 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - versions: (f = msg.getVersions()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.toObject(includeInstance, f), + contestedResources: (f = msg.getContestedResources()) && proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.toObject(includeInstance, f), proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; @@ -19962,23 +24167,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0; + return proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -19986,9 +24191,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.deserializeBinaryFromReader); - msg.setVersions(value); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.deserializeBinaryFromReader); + msg.setContestedResources(value); break; case 2: var value = new proto.org.dash.platform.dapi.v0.Proof; @@ -20013,9 +24218,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -20023,18 +24228,18 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getVersions(); + f = message.getContestedResources(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.serializeBinaryToWriter ); } f = message.getProof(); @@ -20062,7 +24267,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * @private {!Array} * @const */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.repeatedFields_ = [1]; @@ -20079,8 +24284,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.toObject(opt_includeInstance, this); }; @@ -20089,14 +24294,15 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.toObject = function(includeInstance, msg) { var f, obj = { - versionsList: jspb.Message.toObjectList(msg.getVersionsList(), - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.toObject, includeInstance) + contestedResourcesList: jspb.Message.toObjectList(msg.getContestedResourcesList(), + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.toObject, includeInstance), + finishedResults: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) }; if (includeInstance) { @@ -20110,23 +24316,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources; + return proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -20134,9 +24340,13 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.deserializeBinaryFromReader); - msg.addVersions(value); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.deserializeBinaryFromReader); + msg.addContestedResources(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setFinishedResults(value); break; default: reader.skipField(); @@ -20151,9 +24361,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -20161,58 +24371,83 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getVersionsList(); + f = message.getContestedResourcesList(); if (f.length > 0) { writer.writeRepeatedMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.serializeBinaryToWriter + ); + } + f = message.getFinishedResults(); + if (f) { + writer.writeBool( + 2, + f ); } }; /** - * repeated VersionEntry versions = 1; - * @return {!Array} + * repeated ContestedResource contested_resources = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.getVersionsList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.prototype.getContestedResourcesList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource, 1)); }; /** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} returns this + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.setVersionsList = function(value) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.prototype.setContestedResourcesList = function(value) { return jspb.Message.setRepeatedWrapperField(this, 1, value); }; /** - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry=} opt_value + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource=} opt_value * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.addVersions = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry, opt_index); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.prototype.addContestedResources = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource, opt_index); }; /** * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions.prototype.clearVersionsList = function() { - return this.setVersionsList([]); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.prototype.clearContestedResourcesList = function() { + return this.setContestedResourcesList([]); +}; + + +/** + * optional bool finished_results = 2; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.prototype.getFinishedResults = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources.prototype.setFinishedResults = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); }; @@ -20232,8 +24467,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.toObject(opt_includeInstance, this); }; @@ -20242,14 +24477,13 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.toObject = function(includeInstance, msg) { var f, obj = { - versionNumber: jspb.Message.getFieldWithDefault(msg, 1, 0), - voteCount: jspb.Message.getFieldWithDefault(msg, 2, 0) + identifier: msg.getIdentifier_asB64() }; if (includeInstance) { @@ -20263,23 +24497,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource; + return proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -20287,12 +24521,8 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {number} */ (reader.readUint32()); - msg.setVersionNumber(value); - break; - case 2: - var value = /** @type {number} */ (reader.readUint32()); - msg.setVoteCount(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setIdentifier(value); break; default: reader.skipField(); @@ -20307,9 +24537,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -20317,90 +24547,89 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getVersionNumber(); - if (f !== 0) { - writer.writeUint32( + f = message.getIdentifier_asU8(); + if (f.length > 0) { + writer.writeBytes( 1, f ); } - f = message.getVoteCount(); - if (f !== 0) { - writer.writeUint32( - 2, - f - ); - } }; /** - * optional uint32 version_number = 1; - * @return {number} + * optional bytes identifier = 1; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.getVersionNumber = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.prototype.getIdentifier = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} returns this + * optional bytes identifier = 1; + * This is a type-conversion wrapper around `getIdentifier()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.setVersionNumber = function(value) { - return jspb.Message.setProto3IntField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.prototype.getIdentifier_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getIdentifier())); }; /** - * optional uint32 vote_count = 2; - * @return {number} + * optional bytes identifier = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getIdentifier()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.getVoteCount = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.prototype.getIdentifier_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getIdentifier())); }; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry} returns this + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.VersionEntry.prototype.setVoteCount = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResource.prototype.setIdentifier = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional Versions versions = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} + * optional ContestedResources contested_resources = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.getVersions = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.getContestedResources = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.Versions|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.ContestedResources|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.setVersions = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.setContestedResources = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.clearVersions = function() { - return this.setVersions(undefined); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.clearContestedResources = function() { + return this.setContestedResources(undefined); }; @@ -20408,7 +24637,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.hasVersions = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.hasContestedResources = function() { return jspb.Message.getField(this, 1) != null; }; @@ -20417,7 +24646,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * optional Proof proof = 2; * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.getProof = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.getProof = function() { return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; @@ -20425,18 +24654,18 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc /** * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.clearProof = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.clearProof = function() { return this.setProof(undefined); }; @@ -20445,7 +24674,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.hasProof = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.hasProof = function() { return jspb.Message.getField(this, 2) != null; }; @@ -20454,7 +24683,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * optional ResponseMetadata metadata = 3; * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.getMetadata = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.getMetadata = function() { return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; @@ -20462,18 +24691,18 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc /** * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.setMetadata = function(value) { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.setMetadata = function(value) { return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.clearMetadata = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.clearMetadata = function() { return this.setMetadata(undefined); }; @@ -20482,35 +24711,35 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtoc * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0.prototype.hasMetadata = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0.prototype.hasMetadata = function() { return jspb.Message.getField(this, 3) != null; }; /** - * optional GetProtocolVersionUpgradeStateResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} + * optional GetContestedResourcesResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.GetProtocolVersionUpgradeStateResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.GetContestedResourcesResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -20519,7 +24748,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourcesResponse.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -20533,21 +24762,21 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeStateResponse.prototype * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.oneofGroups_[0])); }; @@ -20565,8 +24794,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.toObject(opt_includeInstance, this); }; @@ -20575,13 +24804,13 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.proto * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -20595,23 +24824,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.toObj /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -20619,8 +24848,8 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.deser var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -20636,9 +24865,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.deser * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -20646,24 +24875,31 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.proto /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.serializeBinaryToWriter ); } }; +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.repeatedFields_ = [2]; + if (jspb.Message.GENERATE_TO_OBJECT) { @@ -20679,8 +24915,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.toObject(opt_includeInstance, this); }; @@ -20689,15 +24925,18 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetPr * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.toObject = function(includeInstance, msg) { var f, obj = { - startProTxHash: msg.getStartProTxHash_asB64(), - count: jspb.Message.getFieldWithDefault(msg, 2, 0), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 3, false) + prove: jspb.Message.getBooleanFieldWithDefault(msg, 1, false), + resourcePathList: msg.getResourcePathList_asB64(), + contestedResource: msg.getContestedResource_asB64(), + startIdentifier: msg.getStartIdentifier_asB64(), + count: jspb.Message.getFieldWithDefault(msg, 5, 0), + ascending: jspb.Message.getBooleanFieldWithDefault(msg, 6, false) }; if (includeInstance) { @@ -20711,23 +24950,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetPr /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -20735,16 +24974,28 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetPr var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setStartProTxHash(value); + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); break; case 2: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.addResourcePath(value); + break; + case 3: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setContestedResource(value); + break; + case 4: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setStartIdentifier(value); + break; + case 5: var value = /** @type {number} */ (reader.readUint32()); msg.setCount(value); break; - case 3: + case 6: var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); + msg.setAscending(value); break; default: reader.skipField(); @@ -20759,9 +25010,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetPr * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -20769,138 +25020,334 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetPr /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getStartProTxHash_asU8(); - if (f.length > 0) { - writer.writeBytes( - 1, - f - ); - } - f = message.getCount(); - if (f !== 0) { - writer.writeUint32( - 2, - f - ); - } - f = message.getProve(); - if (f) { - writer.writeBool( - 3, - f - ); - } +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getProve(); + if (f) { + writer.writeBool( + 1, + f + ); + } + f = message.getResourcePathList_asU8(); + if (f.length > 0) { + writer.writeRepeatedBytes( + 2, + f + ); + } + f = message.getContestedResource_asU8(); + if (f.length > 0) { + writer.writeBytes( + 3, + f + ); + } + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeBytes( + 4, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 5)); + if (f != null) { + writer.writeUint32( + 5, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 6)); + if (f != null) { + writer.writeBool( + 6, + f + ); + } +}; + + +/** + * optional bool prove = 1; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 1, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 1, value); +}; + + +/** + * repeated bytes resource_path = 2; + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getResourcePathList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); +}; + + +/** + * repeated bytes resource_path = 2; + * This is a type-conversion wrapper around `getResourcePathList()` + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getResourcePathList_asB64 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsB64( + this.getResourcePathList())); +}; + + +/** + * repeated bytes resource_path = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getResourcePathList()` + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getResourcePathList_asU8 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsU8( + this.getResourcePathList())); +}; + + +/** + * @param {!(Array|Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.setResourcePathList = function(value) { + return jspb.Message.setField(this, 2, value || []); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.addResourcePath = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 2, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.clearResourcePathList = function() { + return this.setResourcePathList([]); +}; + + +/** + * optional bytes contested_resource = 3; + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getContestedResource = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * optional bytes contested_resource = 3; + * This is a type-conversion wrapper around `getContestedResource()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getContestedResource_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getContestedResource())); +}; + + +/** + * optional bytes contested_resource = 3; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getContestedResource()` + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getContestedResource_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getContestedResource())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.setContestedResource = function(value) { + return jspb.Message.setProto3BytesField(this, 3, value); }; /** - * optional bytes start_pro_tx_hash = 1; + * optional bytes start_identifier = 4; * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.getStartProTxHash = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getStartIdentifier = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); }; /** - * optional bytes start_pro_tx_hash = 1; - * This is a type-conversion wrapper around `getStartProTxHash()` + * optional bytes start_identifier = 4; + * This is a type-conversion wrapper around `getStartIdentifier()` * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.getStartProTxHash_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getStartIdentifier_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getStartProTxHash())); + this.getStartIdentifier())); }; /** - * optional bytes start_pro_tx_hash = 1; + * optional bytes start_identifier = 4; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getStartProTxHash()` + * This is a type-conversion wrapper around `getStartIdentifier()` * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.getStartProTxHash_asU8 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getStartIdentifier_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getStartProTxHash())); + this.getStartIdentifier())); }; /** * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.setStartProTxHash = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.setStartIdentifier = function(value) { + return jspb.Message.setField(this, 4, value); }; /** - * optional uint32 count = 2; + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.clearStartIdentifier = function() { + return jspb.Message.setField(this, 4, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.hasStartIdentifier = function() { + return jspb.Message.getField(this, 4) != null; +}; + + +/** + * optional uint32 count = 5; * @return {number} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.getCount = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); }; /** * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.setCount = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.setCount = function(value) { + return jspb.Message.setField(this, 5, value); }; /** - * optional bool prove = 3; + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.clearCount = function() { + return jspb.Message.setField(this, 5, undefined); +}; + + +/** + * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 3, false)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.hasCount = function() { + return jspb.Message.getField(this, 5) != null; +}; + + +/** + * optional bool ascending = 6; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.getAscending = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 6, false)); }; /** * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 3, value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.setAscending = function(value) { + return jspb.Message.setField(this, 6, value); }; /** - * optional GetProtocolVersionUpgradeVoteStatusRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.clearAscending = function() { + return jspb.Message.setField(this, 6, undefined); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.GetProtocolVersionUpgradeVoteStatusRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} returns this + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0.prototype.hasAscending = function() { + return jspb.Message.getField(this, 6) != null; +}; + + +/** + * optional GetContestedResourceVoteStateRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.GetContestedResourceVoteStateRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -20909,7 +25356,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.proto * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -20923,21 +25370,21 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusRequest.proto * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.oneofGroups_[0])); }; @@ -20955,8 +25402,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.toObject(opt_includeInstance, this); }; @@ -20965,13 +25412,13 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prot * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -20985,23 +25432,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.toOb /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -21009,8 +25456,8 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.dese var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -21026,9 +25473,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.dese * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -21036,18 +25483,18 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prot /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.serializeBinaryToWriter ); } }; @@ -21062,22 +25509,22 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.seri * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.ResultCase = { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ResultCase = { RESULT_NOT_SET: 0, - VERSIONS: 1, + CONTESTED_RESOURCE_CONTENDERS: 1, PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.ResultCase} + * @return {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.oneofGroups_[0])); }; @@ -21095,8 +25542,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.toObject(opt_includeInstance, this); }; @@ -21105,13 +25552,13 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - versions: (f = msg.getVersions()) && proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.toObject(includeInstance, f), + contestedResourceContenders: (f = msg.getContestedResourceContenders()) && proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.toObject(includeInstance, f), proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; @@ -21127,23 +25574,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -21151,9 +25598,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.deserializeBinaryFromReader); - msg.setVersions(value); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.deserializeBinaryFromReader); + msg.setContestedResourceContenders(value); break; case 2: var value = new proto.org.dash.platform.dapi.v0.Proof; @@ -21178,9 +25625,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -21188,18 +25635,18 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getVersions(); + f = message.getContestedResourceContenders(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.serializeBinaryToWriter ); } f = message.getProof(); @@ -21227,7 +25674,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * @private {!Array} * @const */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.repeatedFields_ = [1]; @@ -21244,8 +25691,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.toObject(opt_includeInstance, this); }; @@ -21254,14 +25701,15 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.toObject = function(includeInstance, msg) { var f, obj = { - versionSignalsList: jspb.Message.toObjectList(msg.getVersionSignalsList(), - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.toObject, includeInstance) + contendersList: jspb.Message.toObjectList(msg.getContendersList(), + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.toObject, includeInstance), + finishedResults: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) }; if (includeInstance) { @@ -21275,23 +25723,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -21299,9 +25747,13 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.deserializeBinaryFromReader); - msg.addVersionSignals(value); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.deserializeBinaryFromReader); + msg.addContenders(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setFinishedResults(value); break; default: reader.skipField(); @@ -21316,9 +25768,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -21326,58 +25778,83 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getVersionSignalsList(); + f = message.getContendersList(); if (f.length > 0) { writer.writeRepeatedMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.serializeBinaryToWriter + ); + } + f = message.getFinishedResults(); + if (f) { + writer.writeBool( + 2, + f ); } }; /** - * repeated VersionSignal version_signals = 1; - * @return {!Array} + * repeated Contender contenders = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.getVersionSignalsList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.prototype.getContendersList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender, 1)); }; /** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} returns this + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.setVersionSignalsList = function(value) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.prototype.setContendersList = function(value) { return jspb.Message.setRepeatedWrapperField(this, 1, value); }; /** - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal=} opt_value + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender=} opt_value * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.addVersionSignals = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal, opt_index); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.prototype.addContenders = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender, opt_index); }; /** * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals.prototype.clearVersionSignalsList = function() { - return this.setVersionSignalsList([]); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.prototype.clearContendersList = function() { + return this.setContendersList([]); +}; + + +/** + * optional bool finished_results = 2; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.prototype.getFinishedResults = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders.prototype.setFinishedResults = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); }; @@ -21397,8 +25874,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.toObject(opt_includeInstance, this); }; @@ -21407,14 +25884,14 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.toObject = function(includeInstance, msg) { var f, obj = { - proTxHash: msg.getProTxHash_asB64(), - version: jspb.Message.getFieldWithDefault(msg, 2, 0) + identifier: msg.getIdentifier_asB64(), + voteCount: jspb.Message.getFieldWithDefault(msg, 2, 0) }; if (includeInstance) { @@ -21428,23 +25905,23 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal; - return proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -21453,11 +25930,11 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); - msg.setProTxHash(value); + msg.setIdentifier(value); break; case 2: var value = /** @type {number} */ (reader.readUint32()); - msg.setVersion(value); + msg.setVoteCount(value); break; default: reader.skipField(); @@ -21472,9 +25949,9 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -21482,20 +25959,20 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getProTxHash_asU8(); + f = message.getIdentifier_asU8(); if (f.length > 0) { writer.writeBytes( 1, f ); } - f = message.getVersion(); + f = message.getVoteCount(); if (f !== 0) { writer.writeUint32( 2, @@ -21506,90 +25983,90 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP /** - * optional bytes pro_tx_hash = 1; + * optional bytes identifier = 1; * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.getProTxHash = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.prototype.getIdentifier = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * optional bytes pro_tx_hash = 1; - * This is a type-conversion wrapper around `getProTxHash()` + * optional bytes identifier = 1; + * This is a type-conversion wrapper around `getIdentifier()` * @return {string} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.getProTxHash_asB64 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.prototype.getIdentifier_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( - this.getProTxHash())); + this.getIdentifier())); }; /** - * optional bytes pro_tx_hash = 1; + * optional bytes identifier = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array - * This is a type-conversion wrapper around `getProTxHash()` + * This is a type-conversion wrapper around `getIdentifier()` * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.getProTxHash_asU8 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.prototype.getIdentifier_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( - this.getProTxHash())); + this.getIdentifier())); }; /** * @param {!(string|Uint8Array)} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.setProTxHash = function(value) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.prototype.setIdentifier = function(value) { return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional uint32 version = 2; + * optional uint32 vote_count = 2; * @return {number} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.getVersion = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.prototype.getVoteCount = function() { return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); }; /** * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignal.prototype.setVersion = function(value) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.Contender.prototype.setVoteCount = function(value) { return jspb.Message.setProto3IntField(this, 2, value); }; /** - * optional VersionSignals versions = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} + * optional ContestedResourceContenders contested_resource_contenders = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.getVersions = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.getContestedResourceContenders = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.VersionSignals|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.ContestedResourceContenders|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.setVersions = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.setContestedResourceContenders = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.clearVersions = function() { - return this.setVersions(undefined); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.clearContestedResourceContenders = function() { + return this.setContestedResourceContenders(undefined); }; @@ -21597,7 +26074,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.hasVersions = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.hasContestedResourceContenders = function() { return jspb.Message.getField(this, 1) != null; }; @@ -21606,7 +26083,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * optional Proof proof = 2; * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.getProof = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.getProof = function() { return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; @@ -21614,18 +26091,18 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP /** * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.clearProof = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.clearProof = function() { return this.setProof(undefined); }; @@ -21634,7 +26111,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.hasProof = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.hasProof = function() { return jspb.Message.getField(this, 2) != null; }; @@ -21643,7 +26120,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * optional ResponseMetadata metadata = 3; * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.getMetadata = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.getMetadata = function() { return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; @@ -21651,18 +26128,18 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP /** * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.setMetadata = function(value) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.setMetadata = function(value) { return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.clearMetadata = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.clearMetadata = function() { return this.setMetadata(undefined); }; @@ -21671,35 +26148,35 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetP * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0.prototype.hasMetadata = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0.prototype.hasMetadata = function() { return jspb.Message.getField(this, 3) != null; }; /** - * optional GetProtocolVersionUpgradeVoteStatusResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} + * optional GetContestedResourceVoteStateResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.GetProtocolVersionUpgradeVoteStatusResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.GetContestedResourceVoteStateResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -21708,7 +26185,7 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prot * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStateResponse.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -21722,21 +26199,21 @@ proto.org.dash.platform.dapi.v0.GetProtocolVersionUpgradeVoteStatusResponse.prot * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.VersionCase = { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.oneofGroups_[0])); }; @@ -21754,8 +26231,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.toObject(opt_includeInstance, this); }; @@ -21764,13 +26241,13 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.toObject = functi * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -21784,23 +26261,23 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.toObject = function(include /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest; - return proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -21808,8 +26285,8 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.deserializeBinaryFromReader var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -21825,9 +26302,9 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.deserializeBinaryFromReader * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -21835,24 +26312,31 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.serializeBinary = /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.serializeBinaryToWriter ); } }; +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.repeatedFields_ = [2]; + if (jspb.Message.GENERATE_TO_OBJECT) { @@ -21868,165 +26352,331 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.toObject = function(includeInstance, msg) { + var f, obj = { + prove: jspb.Message.getBooleanFieldWithDefault(msg, 1, false), + resourcePathList: msg.getResourcePathList_asB64(), + resourceIdentifier: msg.getResourceIdentifier_asB64(), + voterIdentifier: msg.getVoterIdentifier_asB64(), + count: jspb.Message.getFieldWithDefault(msg, 5, 0), + ascending: jspb.Message.getBooleanFieldWithDefault(msg, 6, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setProve(value); + break; + case 2: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.addResourcePath(value); + break; + case 3: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setResourceIdentifier(value); + break; + case 4: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setVoterIdentifier(value); + break; + case 5: + var value = /** @type {number} */ (reader.readUint32()); + msg.setCount(value); + break; + case 6: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setAscending(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getProve(); + if (f) { + writer.writeBool( + 1, + f + ); + } + f = message.getResourcePathList_asU8(); + if (f.length > 0) { + writer.writeRepeatedBytes( + 2, + f + ); + } + f = message.getResourceIdentifier_asU8(); + if (f.length > 0) { + writer.writeBytes( + 3, + f + ); + } + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeBytes( + 4, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 5)); + if (f != null) { + writer.writeUint32( + 5, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 6)); + if (f != null) { + writer.writeBool( + 6, + f + ); + } +}; + + +/** + * optional bool prove = 1; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getProve = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 1, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.setProve = function(value) { + return jspb.Message.setProto3BooleanField(this, 1, value); +}; + + +/** + * repeated bytes resource_path = 2; + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getResourcePathList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); +}; + + +/** + * repeated bytes resource_path = 2; + * This is a type-conversion wrapper around `getResourcePathList()` + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getResourcePathList_asB64 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsB64( + this.getResourcePathList())); +}; + + +/** + * repeated bytes resource_path = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getResourcePathList()` + * @return {!Array} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getResourcePathList_asU8 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsU8( + this.getResourcePathList())); +}; + + +/** + * @param {!(Array|Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.setResourcePathList = function(value) { + return jspb.Message.setField(this, 2, value || []); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @param {number=} opt_index + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.addResourcePath = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 2, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.clearResourcePathList = function() { + return this.setResourcePathList([]); }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional bytes resource_identifier = 3; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.toObject = function(includeInstance, msg) { - var f, obj = { - startEpoch: (f = msg.getStartEpoch()) && google_protobuf_wrappers_pb.UInt32Value.toObject(includeInstance, f), - count: jspb.Message.getFieldWithDefault(msg, 2, 0), - ascending: jspb.Message.getBooleanFieldWithDefault(msg, 3, false), - prove: jspb.Message.getBooleanFieldWithDefault(msg, 4, false) - }; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getResourceIdentifier = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; + +/** + * optional bytes resource_identifier = 3; + * This is a type-conversion wrapper around `getResourceIdentifier()` + * @return {string} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getResourceIdentifier_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getResourceIdentifier())); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} + * optional bytes resource_identifier = 3; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getResourceIdentifier()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0; - return proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.deserializeBinaryFromReader(msg, reader); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getResourceIdentifier_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getResourceIdentifier())); }; /** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new google_protobuf_wrappers_pb.UInt32Value; - reader.readMessage(value,google_protobuf_wrappers_pb.UInt32Value.deserializeBinaryFromReader); - msg.setStartEpoch(value); - break; - case 2: - var value = /** @type {number} */ (reader.readUint32()); - msg.setCount(value); - break; - case 3: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setAscending(value); - break; - case 4: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setProve(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.setResourceIdentifier = function(value) { + return jspb.Message.setProto3BytesField(this, 3, value); }; /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * optional bytes voter_identifier = 4; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getVoterIdentifier = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); }; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * optional bytes voter_identifier = 4; + * This is a type-conversion wrapper around `getVoterIdentifier()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getStartEpoch(); - if (f != null) { - writer.writeMessage( - 1, - f, - google_protobuf_wrappers_pb.UInt32Value.serializeBinaryToWriter - ); - } - f = message.getCount(); - if (f !== 0) { - writer.writeUint32( - 2, - f - ); - } - f = message.getAscending(); - if (f) { - writer.writeBool( - 3, - f - ); - } - f = message.getProve(); - if (f) { - writer.writeBool( - 4, - f - ); - } +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getVoterIdentifier_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getVoterIdentifier())); }; /** - * optional google.protobuf.UInt32Value start_epoch = 1; - * @return {?proto.google.protobuf.UInt32Value} + * optional bytes voter_identifier = 4; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getVoterIdentifier()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.getStartEpoch = function() { - return /** @type{?proto.google.protobuf.UInt32Value} */ ( - jspb.Message.getWrapperField(this, google_protobuf_wrappers_pb.UInt32Value, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getVoterIdentifier_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getVoterIdentifier())); }; /** - * @param {?proto.google.protobuf.UInt32Value|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} returns this -*/ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.setStartEpoch = function(value) { - return jspb.Message.setWrapperField(this, 1, value); + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.setVoterIdentifier = function(value) { + return jspb.Message.setField(this, 4, value); }; /** - * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} returns this + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.clearStartEpoch = function() { - return this.setStartEpoch(undefined); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.clearVoterIdentifier = function() { + return jspb.Message.setField(this, 4, undefined); }; @@ -22034,89 +26684,107 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prot * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.hasStartEpoch = function() { - return jspb.Message.getField(this, 1) != null; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.hasVoterIdentifier = function() { + return jspb.Message.getField(this, 4) != null; }; /** - * optional uint32 count = 2; + * optional uint32 count = 5; * @return {number} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.getCount = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); }; /** * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.setCount = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.setCount = function(value) { + return jspb.Message.setField(this, 5, value); }; /** - * optional bool ascending = 3; - * @return {boolean} + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.getAscending = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 3, false)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.clearCount = function() { + return jspb.Message.setField(this, 5, undefined); }; /** - * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.setAscending = function(value) { - return jspb.Message.setProto3BooleanField(this, 3, value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.hasCount = function() { + return jspb.Message.getField(this, 5) != null; }; /** - * optional bool prove = 4; + * optional bool ascending = 6; * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.getProve = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 4, false)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.getAscending = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 6, false)); }; /** * @param {boolean} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0.prototype.setProve = function(value) { - return jspb.Message.setProto3BooleanField(this, 4, value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.setAscending = function(value) { + return jspb.Message.setField(this, 6, value); }; /** - * optional GetEpochsInfoRequestV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} + * Clears the field making it undefined. + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.clearAscending = function() { + return jspb.Message.setField(this, 6, undefined); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.GetEpochsInfoRequestV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} returns this + * Returns whether this field is set. + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0.prototype.hasAscending = function() { + return jspb.Message.getField(this, 6) != null; +}; + + +/** + * optional GetContestedResourceVoteStatusRequestV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0, 1)); +}; + + +/** + * @param {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.GetContestedResourceVoteStatusRequestV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -22125,7 +26793,7 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.clearV0 = functio * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusRequest.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; @@ -22139,21 +26807,21 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoRequest.prototype.hasV0 = function( * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.oneofGroups_ = [[1]]; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.oneofGroups_ = [[1]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.VersionCase = { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.VersionCase = { VERSION_NOT_SET: 0, V0: 1 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.VersionCase} + * @return {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.VersionCase} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.getVersionCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.prototype.getVersionCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.VersionCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.oneofGroups_[0])); }; @@ -22171,8 +26839,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.toObject(opt_includeInstance, this); }; @@ -22181,13 +26849,13 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.toObject = funct * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.toObject = function(includeInstance, msg) { var f, obj = { - v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.toObject(includeInstance, f) + v0: (f = msg.getV0()) && proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.toObject(includeInstance, f) }; if (includeInstance) { @@ -22201,23 +26869,23 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.toObject = function(includ /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse; - return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -22225,8 +26893,8 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.deserializeBinaryFromReade var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.deserializeBinaryFromReader); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.deserializeBinaryFromReader); msg.setV0(value); break; default: @@ -22242,9 +26910,9 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.deserializeBinaryFromReade * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -22252,18 +26920,18 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.serializeBinary /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getV0(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.serializeBinaryToWriter ); } }; @@ -22278,22 +26946,22 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.serializeBinaryToWriter = * @private {!Array>} * @const */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.oneofGroups_ = [[1,2]]; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.oneofGroups_ = [[1,2]]; /** * @enum {number} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.ResultCase = { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ResultCase = { RESULT_NOT_SET: 0, - EPOCHS: 1, + CONTESTED_RESOURCE_VOTERS: 1, PROOF: 2 }; /** - * @return {proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.ResultCase} + * @return {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ResultCase} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.getResultCase = function() { - return /** @type {proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.oneofGroups_[0])); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.getResultCase = function() { + return /** @type {proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ResultCase} */(jspb.Message.computeOneofCase(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.oneofGroups_[0])); }; @@ -22311,8 +26979,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.toObject(opt_includeInstance, this); }; @@ -22321,13 +26989,13 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.pr * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.toObject = function(includeInstance, msg) { var f, obj = { - epochs: (f = msg.getEpochs()) && proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.toObject(includeInstance, f), + contestedResourceVoters: (f = msg.getContestedResourceVoters()) && proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.toObject(includeInstance, f), proof: (f = msg.getProof()) && proto.org.dash.platform.dapi.v0.Proof.toObject(includeInstance, f), metadata: (f = msg.getMetadata()) && proto.org.dash.platform.dapi.v0.ResponseMetadata.toObject(includeInstance, f) }; @@ -22343,23 +27011,23 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.to /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0; - return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -22367,9 +27035,9 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.de var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.deserializeBinaryFromReader); - msg.setEpochs(value); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.deserializeBinaryFromReader); + msg.setContestedResourceVoters(value); break; case 2: var value = new proto.org.dash.platform.dapi.v0.Proof; @@ -22394,9 +27062,9 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.de * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -22404,18 +27072,18 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.pr /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getEpochs(); + f = message.getContestedResourceVoters(); if (f != null) { writer.writeMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.serializeBinaryToWriter ); } f = message.getProof(); @@ -22443,7 +27111,7 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.se * @private {!Array} * @const */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.repeatedFields_ = [1]; +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.repeatedFields_ = [1]; @@ -22460,8 +27128,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.toObject(opt_includeInstance, this); }; @@ -22470,14 +27138,15 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.toObject = function(includeInstance, msg) { var f, obj = { - epochInfosList: jspb.Message.toObjectList(msg.getEpochInfosList(), - proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.toObject, includeInstance) + votersList: jspb.Message.toObjectList(msg.getVotersList(), + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.toObject, includeInstance), + finishedResults: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) }; if (includeInstance) { @@ -22491,23 +27160,23 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos; - return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -22515,9 +27184,13 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo; - reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.deserializeBinaryFromReader); - msg.addEpochInfos(value); + var value = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter; + reader.readMessage(value,proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.deserializeBinaryFromReader); + msg.addVoters(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setFinishedResults(value); break; default: reader.skipField(); @@ -22532,9 +27205,9 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -22542,58 +27215,83 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getEpochInfosList(); + f = message.getVotersList(); if (f.length > 0) { writer.writeRepeatedMessage( 1, f, - proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.serializeBinaryToWriter + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.serializeBinaryToWriter + ); + } + f = message.getFinishedResults(); + if (f) { + writer.writeBool( + 2, + f ); } }; /** - * repeated EpochInfo epoch_infos = 1; - * @return {!Array} + * repeated Voter voters = 1; + * @return {!Array} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.getEpochInfosList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.prototype.getVotersList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter, 1)); }; /** - * @param {!Array} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} returns this + * @param {!Array} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.setEpochInfosList = function(value) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.prototype.setVotersList = function(value) { return jspb.Message.setRepeatedWrapperField(this, 1, value); }; /** - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo=} opt_value + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter=} opt_value * @param {number=} opt_index - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.addEpochInfos = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo, opt_index); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.prototype.addVoters = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter, opt_index); }; /** * Clears the list making it empty but non-null. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos.prototype.clearEpochInfosList = function() { - return this.setEpochInfosList([]); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.prototype.clearVotersList = function() { + return this.setVotersList([]); +}; + + +/** + * optional bool finished_results = 2; + * @return {boolean} + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.prototype.getFinishedResults = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} returns this + */ +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters.prototype.setFinishedResults = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); }; @@ -22613,8 +27311,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.toObject = function(opt_includeInstance) { - return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.toObject(opt_includeInstance, this); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.prototype.toObject = function(opt_includeInstance) { + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.toObject(opt_includeInstance, this); }; @@ -22623,17 +27321,13 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} msg The msg instance to transform. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.toObject = function(includeInstance, msg) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.toObject = function(includeInstance, msg) { var f, obj = { - number: jspb.Message.getFieldWithDefault(msg, 1, 0), - firstBlockHeight: jspb.Message.getFieldWithDefault(msg, 2, 0), - firstCoreBlockHeight: jspb.Message.getFieldWithDefault(msg, 3, 0), - startTime: jspb.Message.getFieldWithDefault(msg, 4, 0), - feeMultiplier: jspb.Message.getFloatingPointFieldWithDefault(msg, 5, 0.0) + identifier: msg.getIdentifier_asB64() }; if (includeInstance) { @@ -22647,23 +27341,23 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.deserializeBinary = function(bytes) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo; - return proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.deserializeBinaryFromReader(msg, reader); + var msg = new proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter; + return proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} msg The message object to deserialize into. + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.deserializeBinaryFromReader = function(msg, reader) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -22671,24 +27365,8 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {number} */ (reader.readUint32()); - msg.setNumber(value); - break; - case 2: - var value = /** @type {number} */ (reader.readUint64()); - msg.setFirstBlockHeight(value); - break; - case 3: - var value = /** @type {number} */ (reader.readUint32()); - msg.setFirstCoreBlockHeight(value); - break; - case 4: - var value = /** @type {number} */ (reader.readUint64()); - msg.setStartTime(value); - break; - case 5: - var value = /** @type {number} */ (reader.readDouble()); - msg.setFeeMultiplier(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setIdentifier(value); break; default: reader.skipField(); @@ -22703,9 +27381,9 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.serializeBinary = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.serializeBinaryToWriter(this, writer); + proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -22713,165 +27391,89 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.Ep /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} message + * @param {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.serializeBinaryToWriter = function(message, writer) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getNumber(); - if (f !== 0) { - writer.writeUint32( + f = message.getIdentifier_asU8(); + if (f.length > 0) { + writer.writeBytes( 1, f ); } - f = message.getFirstBlockHeight(); - if (f !== 0) { - writer.writeUint64( - 2, - f - ); - } - f = message.getFirstCoreBlockHeight(); - if (f !== 0) { - writer.writeUint32( - 3, - f - ); - } - f = message.getStartTime(); - if (f !== 0) { - writer.writeUint64( - 4, - f - ); - } - f = message.getFeeMultiplier(); - if (f !== 0.0) { - writer.writeDouble( - 5, - f - ); - } -}; - - -/** - * optional uint32 number = 1; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getNumber = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this - */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setNumber = function(value) { - return jspb.Message.setProto3IntField(this, 1, value); -}; - - -/** - * optional uint64 first_block_height = 2; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getFirstBlockHeight = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this - */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setFirstBlockHeight = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); -}; - - -/** - * optional uint32 first_core_block_height = 3; - * @return {number} - */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getFirstCoreBlockHeight = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); }; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this - */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setFirstCoreBlockHeight = function(value) { - return jspb.Message.setProto3IntField(this, 3, value); -}; - - -/** - * optional uint64 start_time = 4; - * @return {number} + * optional bytes identifier = 1; + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getStartTime = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.prototype.getIdentifier = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this + * optional bytes identifier = 1; + * This is a type-conversion wrapper around `getIdentifier()` + * @return {string} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setStartTime = function(value) { - return jspb.Message.setProto3IntField(this, 4, value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.prototype.getIdentifier_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getIdentifier())); }; /** - * optional double fee_multiplier = 5; - * @return {number} + * optional bytes identifier = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getIdentifier()` + * @return {!Uint8Array} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.getFeeMultiplier = function() { - return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 5, 0.0)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.prototype.getIdentifier_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getIdentifier())); }; /** - * @param {number} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo} returns this + * @param {!(string|Uint8Array)} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfo.prototype.setFeeMultiplier = function(value) { - return jspb.Message.setProto3FloatField(this, 5, value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.Voter.prototype.setIdentifier = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional EpochInfos epochs = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} + * optional ContestedResourceVoters contested_resource_voters = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.getEpochs = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.getContestedResourceVoters = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.EpochInfos|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.ContestedResourceVoters|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.setEpochs = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.setContestedResourceVoters = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.clearEpochs = function() { - return this.setEpochs(undefined); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.clearContestedResourceVoters = function() { + return this.setContestedResourceVoters(undefined); }; @@ -22879,7 +27481,7 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.pr * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.hasEpochs = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.hasContestedResourceVoters = function() { return jspb.Message.getField(this, 1) != null; }; @@ -22888,7 +27490,7 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.pr * optional Proof proof = 2; * @return {?proto.org.dash.platform.dapi.v0.Proof} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.getProof = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.getProof = function() { return /** @type{?proto.org.dash.platform.dapi.v0.Proof} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.Proof, 2)); }; @@ -22896,18 +27498,18 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.pr /** * @param {?proto.org.dash.platform.dapi.v0.Proof|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.setProof = function(value) { - return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.setProof = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.clearProof = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.clearProof = function() { return this.setProof(undefined); }; @@ -22916,7 +27518,7 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.pr * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.hasProof = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.hasProof = function() { return jspb.Message.getField(this, 2) != null; }; @@ -22925,7 +27527,7 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.pr * optional ResponseMetadata metadata = 3; * @return {?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.getMetadata = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.getMetadata = function() { return /** @type{?proto.org.dash.platform.dapi.v0.ResponseMetadata} */ ( jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.ResponseMetadata, 3)); }; @@ -22933,18 +27535,18 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.pr /** * @param {?proto.org.dash.platform.dapi.v0.ResponseMetadata|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.setMetadata = function(value) { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.setMetadata = function(value) { return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.clearMetadata = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.clearMetadata = function() { return this.setMetadata(undefined); }; @@ -22953,35 +27555,35 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.pr * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0.prototype.hasMetadata = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0.prototype.hasMetadata = function() { return jspb.Message.getField(this, 3) != null; }; /** - * optional GetEpochsInfoResponseV0 v0 = 1; - * @return {?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} + * optional GetContestedResourceVoteStatusResponseV0 v0 = 1; + * @return {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.getV0 = function() { - return /** @type{?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0} */ ( - jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0, 1)); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.prototype.getV0 = function() { + return /** @type{?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0} */ ( + jspb.Message.getWrapperField(this, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0, 1)); }; /** - * @param {?proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.GetEpochsInfoResponseV0|undefined} value - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} returns this + * @param {?proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.GetContestedResourceVoteStatusResponseV0|undefined} value + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.setV0 = function(value) { - return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.oneofGroups_[0], value); +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.prototype.setV0 = function(value) { + return jspb.Message.setOneofWrapperField(this, 1, proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. - * @return {!proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse} returns this + * @return {!proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse} returns this */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.clearV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.prototype.clearV0 = function() { return this.setV0(undefined); }; @@ -22990,7 +27592,7 @@ proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.clearV0 = functi * Returns whether this field is set. * @return {boolean} */ -proto.org.dash.platform.dapi.v0.GetEpochsInfoResponse.prototype.hasV0 = function() { +proto.org.dash.platform.dapi.v0.GetContestedResourceVoteStatusResponse.prototype.hasV0 = function() { return jspb.Message.getField(this, 1) != null; }; diff --git a/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.d.ts b/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.d.ts index eb5810b925..7ff8c2a2e8 100644 --- a/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.d.ts +++ b/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.d.ts @@ -166,6 +166,33 @@ type PlatformgetEpochsInfo = { readonly responseType: typeof platform_pb.GetEpochsInfoResponse; }; +type PlatformgetContestedResources = { + readonly methodName: string; + readonly service: typeof Platform; + readonly requestStream: false; + readonly responseStream: false; + readonly requestType: typeof platform_pb.GetContestedResourcesRequest; + readonly responseType: typeof platform_pb.GetContestedResourcesResponse; +}; + +type PlatformgetContestedResourceVoteState = { + readonly methodName: string; + readonly service: typeof Platform; + readonly requestStream: false; + readonly responseStream: false; + readonly requestType: typeof platform_pb.GetContestedResourceVoteStateRequest; + readonly responseType: typeof platform_pb.GetContestedResourceVoteStateResponse; +}; + +type PlatformgetContestedResourceVoteStatus = { + readonly methodName: string; + readonly service: typeof Platform; + readonly requestStream: false; + readonly responseStream: false; + readonly requestType: typeof platform_pb.GetContestedResourceVoteStatusRequest; + readonly responseType: typeof platform_pb.GetContestedResourceVoteStatusResponse; +}; + export class Platform { static readonly serviceName: string; static readonly broadcastStateTransition: PlatformbroadcastStateTransition; @@ -186,6 +213,9 @@ export class Platform { static readonly getProtocolVersionUpgradeState: PlatformgetProtocolVersionUpgradeState; static readonly getProtocolVersionUpgradeVoteStatus: PlatformgetProtocolVersionUpgradeVoteStatus; static readonly getEpochsInfo: PlatformgetEpochsInfo; + static readonly getContestedResources: PlatformgetContestedResources; + static readonly getContestedResourceVoteState: PlatformgetContestedResourceVoteState; + static readonly getContestedResourceVoteStatus: PlatformgetContestedResourceVoteStatus; } export type ServiceError = { message: string, code: number; metadata: grpc.Metadata } @@ -382,5 +412,32 @@ export class PlatformClient { requestMessage: platform_pb.GetEpochsInfoRequest, callback: (error: ServiceError|null, responseMessage: platform_pb.GetEpochsInfoResponse|null) => void ): UnaryResponse; + getContestedResources( + requestMessage: platform_pb.GetContestedResourcesRequest, + metadata: grpc.Metadata, + callback: (error: ServiceError|null, responseMessage: platform_pb.GetContestedResourcesResponse|null) => void + ): UnaryResponse; + getContestedResources( + requestMessage: platform_pb.GetContestedResourcesRequest, + callback: (error: ServiceError|null, responseMessage: platform_pb.GetContestedResourcesResponse|null) => void + ): UnaryResponse; + getContestedResourceVoteState( + requestMessage: platform_pb.GetContestedResourceVoteStateRequest, + metadata: grpc.Metadata, + callback: (error: ServiceError|null, responseMessage: platform_pb.GetContestedResourceVoteStateResponse|null) => void + ): UnaryResponse; + getContestedResourceVoteState( + requestMessage: platform_pb.GetContestedResourceVoteStateRequest, + callback: (error: ServiceError|null, responseMessage: platform_pb.GetContestedResourceVoteStateResponse|null) => void + ): UnaryResponse; + getContestedResourceVoteStatus( + requestMessage: platform_pb.GetContestedResourceVoteStatusRequest, + metadata: grpc.Metadata, + callback: (error: ServiceError|null, responseMessage: platform_pb.GetContestedResourceVoteStatusResponse|null) => void + ): UnaryResponse; + getContestedResourceVoteStatus( + requestMessage: platform_pb.GetContestedResourceVoteStatusRequest, + callback: (error: ServiceError|null, responseMessage: platform_pb.GetContestedResourceVoteStatusResponse|null) => void + ): UnaryResponse; } diff --git a/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.js b/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.js index f0857a73bc..c30613749e 100644 --- a/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.js +++ b/packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.js @@ -172,6 +172,33 @@ Platform.getEpochsInfo = { responseType: platform_pb.GetEpochsInfoResponse }; +Platform.getContestedResources = { + methodName: "getContestedResources", + service: Platform, + requestStream: false, + responseStream: false, + requestType: platform_pb.GetContestedResourcesRequest, + responseType: platform_pb.GetContestedResourcesResponse +}; + +Platform.getContestedResourceVoteState = { + methodName: "getContestedResourceVoteState", + service: Platform, + requestStream: false, + responseStream: false, + requestType: platform_pb.GetContestedResourceVoteStateRequest, + responseType: platform_pb.GetContestedResourceVoteStateResponse +}; + +Platform.getContestedResourceVoteStatus = { + methodName: "getContestedResourceVoteStatus", + service: Platform, + requestStream: false, + responseStream: false, + requestType: platform_pb.GetContestedResourceVoteStatusRequest, + responseType: platform_pb.GetContestedResourceVoteStatusResponse +}; + exports.Platform = Platform; function PlatformClient(serviceHost, options) { @@ -737,5 +764,98 @@ PlatformClient.prototype.getEpochsInfo = function getEpochsInfo(requestMessage, }; }; +PlatformClient.prototype.getContestedResources = function getContestedResources(requestMessage, metadata, callback) { + if (arguments.length === 2) { + callback = arguments[1]; + } + var client = grpc.unary(Platform.getContestedResources, { + request: requestMessage, + host: this.serviceHost, + metadata: metadata, + transport: this.options.transport, + debug: this.options.debug, + onEnd: function (response) { + if (callback) { + if (response.status !== grpc.Code.OK) { + var err = new Error(response.statusMessage); + err.code = response.status; + err.metadata = response.trailers; + callback(err, null); + } else { + callback(null, response.message); + } + } + } + }); + return { + cancel: function () { + callback = null; + client.close(); + } + }; +}; + +PlatformClient.prototype.getContestedResourceVoteState = function getContestedResourceVoteState(requestMessage, metadata, callback) { + if (arguments.length === 2) { + callback = arguments[1]; + } + var client = grpc.unary(Platform.getContestedResourceVoteState, { + request: requestMessage, + host: this.serviceHost, + metadata: metadata, + transport: this.options.transport, + debug: this.options.debug, + onEnd: function (response) { + if (callback) { + if (response.status !== grpc.Code.OK) { + var err = new Error(response.statusMessage); + err.code = response.status; + err.metadata = response.trailers; + callback(err, null); + } else { + callback(null, response.message); + } + } + } + }); + return { + cancel: function () { + callback = null; + client.close(); + } + }; +}; + +PlatformClient.prototype.getContestedResourceVoteStatus = function getContestedResourceVoteStatus(requestMessage, metadata, callback) { + if (arguments.length === 2) { + callback = arguments[1]; + } + var client = grpc.unary(Platform.getContestedResourceVoteStatus, { + request: requestMessage, + host: this.serviceHost, + metadata: metadata, + transport: this.options.transport, + debug: this.options.debug, + onEnd: function (response) { + if (callback) { + if (response.status !== grpc.Code.OK) { + var err = new Error(response.statusMessage); + err.code = response.status; + err.metadata = response.trailers; + callback(err, null); + } else { + callback(null, response.message); + } + } + } + }); + return { + cancel: function () { + callback = null; + client.close(); + } + }; +}; + exports.PlatformClient = PlatformClient; diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index 5407772dc0..6df8c16fa7 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -34,6 +34,9 @@ service Platform { rpc getProtocolVersionUpgradeState(GetProtocolVersionUpgradeStateRequest) returns (GetProtocolVersionUpgradeStateResponse); rpc getProtocolVersionUpgradeVoteStatus(GetProtocolVersionUpgradeVoteStatusRequest) returns (GetProtocolVersionUpgradeVoteStatusResponse); rpc getEpochsInfo(GetEpochsInfoRequest) returns (GetEpochsInfoResponse); + rpc getContestedResources(GetContestedResourcesRequest) returns (GetContestedResourcesResponse); + rpc getContestedResourceVoteState(GetContestedResourceVoteStateRequest) returns (GetContestedResourceVoteStateResponse); + rpc getContestedResourceVoteStatus(GetContestedResourceVoteStatusRequest) returns (GetContestedResourceVoteStatusResponse); } message Proof { @@ -568,3 +571,119 @@ message GetEpochsInfoResponse { GetEpochsInfoResponseV0 v0 = 1; } } + + +message GetContestedResourcesRequest { + message GetContestedResourcesRequestV0 { + bool prove = 1; + repeated bytes resource_path = 2; + optional bytes start_contested_resource_identifier = 3; + optional uint32 count = 4; + optional bool ascending = 5; + } + + oneof version { + GetContestedResourcesRequestV0 v0 = 1; + } +} + +message GetContestedResourcesResponse { + message GetContestedResourcesResponseV0 { + message ContestedResources { + repeated ContestedResource contested_resources = 1; + bool finished_results = 2; + } + + message ContestedResource { + bytes identifier = 1; + } + + oneof result { + ContestedResources contested_resources = 1; + Proof proof = 2; + } + ResponseMetadata metadata = 3; + } + + oneof version { + GetContestedResourcesResponseV0 v0 = 1; + } +} + +message GetContestedResourceVoteStateRequest { + message GetContestedResourceVoteStateRequestV0 { + bool prove = 1; + repeated bytes resource_path = 2; + bytes contested_resource = 3; + optional bytes start_identifier = 4; + optional uint32 count = 5; + optional bool ascending = 6; + } + + oneof version { + GetContestedResourceVoteStateRequestV0 v0 = 1; + } +} + +message GetContestedResourceVoteStateResponse { + message GetContestedResourceVoteStateResponseV0 { + message ContestedResourceContenders { + repeated Contender contenders = 1; + bool finished_results = 2; + } + + message Contender { + bytes identifier = 1; + uint32 vote_count = 2; + } + + oneof result { + ContestedResourceContenders contested_resource_contenders = 1; + Proof proof = 2; + } + ResponseMetadata metadata = 3; + } + + oneof version { + GetContestedResourceVoteStateResponseV0 v0 = 1; + } +} + + +message GetContestedResourceVoteStatusRequest { + message GetContestedResourceVoteStatusRequestV0 { + bool prove = 1; + repeated bytes resource_path = 2; + bytes resource_identifier = 3; + optional bytes voter_identifier = 4; + optional uint32 count = 5; + optional bool ascending = 6; + } + + oneof version { + GetContestedResourceVoteStatusRequestV0 v0 = 1; + } +} + +message GetContestedResourceVoteStatusResponse { + message GetContestedResourceVoteStatusResponseV0 { + message ContestedResourceVoters { + repeated Voter voters = 1; + bool finished_results = 2; + } + + message Voter { + bytes identifier = 1; + } + + oneof result { + ContestedResourceVoters contested_resource_voters = 1; + Proof proof = 2; + } + ResponseMetadata metadata = 3; + } + + oneof version { + GetContestedResourceVoteStatusResponseV0 v0 = 1; + } +} \ No newline at end of file diff --git a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs index eb8b1b9123..5446305204 100644 --- a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs +++ b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs @@ -1855,6 +1855,317 @@ pub mod get_epochs_info_response { V0(GetEpochsInfoResponseV0), } } +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(rename_all = "snake_case")] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetContestedResourcesRequest { + #[prost(oneof = "get_contested_resources_request::Version", tags = "1")] + pub version: ::core::option::Option, +} +/// Nested message and enum types in `GetContestedResourcesRequest`. +pub mod get_contested_resources_request { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct GetContestedResourcesRequestV0 { + #[prost(bool, tag = "1")] + pub prove: bool, + #[prost(bytes = "vec", repeated, tag = "2")] + pub resource_path: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, + #[prost(bytes = "vec", optional, tag = "3")] + pub start_contested_resource_identifier: ::core::option::Option< + ::prost::alloc::vec::Vec, + >, + #[prost(uint32, optional, tag = "4")] + pub count: ::core::option::Option, + #[prost(bool, optional, tag = "5")] + pub ascending: ::core::option::Option, + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Version { + #[prost(message, tag = "1")] + V0(GetContestedResourcesRequestV0), + } +} +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(rename_all = "snake_case")] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetContestedResourcesResponse { + #[prost(oneof = "get_contested_resources_response::Version", tags = "1")] + pub version: ::core::option::Option, +} +/// Nested message and enum types in `GetContestedResourcesResponse`. +pub mod get_contested_resources_response { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct GetContestedResourcesResponseV0 { + #[prost(message, optional, tag = "3")] + pub metadata: ::core::option::Option, + #[prost(oneof = "get_contested_resources_response_v0::Result", tags = "1, 2")] + pub result: ::core::option::Option, + } + /// Nested message and enum types in `GetContestedResourcesResponseV0`. + pub mod get_contested_resources_response_v0 { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ContestedResources { + #[prost(message, repeated, tag = "1")] + pub contested_resources: ::prost::alloc::vec::Vec, + #[prost(bool, tag = "2")] + pub finished_results: bool, + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ContestedResource { + #[prost(bytes = "vec", tag = "1")] + pub identifier: ::prost::alloc::vec::Vec, + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Result { + #[prost(message, tag = "1")] + ContestedResources(ContestedResources), + #[prost(message, tag = "2")] + Proof(super::super::Proof), + } + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Version { + #[prost(message, tag = "1")] + V0(GetContestedResourcesResponseV0), + } +} +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(rename_all = "snake_case")] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetContestedResourceVoteStateRequest { + #[prost(oneof = "get_contested_resource_vote_state_request::Version", tags = "1")] + pub version: ::core::option::Option< + get_contested_resource_vote_state_request::Version, + >, +} +/// Nested message and enum types in `GetContestedResourceVoteStateRequest`. +pub mod get_contested_resource_vote_state_request { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct GetContestedResourceVoteStateRequestV0 { + #[prost(bool, tag = "1")] + pub prove: bool, + #[prost(bytes = "vec", repeated, tag = "2")] + pub resource_path: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, + #[prost(bytes = "vec", tag = "3")] + pub contested_resource: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", optional, tag = "4")] + pub start_identifier: ::core::option::Option<::prost::alloc::vec::Vec>, + #[prost(uint32, optional, tag = "5")] + pub count: ::core::option::Option, + #[prost(bool, optional, tag = "6")] + pub ascending: ::core::option::Option, + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Version { + #[prost(message, tag = "1")] + V0(GetContestedResourceVoteStateRequestV0), + } +} +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(rename_all = "snake_case")] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetContestedResourceVoteStateResponse { + #[prost(oneof = "get_contested_resource_vote_state_response::Version", tags = "1")] + pub version: ::core::option::Option< + get_contested_resource_vote_state_response::Version, + >, +} +/// Nested message and enum types in `GetContestedResourceVoteStateResponse`. +pub mod get_contested_resource_vote_state_response { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct GetContestedResourceVoteStateResponseV0 { + #[prost(message, optional, tag = "3")] + pub metadata: ::core::option::Option, + #[prost( + oneof = "get_contested_resource_vote_state_response_v0::Result", + tags = "1, 2" + )] + pub result: ::core::option::Option< + get_contested_resource_vote_state_response_v0::Result, + >, + } + /// Nested message and enum types in `GetContestedResourceVoteStateResponseV0`. + pub mod get_contested_resource_vote_state_response_v0 { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ContestedResourceContenders { + #[prost(message, repeated, tag = "1")] + pub contenders: ::prost::alloc::vec::Vec, + #[prost(bool, tag = "2")] + pub finished_results: bool, + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Contender { + #[prost(bytes = "vec", tag = "1")] + pub identifier: ::prost::alloc::vec::Vec, + #[prost(uint32, tag = "2")] + pub vote_count: u32, + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Result { + #[prost(message, tag = "1")] + ContestedResourceContenders(ContestedResourceContenders), + #[prost(message, tag = "2")] + Proof(super::super::Proof), + } + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Version { + #[prost(message, tag = "1")] + V0(GetContestedResourceVoteStateResponseV0), + } +} +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(rename_all = "snake_case")] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetContestedResourceVoteStatusRequest { + #[prost(oneof = "get_contested_resource_vote_status_request::Version", tags = "1")] + pub version: ::core::option::Option< + get_contested_resource_vote_status_request::Version, + >, +} +/// Nested message and enum types in `GetContestedResourceVoteStatusRequest`. +pub mod get_contested_resource_vote_status_request { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct GetContestedResourceVoteStatusRequestV0 { + #[prost(bool, tag = "1")] + pub prove: bool, + #[prost(bytes = "vec", repeated, tag = "2")] + pub resource_path: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, + #[prost(bytes = "vec", tag = "3")] + pub resource_identifier: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", optional, tag = "4")] + pub voter_identifier: ::core::option::Option<::prost::alloc::vec::Vec>, + #[prost(uint32, optional, tag = "5")] + pub count: ::core::option::Option, + #[prost(bool, optional, tag = "6")] + pub ascending: ::core::option::Option, + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Version { + #[prost(message, tag = "1")] + V0(GetContestedResourceVoteStatusRequestV0), + } +} +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(rename_all = "snake_case")] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetContestedResourceVoteStatusResponse { + #[prost(oneof = "get_contested_resource_vote_status_response::Version", tags = "1")] + pub version: ::core::option::Option< + get_contested_resource_vote_status_response::Version, + >, +} +/// Nested message and enum types in `GetContestedResourceVoteStatusResponse`. +pub mod get_contested_resource_vote_status_response { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct GetContestedResourceVoteStatusResponseV0 { + #[prost(message, optional, tag = "3")] + pub metadata: ::core::option::Option, + #[prost( + oneof = "get_contested_resource_vote_status_response_v0::Result", + tags = "1, 2" + )] + pub result: ::core::option::Option< + get_contested_resource_vote_status_response_v0::Result, + >, + } + /// Nested message and enum types in `GetContestedResourceVoteStatusResponseV0`. + pub mod get_contested_resource_vote_status_response_v0 { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ContestedResourceVoters { + #[prost(message, repeated, tag = "1")] + pub voters: ::prost::alloc::vec::Vec, + #[prost(bool, tag = "2")] + pub finished_results: bool, + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Voter { + #[prost(bytes = "vec", tag = "1")] + pub identifier: ::prost::alloc::vec::Vec, + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Result { + #[prost(message, tag = "1")] + ContestedResourceVoters(ContestedResourceVoters), + #[prost(message, tag = "2")] + Proof(super::super::Proof), + } + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Version { + #[prost(message, tag = "1")] + V0(GetContestedResourceVoteStatusResponseV0), + } +} /// Generated client implementations. pub mod platform_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] @@ -2477,5 +2788,97 @@ pub mod platform_client { ); self.inner.unary(req, path, codec).await } + pub async fn get_contested_resources( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/org.dash.platform.dapi.v0.Platform/getContestedResources", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "org.dash.platform.dapi.v0.Platform", + "getContestedResources", + ), + ); + self.inner.unary(req, path, codec).await + } + pub async fn get_contested_resource_vote_state( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/org.dash.platform.dapi.v0.Platform/getContestedResourceVoteState", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "org.dash.platform.dapi.v0.Platform", + "getContestedResourceVoteState", + ), + ); + self.inner.unary(req, path, codec).await + } + pub async fn get_contested_resource_vote_status( + &mut self, + request: impl tonic::IntoRequest< + super::GetContestedResourceVoteStatusRequest, + >, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/org.dash.platform.dapi.v0.Platform/getContestedResourceVoteStatus", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "org.dash.platform.dapi.v0.Platform", + "getContestedResourceVoteStatus", + ), + ); + self.inner.unary(req, path, codec).await + } } } From 0a2cdfee9a852e821e2efcd24529d82bd363a872 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 2 Jan 2024 20:01:57 +0700 Subject: [PATCH 015/135] added thing --- .../src/identity/state_transition/transition_types.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/wasm-dpp/src/identity/state_transition/transition_types.rs b/packages/wasm-dpp/src/identity/state_transition/transition_types.rs index fec6d183f7..7253a89a30 100644 --- a/packages/wasm-dpp/src/identity/state_transition/transition_types.rs +++ b/packages/wasm-dpp/src/identity/state_transition/transition_types.rs @@ -12,6 +12,7 @@ pub enum StateTransitionTypeWasm { IdentityUpdate = 5, IdentityCreditWithdrawal = 6, IdentityCreditTransfer = 7, + MasternodeVote = 8, } impl From for StateTransitionTypeWasm { @@ -29,6 +30,9 @@ impl From for StateTransitionTypeWasm { StateTransitionType::IdentityCreditTransfer => { StateTransitionTypeWasm::IdentityCreditTransfer } + StateTransitionType::MasternodeVote => { + StateTransitionTypeWasm::MasternodeVote + } } } } From afa81fb7a1b70238ef000cd229e01e80812fc192 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 3 Jan 2024 17:18:44 +0700 Subject: [PATCH 016/135] dev.2 --- Cargo.lock | 2 +- packages/dapi-grpc/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ecef836e0b..e8e3f54a9e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -951,7 +951,7 @@ dependencies = [ "prost 0.11.9", "serde", "serde_bytes", - "tenderdash-proto 0.14.0-dev.1 (git+https://github.com/dashpay/rs-tenderdash-abci)", + "tenderdash-proto 0.14.0-dev.1 (git+https://github.com/dashpay/rs-tenderdash-abci?tag=v0.14.0-dev.2)", "tonic", "tonic-build", ] diff --git a/packages/dapi-grpc/Cargo.toml b/packages/dapi-grpc/Cargo.toml index 7160550b71..2d278e329d 100644 --- a/packages/dapi-grpc/Cargo.toml +++ b/packages/dapi-grpc/Cargo.toml @@ -30,7 +30,7 @@ tonic = { version = "0.9.2", features = [ ], default-features = false } serde = { version = "1.0.171", optional = true, features = ["derive"] } serde_bytes = { version = "0.11.12", optional = true } -tenderdash-proto = { git = "https://github.com/dashpay/rs-tenderdash-abci" } +tenderdash-proto = { git = "https://github.com/dashpay/rs-tenderdash-abci", tag = "v0.14.0-dev.2" } dapi-grpc-macros = { path = "../rs-dapi-grpc-macros" } platform-version = { path = "../rs-platform-version" } From 8ccef9fcca53fc1f69026602dce18bfa45acf681 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Thu, 4 Jan 2024 16:15:40 +0700 Subject: [PATCH 017/135] more work --- Cargo.lock | 63 ++----------------- packages/rs-drive-proof-verifier/Cargo.toml | 2 +- .../cleanup/remove_votes_for_identity/mod.rs | 2 +- packages/rs-drive/src/drive/votes/mod.rs | 44 +++++-------- 4 files changed, 21 insertions(+), 90 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e8e3f54a9e..deb5515dd5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -951,7 +951,7 @@ dependencies = [ "prost 0.11.9", "serde", "serde_bytes", - "tenderdash-proto 0.14.0-dev.1 (git+https://github.com/dashpay/rs-tenderdash-abci?tag=v0.14.0-dev.2)", + "tenderdash-proto", "tonic", "tonic-build", ] @@ -1299,7 +1299,7 @@ dependencies = [ "simple-signer", "strategy-tests", "tempfile", - "tenderdash-abci 0.14.0-dev.1 (git+https://github.com/dashpay/rs-tenderdash-abci?tag=v0.14.0-dev.2)", + "tenderdash-abci", "thiserror", "tokio", "tokio-util", @@ -1320,7 +1320,7 @@ dependencies = [ "lazy_static", "serde", "serde_json", - "tenderdash-abci 0.14.0-dev.1 (git+https://github.com/dashpay/rs-tenderdash-abci)", + "tenderdash-abci", "thiserror", "tracing", ] @@ -4140,28 +4140,7 @@ dependencies = [ "lhash", "prost 0.12.3", "semver", - "tenderdash-proto 0.14.0-dev.1 (git+https://github.com/dashpay/rs-tenderdash-abci?tag=v0.14.0-dev.2)", - "thiserror", - "tokio", - "tokio-util", - "tracing", - "tracing-subscriber", - "url", - "uuid 1.6.1", -] - -[[package]] -name = "tenderdash-abci" -version = "0.14.0-dev.1" -source = "git+https://github.com/dashpay/rs-tenderdash-abci#6ebfaa31052f7ad538d6589323e5daf7e5e55999" -dependencies = [ - "bytes", - "futures", - "hex", - "lhash", - "prost 0.12.3", - "semver", - "tenderdash-proto 0.14.0-dev.1 (git+https://github.com/dashpay/rs-tenderdash-abci)", + "tenderdash-proto", "thiserror", "tokio", "tokio-util", @@ -4185,25 +4164,7 @@ dependencies = [ "prost 0.12.3", "serde", "subtle-encoding", - "tenderdash-proto-compiler 0.14.0-dev.1 (git+https://github.com/dashpay/rs-tenderdash-abci?tag=v0.14.0-dev.2)", - "time", -] - -[[package]] -name = "tenderdash-proto" -version = "0.14.0-dev.1" -source = "git+https://github.com/dashpay/rs-tenderdash-abci#6ebfaa31052f7ad538d6589323e5daf7e5e55999" -dependencies = [ - "bytes", - "chrono", - "derive_more", - "flex-error", - "num-derive", - "num-traits", - "prost 0.12.3", - "serde", - "subtle-encoding", - "tenderdash-proto-compiler 0.14.0-dev.1 (git+https://github.com/dashpay/rs-tenderdash-abci)", + "tenderdash-proto-compiler", "time", ] @@ -4221,20 +4182,6 @@ dependencies = [ "zip", ] -[[package]] -name = "tenderdash-proto-compiler" -version = "0.14.0-dev.1" -source = "git+https://github.com/dashpay/rs-tenderdash-abci#6ebfaa31052f7ad538d6589323e5daf7e5e55999" -dependencies = [ - "fs_extra", - "prost-build 0.12.3", - "regex", - "tempfile", - "ureq", - "walkdir", - "zip", -] - [[package]] name = "termcolor" version = "1.4.0" diff --git a/packages/rs-drive-proof-verifier/Cargo.toml b/packages/rs-drive-proof-verifier/Cargo.toml index fa889b441e..6895bf4cce 100644 --- a/packages/rs-drive-proof-verifier/Cargo.toml +++ b/packages/rs-drive-proof-verifier/Cargo.toml @@ -20,7 +20,7 @@ drive = { path = "../rs-drive", default-features = false, features = [ "verify", ] } dpp = { path = "../rs-dpp" } -tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci" } +tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", tag = "v0.14.0-dev.2" } # tenderdash-abci = { path = "../../../rs-tenderdash-abci/abci" } tracing = { version = "0.1.37" } serde = { version = "1.0.171", default-features = false, optional = true } diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs index fe63d862a6..5e6aba963f 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs @@ -23,7 +23,7 @@ impl Drive { ) -> Result<(), Error> { match platform_version.drive.methods.vote.cleanup.remove_votes_for_identity { 0 => self.remove_votes_for_identity_v0( - identity_id + identity_id, transaction, platform_version, ), diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 1152be443d..eea169633e 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -1,3 +1,4 @@ +use dpp::consensus::basic::data_contract::DuplicateIndexError; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::DataContract; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; @@ -91,7 +92,7 @@ pub trait TreePath { } -impl TreePath for ContestedDocumentResourceVoteType { +impl TreePath for ContestedDocumentResourceVoteType { fn tree_path(&self, contract: &DataContract) -> Result, ProtocolError> { if contract.id() != self.vote_poll.contract_id { return Err(ProtocolError::VoteError(format!("contract id of vote {} does not match supplied contract {}", self.vote_poll.contract_id, contract.id()))); @@ -105,35 +106,18 @@ impl TreePath for ContestedDocumentResourceVoteType { let Some(contested_index) = &index.contested_index else { return Err(ProtocolError::VoteError("we expect the index in a contested document resource vote type to be contested".to_string())); }; - let mut properties_iter = index.properties.iter().peekable(); - - while let Some(index_part) = properties_iter.next() { - let level_name = if contested_index.contested_field_name == index_part.name { - &contested_index.contested_field_temp_replacement_name - } else { - &index_part.name - }; - - // The last property - if properties_iter.peek().is_none() { - // This level already has been initialized. - // It means there are two indices with the same combination of properties. - - // We might need to take into account the sorting order when we have it - if current_level.has_index_with_type.is_some() { - // an index already exists return error - return Err(ConsensusError::BasicError( - BasicError::DuplicateIndexError(DuplicateIndexError::new( - document_type_name.to_owned(), - level_name.clone(), - )), - ) - .into()); - } - - current_level.has_index_with_type = Some(ContestedResourceIndex); - } - } + + let mut properties_iter = index.properties.iter(); + + while let Some(index_part) = properties_iter.next() { + let level_name = if contested_index.contested_field_name == index_part.name { + &contested_index.contested_field_temp_replacement_name + } else { + &index_part.name + }; + + path.push(level_name.as_bytes()); } + Ok(path) } } From ba243871c760b85b5bf75aa5dc100dc131ddb8f3 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 9 Jan 2024 17:47:50 +0700 Subject: [PATCH 018/135] review fixes --- Cargo.lock | 12 ++++++------ packages/dapi-grpc/Cargo.toml | 2 +- .../schema/dpns-contract-documents.json | 4 ++-- .../masternode_vote_transition/fields.rs | 6 +++--- .../identity/masternode_vote_transition/mod.rs | 8 ++++++-- .../v0/identity_signed.rs | 4 ++-- .../masternode_vote_transition/v0/mod.rs | 16 ++++++++++------ packages/rs-drive-abci/Cargo.toml | 2 +- packages/rs-drive-proof-verifier/Cargo.toml | 2 +- 9 files changed, 32 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ed38ded9d7..e7c9a55c0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4130,8 +4130,8 @@ dependencies = [ [[package]] name = "tenderdash-abci" -version = "0.14.0-dev.1" -source = "git+https://github.com/dashpay/rs-tenderdash-abci?tag=v0.14.0-dev.2#6ebfaa31052f7ad538d6589323e5daf7e5e55999" +version = "0.14.0-dev.5" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?tag=v0.14.0-dev.5#556f3a9b6724bdbe44acf8045cd87144a997bccb" dependencies = [ "bytes", "futures", @@ -4151,8 +4151,8 @@ dependencies = [ [[package]] name = "tenderdash-proto" -version = "0.14.0-dev.1" -source = "git+https://github.com/dashpay/rs-tenderdash-abci?tag=v0.14.0-dev.2#6ebfaa31052f7ad538d6589323e5daf7e5e55999" +version = "0.14.0-dev.5" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?tag=v0.14.0-dev.5#556f3a9b6724bdbe44acf8045cd87144a997bccb" dependencies = [ "bytes", "chrono", @@ -4169,8 +4169,8 @@ dependencies = [ [[package]] name = "tenderdash-proto-compiler" -version = "0.14.0-dev.1" -source = "git+https://github.com/dashpay/rs-tenderdash-abci?tag=v0.14.0-dev.2#6ebfaa31052f7ad538d6589323e5daf7e5e55999" +version = "0.14.0-dev.5" +source = "git+https://github.com/dashpay/rs-tenderdash-abci?tag=v0.14.0-dev.5#556f3a9b6724bdbe44acf8045cd87144a997bccb" dependencies = [ "fs_extra", "prost-build 0.12.3", diff --git a/packages/dapi-grpc/Cargo.toml b/packages/dapi-grpc/Cargo.toml index 2d278e329d..ba1f2d4bca 100644 --- a/packages/dapi-grpc/Cargo.toml +++ b/packages/dapi-grpc/Cargo.toml @@ -30,7 +30,7 @@ tonic = { version = "0.9.2", features = [ ], default-features = false } serde = { version = "1.0.171", optional = true, features = ["derive"] } serde_bytes = { version = "0.11.12", optional = true } -tenderdash-proto = { git = "https://github.com/dashpay/rs-tenderdash-abci", tag = "v0.14.0-dev.2" } +tenderdash-proto = { git = "https://github.com/dashpay/rs-tenderdash-abci", tag = "v0.14.0-dev.5" } dapi-grpc-macros = { path = "../rs-dapi-grpc-macros" } platform-version = { path = "../rs-platform-version" } diff --git a/packages/dpns-contract/schema/dpns-contract-documents.json b/packages/dpns-contract/schema/dpns-contract-documents.json index f8c62dbf8c..5f6d88ca15 100644 --- a/packages/dpns-contract/schema/dpns-contract-documents.json +++ b/packages/dpns-contract/schema/dpns-contract-documents.json @@ -16,9 +16,9 @@ "contested": { "name": "normalizedLabelContested", "fieldMatch": "normalizedLabel", - "regexPattern": "^[a-zA-Z]{3,19}$", + "regexPattern": "^[a-zA-Z01]{3,19}$", "resolution": 0, - "description": "If the normalized label part of this index is less than 20 characters (all non numeric) then this index is non unique while contest resolution takes place." + "description": "If the normalized label part of this index is less than 20 characters (all alphabet a-z and 0 and 1) then this index is non unique while contest resolution takes place." } }, { diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/fields.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/fields.rs index 95e00a9c8f..3bf2fb5a71 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/fields.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/fields.rs @@ -1,15 +1,15 @@ use crate::state_transition::state_transitions; -use crate::state_transition::masternode_vote_transition::fields::property_names::RECIPIENT_ID; +use crate::state_transition::masternode_vote_transition::fields::property_names::{PRO_TX_HASH}; pub use state_transitions::common_fields::property_names::{ ENTROPY, SIGNATURE, SIGNATURE_PUBLIC_KEY_ID, STATE_TRANSITION_PROTOCOL_VERSION, TRANSITION_TYPE, }; pub use state_transitions::identity::common_fields::property_names::IDENTITY_ID; pub(crate) mod property_names { - pub const RECIPIENT_ID: &str = "recipientId"; + pub const PRO_TX_HASH: &str = "proTxHash"; } -pub const IDENTIFIER_FIELDS: [&str; 2] = [IDENTITY_ID, RECIPIENT_ID]; +pub const IDENTIFIER_FIELDS: [&str; 1] = [PRO_TX_HASH]; pub const BINARY_FIELDS: [&str; 1] = [SIGNATURE]; pub const U32_FIELDS: [&str; 1] = [STATE_TRANSITION_PROTOCOL_VERSION]; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs index 644714af10..ffda64bd96 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs @@ -10,7 +10,7 @@ pub mod v0; mod value_conversion; mod version; -use crate::state_transition::masternode_vote_transition::fields::property_names::RECIPIENT_ID; +use crate::state_transition::masternode_vote_transition::fields::property_names::{PRO_TX_HASH, RECIPIENT_ID}; use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0Signable; use crate::state_transition::StateTransitionFieldTypes; @@ -23,6 +23,8 @@ use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize, Plat use platform_version::version::PlatformVersion; use platform_versioning::PlatformVersioned; use serde::{Deserialize, Serialize}; +use crate::identity::state_transition::OptionallyAssetLockProved; +use crate::state_transition::data_contract_update_transition::DataContractUpdateTransition; pub type MasternodeVoteTransitionLatest = MasternodeVoteTransitionV0; @@ -71,13 +73,15 @@ impl MasternodeVoteTransition { } } +impl OptionallyAssetLockProved for MasternodeVoteTransition {} + impl StateTransitionFieldTypes for MasternodeVoteTransition { fn signature_property_paths() -> Vec<&'static str> { vec![SIGNATURE] } fn identifiers_property_paths() -> Vec<&'static str> { - vec![IDENTITY_ID, RECIPIENT_ID] + vec![PRO_TX_HASH] } fn binary_property_paths() -> Vec<&'static str> { diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/identity_signed.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/identity_signed.rs index 52ca167dca..ec71943fb8 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/identity_signed.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/identity_signed.rs @@ -1,4 +1,4 @@ -use crate::identity::SecurityLevel::CRITICAL; +use crate::identity::SecurityLevel::{CRITICAL, HIGH}; use crate::identity::{KeyID, SecurityLevel}; use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; use crate::state_transition::StateTransitionIdentitySigned; @@ -13,6 +13,6 @@ impl StateTransitionIdentitySigned for MasternodeVoteTransitionV0 { } fn security_level_requirement(&self) -> Vec { - vec![CRITICAL] + vec![CRITICAL, HIGH] } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs index c80bf43f9a..c97b3e9c3d 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs @@ -53,7 +53,7 @@ mod test { use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; use crate::voting::resource_vote::ResourceVote; - use crate::voting::Vote; + use crate::voting::{ContestedDocumentResourceVotePoll, ContestedDocumentResourceVoteType, Vote}; use platform_value::Identifier; use rand::Rng; use std::fmt::Debug; @@ -77,11 +77,15 @@ mod test { let transition = MasternodeVoteTransitionV0 { pro_tx_hash: Identifier::random(), vote: Vote::ContestedDocumentResourceVote( - Identifier::random(), - "hello".to_string(), - "index_1".to_string(), - vec![], - ResourceVote::TowardsIdentity(Identifier::random()), + ContestedDocumentResourceVoteType { + vote_poll: ContestedDocumentResourceVotePoll { + contract_id: Default::default(), + document_type_name: "hello".to_string(), + index_name: "index_1".to_string(), + index_values: vec![], + }, + resource_vote: ResourceVote::TowardsIdentity(Identifier::random()), + } ), signature_public_key_id: rng.gen(), signature: [0; 65].to_vec().into(), diff --git a/packages/rs-drive-abci/Cargo.toml b/packages/rs-drive-abci/Cargo.toml index af6227b883..aee530a8fa 100644 --- a/packages/rs-drive-abci/Cargo.toml +++ b/packages/rs-drive-abci/Cargo.toml @@ -58,7 +58,7 @@ tracing-subscriber = { version = "0.3.16", default-features = false, features = "tracing-log", ], optional = false } atty = { version = "0.2.14", optional = false } -tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", tag = "v0.14.0-dev.2" } +tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", tag = "v0.14.0-dev.5" } lazy_static = "1.4.0" itertools = { version = "0.10.5" } file-rotate = { version = "0.7.3" } diff --git a/packages/rs-drive-proof-verifier/Cargo.toml b/packages/rs-drive-proof-verifier/Cargo.toml index 6895bf4cce..048254f2fc 100644 --- a/packages/rs-drive-proof-verifier/Cargo.toml +++ b/packages/rs-drive-proof-verifier/Cargo.toml @@ -20,7 +20,7 @@ drive = { path = "../rs-drive", default-features = false, features = [ "verify", ] } dpp = { path = "../rs-dpp" } -tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", tag = "v0.14.0-dev.2" } +tenderdash-abci = { git = "https://github.com/dashpay/rs-tenderdash-abci", tag = "v0.14.0-dev.5" } # tenderdash-abci = { path = "../../../rs-tenderdash-abci/abci" } tracing = { version = "0.1.37" } serde = { version = "1.0.171", default-features = false, optional = true } From 19b739f471fe73d9eb8691638dd863166735b450 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 9 Jan 2024 17:48:04 +0700 Subject: [PATCH 019/135] fmt --- packages/rs-dpp/src/state_transition/mod.rs | 2 +- .../masternode_vote_transition/fields.rs | 2 +- .../masternode_vote_transition/mod.rs | 8 ++- .../masternode_vote_transition/v0/mod.rs | 24 +++---- packages/rs-dpp/src/voting/mod.rs | 30 ++++---- .../tests/strategy_tests/core_update_tests.rs | 9 +-- .../tests/strategy_tests/failures.rs | 1 - .../tests/strategy_tests/main.rs | 69 ++++--------------- .../tests/strategy_tests/masternodes.rs | 20 ------ .../strategy_tests/upgrade_fork_tests.rs | 6 -- .../tests/strategy_tests/voting_tests.rs | 30 ++++---- .../rs-drive/src/drive/votes/cleanup/mod.rs | 1 - .../cleanup/remove_votes_for_identity/mod.rs | 21 +++--- .../remove_votes_for_identity/v0/mod.rs | 66 ++++++++++++------ .../mod.rs | 12 +++- .../v0/mod.rs | 10 +-- .../mod.rs | 13 ++-- .../v0/mod.rs | 1 + .../add_vote_poll_end_date_query/mod.rs | 19 ++--- .../add_vote_poll_end_date_query/v0/mod.rs | 1 + .../rs-drive/src/drive/votes/insert/mod.rs | 2 +- .../insert/register_identity_vote/mod.rs | 17 ++--- .../insert/register_identity_vote/v0/mod.rs | 18 +++-- packages/rs-drive/src/drive/votes/mod.rs | 57 ++++++++++----- .../rs-drive/src/drive/votes/setup/mod.rs | 2 +- .../mod.rs | 7 +- .../v0/mod.rs | 9 ++- .../src/version/mocks/v2_test.rs | 39 ++++++++++- .../src/version/mocks/v3_test.rs | 39 ++++++++++- .../rs-platform-version/src/version/v1.rs | 39 ++++++++++- .../state_transition/transition_types.rs | 4 +- 31 files changed, 339 insertions(+), 239 deletions(-) diff --git a/packages/rs-dpp/src/state_transition/mod.rs b/packages/rs-dpp/src/state_transition/mod.rs index e4f5317dbb..e766ba77cf 100644 --- a/packages/rs-dpp/src/state_transition/mod.rs +++ b/packages/rs-dpp/src/state_transition/mod.rs @@ -38,8 +38,8 @@ use crate::identity::identity_public_key::accessors::v0::IdentityPublicKeyGetter use crate::identity::signer::Signer; use crate::identity::state_transition::OptionallyAssetLockProved; use crate::identity::{IdentityPublicKey, KeyID, KeyType, Purpose, SecurityLevel}; -use crate::state_transition::masternode_vote_transition::MasternodeVoteTransitionSignable; use crate::prelude::AssetLockProof; +use crate::state_transition::masternode_vote_transition::MasternodeVoteTransitionSignable; pub use state_transitions::*; use crate::serialization::Signable; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/fields.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/fields.rs index 3bf2fb5a71..e278176f74 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/fields.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/fields.rs @@ -1,6 +1,6 @@ use crate::state_transition::state_transitions; -use crate::state_transition::masternode_vote_transition::fields::property_names::{PRO_TX_HASH}; +use crate::state_transition::masternode_vote_transition::fields::property_names::PRO_TX_HASH; pub use state_transitions::common_fields::property_names::{ ENTROPY, SIGNATURE, SIGNATURE_PUBLIC_KEY_ID, STATE_TRANSITION_PROTOCOL_VERSION, TRANSITION_TYPE, }; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs index ffda64bd96..67fd1014ca 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs @@ -10,11 +10,15 @@ pub mod v0; mod value_conversion; mod version; -use crate::state_transition::masternode_vote_transition::fields::property_names::{PRO_TX_HASH, RECIPIENT_ID}; +use crate::state_transition::masternode_vote_transition::fields::property_names::{ + PRO_TX_HASH, RECIPIENT_ID, +}; use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0Signable; use crate::state_transition::StateTransitionFieldTypes; +use crate::identity::state_transition::OptionallyAssetLockProved; +use crate::state_transition::data_contract_update_transition::DataContractUpdateTransition; use crate::ProtocolError; use bincode::{Decode, Encode}; use derive_more::From; @@ -23,8 +27,6 @@ use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize, Plat use platform_version::version::PlatformVersion; use platform_versioning::PlatformVersioned; use serde::{Deserialize, Serialize}; -use crate::identity::state_transition::OptionallyAssetLockProved; -use crate::state_transition::data_contract_update_transition::DataContractUpdateTransition; pub type MasternodeVoteTransitionLatest = MasternodeVoteTransitionV0; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs index c97b3e9c3d..1204fab66f 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs @@ -53,7 +53,9 @@ mod test { use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; use crate::voting::resource_vote::ResourceVote; - use crate::voting::{ContestedDocumentResourceVotePoll, ContestedDocumentResourceVoteType, Vote}; + use crate::voting::{ + ContestedDocumentResourceVotePoll, ContestedDocumentResourceVoteType, Vote, + }; use platform_value::Identifier; use rand::Rng; use std::fmt::Debug; @@ -76,17 +78,15 @@ mod test { let mut rng = rand::thread_rng(); let transition = MasternodeVoteTransitionV0 { pro_tx_hash: Identifier::random(), - vote: Vote::ContestedDocumentResourceVote( - ContestedDocumentResourceVoteType { - vote_poll: ContestedDocumentResourceVotePoll { - contract_id: Default::default(), - document_type_name: "hello".to_string(), - index_name: "index_1".to_string(), - index_values: vec![], - }, - resource_vote: ResourceVote::TowardsIdentity(Identifier::random()), - } - ), + vote: Vote::ContestedDocumentResourceVote(ContestedDocumentResourceVoteType { + vote_poll: ContestedDocumentResourceVotePoll { + contract_id: Default::default(), + document_type_name: "hello".to_string(), + index_name: "index_1".to_string(), + index_values: vec![], + }, + resource_vote: ResourceVote::TowardsIdentity(Identifier::random()), + }), signature_public_key_id: rng.gen(), signature: [0; 65].to_vec().into(), }; diff --git a/packages/rs-dpp/src/voting/mod.rs b/packages/rs-dpp/src/voting/mod.rs index 4b722ea219..f685e11e00 100644 --- a/packages/rs-dpp/src/voting/mod.rs +++ b/packages/rs-dpp/src/voting/mod.rs @@ -1,22 +1,22 @@ +use crate::data_contract::accessors::v0::DataContractV0Getters; +use crate::data_contract::document_type::accessors::DocumentTypeV0Getters; +use crate::prelude::DataContract; use crate::voting::resource_vote::ResourceVote; use crate::voting::Vote::ContestedDocumentResourceVote; +use crate::ProtocolError; use bincode::{Decode, Encode}; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use platform_value::{Identifier, Value}; use serde::{Deserialize, Serialize}; -use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; -use crate::data_contract::accessors::v0::DataContractV0Getters; -use crate::data_contract::document_type::accessors::DocumentTypeV0Getters; -use crate::prelude::DataContract; -use crate::ProtocolError; pub mod common_vote; pub mod resource_vote; #[derive(Debug, Clone, Encode, Decode, PartialEq)] #[cfg_attr( -feature = "state-transition-serde-conversion", -derive(Serialize, Deserialize), -serde(rename_all = "camelCase") + feature = "state-transition-serde-conversion", + derive(Serialize, Deserialize), + serde(rename_all = "camelCase") )] pub struct ContestedDocumentResourceVotePoll { pub contract_id: Identifier, @@ -38,9 +38,9 @@ impl Default for ContestedDocumentResourceVotePoll { #[derive(Debug, Clone, Encode, Decode, PlatformDeserialize, PlatformSerialize, PartialEq)] #[cfg_attr( -feature = "state-transition-serde-conversion", -derive(Serialize, Deserialize), -serde(rename_all = "camelCase") + feature = "state-transition-serde-conversion", + derive(Serialize, Deserialize), + serde(rename_all = "camelCase") )] #[platform_serialize(unversioned)] pub struct ContestedDocumentResourceVoteType { @@ -64,15 +64,11 @@ impl Default for ContestedDocumentResourceVoteType { serde(rename_all = "camelCase") )] pub enum Vote { - ContestedDocumentResourceVote( - ContestedDocumentResourceVoteType, - ), + ContestedDocumentResourceVote(ContestedDocumentResourceVoteType), } impl Default for Vote { fn default() -> Self { - ContestedDocumentResourceVote( - ContestedDocumentResourceVoteType::default() - ) + ContestedDocumentResourceVote(ContestedDocumentResourceVoteType::default()) } } diff --git a/packages/rs-drive-abci/tests/strategy_tests/core_update_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/core_update_tests.rs index d7aab33adf..7f9a10cdd3 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/core_update_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/core_update_tests.rs @@ -31,7 +31,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: None, - }, proposer_strategy: MasternodeListChangesStrategy { new_hpmns: Default::default(), @@ -40,7 +39,6 @@ mod tests { banned_hpmns: Frequency { times_per_block_range: 1..2, chance_per_block: Some(0.1), - }, unbanned_hpmns: Default::default(), changed_ip_hpmns: Default::default(), @@ -139,14 +137,12 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: None, - }, proposer_strategy: MasternodeListChangesStrategy { new_hpmns: Default::default(), removed_hpmns: Frequency { times_per_block_range: 1..2, chance_per_block: Some(0.1), - }, updated_hpmns: Default::default(), banned_hpmns: Default::default(), @@ -233,7 +229,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: None, - }, proposer_strategy: MasternodeListChangesStrategy { new_hpmns: Default::default(), @@ -242,12 +237,12 @@ mod tests { banned_hpmns: Frequency { times_per_block_range: 1..2, chance_per_block: Some(0.1), - //lower chance of banning + //lower chance of banning }, unbanned_hpmns: Frequency { times_per_block_range: 1..2, chance_per_block: Some(0.3), - //higher chance of unbanning + //higher chance of unbanning }, changed_ip_hpmns: Default::default(), changed_p2p_port_hpmns: Default::default(), diff --git a/packages/rs-drive-abci/tests/strategy_tests/failures.rs b/packages/rs-drive-abci/tests/strategy_tests/failures.rs index 192b5e6ca1..6f55d48d65 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/failures.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/failures.rs @@ -151,7 +151,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, diff --git a/packages/rs-drive-abci/tests/strategy_tests/main.rs b/packages/rs-drive-abci/tests/strategy_tests/main.rs index 34d5343fea..9553ead478 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/main.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/main.rs @@ -137,7 +137,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -194,7 +193,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -251,7 +249,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -531,7 +528,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -657,7 +653,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..3, chance_per_block: Some(0.5), - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -789,7 +784,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 5..6, chance_per_block: Some(0.5), - }, proposer_strategy: Default::default(), rotate_quorums: true, @@ -874,13 +868,11 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: Some(0.2), - }, proposer_strategy: MasternodeListChangesStrategy { new_hpmns: Frequency { times_per_block_range: 1..3, chance_per_block: Some(0.5), - }, ..Default::default() }, @@ -947,18 +939,15 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: Some(0.2), - }, proposer_strategy: MasternodeListChangesStrategy { new_hpmns: Frequency { times_per_block_range: 1..3, chance_per_block: Some(0.5), - }, removed_hpmns: Frequency { times_per_block_range: 1..3, chance_per_block: Some(0.5), - }, ..Default::default() }, @@ -1024,13 +1013,11 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: Some(0.2), - }, proposer_strategy: MasternodeListChangesStrategy { updated_hpmns: Frequency { times_per_block_range: 1..3, chance_per_block: Some(0.5), - }, ..Default::default() }, @@ -1127,7 +1114,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1136,7 +1122,6 @@ mod tests { query_identities_by_public_key_hashes: Frequency { times_per_block_range: 1..5, chance_per_block: None, - }, }), verify_state_transition_results: true, @@ -1191,7 +1176,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1277,7 +1261,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1390,7 +1373,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1488,7 +1470,6 @@ mod tests { identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, - }, signer: None, }, @@ -1499,7 +1480,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1573,7 +1553,6 @@ mod tests { identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, - }, signer: None, }, @@ -1584,7 +1563,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1696,7 +1674,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1808,7 +1785,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1934,7 +1910,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -2066,7 +2041,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -2133,7 +2107,6 @@ mod tests { identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, - }, signer: None, }, @@ -2144,7 +2117,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -2217,7 +2189,6 @@ mod tests { identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, - }, signer: None, }, @@ -2228,7 +2199,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -2308,7 +2278,6 @@ mod tests { identities_inserts: Frequency { times_per_block_range: 1..2, chance_per_block: None, - }, signer: None, }, @@ -2319,7 +2288,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -2385,23 +2353,23 @@ mod tests { fn run_chain_top_up_and_withdraw_from_identities() { let strategy = NetworkStrategy { strategy: Strategy { - contracts_with_updates: vec![], - operations: vec![ - Operation { - op_type: OperationType::IdentityTopUp, - frequency: Frequency { - times_per_block_range: 1..4, - chance_per_block: None, - + contracts_with_updates: vec![], + operations: vec![ + Operation { + op_type: OperationType::IdentityTopUp, + frequency: Frequency { + times_per_block_range: 1..4, + chance_per_block: None, + }, }, - }, - Operation { - op_type: OperationType::IdentityWithdrawal, - frequency: Frequency { - times_per_block_range: 1..4, - chance_per_block: None, + Operation { + op_type: OperationType::IdentityWithdrawal, + frequency: Frequency { + times_per_block_range: 1..4, + chance_per_block: None, + }, }, - }], + ], start_identities: vec![], identities_inserts: Frequency { times_per_block_range: 1..2, @@ -2416,7 +2384,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -2478,7 +2445,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: true, @@ -2636,7 +2602,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: true, @@ -2765,7 +2730,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: 1..2, chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: true, @@ -2894,7 +2858,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -3027,7 +2990,6 @@ mod tests { identities_inserts: Frequency { times_per_block_range: 6..10, chance_per_block: None, - }, signer: None, }, @@ -3038,7 +3000,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, diff --git a/packages/rs-drive-abci/tests/strategy_tests/masternodes.rs b/packages/rs-drive-abci/tests/strategy_tests/masternodes.rs index 98155b38ae..75acbf8a11 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/masternodes.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/masternodes.rs @@ -603,52 +603,42 @@ mod tests { update_masternode_keys_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - }, update_hpmn_keys_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - }, ban_masternode_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - }, ban_hpmn_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - }, unban_masternode_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - }, unban_hpmn_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - }, change_masternode_ip_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - }, change_hpmn_ip_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - }, change_hpmn_p2p_port_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - }, change_hpmn_http_port_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - }, }); let mut rng1 = StdRng::seed_from_u64(12345); @@ -711,52 +701,42 @@ mod tests { update_masternode_keys_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - }, update_hpmn_keys_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - }, ban_masternode_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - }, ban_hpmn_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - }, unban_masternode_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - }, unban_hpmn_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - }, change_masternode_ip_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - }, change_hpmn_ip_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - }, change_hpmn_p2p_port_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - }, change_hpmn_http_port_frequency: &Frequency { times_per_block_range: Range { start: 1, end: 3 }, chance_per_block: Some(0.5), - }, }); diff --git a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs index 4b396abb3c..8fe6259375 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs @@ -52,7 +52,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -584,7 +583,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -846,7 +844,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1028,7 +1025,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1214,7 +1210,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, @@ -1327,7 +1322,6 @@ mod tests { core_height_increase: Frequency { times_per_block_range: Default::default(), chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index a6d648b1ff..246e4a9af6 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -1,25 +1,25 @@ - - #[cfg(test)] mod tests { - use std::collections::BTreeMap; - use rand::prelude::StdRng; - use rand::SeedableRng; use crate::execution::run_chain_for_strategy; use crate::strategy::{NetworkStrategy, Strategy}; use dpp::data_contract::accessors::v0::DataContractV0Getters; - use drive_abci::config::{ExecutionConfig, PlatformConfig, PlatformTestConfig}; - use drive_abci::test::helpers::setup::TestPlatformBuilder; - use tenderdash_abci::proto::types::CoreChainLock; - use dpp::data_contract::document_type::random_document::{DocumentFieldFillSize, DocumentFieldFillType}; + use dpp::data_contract::document_type::random_document::{ + DocumentFieldFillSize, DocumentFieldFillType, + }; use dpp::identity::accessors::IdentityGettersV0; use dpp::identity::Identity; use dpp::platform_value::Value; + use drive_abci::config::{ExecutionConfig, PlatformConfig, PlatformTestConfig}; + use drive_abci::test::helpers::setup::TestPlatformBuilder; use platform_version::version::PlatformVersion; + use rand::prelude::StdRng; + use rand::SeedableRng; use simple_signer::signer::SimpleSigner; + use std::collections::BTreeMap; use strategy_tests::frequency::Frequency; use strategy_tests::operations::{DocumentAction, DocumentOp, Operation, OperationType}; use strategy_tests::transitions::create_state_transitions_for_identities; + use tenderdash_abci::proto::types::CoreChainLock; #[test] fn run_chain_block_two_state_transitions_conflicting_unique_index() { @@ -54,7 +54,7 @@ mod tests { &mut rng, platform_version, ) - .unwrap(); + .unwrap(); simple_signer.add_keys(keys); @@ -64,7 +64,7 @@ mod tests { &mut rng, platform_version, ) - .unwrap(); + .unwrap(); simple_signer.add_keys(keys); @@ -88,7 +88,7 @@ mod tests { "dashUniqueIdentityId", Value::from(start_identities.first().unwrap().0.id()), )]) - .into(), + .into(), ), ]), Some(start_identities.first().unwrap().0.id()), @@ -117,7 +117,7 @@ mod tests { "dashUniqueIdentityId", Value::from(start_identities.last().unwrap().0.id()), )]) - .into(), + .into(), ), ]), Some(start_identities.last().unwrap().0.id()), @@ -142,7 +142,6 @@ mod tests { frequency: Frequency { times_per_block_range: 1..2, chance_per_block: None, - }, }, Operation { @@ -174,7 +173,6 @@ mod tests { failure_testing: None, query_testing: None, verify_state_transition_results: true, - }; let mut core_block_heights = vec![10, 11]; @@ -218,4 +216,4 @@ mod tests { assert_eq!(second_document_insert_result.code, 4009); // we expect an error } -} \ No newline at end of file +} diff --git a/packages/rs-drive/src/drive/votes/cleanup/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/mod.rs index 1c1f9dbd0a..7abdec7feb 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/mod.rs @@ -1,2 +1 @@ - mod remove_votes_for_identity; diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs index 5e6aba963f..5ff3050774 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs @@ -7,13 +7,12 @@ use crate::error::Error; use dpp::fee::fee_result::FeeResult; +use dpp::prelude::Identifier; use dpp::version::PlatformVersion; use grovedb::TransactionArg; -use dpp::prelude::Identifier; impl Drive { - - /// We remove votes for an identity when that identity is somehow disabled. Currently there is + /// We remove votes for an identity when that identity is somehow disabled. Currently there is /// no way to "disable" identities except for masternodes being removed from the list pub fn remove_votes_for_identity( &self, @@ -21,12 +20,14 @@ impl Drive { transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { - match platform_version.drive.methods.vote.cleanup.remove_votes_for_identity { - 0 => self.remove_votes_for_identity_v0( - identity_id, - transaction, - platform_version, - ), + match platform_version + .drive + .methods + .vote + .cleanup + .remove_votes_for_identity + { + 0 => self.remove_votes_for_identity_v0(identity_id, transaction, platform_version), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "remove_votes_for_identity".to_string(), known_versions: vec![0], @@ -34,4 +35,4 @@ impl Drive { })), } } -} \ No newline at end of file +} diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs index b66cfa256c..d6f7e7b8f8 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs @@ -1,21 +1,20 @@ -use std::ops::RangeFull; use crate::drive::Drive; +use std::ops::RangeFull; use crate::error::drive::DriveError; use crate::error::Error; -use dpp::version::PlatformVersion; -use grovedb::{Element, PathQuery, Query, SizedQuery, TransactionArg}; -use grovedb::query_result_type::QueryResultType::QueryElementResultType; +use crate::drive::grove_operations::BatchDeleteApplyType; +use crate::drive::votes::vote_contested_resource_identity_votes_tree_path_for_identity_vec; +use crate::query::QueryItem; use dpp::prelude::Identifier; use dpp::serialization::PlatformDeserializable; +use dpp::version::PlatformVersion; use dpp::voting::ContestedDocumentResourceVoteType; -use crate::drive::grove_operations::BatchDeleteApplyType; -use crate::drive::votes::{vote_contested_resource_identity_votes_tree_path_for_identity_vec}; -use crate::query::QueryItem; +use grovedb::query_result_type::QueryResultType::QueryElementResultType; +use grovedb::{Element, PathQuery, Query, SizedQuery, TransactionArg}; impl Drive { - /// We remove votes for an identity when that identity is somehow disabled. Currently there is /// no way to "disable" identities except for masternodes being removed from the list pub(super) fn remove_votes_for_identity_v0( @@ -26,11 +25,29 @@ impl Drive { ) -> Result<(), Error> { // We first query for all votes that the identity has - let vote_path = vote_contested_resource_identity_votes_tree_path_for_identity_vec(identity_id.as_bytes()); - - let path_query = PathQuery::new(vote_path, SizedQuery::new(Query::new_single_query_item(QueryItem::RangeFull(RangeFull)), Some(512), None)); - - let votes_to_remove_elements = self.grove_get_path_query(&path_query, transaction, QueryElementResultType, &mut vec![], &platform_version.drive)?.0.to_elements(); + let vote_path = vote_contested_resource_identity_votes_tree_path_for_identity_vec( + identity_id.as_bytes(), + ); + + let path_query = PathQuery::new( + vote_path, + SizedQuery::new( + Query::new_single_query_item(QueryItem::RangeFull(RangeFull)), + Some(512), + None, + ), + ); + + let votes_to_remove_elements = self + .grove_get_path_query( + &path_query, + transaction, + QueryElementResultType, + &mut vec![], + &platform_version.drive, + )? + .0 + .to_elements(); // Then we take each vote and go looking for it (to remove it) @@ -38,19 +55,28 @@ impl Drive { for vote_to_remove in votes_to_remove_elements { let Element::Item(vote, ..) = vote_to_remove else { - return Err(Error::Drive(DriveError::CorruptedDriveState(format!("vote {:?} for identity {} is not an item", vote_to_remove, identity_id)))); + return Err(Error::Drive(DriveError::CorruptedDriveState(format!( + "vote {:?} for identity {} is not an item", + vote_to_remove, identity_id + )))); }; let vote = ContestedDocumentResourceVoteType::deserialize_from_bytes(vote.as_slice())?; // we then need to add to the batch the deletion - self.batch_delete(vote.tree_path(), vote.tree_key(), BatchDeleteApplyType::StatefulBatchDelete { is_known_to_be_subtree_with_sum: Some((false, false)) }, transaction, &mut deletion_batch, &platform_version.drive)?; + self.batch_delete( + vote.tree_path(), + vote.tree_key(), + BatchDeleteApplyType::StatefulBatchDelete { + is_known_to_be_subtree_with_sum: Some((false, false)), + }, + transaction, + &mut deletion_batch, + &platform_version.drive, + )?; } - - self. - - Ok(()) + self.Ok(()) } -} \ No newline at end of file +} diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs index fc88d03aac..412e459227 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs @@ -7,10 +7,10 @@ use crate::error::Error; use dpp::fee::fee_result::FeeResult; -use dpp::version::PlatformVersion; -use grovedb::TransactionArg; use dpp::block::block_info::BlockInfo; +use dpp::version::PlatformVersion; use dpp::voting::{ContestedDocumentResourceVoteType, Vote}; +use grovedb::TransactionArg; impl Drive { pub fn register_contested_resource_identity_vote( @@ -21,7 +21,13 @@ impl Drive { transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { - match platform_version.drive.methods.vote.contested_resource_insert.register_identity_vote { + match platform_version + .drive + .methods + .vote + .contested_resource_insert + .register_identity_vote + { 0 => self.register_contested_resource_identity_vote_v0( vote, block_info, diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index 4826c7d8ba..b3e3abacd3 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -1,12 +1,12 @@ -use grovedb::TransactionArg; -use dpp::block::block_info::BlockInfo; -use dpp::fee::fee_result::FeeResult; -use dpp::voting::{ContestedDocumentResourceVoteType, Vote}; -use platform_version::version::PlatformVersion; use crate::drive::Drive; use crate::error::document::DocumentError; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; +use dpp::block::block_info::BlockInfo; +use dpp::fee::fee_result::FeeResult; +use dpp::voting::{ContestedDocumentResourceVoteType, Vote}; +use grovedb::TransactionArg; +use platform_version::version::PlatformVersion; impl Drive { pub fn register_contested_resource_identity_vote_v0( diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/mod.rs index 32b8645aa7..736a3504e1 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/mod.rs @@ -7,12 +7,11 @@ use crate::error::Error; use dpp::fee::fee_result::FeeResult; +use dpp::prelude::Identifier; use dpp::version::PlatformVersion; use grovedb::TransactionArg; -use dpp::prelude::Identifier; impl Drive { - /// We register the identity vote to be able to query the current votes of an identity, or to /// be able to remove votes from a "disabled" identity (ie a masternode that was removed from /// the list). @@ -22,7 +21,13 @@ impl Drive { transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { - match platform_version.drive.methods.vote.contested_resource_insert.register_identity_vote_for_identity_queries { + match platform_version + .drive + .methods + .vote + .contested_resource_insert + .register_identity_vote_for_identity_queries + { 0 => self.register_identity_vote_for_identity_queries_v0( identity_id, transaction, @@ -35,4 +40,4 @@ impl Drive { })), } } -} \ No newline at end of file +} diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/v0/mod.rs index e69de29bb2..8b13789179 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/v0/mod.rs @@ -0,0 +1 @@ + diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/mod.rs index 2af3c3018e..481d6ec557 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/mod.rs @@ -7,12 +7,11 @@ use crate::error::Error; use dpp::fee::fee_result::FeeResult; +use dpp::prelude::Identifier; use dpp::version::PlatformVersion; use grovedb::TransactionArg; -use dpp::prelude::Identifier; impl Drive { - /// We add vote poll references by end date in order to be able to check on every new block if /// any vote poll should be closed. pub fn add_vote_poll_end_date_query( @@ -21,12 +20,14 @@ impl Drive { transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { - match platform_version.drive.methods.vote.contested_resource_insert.register_identity_vote_for_identity_queries { - 0 => self.add_vote_poll_end_date_query_v0( - identity_id, - transaction, - platform_version, - ), + match platform_version + .drive + .methods + .vote + .contested_resource_insert + .register_identity_vote_for_identity_queries + { + 0 => self.add_vote_poll_end_date_query_v0(identity_id, transaction, platform_version), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "register_identity_vote_for_identity_queries".to_string(), known_versions: vec![0], @@ -34,4 +35,4 @@ impl Drive { })), } } -} \ No newline at end of file +} diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs index e69de29bb2..8b13789179 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs @@ -0,0 +1 @@ + diff --git a/packages/rs-drive/src/drive/votes/insert/mod.rs b/packages/rs-drive/src/drive/votes/insert/mod.rs index 128f3014fe..32924701ca 100644 --- a/packages/rs-drive/src/drive/votes/insert/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/mod.rs @@ -1,3 +1,3 @@ mod add_new_masternode_vote_type; -mod register_identity_vote; mod contested_resource; +mod register_identity_vote; diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs index 3725d55ab4..2738b5979a 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs @@ -8,8 +8,8 @@ use crate::error::Error; use dpp::fee::fee_result::FeeResult; use dpp::version::PlatformVersion; -use grovedb::TransactionArg; use dpp::voting::Vote; +use grovedb::TransactionArg; impl Drive { pub fn register_identity_vote( @@ -19,13 +19,14 @@ impl Drive { transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { - match platform_version.drive.methods.vote.contested_resource_insert.register_identity_vote { - 0 => self.register_identity_vote_v0( - vote, - apply, - transaction, - platform_version, - ), + match platform_version + .drive + .methods + .vote + .contested_resource_insert + .register_identity_vote + { + 0 => self.register_identity_vote_v0(vote, apply, transaction, platform_version), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "register_identity_vote".to_string(), known_versions: vec![0], diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs index d169bb589a..b6aa487388 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs @@ -1,10 +1,10 @@ -use grovedb::TransactionArg; -use dpp::fee::fee_result::FeeResult; -use dpp::voting::Vote; -use platform_version::version::PlatformVersion; use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; +use dpp::fee::fee_result::FeeResult; +use dpp::voting::Vote; +use grovedb::TransactionArg; +use platform_version::version::PlatformVersion; impl Drive { pub fn register_identity_vote( @@ -15,9 +15,13 @@ impl Drive { platform_version: &PlatformVersion, ) -> Result { match vote { - Vote::ContestedDocumentResourceVote(contested_document_resource_vote_type) => { - self.register_contested_resource_identity_vote(contested_document_resource_vote_type, apply, transaction, platform_version) - } + Vote::ContestedDocumentResourceVote(contested_document_resource_vote_type) => self + .register_contested_resource_identity_vote( + contested_document_resource_vote_type, + apply, + transaction, + platform_version, + ), } } } diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index eea169633e..78e820af12 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -1,17 +1,16 @@ +use crate::drive::document::{contract_document_type_path, contract_document_type_path_vec}; +use crate::drive::RootTree; use dpp::consensus::basic::data_contract::DuplicateIndexError; use dpp::data_contract::accessors::v0::DataContractV0Getters; -use dpp::data_contract::DataContract; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; -use dpp::ProtocolError; +use dpp::data_contract::DataContract; use dpp::util::vec; use dpp::voting::ContestedDocumentResourceVoteType; -use crate::drive::document::{contract_document_type_path, contract_document_type_path_vec}; -use crate::drive::RootTree; +use dpp::ProtocolError; +mod cleanup; mod insert; mod setup; -mod cleanup; - /// The vote tree structure looks likes this /// @@ -32,11 +31,8 @@ pub const END_DATE_QUERIES_TREE_KEY: char = 'e'; pub const IDENTITY_VOTES_TREE_KEY: char = 'i'; - pub(in crate::drive::votes) fn vote_root_path<'a>() -> [&'a [u8]; 1] { - [ - Into::<&[u8; 1]>::into(RootTree::Votes), - ] + [Into::<&[u8; 1]>::into(RootTree::Votes)] } pub(in crate::drive::votes) fn vote_decisions_tree_path<'a>() -> [&'a [u8]; 2] { @@ -53,7 +49,8 @@ pub(in crate::drive::votes) fn vote_contested_resource_tree_path<'a>() -> [&'a [ ] } -pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_tree_path<'a>() -> [&'a [u8]; 3] { +pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_tree_path<'a>( +) -> [&'a [u8]; 3] { [ Into::<&[u8; 1]>::into(RootTree::Votes), Into::<&[u8; 1]>::into(CONTESTED_RESOURCE_TREE_KEY), @@ -61,7 +58,8 @@ pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_tree_pat ] } -pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path<'a>() -> [&'a [u8]; 3] { +pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path<'a>( +) -> [&'a [u8]; 3] { [ Into::<&[u8; 1]>::into(RootTree::Votes), Into::<&[u8; 1]>::into(CONTESTED_RESOURCE_TREE_KEY), @@ -69,7 +67,9 @@ pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path< ] } -pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_for_identity<'a>(identity_id: &[u8; 32]) -> [&'a [u8]; 4] { +pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_for_identity<'a>( + identity_id: &[u8; 32], +) -> [&'a [u8]; 4] { [ Into::<&[u8; 1]>::into(RootTree::Votes), Into::<&[u8; 1]>::into(CONTESTED_RESOURCE_TREE_KEY), @@ -78,7 +78,9 @@ pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_ ] } -pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_for_identity_vec(identity_id: &[u8; 32]) -> Vec> { +pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_for_identity_vec( + identity_id: &[u8; 32], +) -> Vec> { vec![ vec![RootTree::Votes as u8], vec![CONTESTED_RESOURCE_TREE_KEY as u8], @@ -91,20 +93,37 @@ pub trait TreePath { fn tree_path(&self, contract: &DataContract) -> Result, ProtocolError>; } - impl TreePath for ContestedDocumentResourceVoteType { fn tree_path(&self, contract: &DataContract) -> Result, ProtocolError> { if contract.id() != self.vote_poll.contract_id { - return Err(ProtocolError::VoteError(format!("contract id of vote {} does not match supplied contract {}", self.vote_poll.contract_id, contract.id()))); + return Err(ProtocolError::VoteError(format!( + "contract id of vote {} does not match supplied contract {}", + self.vote_poll.contract_id, + contract.id() + ))); } let document_type = contract.document_type_for_name(&self.vote_poll.document_type_name)?; - let index = document_type.indices().iter().find(|index| &index.name == &self.vote_poll.index_name).ok_or(ProtocolError::VoteError(format!("vote index name {} not found", &self.vote_poll.index_name)))?; - let mut path = contract_document_type_path(&self.vote_poll.contract_id.as_bytes(), &self.vote_poll.document_type_name).to_vec(); + let index = document_type + .indices() + .iter() + .find(|index| &index.name == &self.vote_poll.index_name) + .ok_or(ProtocolError::VoteError(format!( + "vote index name {} not found", + &self.vote_poll.index_name + )))?; + let mut path = contract_document_type_path( + &self.vote_poll.contract_id.as_bytes(), + &self.vote_poll.document_type_name, + ) + .to_vec(); // at this point the path only contains the parts before the index let Some(contested_index) = &index.contested_index else { - return Err(ProtocolError::VoteError("we expect the index in a contested document resource vote type to be contested".to_string())); + return Err(ProtocolError::VoteError( + "we expect the index in a contested document resource vote type to be contested" + .to_string(), + )); }; let mut properties_iter = index.properties.iter(); diff --git a/packages/rs-drive/src/drive/votes/setup/mod.rs b/packages/rs-drive/src/drive/votes/setup/mod.rs index e2189c9af4..00eb6e7ec3 100644 --- a/packages/rs-drive/src/drive/votes/setup/mod.rs +++ b/packages/rs-drive/src/drive/votes/setup/mod.rs @@ -1 +1 @@ -mod setup_initial_vote_tree_main_structure; \ No newline at end of file +mod setup_initial_vote_tree_main_structure; diff --git a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs index d955d3cdfb..dfefbe6173 100644 --- a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs +++ b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs @@ -14,7 +14,12 @@ impl Drive { transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { - match platform_version.drive.methods.vote.setup_initial_vote_tree_main_structure { + match platform_version + .drive + .methods + .vote + .setup_initial_vote_tree_main_structure + { 0 => self.setup_initial_vote_tree_main_structure_v0(transaction, platform_version), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "setup_initial_vote_tree_main_structure".to_string(), diff --git a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs index dabb30318a..feaa586818 100644 --- a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs @@ -1,10 +1,14 @@ -use grovedb::operations::insert::InsertOptions; +use crate::drive::votes::{ + vote_contested_resource_end_date_queries_tree_path, + vote_contested_resource_identity_votes_tree_path, vote_root_path, CONTESTED_RESOURCE_TREE_KEY, + VOTE_DECISIONS_TREE_KEY, +}; use crate::drive::{Drive, RootTree}; use crate::error::Error; +use grovedb::operations::insert::InsertOptions; use grovedb::TransactionArg; use grovedb_path::SubtreePath; use platform_version::version::PlatformVersion; -use crate::drive::votes::{CONTESTED_RESOURCE_TREE_KEY, vote_contested_resource_end_date_queries_tree_path, vote_contested_resource_identity_votes_tree_path, VOTE_DECISIONS_TREE_KEY, vote_root_path}; impl Drive { pub fn setup_initial_vote_tree_main_structure_v0( @@ -42,7 +46,6 @@ impl Drive { drive_version, )?; - self.grove_insert_empty_tree( SubtreePath::from(vote_contested_resource_end_date_queries_tree_path()), &[CONTESTED_RESOURCE_TREE_KEY.into()], diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 8c983aed89..aa3572d25c 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -26,7 +26,40 @@ use crate::version::drive_abci_versions::{ DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, DriveAbciWithdrawalsMethodVersions, }; -use crate::version::drive_versions::{DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, DriveCreditPoolPendingEpochRefundsMethodVersions, DriveCreditPoolStorageFeeDistributionPoolMethodVersions, DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformSystemMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, DriveSystemProtocolVersionMethodVersions, DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVerifySystemMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions}; +use crate::version::drive_versions::{ + DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, + DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, + DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, + DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, + DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, + DriveCreditPoolPendingEpochRefundsMethodVersions, + DriveCreditPoolStorageFeeDistributionPoolMethodVersions, + DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, + DriveDocumentEstimationCostsMethodVersions, DriveDocumentIndexUniquenessMethodVersions, + DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, + DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, + DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveGroveApplyMethodVersions, + DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, + DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, + DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, + DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, + DriveIdentityFetchPartialIdentityMethodVersions, + DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, + DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, + DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, + DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, + DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, + DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, + DrivePlatformSystemMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, + DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, + DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, + DriveSystemProtocolVersionMethodVersions, DriveVerifyContractMethodVersions, + DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, + DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, + DriveVerifySystemMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, + DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, + DriveVoteMethodVersions, DriveVoteSetupMethodVersions, +}; use crate::version::mocks::TEST_BYTES; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; use crate::version::{AbciStructureVersion, PlatformArchitectureVersion}; @@ -160,7 +193,9 @@ pub(crate) const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { }, }, vote: DriveVoteMethodVersions { - insert: DriveVoteInsertMethodVersions { register_identity_vote: 0 }, + insert: DriveVoteInsertMethodVersions { + register_identity_vote: 0, + }, contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { register_contested_resource_identity_vote: 0, register_identity_vote_for_identity_queries: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 6d21731b8e..4ed36d955a 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -26,7 +26,40 @@ use crate::version::drive_abci_versions::{ DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, DriveAbciWithdrawalsMethodVersions, }; -use crate::version::drive_versions::{DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, DriveCreditPoolPendingEpochRefundsMethodVersions, DriveCreditPoolStorageFeeDistributionPoolMethodVersions, DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformSystemMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, DriveSystemProtocolVersionMethodVersions, DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVerifySystemMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions}; +use crate::version::drive_versions::{ + DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, + DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, + DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, + DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, + DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, + DriveCreditPoolPendingEpochRefundsMethodVersions, + DriveCreditPoolStorageFeeDistributionPoolMethodVersions, + DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, + DriveDocumentEstimationCostsMethodVersions, DriveDocumentIndexUniquenessMethodVersions, + DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, + DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, + DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveGroveApplyMethodVersions, + DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, + DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, + DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, + DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, + DriveIdentityFetchPartialIdentityMethodVersions, + DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, + DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, + DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, + DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, + DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, + DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, + DrivePlatformSystemMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, + DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, + DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, + DriveSystemProtocolVersionMethodVersions, DriveVerifyContractMethodVersions, + DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, + DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, + DriveVerifySystemMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, + DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, + DriveVoteMethodVersions, DriveVoteSetupMethodVersions, +}; use crate::version::mocks::TEST_BYTES; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; use crate::version::{AbciStructureVersion, PlatformArchitectureVersion}; @@ -168,7 +201,9 @@ pub(crate) const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { }, }, vote: DriveVoteMethodVersions { - insert: DriveVoteInsertMethodVersions { register_identity_vote: 0 }, + insert: DriveVoteInsertMethodVersions { + register_identity_vote: 0, + }, contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { register_contested_resource_identity_vote: 0, register_identity_vote_for_identity_queries: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 24725e4fb9..7fc5139ba7 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -26,7 +26,40 @@ use crate::version::drive_abci_versions::{ DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, DriveAbciWithdrawalsMethodVersions, }; -use crate::version::drive_versions::{DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, DriveCreditPoolPendingEpochRefundsMethodVersions, DriveCreditPoolStorageFeeDistributionPoolMethodVersions, DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformSystemMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, DriveSystemProtocolVersionMethodVersions, DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVerifySystemMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions}; +use crate::version::drive_versions::{ + DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, + DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, + DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, + DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, + DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, + DriveCreditPoolPendingEpochRefundsMethodVersions, + DriveCreditPoolStorageFeeDistributionPoolMethodVersions, + DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, + DriveDocumentEstimationCostsMethodVersions, DriveDocumentIndexUniquenessMethodVersions, + DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, + DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, + DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveGroveApplyMethodVersions, + DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, + DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, + DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, + DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, + DriveIdentityFetchPartialIdentityMethodVersions, + DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, + DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, + DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, + DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, + DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, + DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, + DrivePlatformSystemMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, + DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, + DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, + DriveSystemProtocolVersionMethodVersions, DriveVerifyContractMethodVersions, + DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, + DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, + DriveVerifySystemMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, + DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, + DriveVoteMethodVersions, DriveVoteSetupMethodVersions, +}; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; use crate::version::{AbciStructureVersion, PlatformArchitectureVersion}; @@ -157,7 +190,9 @@ pub(super) const PLATFORM_V1: PlatformVersion = PlatformVersion { }, }, vote: DriveVoteMethodVersions { - insert: DriveVoteInsertMethodVersions { register_identity_vote: 0 }, + insert: DriveVoteInsertMethodVersions { + register_identity_vote: 0, + }, contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { register_contested_resource_identity_vote: 0, register_identity_vote_for_identity_queries: 0, diff --git a/packages/wasm-dpp/src/identity/state_transition/transition_types.rs b/packages/wasm-dpp/src/identity/state_transition/transition_types.rs index 7253a89a30..1a4942726e 100644 --- a/packages/wasm-dpp/src/identity/state_transition/transition_types.rs +++ b/packages/wasm-dpp/src/identity/state_transition/transition_types.rs @@ -30,9 +30,7 @@ impl From for StateTransitionTypeWasm { StateTransitionType::IdentityCreditTransfer => { StateTransitionTypeWasm::IdentityCreditTransfer } - StateTransitionType::MasternodeVote => { - StateTransitionTypeWasm::MasternodeVote - } + StateTransitionType::MasternodeVote => StateTransitionTypeWasm::MasternodeVote, } } } From 3cee601d34dd09574294ef4d83a0d07d163f38ba Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 10 Jan 2024 15:03:00 +0700 Subject: [PATCH 020/135] got insert of trees working --- .../masternode_vote_transition/mod.rs | 2 +- .../masternode_vote_transition/v0/types.rs | 2 +- .../insert/add_contract_to_storage/v0/mod.rs | 1 + .../contract/update/update_contract/v0/mod.rs | 1 + .../v0/mod.rs | 3 +- .../add_document_to_primary_storage/v0/mod.rs | 1 + .../v0/mod.rs | 2 + .../v0/mod.rs | 1 + .../v0/mod.rs | 72 +++++++++++++----- .../v0/mod.rs | 4 + .../mod.rs | 2 + .../v0/mod.rs | 73 ++++++++++++++----- .../insert/add_new_identity/v0/mod.rs | 1 + .../insert/register_identity_vote/mod.rs | 4 +- .../insert/register_identity_vote/v0/mod.rs | 5 +- packages/rs-drive/src/fee/op.rs | 16 ++++ 16 files changed, 145 insertions(+), 45 deletions(-) diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs index 67fd1014ca..bc9b182feb 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs @@ -11,7 +11,7 @@ mod value_conversion; mod version; use crate::state_transition::masternode_vote_transition::fields::property_names::{ - PRO_TX_HASH, RECIPIENT_ID, + PRO_TX_HASH, }; use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0Signable; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/types.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/types.rs index b0ec8019b9..59fcb2f0ed 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/types.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/types.rs @@ -9,7 +9,7 @@ impl StateTransitionFieldTypes for MasternodeVoteTransitionV0 { } fn identifiers_property_paths() -> Vec<&'static str> { - vec![IDENTITY_ID, RECIPIENT_ID] + vec![IDENTITY_ID] } fn binary_property_paths() -> Vec<&'static str> { diff --git a/packages/rs-drive/src/drive/contract/insert/add_contract_to_storage/v0/mod.rs b/packages/rs-drive/src/drive/contract/insert/add_contract_to_storage/v0/mod.rs index b52aadd665..22d9ee4ac6 100644 --- a/packages/rs-drive/src/drive/contract/insert/add_contract_to_storage/v0/mod.rs +++ b/packages/rs-drive/src/drive/contract/insert/add_contract_to_storage/v0/mod.rs @@ -78,6 +78,7 @@ impl Drive { self.batch_insert_empty_tree_if_not_exists( key_info, + false, storage_flags.as_ref().map(|flags| flags.as_ref()), apply_type, transaction, diff --git a/packages/rs-drive/src/drive/contract/update/update_contract/v0/mod.rs b/packages/rs-drive/src/drive/contract/update/update_contract/v0/mod.rs index e0efe9e743..a479b201d5 100644 --- a/packages/rs-drive/src/drive/contract/update/update_contract/v0/mod.rs +++ b/packages/rs-drive/src/drive/contract/update/update_contract/v0/mod.rs @@ -314,6 +314,7 @@ impl Drive { if !index_cache.contains(index_bytes) { self.batch_insert_empty_tree_if_not_exists( PathFixedSizeKeyRef((type_path, index.name.as_bytes())), + false, storage_flags.as_ref().map(|flags| flags.as_ref()), apply_type, transaction, diff --git a/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/v0/mod.rs index bad3f5914a..e0491520f5 100644 --- a/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -8,6 +8,7 @@ use grovedb::{EstimatedLayerInformation, TransactionArg}; use dpp::data_contract::document_type::IndexType; use grovedb::EstimatedSumTrees::NoSumTrees; use std::collections::HashMap; +use dpp::data_contract::document_type::IndexType::{ContestedResourceIndex, NonUniqueIndex}; use crate::drive::defaults::{CONTRACT_DOCUMENTS_PATH_HEIGHT, DEFAULT_HASH_SIZE_U8}; use crate::drive::document::document_reference_size; @@ -45,7 +46,7 @@ impl Drive { // unique indexes will be stored under key "0" // non unique indices should have a tree at key "0" that has all elements based off of primary key - if !unique || any_fields_null { + if index_type == NonUniqueIndex || index_type == ContestedResourceIndex || any_fields_null { key_info_path.push(KnownKey(vec![0])); if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info diff --git a/packages/rs-drive/src/drive/document/insert/add_document_to_primary_storage/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_document_to_primary_storage/v0/mod.rs index 0cfc8f2c30..6ef00d2eac 100644 --- a/packages/rs-drive/src/drive/document/insert/add_document_to_primary_storage/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_document_to_primary_storage/v0/mod.rs @@ -135,6 +135,7 @@ impl Drive { // we first insert an empty tree if the document is new self.batch_insert_empty_tree_if_not_exists( path_key_info, + false, storage_flags, apply_type, transaction, diff --git a/packages/rs-drive/src/drive/document/insert/add_indices_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_indices_for_index_level_for_contract_operations/v0/mod.rs index ffc85440b9..83416eabdb 100644 --- a/packages/rs-drive/src/drive/document/insert/add_indices_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_indices_for_index_level_for_contract_operations/v0/mod.rs @@ -106,6 +106,7 @@ impl Drive { // here we are inserting an empty tree that will have a subtree of all other index properties self.batch_insert_empty_tree_if_not_exists( path_key_info.clone(), + false, *storage_flags, apply_type, transaction, @@ -153,6 +154,7 @@ impl Drive { // here we are inserting an empty tree that will have a subtree of all other index properties self.batch_insert_empty_tree_if_not_exists( path_key_info.clone(), + false, *storage_flags, apply_type, transaction, diff --git a/packages/rs-drive/src/drive/document/insert/add_indices_for_top_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_indices_for_top_index_level_for_contract_operations/v0/mod.rs index 2c7c14d1b5..854c50f279 100644 --- a/packages/rs-drive/src/drive/document/insert/add_indices_for_top_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_indices_for_top_index_level_for_contract_operations/v0/mod.rs @@ -119,6 +119,7 @@ impl Drive { // here we are inserting an empty tree that will have a subtree of all other index properties self.batch_insert_empty_tree_if_not_exists( path_key_info.clone(), + false, storage_flags, apply_type, transaction, diff --git a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs index 41719759d6..2cf0e8ef91 100644 --- a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -9,7 +9,7 @@ use crate::drive::object_size_info::DocumentInfo::{ }; use crate::drive::object_size_info::DriveKeyInfo::{Key, KeyRef}; use crate::drive::object_size_info::KeyElementInfo::{KeyElement, KeyUnknownElementSize}; -use crate::drive::object_size_info::{DocumentAndContractInfo, PathInfo, PathKeyElementInfo}; +use crate::drive::object_size_info::{DocumentAndContractInfo, PathInfo, PathKeyElementInfo, PathKeyInfo}; use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; @@ -65,9 +65,13 @@ impl Drive { } }; - // here we are inserting an empty tree that will have a subtree of all other index properties + // Here we are inserting an empty tree that will have a subtree of all other index properties + // It is basically the 0 + // Underneath we will have all elements if non unique index, or all identity contenders if + // a contested resource index self.batch_insert_empty_tree_if_not_exists( path_key_info, + false, *storage_flags, apply_type, transaction, @@ -154,6 +158,7 @@ impl Drive { // 0 (ref) 1 (sum tree) 0 (ref) 1 (sum tree) // + // Here we are getting the document id and the reference let (document_id, ref_key_element_info) = match &document_and_contract_info.owned_document_info.document_info { DocumentRefAndSerialization((document, _, storage_flags)) @@ -192,18 +197,25 @@ impl Drive { } }; - let document_key_path_info = KeyRef(document_id.as_slice()); + // Let's start by inserting the document id tree - let mut document_path_info = index_path_info.clone(); + // here we are the tree that will contain the ref + // We are inserting this at item name contested / Goblet of Fire / 0 with the key of + // document_key_path_info + self.batch_insert_empty_tree( + index_path_info, + KeyRef(document_id.as_slice()), + *storage_flags, + batch_operations, + drive_version, + )?; - document_path_info.push(document_key_path_info)?; + let mut document_path_info = index_path_info.clone(); - let ref_key_path_info = KeyRef(&[0]); + document_path_info.push(KeyRef(document_id.as_slice()))?; let votes_key_path_info = KeyRef(&[1]); - let ref_path_key_info = ref_key_path_info.add_path_info(document_path_info.clone()); - let votes_path_key_info = votes_key_path_info.add_path_info(document_path_info.clone()); @@ -239,28 +251,48 @@ impl Drive { ); } - let path_key_element_info = PathKeyElementInfo::from_path_info_and_key_element( - index_path_info, - key_element_info, + let reference_path_key_element_info = PathKeyElementInfo::from_path_info_and_key_element( + document_path_info.clone(), + ref_key_element_info, )?; - // here we are the tree that will contain the ref and the voting tree - self.batch_insert_empty_tree( - document_path_info, - *storage_flags, - previous_batch_operations, + // here we are inserting the ref + self.batch_insert( + reference_path_key_element_info, batch_operations, drive_version, )?; - // here we are the tree that will contain the ref and the voting tree - self.batch_insert_empty_tree( - document_path_info, + let apply_type = if estimated_costs_only_with_layer_info.is_none() { + BatchInsertTreeApplyType::StatefulBatchInsertTree + } else { + BatchInsertTreeApplyType::StatelessBatchInsertTree { + in_tree_using_sums: false, + is_sum_tree: true, + flags_len: storage_flags + .map(|s| s.serialized_size()) + .unwrap_or_default(), + } + }; + + + // here we are the tree that will contain the voting tree + let inserted = self.batch_insert_empty_tree_if_not_exists( + votes_path_key_info, + true, *storage_flags, - previous_batch_operations, + apply_type, + transaction, + &mut None, batch_operations, drive_version, )?; + + if !inserted { + return Err(Error::Drive(DriveError::CorruptedContractIndexes( + "contested vote tree already exists", + ))); + } } } else { let key_element_info = diff --git a/packages/rs-drive/src/drive/document/update/internal/update_document_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/update/internal/update_document_for_contract_operations/v0/mod.rs index 082b51ed4e..1f4665504c 100644 --- a/packages/rs-drive/src/drive/document/update/internal/update_document_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/update/internal/update_document_for_contract_operations/v0/mod.rs @@ -223,6 +223,7 @@ impl Drive { index_path.clone(), document_top_field.as_slice(), )), + false, storage_flags, BatchInsertTreeApplyType::StatefulBatchInsertTree, transaction, @@ -295,6 +296,7 @@ impl Drive { index_path.clone(), index_property.name.as_bytes(), )), + false, storage_flags, BatchInsertTreeApplyType::StatefulBatchInsertTree, transaction, @@ -326,6 +328,7 @@ impl Drive { index_path.clone(), document_index_field.as_slice(), )), + false, storage_flags, BatchInsertTreeApplyType::StatefulBatchInsertTree, transaction, @@ -402,6 +405,7 @@ impl Drive { // here we are inserting an empty tree that will have a subtree of all other index properties self.batch_insert_empty_tree_if_not_exists( PathKeyInfo::PathKeyRef::<0>((index_path.clone(), &[0])), + false, storage_flags, BatchInsertTreeApplyType::StatefulBatchInsertTree, transaction, diff --git a/packages/rs-drive/src/drive/grove_operations/batch_insert_empty_tree_if_not_exists/mod.rs b/packages/rs-drive/src/drive/grove_operations/batch_insert_empty_tree_if_not_exists/mod.rs index 7a9bc12766..e4de42378b 100644 --- a/packages/rs-drive/src/drive/grove_operations/batch_insert_empty_tree_if_not_exists/mod.rs +++ b/packages/rs-drive/src/drive/grove_operations/batch_insert_empty_tree_if_not_exists/mod.rs @@ -18,6 +18,7 @@ impl Drive { pub fn batch_insert_empty_tree_if_not_exists( &self, path_key_info: PathKeyInfo, + use_sum_tree: bool, storage_flags: Option<&StorageFlags>, apply_type: BatchInsertTreeApplyType, transaction: TransactionArg, @@ -32,6 +33,7 @@ impl Drive { { 0 => self.batch_insert_empty_tree_if_not_exists_v0( path_key_info, + use_sum_tree, storage_flags, apply_type, transaction, diff --git a/packages/rs-drive/src/drive/grove_operations/batch_insert_empty_tree_if_not_exists/v0/mod.rs b/packages/rs-drive/src/drive/grove_operations/batch_insert_empty_tree_if_not_exists/v0/mod.rs index 1c1709184f..63edb4d707 100644 --- a/packages/rs-drive/src/drive/grove_operations/batch_insert_empty_tree_if_not_exists/v0/mod.rs +++ b/packages/rs-drive/src/drive/grove_operations/batch_insert_empty_tree_if_not_exists/v0/mod.rs @@ -19,6 +19,7 @@ impl Drive { pub(super) fn batch_insert_empty_tree_if_not_exists_v0( &self, path_key_info: PathKeyInfo, + use_sum_tree: bool, storage_flags: Option<&StorageFlags>, apply_type: BatchInsertTreeApplyType, transaction: TransactionArg, @@ -29,11 +30,19 @@ impl Drive { //todo: clean up the duplication match path_key_info { PathKeyRef((path, key)) => { - let drive_operation = LowLevelDriveOperation::for_known_path_key_empty_tree( - path.clone(), - key.to_vec(), - storage_flags, - ); + let drive_operation = if use_sum_tree { + LowLevelDriveOperation::for_known_path_key_empty_sum_tree( + path.clone(), + key.to_vec(), + storage_flags, + ) + } else { + LowLevelDriveOperation::for_known_path_key_empty_tree( + path.clone(), + key.to_vec(), + storage_flags, + ) + }; // we only add the operation if it doesn't already exist in the current batch if let Some(existing_operations) = check_existing_operations { let mut i = 0; @@ -96,11 +105,19 @@ impl Drive { DriveError::NotSupportedPrivate("document sizes in batch operations not supported"), )), PathKey((path, key)) => { - let drive_operation = LowLevelDriveOperation::for_known_path_key_empty_tree( - path.clone(), - key.to_vec(), - storage_flags, - ); + let drive_operation = if use_sum_tree { + LowLevelDriveOperation::for_known_path_key_empty_sum_tree( + path.clone(), + key.to_vec(), + storage_flags, + ) + } else { + LowLevelDriveOperation::for_known_path_key_empty_tree( + path.clone(), + key.to_vec(), + storage_flags, + ) + }; // we only add the operation if it doesn't already exist in the current batch if let Some(existing_operations) = check_existing_operations { let mut i = 0; @@ -161,11 +178,19 @@ impl Drive { } PathFixedSizeKey((path, key)) => { let path_items: Vec> = path.into_iter().map(Vec::from).collect(); - let drive_operation = LowLevelDriveOperation::for_known_path_key_empty_tree( - path_items, - key.to_vec(), - storage_flags, - ); + let drive_operation = if use_sum_tree { + LowLevelDriveOperation::for_known_path_key_empty_sum_tree( + path_items, + key.to_vec(), + storage_flags, + ) + } else { + LowLevelDriveOperation::for_known_path_key_empty_tree( + path_items, + key.to_vec(), + storage_flags, + ) + }; // we only add the operation if it doesn't already exist in the current batch if let Some(existing_operations) = check_existing_operations { let mut i = 0; @@ -226,11 +251,19 @@ impl Drive { } PathFixedSizeKeyRef((path, key)) => { let path_items: Vec> = path.into_iter().map(Vec::from).collect(); - let drive_operation = LowLevelDriveOperation::for_known_path_key_empty_tree( - path_items, - key.to_vec(), - storage_flags, - ); + let drive_operation = if use_sum_tree { + LowLevelDriveOperation::for_known_path_key_empty_sum_tree( + path_items, + key.to_vec(), + storage_flags, + ) + } else { + LowLevelDriveOperation::for_known_path_key_empty_tree( + path_items, + key.to_vec(), + storage_flags, + ) + }; // we only add the operation if it doesn't already exist in the current batch if let Some(existing_operations) = check_existing_operations { let mut i = 0; diff --git a/packages/rs-drive/src/drive/identity/insert/add_new_identity/v0/mod.rs b/packages/rs-drive/src/drive/identity/insert/add_new_identity/v0/mod.rs index e2455dae82..e8039720cd 100644 --- a/packages/rs-drive/src/drive/identity/insert/add_new_identity/v0/mod.rs +++ b/packages/rs-drive/src/drive/identity/insert/add_new_identity/v0/mod.rs @@ -130,6 +130,7 @@ impl Drive { // We insert the identity tree let inserted = self.batch_insert_empty_tree_if_not_exists( PathFixedSizeKey((identity_tree_path, id.to_vec())), + false, Some(&storage_flags), apply_type, transaction, diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs index 2738b5979a..581585c611 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs @@ -10,11 +10,13 @@ use dpp::fee::fee_result::FeeResult; use dpp::version::PlatformVersion; use dpp::voting::Vote; use grovedb::TransactionArg; +use dpp::block::block_info::BlockInfo; impl Drive { pub fn register_identity_vote( &self, vote: Vote, + block_info: &BlockInfo, apply: bool, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -26,7 +28,7 @@ impl Drive { .contested_resource_insert .register_identity_vote { - 0 => self.register_identity_vote_v0(vote, apply, transaction, platform_version), + 0 => self.register_identity_vote_v0(vote, block_info, apply, transaction, platform_version), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "register_identity_vote".to_string(), known_versions: vec![0], diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs index b6aa487388..6e05e758f8 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs @@ -4,12 +4,14 @@ use crate::fee::op::LowLevelDriveOperation; use dpp::fee::fee_result::FeeResult; use dpp::voting::Vote; use grovedb::TransactionArg; +use dpp::block::block_info::BlockInfo; use platform_version::version::PlatformVersion; impl Drive { - pub fn register_identity_vote( + pub fn register_identity_vote_v0( &self, vote: Vote, + block_info: &BlockInfo, apply: bool, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -18,6 +20,7 @@ impl Drive { Vote::ContestedDocumentResourceVote(contested_document_resource_vote_type) => self .register_contested_resource_identity_vote( contested_document_resource_vote_type, + block_info, apply, transaction, platform_version, diff --git a/packages/rs-drive/src/fee/op.rs b/packages/rs-drive/src/fee/op.rs index 527c55e9f9..1a13f8ea69 100644 --- a/packages/rs-drive/src/fee/op.rs +++ b/packages/rs-drive/src/fee/op.rs @@ -319,6 +319,22 @@ impl LowLevelDriveOperation { LowLevelDriveOperation::insert_for_known_path_key_element(path, key, tree) } + /// Sets `GroveOperation` for inserting an empty sum tree at the given path and key + pub fn for_known_path_key_empty_sum_tree( + path: Vec>, + key: Vec, + storage_flags: Option<&StorageFlags>, + ) -> Self { + let tree = match storage_flags { + Some(storage_flags) => { + Element::empty_sum_tree_with_flags(storage_flags.to_some_element_flags()) + } + None => Element::empty_sum_tree(), + }; + + LowLevelDriveOperation::insert_for_known_path_key_element(path, key, tree) + } + /// Sets `GroveOperation` for inserting an empty tree at the given path and key pub fn for_estimated_path_key_empty_tree( path: KeyInfoPath, From 123846369f59a7a42d88a2601f28f4c9ebeddf74 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 10 Jan 2024 16:02:03 +0700 Subject: [PATCH 021/135] more work --- .../drive/batch/drive_op_batch/identity.rs | 18 ++++----- .../mod.rs | 40 ++++++++++++++++++- .../v0/mod.rs | 2 + 3 files changed, 49 insertions(+), 11 deletions(-) diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs index 90704e90e6..3005569a05 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs @@ -7,10 +7,10 @@ use dpp::identity::{Identity, IdentityPublicKey, KeyID, TimestampMillis}; use dpp::prelude::Revision; use dpp::version::PlatformVersion; -use dpp::voting::resource_vote::ResourceVote; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; +use dpp::voting::ContestedDocumentResourceVoteType; /// Operations on Identities #[derive(Clone, Debug)] @@ -78,11 +78,11 @@ pub enum IdentityOperationType { }, /// Updates an identities revision. - MasternodeResourceVote { - /// The pro tx hash of the masternode + MasternodeContestedResourceCastVote { + /// The pro tx hash of the masternode doing the voting pro_tx_hash: [u8; 32], - /// The resource vote - resource_vote: ResourceVote, + /// Contested Vote type + contested_vote_type: ContestedDocumentResourceVoteType, }, } @@ -176,10 +176,10 @@ impl DriveLowLevelOperationConverter for IdentityOperationType { estimated_costs_only_with_layer_info, platform_version, )?]), - IdentityOperationType::MasternodeResourceVote { - identity_id, - resource_vote, - } => {} + IdentityOperationType::MasternodeContestedResourceCastVote { + pro_tx_hash, + contested_vote_type, + } => drive.register_contested_resource_identity_vote(contested_vote_type, block_info, estimated_costs_only_with_layer_info.is_some(), transaction, platform_version) } } } diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs index 412e459227..72d0e1c853 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs @@ -9,12 +9,15 @@ use dpp::fee::fee_result::FeeResult; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; -use dpp::voting::{ContestedDocumentResourceVoteType, Vote}; +use dpp::voting::ContestedDocumentResourceVoteType; use grovedb::TransactionArg; +use dpp::identifier::Identifier; +use crate::fee::op::LowLevelDriveOperation; impl Drive { pub fn register_contested_resource_identity_vote( &self, + voter_pro_tx_hash: Identifier, vote: ContestedDocumentResourceVoteType, block_info: &BlockInfo, apply: bool, @@ -26,9 +29,42 @@ impl Drive { .methods .vote .contested_resource_insert - .register_identity_vote + .register_contested_resource_identity_vote { 0 => self.register_contested_resource_identity_vote_v0( + voter_pro_tx_hash, + vote, + block_info, + apply, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "register_identity_vote".to_string(), + known_versions: vec![0], + received: version, + })), + } + } + + pub fn register_contested_resource_identity_vote_operations( + &self, + voter_pro_tx_hash: Identifier, + vote: ContestedDocumentResourceVoteType, + block_info: &BlockInfo, + apply: bool, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + match platform_version + .drive + .methods + .vote + .contested_resource_insert + .register_contested_resource_identity_vote + { + 0 => self.register_contested_resource_identity_vote_v0( + voter_pro_tx_hash, vote, block_info, apply, diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index b3e3abacd3..844ff21228 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -6,11 +6,13 @@ use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; use dpp::voting::{ContestedDocumentResourceVoteType, Vote}; use grovedb::TransactionArg; +use dpp::prelude::Identifier; use platform_version::version::PlatformVersion; impl Drive { pub fn register_contested_resource_identity_vote_v0( &self, + voter_pro_tx_hash: Identifier, vote: ContestedDocumentResourceVoteType, block_info: &BlockInfo, apply: bool, From 98cc21dabd2e79b7a587fa004d2cf60318c702a7 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 10 Jan 2024 19:29:22 +0700 Subject: [PATCH 022/135] more work --- .../drive/batch/drive_op_batch/identity.rs | 6 ++-- .../mod.rs | 14 +++++---- .../v0/mod.rs | 30 ++++++++++++++++++- 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs index 3005569a05..9d58c191c5 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs @@ -80,7 +80,7 @@ pub enum IdentityOperationType { /// Updates an identities revision. MasternodeContestedResourceCastVote { /// The pro tx hash of the masternode doing the voting - pro_tx_hash: [u8; 32], + voter_pro_tx_hash: [u8; 32], /// Contested Vote type contested_vote_type: ContestedDocumentResourceVoteType, }, @@ -177,9 +177,9 @@ impl DriveLowLevelOperationConverter for IdentityOperationType { platform_version, )?]), IdentityOperationType::MasternodeContestedResourceCastVote { - pro_tx_hash, + voter_pro_tx_hash, contested_vote_type, - } => drive.register_contested_resource_identity_vote(contested_vote_type, block_info, estimated_costs_only_with_layer_info.is_some(), transaction, platform_version) + } => drive.register_contested_resource_identity_vote_operations(voter_pro_tx_hash, contested_vote_type, block_info, estimated_costs_only_with_layer_info, transaction, platform_version) } } } diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs index 72d0e1c853..ac321bf2f5 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs @@ -1,5 +1,7 @@ mod v0; +use std::collections::HashMap; +use grovedb::batch::KeyInfoPath; use crate::drive::Drive; use crate::error::drive::DriveError; @@ -10,7 +12,7 @@ use dpp::fee::fee_result::FeeResult; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; use dpp::voting::ContestedDocumentResourceVoteType; -use grovedb::TransactionArg; +use grovedb::{EstimatedLayerInformation, TransactionArg}; use dpp::identifier::Identifier; use crate::fee::op::LowLevelDriveOperation; @@ -49,10 +51,12 @@ impl Drive { pub fn register_contested_resource_identity_vote_operations( &self, - voter_pro_tx_hash: Identifier, + voter_pro_tx_hash: [u8; 32], vote: ContestedDocumentResourceVoteType, block_info: &BlockInfo, - apply: bool, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { @@ -63,11 +67,11 @@ impl Drive { .contested_resource_insert .register_contested_resource_identity_vote { - 0 => self.register_contested_resource_identity_vote_v0( + 0 => self.register_contested_resource_identity_vote_operations_v0( voter_pro_tx_hash, vote, block_info, - apply, + estimated_costs_only_with_layer_info, transaction, platform_version, ), diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index 844ff21228..563d358bc6 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -1,3 +1,5 @@ +use std::collections::HashMap; +use grovedb::batch::KeyInfoPath; use crate::drive::Drive; use crate::error::document::DocumentError; use crate::error::Error; @@ -5,7 +7,7 @@ use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; use dpp::voting::{ContestedDocumentResourceVoteType, Vote}; -use grovedb::TransactionArg; +use grovedb::{EstimatedLayerInformation, TransactionArg}; use dpp::prelude::Identifier; use platform_version::version::PlatformVersion; @@ -33,4 +35,30 @@ impl Drive { )? .ok_or(Error::Document(DocumentError::DataContractNotFound))?; } + + pub fn register_contested_resource_identity_vote_operations_v0( + &self, + voter_pro_tx_hash: [u8; 32], + vote: ContestedDocumentResourceVoteType, + block_info: &BlockInfo, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + // let's start by creating a batch of operations + let mut drive_operations: Vec = vec![]; + + let contract_fetch_info = self + .get_contract_with_fetch_info_and_add_to_operations( + vote.contract_id.to_buffer(), + Some(&block_info.epoch), + true, + transaction, + &mut drive_operations, + platform_version, + )? + .ok_or(Error::Document(DocumentError::DataContractNotFound))?; + } } From f4c859da4f90981864f673047045b5f77d34c498 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 21 Feb 2024 08:47:17 +0700 Subject: [PATCH 023/135] more fixes --- .../clients/platform/v0/python/platform_pb2.py | 5 ----- .../proto/org.dash.platform.dapi.v0.rs | 18 ++++++++++++++++++ .../state_transition_like.rs | 6 ++++++ .../masternode_vote_transition/v0/mod.rs | 3 ++- .../v0/state_transition_like.rs | 8 ++++++++ .../mod.rs | 5 ++++- .../v0/mod.rs | 4 +++- .../src/version/mocks/v2_test.rs | 5 ++++- .../src/version/mocks/v3_test.rs | 5 ++++- packages/rs-platform-version/src/version/v1.rs | 5 ++++- 10 files changed, 53 insertions(+), 11 deletions(-) diff --git a/packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py b/packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py index 1559c012d0..eae1e1ddef 100644 --- a/packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py +++ b/packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py @@ -6969,13 +6969,8 @@ index=0, serialized_options=None, create_key=_descriptor._internal_create_key, -<<<<<<< HEAD serialized_start=17897, serialized_end=20869, -======= - serialized_start=15673, - serialized_end=18446, ->>>>>>> v1.0-dev methods=[ _descriptor.MethodDescriptor( name='broadcastStateTransition', diff --git a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs index 20bebf2107..3c3aceb902 100644 --- a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs +++ b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs @@ -2134,6 +2134,7 @@ pub mod get_epochs_info_response { } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] +#[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetContestedResourcesRequest { @@ -2144,6 +2145,7 @@ pub struct GetContestedResourcesRequest { pub mod get_contested_resources_request { #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetContestedResourcesRequestV0 { @@ -2171,6 +2173,7 @@ pub mod get_contested_resources_request { } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] +#[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetContestedResourcesResponse { @@ -2181,6 +2184,7 @@ pub struct GetContestedResourcesResponse { pub mod get_contested_resources_response { #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetContestedResourcesResponseV0 { @@ -2193,6 +2197,7 @@ pub mod get_contested_resources_response { pub mod get_contested_resources_response_v0 { #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ContestedResources { @@ -2203,6 +2208,7 @@ pub mod get_contested_resources_response { } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ContestedResource { @@ -2231,6 +2237,7 @@ pub mod get_contested_resources_response { } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] +#[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetContestedResourceVoteStateRequest { @@ -2243,6 +2250,7 @@ pub struct GetContestedResourceVoteStateRequest { pub mod get_contested_resource_vote_state_request { #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetContestedResourceVoteStateRequestV0 { @@ -2270,6 +2278,7 @@ pub mod get_contested_resource_vote_state_request { } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] +#[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetContestedResourceVoteStateResponse { @@ -2282,6 +2291,7 @@ pub struct GetContestedResourceVoteStateResponse { pub mod get_contested_resource_vote_state_response { #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetContestedResourceVoteStateResponseV0 { @@ -2299,6 +2309,7 @@ pub mod get_contested_resource_vote_state_response { pub mod get_contested_resource_vote_state_response_v0 { #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ContestedResourceContenders { @@ -2309,6 +2320,7 @@ pub mod get_contested_resource_vote_state_response { } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Contender { @@ -2339,6 +2351,7 @@ pub mod get_contested_resource_vote_state_response { } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] +#[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetContestedResourceVoteStatusRequest { @@ -2351,6 +2364,7 @@ pub struct GetContestedResourceVoteStatusRequest { pub mod get_contested_resource_vote_status_request { #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetContestedResourceVoteStatusRequestV0 { @@ -2378,6 +2392,7 @@ pub mod get_contested_resource_vote_status_request { } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] +#[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetContestedResourceVoteStatusResponse { @@ -2390,6 +2405,7 @@ pub struct GetContestedResourceVoteStatusResponse { pub mod get_contested_resource_vote_status_response { #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetContestedResourceVoteStatusResponseV0 { @@ -2407,6 +2423,7 @@ pub mod get_contested_resource_vote_status_response { pub mod get_contested_resource_vote_status_response_v0 { #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ContestedResourceVoters { @@ -2417,6 +2434,7 @@ pub mod get_contested_resource_vote_status_response { } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Voter { diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/state_transition_like.rs index d54d4bb383..d950bc4b42 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/state_transition_like.rs @@ -46,4 +46,10 @@ impl StateTransitionLike for MasternodeVoteTransition { MasternodeVoteTransition::V0(transition) => transition.owner_id(), } } + + fn unique_identifiers(&self) -> Vec { + match self { + MasternodeVoteTransition::V0(transition) => transition.unique_identifiers(), + } + } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs index 1204fab66f..487e7d3c42 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs @@ -10,7 +10,7 @@ mod version; use crate::identity::KeyID; -use crate::prelude::Identifier; +use crate::prelude::{Identifier, IdentityNonce}; use crate::protocol_error::ProtocolError; use crate::voting::Vote; @@ -40,6 +40,7 @@ pub struct MasternodeVoteTransitionV0 { // Own ST fields pub pro_tx_hash: Identifier, pub vote: Vote, + pub nonce: IdentityNonce, #[platform_signable(exclude_from_sig_hash)] pub signature_public_key_id: KeyID, #[platform_signable(exclude_from_sig_hash)] diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/state_transition_like.rs index ec57938247..1e64415b0e 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/state_transition_like.rs @@ -49,4 +49,12 @@ impl StateTransitionLike for MasternodeVoteTransitionV0 { fn owner_id(&self) -> Identifier { self.pro_tx_hash } + + fn unique_identifiers(&self) -> Vec { + vec![format!( + "{}-{:x}", + base64::encode(self.pro_tx_hash), + self.nonce + )] + } } diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs index ac321bf2f5..afd57eb09a 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs @@ -14,6 +14,7 @@ use dpp::version::PlatformVersion; use dpp::voting::ContestedDocumentResourceVoteType; use grovedb::{EstimatedLayerInformation, TransactionArg}; use dpp::identifier::Identifier; +use dpp::prelude::IdentityNonce; use crate::fee::op::LowLevelDriveOperation; impl Drive { @@ -54,12 +55,13 @@ impl Drive { voter_pro_tx_hash: [u8; 32], vote: ContestedDocumentResourceVoteType, block_info: &BlockInfo, + identity_nonce: IdentityNonce, estimated_costs_only_with_layer_info: &mut Option< HashMap, >, transaction: TransactionArg, platform_version: &PlatformVersion, - ) -> Result { + ) -> Result, Error> { match platform_version .drive .methods @@ -71,6 +73,7 @@ impl Drive { voter_pro_tx_hash, vote, block_info, + identity_nonce, estimated_costs_only_with_layer_info, transaction, platform_version, diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index 563d358bc6..83f2641f9d 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -8,7 +8,7 @@ use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; use dpp::voting::{ContestedDocumentResourceVoteType, Vote}; use grovedb::{EstimatedLayerInformation, TransactionArg}; -use dpp::prelude::Identifier; +use dpp::prelude::{Identifier, IdentityNonce}; use platform_version::version::PlatformVersion; impl Drive { @@ -17,6 +17,7 @@ impl Drive { voter_pro_tx_hash: Identifier, vote: ContestedDocumentResourceVoteType, block_info: &BlockInfo, + identity_nonce: IdentityNonce, apply: bool, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -41,6 +42,7 @@ impl Drive { voter_pro_tx_hash: [u8; 32], vote: ContestedDocumentResourceVoteType, block_info: &BlockInfo, + identity_nonce: IdentityNonce, estimated_costs_only_with_layer_info: &mut Option< HashMap, >, diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 65cf8a6a25..394dcb64a0 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -661,10 +661,13 @@ pub(crate) const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { transform_into_action: 0, }, masternode_vote_state_transition: DriveAbciStateTransitionValidationVersion { - structure: 0, + base_structure: 0, identity_signatures: None, + balance: None, + nonce: Some(0), state: 0, transform_into_action: 0, + advanced_structure: None }, contract_create_state_transition: DriveAbciStateTransitionValidationVersion { base_structure: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index fbf31bbdf5..cddaadfba1 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -661,10 +661,13 @@ pub(crate) const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { transform_into_action: 0, }, masternode_vote_state_transition: DriveAbciStateTransitionValidationVersion { - structure: 0, + base_structure: 0, identity_signatures: None, + balance: None, + nonce: Some(0), state: 0, transform_into_action: 0, + advanced_structure: None }, contract_create_state_transition: DriveAbciStateTransitionValidationVersion { base_structure: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 1d54106b38..8894433256 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -658,10 +658,13 @@ pub(super) const PLATFORM_V1: PlatformVersion = PlatformVersion { transform_into_action: 0, }, masternode_vote_state_transition: DriveAbciStateTransitionValidationVersion { - structure: 0, + base_structure: 0, identity_signatures: None, + balance: None, + nonce: Some(0), state: 0, transform_into_action: 0, + advanced_structure: None }, contract_create_state_transition: DriveAbciStateTransitionValidationVersion { base_structure: 0, From 0541be38ecf80d7ac5ec7a3bed534d68fdee1084 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 21 Feb 2024 16:18:06 +0700 Subject: [PATCH 024/135] more fixes --- packages/rs-drive/src/drive/batch/transitions/mod.rs | 1 - .../src/drive/contract/prove/prove_contract/v0/mod.rs | 2 +- .../src/drive/document/query/query_documents/mod.rs | 1 - .../merge_identity_contract_nonce/v0/mod.rs | 2 ++ .../drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs | 4 +++- .../drive/votes/insert/add_new_masternode_vote_type/mod.rs | 2 +- .../register_contested_resource_identity_vote/mod.rs | 2 ++ .../register_contested_resource_identity_vote/v0/mod.rs | 6 +++--- .../setup/setup_initial_vote_tree_main_structure/mod.rs | 1 + .../identity/masternode_vote/v0/mod.rs | 3 +-- 10 files changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/rs-drive/src/drive/batch/transitions/mod.rs b/packages/rs-drive/src/drive/batch/transitions/mod.rs index b9165a98f6..2b7d475e45 100644 --- a/packages/rs-drive/src/drive/batch/transitions/mod.rs +++ b/packages/rs-drive/src/drive/batch/transitions/mod.rs @@ -8,7 +8,6 @@ mod document; mod identity; mod system; -use crate::drive::batch::transitions::document::DriveHighLevelDocumentOperationConverter; use crate::drive::batch::DriveOperation; use crate::error::Error; use crate::state_transition_action::StateTransitionAction; diff --git a/packages/rs-drive/src/drive/contract/prove/prove_contract/v0/mod.rs b/packages/rs-drive/src/drive/contract/prove/prove_contract/v0/mod.rs index 61fa964310..48e694a94d 100644 --- a/packages/rs-drive/src/drive/contract/prove/prove_contract/v0/mod.rs +++ b/packages/rs-drive/src/drive/contract/prove/prove_contract/v0/mod.rs @@ -1,7 +1,7 @@ use crate::drive::Drive; use crate::error::Error; -use crate::drive::contract::paths::{contract_root_path, contract_root_path_vec}; +use crate::drive::contract::paths::contract_root_path; use dpp::version::PlatformVersion; use grovedb::TransactionArg; diff --git a/packages/rs-drive/src/drive/document/query/query_documents/mod.rs b/packages/rs-drive/src/drive/document/query/query_documents/mod.rs index 362ddf218c..ca35f3a5e4 100644 --- a/packages/rs-drive/src/drive/document/query/query_documents/mod.rs +++ b/packages/rs-drive/src/drive/document/query/query_documents/mod.rs @@ -1,4 +1,3 @@ -use crate::drive::document::query::query_documents::v0::QueryDocumentsOutcomeV0; use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; diff --git a/packages/rs-drive/src/drive/identity/contract_info/identity_contract_nonce/merge_identity_contract_nonce/v0/mod.rs b/packages/rs-drive/src/drive/identity/contract_info/identity_contract_nonce/merge_identity_contract_nonce/v0/mod.rs index 392e92c788..92cc32814b 100644 --- a/packages/rs-drive/src/drive/identity/contract_info/identity_contract_nonce/merge_identity_contract_nonce/v0/mod.rs +++ b/packages/rs-drive/src/drive/identity/contract_info/identity_contract_nonce/merge_identity_contract_nonce/v0/mod.rs @@ -118,6 +118,7 @@ impl Drive { // we insert the contract root tree if it doesn't exist already self.batch_insert_empty_tree_if_not_exists( PathKeyInfo::<0>::PathKey((identity_path, vec![IdentityContractInfo as u8])), + false, None, apply_type, transaction, @@ -132,6 +133,7 @@ impl Drive { identity_contract_info_root_path_vec(&identity_id), contract_id.to_vec(), )), + false, None, apply_type, transaction, diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs index d6f7e7b8f8..b6ea84fc29 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs @@ -13,6 +13,8 @@ use dpp::version::PlatformVersion; use dpp::voting::ContestedDocumentResourceVoteType; use grovedb::query_result_type::QueryResultType::QueryElementResultType; use grovedb::{Element, PathQuery, Query, SizedQuery, TransactionArg}; +use grovedb_path::SubtreePath; +use crate::drive::votes::TreePath; impl Drive { /// We remove votes for an identity when that identity is somehow disabled. Currently there is @@ -66,7 +68,7 @@ impl Drive { // we then need to add to the batch the deletion self.batch_delete( - vote.tree_path(), + SubtreePath::from(vote.tree_path()), vote.tree_key(), BatchDeleteApplyType::StatefulBatchDelete { is_known_to_be_subtree_with_sum: Some((false, false)), diff --git a/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/mod.rs b/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/mod.rs index cf81b63c8d..6fc21ae4b7 100644 --- a/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/mod.rs @@ -52,7 +52,7 @@ impl Drive { platform_version, ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "add_document".to_string(), + method: "add_new_masternode_vote_type".to_string(), known_versions: vec![0], received: version, })), diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs index afd57eb09a..05abc4a948 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs @@ -23,6 +23,7 @@ impl Drive { voter_pro_tx_hash: Identifier, vote: ContestedDocumentResourceVoteType, block_info: &BlockInfo, + identity_nonce: IdentityNonce, apply: bool, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -38,6 +39,7 @@ impl Drive { voter_pro_tx_hash, vote, block_info, + identity_nonce, apply, transaction, platform_version, diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index 83f2641f9d..d016f294d2 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -27,7 +27,7 @@ impl Drive { let contract_fetch_info = self .get_contract_with_fetch_info_and_add_to_operations( - vote.contract_id.to_buffer(), + vote.vote_poll.contract_id.to_buffer(), Some(&block_info.epoch), true, transaction, @@ -48,13 +48,13 @@ impl Drive { >, transaction: TransactionArg, platform_version: &PlatformVersion, - ) -> Result { + ) -> Result, Error> { // let's start by creating a batch of operations let mut drive_operations: Vec = vec![]; let contract_fetch_info = self .get_contract_with_fetch_info_and_add_to_operations( - vote.contract_id.to_buffer(), + vote.vote_poll.contract_id.to_buffer(), Some(&block_info.epoch), true, transaction, diff --git a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs index dfefbe6173..05e17f1a7f 100644 --- a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs +++ b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs @@ -18,6 +18,7 @@ impl Drive { .drive .methods .vote + .setup .setup_initial_vote_tree_main_structure { 0 => self.setup_initial_vote_tree_main_structure_v0(transaction, platform_version), diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs index 02eb8ebd9c..4c99cd8a4d 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs @@ -5,8 +5,7 @@ use dpp::voting::Vote; use serde::{Deserialize, Serialize}; /// action v0 -#[derive(Default, Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] +#[derive(Default, Debug, Clone)] pub struct MasternodeVoteTransitionActionV0 { /// the pro tx hash identifier of the masternode pub pro_tx_hash: Identifier, From 477cda5c98156cb9e3e6c20e7197544ab0d9f94d Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Thu, 29 Feb 2024 14:47:32 +0700 Subject: [PATCH 025/135] more fixes --- .../masternode_vote_transition/v0/mod.rs | 1 + packages/rs-drive/src/drive/identity/mod.rs | 3 - .../src/drive/identity/withdrawals/paths.rs | 30 ++++---- .../src/drive/initialization/v0/mod.rs | 15 ++-- .../src/drive/protocol_upgrade/mod.rs | 27 ++++--- .../insert/register_identity_vote/v0/mod.rs | 1 - packages/rs-drive/src/drive/votes/mod.rs | 53 +++++++++++-- .../mod.rs | 13 ++-- .../v0/mod.rs | 75 +++---------------- packages/rs-drive/src/fee_pools/mod.rs | 49 ++++++------ .../identity/masternode_vote/mod.rs | 5 +- .../src/version/drive_versions.rs | 2 +- .../src/version/mocks/v2_test.rs | 2 +- .../src/version/mocks/v3_test.rs | 2 +- .../rs-platform-version/src/version/v1.rs | 2 +- 15 files changed, 136 insertions(+), 144 deletions(-) diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs index 487e7d3c42..3e1197f4ed 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs @@ -88,6 +88,7 @@ mod test { }, resource_vote: ResourceVote::TowardsIdentity(Identifier::random()), }), + nonce: 1, signature_public_key_id: rng.gen(), signature: [0; 65].to_vec().into(), }; diff --git a/packages/rs-drive/src/drive/identity/mod.rs b/packages/rs-drive/src/drive/identity/mod.rs index 4266517050..fbc8820bda 100644 --- a/packages/rs-drive/src/drive/identity/mod.rs +++ b/packages/rs-drive/src/drive/identity/mod.rs @@ -66,9 +66,6 @@ pub mod key; #[cfg(feature = "full")] pub mod update; -#[cfg(feature = "full")] -pub use withdrawals::paths::add_initial_withdrawal_state_structure_operations; - use crate::drive::identity::contract_info::ContractInfoStructure; #[cfg(any(feature = "full", feature = "verify"))] pub use fetch::queries::*; diff --git a/packages/rs-drive/src/drive/identity/withdrawals/paths.rs b/packages/rs-drive/src/drive/identity/withdrawals/paths.rs index 6f73afe5d8..b89f2f7a07 100644 --- a/packages/rs-drive/src/drive/identity/withdrawals/paths.rs +++ b/packages/rs-drive/src/drive/identity/withdrawals/paths.rs @@ -1,27 +1,31 @@ use grovedb::Element; use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; -use crate::drive::{batch::GroveDbOpBatch, RootTree}; +use crate::drive::{batch::GroveDbOpBatch, Drive, RootTree}; /// constant key for transaction counter pub const WITHDRAWAL_TRANSACTIONS_NEXT_INDEX_KEY: [u8; 1] = [0]; /// constant id for subtree containing transactions queue pub const WITHDRAWAL_TRANSACTIONS_QUEUE_KEY: [u8; 1] = [1]; -/// Add operations for creating initial withdrawal state structure -pub fn add_initial_withdrawal_state_structure_operations(batch: &mut GroveDbOpBatch) { - batch.add_insert( - vec![vec![RootTree::WithdrawalTransactions as u8]], - WITHDRAWAL_TRANSACTIONS_NEXT_INDEX_KEY.to_vec(), - Element::Item(0u64.to_be_bytes().to_vec(), None), - ); - - batch.add_insert_empty_tree( - vec![vec![RootTree::WithdrawalTransactions as u8]], - WITHDRAWAL_TRANSACTIONS_QUEUE_KEY.to_vec(), - ); +impl Drive { + /// Add operations for creating initial withdrawal state structure + pub fn add_initial_withdrawal_state_structure_operations(batch: &mut GroveDbOpBatch) { + batch.add_insert( + vec![vec![RootTree::WithdrawalTransactions as u8]], + WITHDRAWAL_TRANSACTIONS_NEXT_INDEX_KEY.to_vec(), + Element::Item(0u64.to_be_bytes().to_vec(), None), + ); + + batch.add_insert_empty_tree( + vec![vec![RootTree::WithdrawalTransactions as u8]], + WITHDRAWAL_TRANSACTIONS_QUEUE_KEY.to_vec(), + ); + } } + + /// Helper function to get root path pub fn get_withdrawal_root_path_vec() -> Vec> { vec![vec![RootTree::WithdrawalTransactions as u8]] diff --git a/packages/rs-drive/src/drive/initialization/v0/mod.rs b/packages/rs-drive/src/drive/initialization/v0/mod.rs index 47a6838094..756fac6b69 100644 --- a/packages/rs-drive/src/drive/initialization/v0/mod.rs +++ b/packages/rs-drive/src/drive/initialization/v0/mod.rs @@ -35,12 +35,9 @@ use crate::drive::balances::TOTAL_SYSTEM_CREDITS_STORAGE_KEY; use crate::drive::batch::GroveDbOpBatch; use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; -use crate::drive::identity::add_initial_withdrawal_state_structure_operations; -use crate::drive::protocol_upgrade::add_initial_fork_update_structure_operations; use crate::drive::system::misc_path_vec; use crate::drive::{Drive, RootTree}; use crate::error::Error; -use crate::fee_pools::add_create_fee_pool_trees_operations; use dpp::version::PlatformVersion; use grovedb::{Element, TransactionArg}; @@ -186,19 +183,19 @@ impl Drive { ); // In Pools: initialize the pools with epochs - add_create_fee_pool_trees_operations(&mut batch, self.config.epochs_per_era)?; + Drive::add_create_fee_pool_trees_operations(&mut batch, self.config.epochs_per_era)?; // In Withdrawals - add_initial_withdrawal_state_structure_operations(&mut batch); + Drive::add_initial_withdrawal_state_structure_operations(&mut batch); // For Versioning via forks - add_initial_fork_update_structure_operations(&mut batch); + Drive::add_initial_fork_update_structure_operations(&mut batch); - self.grove_apply_batch(batch, false, transaction, drive_version)?; + // For the vote tree structure + Drive::add_initial_vote_tree_main_structure_operations(&mut batch, platform_version)?; - // We can then setup the initial vote tree main structure - self.setup_initial_vote_tree_main_structure(transaction, platform_version)?; + self.grove_apply_batch(batch, false, transaction, drive_version)?; Ok(()) } diff --git a/packages/rs-drive/src/drive/protocol_upgrade/mod.rs b/packages/rs-drive/src/drive/protocol_upgrade/mod.rs index 75bc6ed984..48a511a2f8 100644 --- a/packages/rs-drive/src/drive/protocol_upgrade/mod.rs +++ b/packages/rs-drive/src/drive/protocol_upgrade/mod.rs @@ -2,6 +2,7 @@ use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; #[cfg(feature = "full")] use crate::drive::batch::GroveDbOpBatch; +use crate::drive::Drive; #[cfg(any(feature = "full", feature = "verify"))] use crate::drive::RootTree; @@ -30,20 +31,24 @@ pub const VERSIONS_COUNTER: [u8; 1] = [0]; /// constant id for subtree containing the desired versions for each validator pub const VALIDATOR_DESIRED_VERSIONS: [u8; 1] = [1]; -#[cfg(feature = "full")] -/// Add operations for creating initial versioning state structure -pub fn add_initial_fork_update_structure_operations(batch: &mut GroveDbOpBatch) { - batch.add_insert_empty_tree( - vec![vec![RootTree::Versions as u8]], - VERSIONS_COUNTER.to_vec(), - ); +impl Drive { + #[cfg(feature = "full")] + /// Add operations for creating initial versioning state structure + pub fn add_initial_fork_update_structure_operations(batch: &mut GroveDbOpBatch) { + batch.add_insert_empty_tree( + vec![vec![RootTree::Versions as u8]], + VERSIONS_COUNTER.to_vec(), + ); - batch.add_insert_empty_tree( - vec![vec![RootTree::Versions as u8]], - VALIDATOR_DESIRED_VERSIONS.to_vec(), - ); + batch.add_insert_empty_tree( + vec![vec![RootTree::Versions as u8]], + VALIDATOR_DESIRED_VERSIONS.to_vec(), + ); + } } + + #[cfg(any(feature = "full", feature = "verify"))] /// versions counter path pub fn versions_counter_path() -> [&'static [u8]; 2] { diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs index 6e05e758f8..b811bd05cb 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs @@ -1,6 +1,5 @@ use crate::drive::Drive; use crate::error::Error; -use crate::fee::op::LowLevelDriveOperation; use dpp::fee::fee_result::FeeResult; use dpp::voting::Vote; use grovedb::TransactionArg; diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 78e820af12..31d45d2cf8 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -35,17 +35,37 @@ pub(in crate::drive::votes) fn vote_root_path<'a>() -> [&'a [u8]; 1] { [Into::<&[u8; 1]>::into(RootTree::Votes)] } +pub(in crate::drive::votes) fn vote_root_path_vec() -> Vec> { + vec![ + vec![RootTree::Votes as u8], + ] +} + pub(in crate::drive::votes) fn vote_decisions_tree_path<'a>() -> [&'a [u8]; 2] { [ Into::<&[u8; 1]>::into(RootTree::Votes), - Into::<&[u8; 1]>::into(VOTE_DECISIONS_TREE_KEY), + &[VOTE_DECISIONS_TREE_KEY as u8], + ] +} + +pub(in crate::drive::votes) fn vote_decisions_tree_path_vec() -> Vec> { + vec![ + vec![RootTree::Votes as u8], + vec![VOTE_DECISIONS_TREE_KEY as u8], ] } pub(in crate::drive::votes) fn vote_contested_resource_tree_path<'a>() -> [&'a [u8]; 2] { [ Into::<&[u8; 1]>::into(RootTree::Votes), - Into::<&[u8; 1]>::into(CONTESTED_RESOURCE_TREE_KEY), + &[CONTESTED_RESOURCE_TREE_KEY as u8], + ] +} + +pub(in crate::drive::votes) fn vote_contested_resource_tree_path_vec() -> Vec> { + vec![ + vec![RootTree::Votes as u8], + vec![CONTESTED_RESOURCE_TREE_KEY as u8], ] } @@ -53,8 +73,16 @@ pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_tree_pat ) -> [&'a [u8]; 3] { [ Into::<&[u8; 1]>::into(RootTree::Votes), - Into::<&[u8; 1]>::into(CONTESTED_RESOURCE_TREE_KEY), - Into::<&[u8; 1]>::into(END_DATE_QUERIES_TREE_KEY), + &[CONTESTED_RESOURCE_TREE_KEY as u8], + &[END_DATE_QUERIES_TREE_KEY as u8], + ] +} + +pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_tree_path_vec() -> Vec> { + vec![ + vec![RootTree::Votes as u8], + vec![CONTESTED_RESOURCE_TREE_KEY as u8], + vec![END_DATE_QUERIES_TREE_KEY as u8], ] } @@ -62,18 +90,27 @@ pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path< ) -> [&'a [u8]; 3] { [ Into::<&[u8; 1]>::into(RootTree::Votes), - Into::<&[u8; 1]>::into(CONTESTED_RESOURCE_TREE_KEY), - Into::<&[u8; 1]>::into(IDENTITY_VOTES_TREE_KEY), + &[CONTESTED_RESOURCE_TREE_KEY as u8], + &[IDENTITY_VOTES_TREE_KEY as u8], ] } +pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_vec() -> Vec> { + vec![ + vec![RootTree::Votes as u8], + vec![CONTESTED_RESOURCE_TREE_KEY as u8], + vec![IDENTITY_VOTES_TREE_KEY as u8], + ] +} + + pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_for_identity<'a>( identity_id: &[u8; 32], ) -> [&'a [u8]; 4] { [ Into::<&[u8; 1]>::into(RootTree::Votes), - Into::<&[u8; 1]>::into(CONTESTED_RESOURCE_TREE_KEY), - Into::<&[u8; 1]>::into(IDENTITY_VOTES_TREE_KEY), + &[CONTESTED_RESOURCE_TREE_KEY as u8], + &[IDENTITY_VOTES_TREE_KEY as u8], identity_id, ] } diff --git a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs index 05e17f1a7f..dc1fd3c9ab 100644 --- a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs +++ b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs @@ -6,12 +6,11 @@ use crate::error::drive::DriveError; use crate::error::Error; use dpp::version::PlatformVersion; -use grovedb::TransactionArg; +use crate::drive::batch::GroveDbOpBatch; impl Drive { - pub fn setup_initial_vote_tree_main_structure( - &self, - transaction: TransactionArg, + pub fn add_initial_vote_tree_main_structure_operations( + batch: &mut GroveDbOpBatch, platform_version: &PlatformVersion, ) -> Result<(), Error> { match platform_version @@ -19,11 +18,11 @@ impl Drive { .methods .vote .setup - .setup_initial_vote_tree_main_structure + .add_initial_vote_tree_main_structure_operations { - 0 => self.setup_initial_vote_tree_main_structure_v0(transaction, platform_version), + 0 => Drive::add_initial_vote_tree_main_structure_operations_v0(batch), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "setup_initial_vote_tree_main_structure".to_string(), + method: "add_initial_vote_tree_main_structure_operations".to_string(), known_versions: vec![0], received: version, })), diff --git a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs index feaa586818..19debd8f46 100644 --- a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs @@ -1,75 +1,22 @@ -use crate::drive::votes::{ - vote_contested_resource_end_date_queries_tree_path, - vote_contested_resource_identity_votes_tree_path, vote_root_path, CONTESTED_RESOURCE_TREE_KEY, - VOTE_DECISIONS_TREE_KEY, -}; -use crate::drive::{Drive, RootTree}; use crate::error::Error; -use grovedb::operations::insert::InsertOptions; -use grovedb::TransactionArg; -use grovedb_path::SubtreePath; -use platform_version::version::PlatformVersion; +use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; +use crate::drive::batch::GroveDbOpBatch; +use crate::drive::Drive; +use crate::drive::votes::{CONTESTED_RESOURCE_TREE_KEY, END_DATE_QUERIES_TREE_KEY, IDENTITY_VOTES_TREE_KEY, vote_contested_resource_tree_path_vec, VOTE_DECISIONS_TREE_KEY, vote_root_path_vec}; impl Drive { - pub fn setup_initial_vote_tree_main_structure_v0( - &self, - transaction: TransactionArg, - platform_version: &PlatformVersion, + pub(super) fn add_initial_vote_tree_main_structure_operations_v0( + batch: &mut GroveDbOpBatch, ) -> Result<(), Error> { - let drive_version = &platform_version.drive; - let mut drive_operations = vec![]; + batch.add_insert_empty_tree(vote_root_path_vec(), vec![VOTE_DECISIONS_TREE_KEY as u8]); - self.grove_insert_empty_tree( - SubtreePath::from(vote_root_path()), - &[VOTE_DECISIONS_TREE_KEY.into()], - transaction, - Some(InsertOptions { - validate_insertion_does_not_override: true, - validate_insertion_does_not_override_tree: true, - base_root_storage_is_free: true, - }), - &mut drive_operations, - drive_version, - )?; + batch.add_insert_empty_tree(vote_root_path_vec(), vec![CONTESTED_RESOURCE_TREE_KEY as u8]); - self.grove_insert_empty_tree( - SubtreePath::from(vote_root_path()), - &[CONTESTED_RESOURCE_TREE_KEY.into()], - transaction, - Some(InsertOptions { - validate_insertion_does_not_override: true, - validate_insertion_does_not_override_tree: true, - base_root_storage_is_free: true, - }), - &mut drive_operations, - drive_version, - )?; + batch.add_insert_empty_tree(vote_contested_resource_tree_path_vec(), vec![END_DATE_QUERIES_TREE_KEY as u8]); - self.grove_insert_empty_tree( - SubtreePath::from(vote_contested_resource_end_date_queries_tree_path()), - &[CONTESTED_RESOURCE_TREE_KEY.into()], - transaction, - Some(InsertOptions { - validate_insertion_does_not_override: true, - validate_insertion_does_not_override_tree: true, - base_root_storage_is_free: true, - }), - &mut drive_operations, - drive_version, - )?; + batch.add_insert_empty_tree(vote_contested_resource_tree_path_vec(), vec![IDENTITY_VOTES_TREE_KEY as u8]); - self.grove_insert_empty_tree( - SubtreePath::from(vote_contested_resource_identity_votes_tree_path()), - &[CONTESTED_RESOURCE_TREE_KEY.into()], - transaction, - Some(InsertOptions { - validate_insertion_does_not_override: true, - validate_insertion_does_not_override_tree: true, - base_root_storage_is_free: true, - }), - &mut drive_operations, - drive_version, - ) + Ok(()) } } diff --git a/packages/rs-drive/src/fee_pools/mod.rs b/packages/rs-drive/src/fee_pools/mod.rs index e6e74ccb33..69d05229ac 100644 --- a/packages/rs-drive/src/fee_pools/mod.rs +++ b/packages/rs-drive/src/fee_pools/mod.rs @@ -53,6 +53,7 @@ use dpp::fee::Credits; use grovedb::batch::GroveDbOp; #[cfg(feature = "full")] use grovedb::Element; +use crate::drive::Drive; #[cfg(any(feature = "full", feature = "verify"))] /// Epochs module @@ -62,31 +63,35 @@ pub mod epochs; /// Epochs root tree key constants module pub mod epochs_root_tree_key_constants; -#[cfg(feature = "full")] -/// Adds the operations to groveDB op batch to create the fee pool trees -pub fn add_create_fee_pool_trees_operations( - batch: &mut GroveDbOpBatch, - epochs_per_era: u16, -) -> Result<(), Error> { - // Init storage credit pool - batch.push(update_storage_fee_distribution_pool_operation(0)?); - - // Init next epoch to pay - batch.push(update_unpaid_epoch_index_operation(GENESIS_EPOCH_INDEX)); - - add_create_pending_epoch_refunds_tree_operations(batch); - - // We need to insert 50 era worth of epochs, - // with 40 epochs per era that's 2000 epochs - // however this is configurable - for i in GENESIS_EPOCH_INDEX..perpetual_storage_epochs(epochs_per_era) { - let epoch = Epoch::new(i)?; - epoch.add_init_empty_operations(batch)?; - } +impl Drive { + #[cfg(feature = "full")] + /// Adds the operations to groveDB op batch to create the fee pool trees + pub fn add_create_fee_pool_trees_operations( + batch: &mut GroveDbOpBatch, + epochs_per_era: u16, + ) -> Result<(), Error> { + // Init storage credit pool + batch.push(update_storage_fee_distribution_pool_operation(0)?); + + // Init next epoch to pay + batch.push(update_unpaid_epoch_index_operation(GENESIS_EPOCH_INDEX)); + + add_create_pending_epoch_refunds_tree_operations(batch); + + // We need to insert 50 era worth of epochs, + // with 40 epochs per era that's 2000 epochs + // however this is configurable + for i in GENESIS_EPOCH_INDEX..perpetual_storage_epochs(epochs_per_era) { + let epoch = Epoch::new(i)?; + epoch.add_init_empty_operations(batch)?; + } - Ok(()) + Ok(()) + } } + + #[cfg(feature = "full")] /// Adds operations to batch to create pending pool updates tree pub fn add_create_pending_epoch_refunds_tree_operations(batch: &mut GroveDbOpBatch) { diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs index a4b5c18cb2..379c11d6fe 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs @@ -7,6 +7,7 @@ use crate::state_transition_action::identity::masternode_vote::v0::MasternodeVot use derive_more::From; use dpp::platform_value::Identifier; use dpp::voting::resource_vote::ResourceVote; +use dpp::voting::Vote; /// action #[derive(Debug, Clone, From)] @@ -24,9 +25,9 @@ impl MasternodeVoteTransitionAction { } /// Resource vote - pub fn resource_vote(&self) -> ResourceVote { + pub fn vote(&self) -> &Vote { match self { - MasternodeVoteTransitionAction::V0(transition) => transition.resource_vote, + MasternodeVoteTransitionAction::V0(transition) => &transition.vote, } } } diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 73f5b16f9d..73b675b1e5 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -246,7 +246,7 @@ pub struct DriveVoteMethodVersions { #[derive(Clone, Debug, Default)] pub struct DriveVoteSetupMethodVersions { - pub setup_initial_vote_tree_main_structure: FeatureVersion, + pub add_initial_vote_tree_main_structure_operations: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 394dcb64a0..1f95bd0d79 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -211,7 +211,7 @@ pub(crate) const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { remove_votes_for_identity: 0, }, setup: DriveVoteSetupMethodVersions { - setup_initial_vote_tree_main_structure: 0, + add_initial_vote_tree_main_structure_operations: 0, }, }, contract: DriveContractMethodVersions { diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index cddaadfba1..1d39ed6490 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -219,7 +219,7 @@ pub(crate) const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { remove_votes_for_identity: 0, }, setup: DriveVoteSetupMethodVersions { - setup_initial_vote_tree_main_structure: 0, + add_initial_vote_tree_main_structure_operations: 0, }, }, contract: DriveContractMethodVersions { diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 8894433256..77f3c3f21d 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -208,7 +208,7 @@ pub(super) const PLATFORM_V1: PlatformVersion = PlatformVersion { remove_votes_for_identity: 0, }, setup: DriveVoteSetupMethodVersions { - setup_initial_vote_tree_main_structure: 0, + add_initial_vote_tree_main_structure_operations: 0, }, }, contract: DriveContractMethodVersions { From 41a3bba534d9c0faaccd88d472e37fc674430691 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 8 Apr 2024 09:33:38 +0700 Subject: [PATCH 026/135] proto update --- .../proto/org.dash.platform.dapi.v0.rs | 165 ++++++++++++++++++ 1 file changed, 165 insertions(+) diff --git a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs index d0a2fc3495..d2e19584af 100644 --- a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs +++ b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs @@ -3386,6 +3386,27 @@ pub mod platform_server { tonic::Response, tonic::Status, >; + async fn get_contested_resources( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn get_contested_resource_vote_state( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn get_contested_resource_vote_status( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; } #[derive(Debug)] pub struct PlatformServer { @@ -4410,6 +4431,150 @@ pub mod platform_server { }; Box::pin(fut) } + "/org.dash.platform.dapi.v0.Platform/getContestedResources" => { + #[allow(non_camel_case_types)] + struct getContestedResourcesSvc(pub Arc); + impl< + T: Platform, + > tonic::server::UnaryService + for getContestedResourcesSvc { + type Response = super::GetContestedResourcesResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + (*inner).get_contested_resources(request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = getContestedResourcesSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/org.dash.platform.dapi.v0.Platform/getContestedResourceVoteState" => { + #[allow(non_camel_case_types)] + struct getContestedResourceVoteStateSvc(pub Arc); + impl< + T: Platform, + > tonic::server::UnaryService< + super::GetContestedResourceVoteStateRequest, + > for getContestedResourceVoteStateSvc { + type Response = super::GetContestedResourceVoteStateResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + super::GetContestedResourceVoteStateRequest, + >, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + (*inner).get_contested_resource_vote_state(request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = getContestedResourceVoteStateSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/org.dash.platform.dapi.v0.Platform/getContestedResourceVoteStatus" => { + #[allow(non_camel_case_types)] + struct getContestedResourceVoteStatusSvc(pub Arc); + impl< + T: Platform, + > tonic::server::UnaryService< + super::GetContestedResourceVoteStatusRequest, + > for getContestedResourceVoteStatusSvc { + type Response = super::GetContestedResourceVoteStatusResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + super::GetContestedResourceVoteStatusRequest, + >, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + (*inner).get_contested_resource_vote_status(request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = getContestedResourceVoteStatusSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } _ => { Box::pin(async move { Ok( From 56024d56e5d6e9bf7f65d7758a290ee5f905732d Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sat, 13 Apr 2024 21:21:47 +0700 Subject: [PATCH 027/135] small fixes --- .../core/proto/org.dash.platform.dapi.v0.rs | 319 ----- .../proto/org.dash.platform.dapi.v0.rs | 1192 ----------------- .../masternode_vote_transition/fields.rs | 2 +- .../masternode_vote_transition/mod.rs | 1 - .../state_transition_like.rs | 13 + .../v0/state_transition_like.rs | 15 +- .../masternode_vote_transition/v0/types.rs | 1 - packages/rs-dpp/src/voting/mod.rs | 3 - .../src/version/mocks/v3_test.rs | 6 +- 9 files changed, 31 insertions(+), 1521 deletions(-) diff --git a/packages/dapi-grpc/src/core/proto/org.dash.platform.dapi.v0.rs b/packages/dapi-grpc/src/core/proto/org.dash.platform.dapi.v0.rs index 05b6d41005..7fe0b85c23 100644 --- a/packages/dapi-grpc/src/core/proto/org.dash.platform.dapi.v0.rs +++ b/packages/dapi-grpc/src/core/proto/org.dash.platform.dapi.v0.rs @@ -1,9 +1,7 @@ -#[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetStatusRequest {} -#[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -25,7 +23,6 @@ pub struct GetStatusResponse { } /// Nested message and enum types in `GetStatusResponse`. pub mod get_status_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -37,7 +34,6 @@ pub mod get_status_response { #[prost(string, tag = "3")] pub agent: ::prost::alloc::string::String, } - #[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -49,7 +45,6 @@ pub mod get_status_response { #[prost(uint32, tag = "3")] pub median: u32, } - #[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -71,7 +66,6 @@ pub mod get_status_response { #[prost(double, tag = "8")] pub sync_progress: f64, } - #[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -89,7 +83,6 @@ pub mod get_status_response { } /// Nested message and enum types in `Masternode`. pub mod masternode { - #[derive(::serde::Serialize, ::serde::Deserialize)] #[derive( Clone, Copy, @@ -145,7 +138,6 @@ pub mod get_status_response { } } } - #[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -155,7 +147,6 @@ pub mod get_status_response { #[prost(double, tag = "2")] pub incremental: f64, } - #[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -165,7 +156,6 @@ pub mod get_status_response { #[prost(message, optional, tag = "2")] pub fee: ::core::option::Option, } - #[derive(::serde::Serialize, ::serde::Deserialize)] #[derive( Clone, Copy, @@ -209,7 +199,6 @@ pub mod get_status_response { } } } -#[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -219,7 +208,6 @@ pub struct GetBlockRequest { } /// Nested message and enum types in `GetBlockRequest`. pub mod get_block_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Block { @@ -229,7 +217,6 @@ pub mod get_block_request { Hash(::prost::alloc::string::String), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -237,7 +224,6 @@ pub struct GetBlockResponse { #[prost(bytes = "vec", tag = "1")] pub block: ::prost::alloc::vec::Vec, } -#[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -249,7 +235,6 @@ pub struct BroadcastTransactionRequest { #[prost(bool, tag = "3")] pub bypass_limits: bool, } -#[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -257,7 +242,6 @@ pub struct BroadcastTransactionResponse { #[prost(string, tag = "1")] pub transaction_id: ::prost::alloc::string::String, } -#[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -265,7 +249,6 @@ pub struct GetTransactionRequest { #[prost(string, tag = "1")] pub id: ::prost::alloc::string::String, } -#[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -283,7 +266,6 @@ pub struct GetTransactionResponse { #[prost(bool, tag = "6")] pub is_chain_locked: bool, } -#[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -297,7 +279,6 @@ pub struct BlockHeadersWithChainLocksRequest { } /// Nested message and enum types in `BlockHeadersWithChainLocksRequest`. pub mod block_headers_with_chain_locks_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum FromBlock { @@ -307,7 +288,6 @@ pub mod block_headers_with_chain_locks_request { FromBlockHeight(u32), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -319,7 +299,6 @@ pub struct BlockHeadersWithChainLocksResponse { } /// Nested message and enum types in `BlockHeadersWithChainLocksResponse`. pub mod block_headers_with_chain_locks_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Responses { @@ -329,7 +308,6 @@ pub mod block_headers_with_chain_locks_response { ChainLock(::prost::alloc::vec::Vec), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -337,7 +315,6 @@ pub struct BlockHeaders { #[prost(bytes = "vec", repeated, tag = "1")] pub headers: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, } -#[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -345,7 +322,6 @@ pub struct GetEstimatedTransactionFeeRequest { #[prost(uint32, tag = "1")] pub blocks: u32, } -#[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -353,7 +329,6 @@ pub struct GetEstimatedTransactionFeeResponse { #[prost(double, tag = "1")] pub fee: f64, } -#[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -369,7 +344,6 @@ pub struct TransactionsWithProofsRequest { } /// Nested message and enum types in `TransactionsWithProofsRequest`. pub mod transactions_with_proofs_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum FromBlock { @@ -379,7 +353,6 @@ pub mod transactions_with_proofs_request { FromBlockHeight(u32), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -393,7 +366,6 @@ pub struct BloomFilter { #[prost(uint32, tag = "4")] pub n_flags: u32, } -#[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -403,7 +375,6 @@ pub struct TransactionsWithProofsResponse { } /// Nested message and enum types in `TransactionsWithProofsResponse`. pub mod transactions_with_proofs_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Responses { @@ -415,7 +386,6 @@ pub mod transactions_with_proofs_response { RawMerkleBlock(::prost::alloc::vec::Vec), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -423,7 +393,6 @@ pub struct RawTransactions { #[prost(bytes = "vec", repeated, tag = "1")] pub transactions: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, } -#[derive(::serde::Serialize, ::serde::Deserialize)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -431,294 +400,6 @@ pub struct InstantSendLockMessages { #[prost(bytes = "vec", repeated, tag = "1")] pub messages: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, } -/// Generated client implementations. -pub mod core_client { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; - use tonic::codegen::http::Uri; - #[derive(Debug, Clone)] - pub struct CoreClient { - inner: tonic::client::Grpc, - } - impl CoreClient { - /// Attempt to create a new client by connecting to a given endpoint. - pub async fn connect(dst: D) -> Result - where - D: TryInto, - D::Error: Into, - { - let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; - Ok(Self::new(conn)) - } - } - impl CoreClient - where - T: tonic::client::GrpcService, - T::Error: Into, - T::ResponseBody: Body + Send + 'static, - ::Error: Into + Send, - { - pub fn new(inner: T) -> Self { - let inner = tonic::client::Grpc::new(inner); - Self { inner } - } - pub fn with_origin(inner: T, origin: Uri) -> Self { - let inner = tonic::client::Grpc::with_origin(inner, origin); - Self { inner } - } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> CoreClient> - where - F: tonic::service::Interceptor, - T::ResponseBody: Default, - T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, - >, - , - >>::Error: Into + Send + Sync, - { - CoreClient::new(InterceptedService::new(inner, interceptor)) - } - /// Compress requests with the given encoding. - /// - /// This requires the server to support it otherwise it might respond with an - /// error. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.send_compressed(encoding); - self - } - /// Enable decompressing responses. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.accept_compressed(encoding); - self - } - /// Limits the maximum size of a decoded message. - /// - /// Default: `4MB` - #[must_use] - pub fn max_decoding_message_size(mut self, limit: usize) -> Self { - self.inner = self.inner.max_decoding_message_size(limit); - self - } - /// Limits the maximum size of an encoded message. - /// - /// Default: `usize::MAX` - #[must_use] - pub fn max_encoding_message_size(mut self, limit: usize) -> Self { - self.inner = self.inner.max_encoding_message_size(limit); - self - } - pub async fn get_status( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Core/getStatus", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("org.dash.platform.dapi.v0.Core", "getStatus")); - self.inner.unary(req, path, codec).await - } - pub async fn get_block( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Core/getBlock", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("org.dash.platform.dapi.v0.Core", "getBlock")); - self.inner.unary(req, path, codec).await - } - pub async fn broadcast_transaction( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Core/broadcastTransaction", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Core", - "broadcastTransaction", - ), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_transaction( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Core/getTransaction", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new("org.dash.platform.dapi.v0.Core", "getTransaction"), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_estimated_transaction_fee( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Core/getEstimatedTransactionFee", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Core", - "getEstimatedTransactionFee", - ), - ); - self.inner.unary(req, path, codec).await - } - pub async fn subscribe_to_block_headers_with_chain_locks( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response< - tonic::codec::Streaming, - >, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Core/subscribeToBlockHeadersWithChainLocks", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Core", - "subscribeToBlockHeadersWithChainLocks", - ), - ); - self.inner.server_streaming(req, path, codec).await - } - pub async fn subscribe_to_transactions_with_proofs( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response< - tonic::codec::Streaming, - >, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Core/subscribeToTransactionsWithProofs", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Core", - "subscribeToTransactionsWithProofs", - ), - ); - self.inner.server_streaming(req, path, codec).await - } - } -} /// Generated server implementations. pub mod core_server { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] diff --git a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs index d2e19584af..98b09f7ccb 100644 --- a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs +++ b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs @@ -1,49 +1,37 @@ -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Proof { #[prost(bytes = "vec", tag = "1")] - #[serde(with = "serde_bytes")] pub grovedb_proof: ::prost::alloc::vec::Vec, #[prost(bytes = "vec", tag = "2")] - #[serde(with = "serde_bytes")] pub quorum_hash: ::prost::alloc::vec::Vec, #[prost(bytes = "vec", tag = "3")] - #[serde(with = "serde_bytes")] pub signature: ::prost::alloc::vec::Vec, #[prost(uint32, tag = "4")] pub round: u32, #[prost(bytes = "vec", tag = "5")] - #[serde(with = "serde_bytes")] pub block_id_hash: ::prost::alloc::vec::Vec, #[prost(uint32, tag = "6")] pub quorum_type: u32, } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ResponseMetadata { #[prost(uint64, tag = "1")] - #[serde(with = "crate::deserialization::from_to_string")] pub height: u64, #[prost(uint32, tag = "2")] pub core_chain_locked_height: u32, #[prost(uint32, tag = "3")] pub epoch: u32, #[prost(uint64, tag = "4")] - #[serde(with = "crate::deserialization::from_to_string")] pub time_ms: u64, #[prost(uint32, tag = "5")] pub protocol_version: u32, #[prost(string, tag = "6")] pub chain_id: ::prost::alloc::string::String, } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -55,8 +43,6 @@ pub struct StateTransitionBroadcastError { #[prost(bytes = "vec", tag = "3")] pub data: ::prost::alloc::vec::Vec, } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -64,14 +50,10 @@ pub struct BroadcastStateTransitionRequest { #[prost(bytes = "vec", tag = "1")] pub state_transition: ::prost::alloc::vec::Vec, } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct BroadcastStateTransitionResponse {} -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::VersionedGrpcMessage)] #[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] @@ -83,20 +65,15 @@ pub struct GetIdentityRequest { } /// Nested message and enum types in `GetIdentityRequest`. pub mod get_identity_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetIdentityRequestV0 { #[prost(bytes = "vec", tag = "1")] - #[serde(with = "serde_bytes")] pub id: ::prost::alloc::vec::Vec, #[prost(bool, tag = "2")] pub prove: bool, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -104,8 +81,6 @@ pub mod get_identity_request { V0(GetIdentityRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::VersionedGrpcMessage)] #[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] @@ -117,20 +92,15 @@ pub struct GetIdentityNonceRequest { } /// Nested message and enum types in `GetIdentityNonceRequest`. pub mod get_identity_nonce_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetIdentityNonceRequestV0 { #[prost(bytes = "vec", tag = "1")] - #[serde(with = "serde_bytes")] pub identity_id: ::prost::alloc::vec::Vec, #[prost(bool, tag = "2")] pub prove: bool, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -138,8 +108,6 @@ pub mod get_identity_nonce_request { V0(GetIdentityNonceRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::VersionedGrpcMessage)] #[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] @@ -151,22 +119,17 @@ pub struct GetIdentityContractNonceRequest { } /// Nested message and enum types in `GetIdentityContractNonceRequest`. pub mod get_identity_contract_nonce_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetIdentityContractNonceRequestV0 { #[prost(bytes = "vec", tag = "1")] - #[serde(with = "serde_bytes")] pub identity_id: ::prost::alloc::vec::Vec, #[prost(bytes = "vec", tag = "2")] pub contract_id: ::prost::alloc::vec::Vec, #[prost(bool, tag = "3")] pub prove: bool, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -174,8 +137,6 @@ pub mod get_identity_contract_nonce_request { V0(GetIdentityContractNonceRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::VersionedGrpcMessage)] #[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] @@ -187,20 +148,15 @@ pub struct GetIdentityBalanceRequest { } /// Nested message and enum types in `GetIdentityBalanceRequest`. pub mod get_identity_balance_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetIdentityBalanceRequestV0 { #[prost(bytes = "vec", tag = "1")] - #[serde(with = "serde_bytes")] pub id: ::prost::alloc::vec::Vec, #[prost(bool, tag = "2")] pub prove: bool, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -208,8 +164,6 @@ pub mod get_identity_balance_request { V0(GetIdentityBalanceRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::VersionedGrpcMessage)] #[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] @@ -223,20 +177,15 @@ pub struct GetIdentityBalanceAndRevisionRequest { } /// Nested message and enum types in `GetIdentityBalanceAndRevisionRequest`. pub mod get_identity_balance_and_revision_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetIdentityBalanceAndRevisionRequestV0 { #[prost(bytes = "vec", tag = "1")] - #[serde(with = "serde_bytes")] pub id: ::prost::alloc::vec::Vec, #[prost(bool, tag = "2")] pub prove: bool, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -244,8 +193,6 @@ pub mod get_identity_balance_and_revision_request { V0(GetIdentityBalanceAndRevisionRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive( ::dapi_grpc_macros::VersionedGrpcMessage, ::dapi_grpc_macros::VersionedGrpcResponse @@ -260,8 +207,6 @@ pub struct GetIdentityResponse { } /// Nested message and enum types in `GetIdentityResponse`. pub mod get_identity_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -273,8 +218,6 @@ pub mod get_identity_response { } /// Nested message and enum types in `GetIdentityResponseV0`. pub mod get_identity_response_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { @@ -284,8 +227,6 @@ pub mod get_identity_response { Proof(super::super::Proof), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -293,8 +234,6 @@ pub mod get_identity_response { V0(GetIdentityResponseV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::VersionedGrpcMessage)] #[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] @@ -306,20 +245,15 @@ pub struct GetIdentitiesRequest { } /// Nested message and enum types in `GetIdentitiesRequest`. pub mod get_identities_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetIdentitiesRequestV0 { #[prost(bytes = "vec", repeated, tag = "1")] - #[serde(with = "crate::deserialization::vec_base64string")] pub ids: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, #[prost(bool, tag = "2")] pub prove: bool, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -327,8 +261,6 @@ pub mod get_identities_request { V0(GetIdentitiesRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive( ::dapi_grpc_macros::VersionedGrpcMessage, ::dapi_grpc_macros::VersionedGrpcResponse @@ -343,8 +275,6 @@ pub struct GetIdentitiesResponse { } /// Nested message and enum types in `GetIdentitiesResponse`. pub mod get_identities_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -352,8 +282,6 @@ pub mod get_identities_response { #[prost(bytes = "vec", tag = "1")] pub value: ::prost::alloc::vec::Vec, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -363,8 +291,6 @@ pub mod get_identities_response { #[prost(message, optional, tag = "2")] pub value: ::core::option::Option, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -372,8 +298,6 @@ pub mod get_identities_response { #[prost(message, repeated, tag = "1")] pub identity_entries: ::prost::alloc::vec::Vec, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -385,8 +309,6 @@ pub mod get_identities_response { } /// Nested message and enum types in `GetIdentitiesResponseV0`. pub mod get_identities_response_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { @@ -396,8 +318,6 @@ pub mod get_identities_response { Proof(super::super::Proof), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -405,8 +325,6 @@ pub mod get_identities_response { V0(GetIdentitiesResponseV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive( ::dapi_grpc_macros::VersionedGrpcMessage, ::dapi_grpc_macros::VersionedGrpcResponse @@ -421,8 +339,6 @@ pub struct GetIdentityNonceResponse { } /// Nested message and enum types in `GetIdentityNonceResponse`. pub mod get_identity_nonce_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -434,8 +350,6 @@ pub mod get_identity_nonce_response { } /// Nested message and enum types in `GetIdentityNonceResponseV0`. pub mod get_identity_nonce_response_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { @@ -445,8 +359,6 @@ pub mod get_identity_nonce_response { Proof(super::super::Proof), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -454,8 +366,6 @@ pub mod get_identity_nonce_response { V0(GetIdentityNonceResponseV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive( ::dapi_grpc_macros::VersionedGrpcMessage, ::dapi_grpc_macros::VersionedGrpcResponse @@ -470,8 +380,6 @@ pub struct GetIdentityContractNonceResponse { } /// Nested message and enum types in `GetIdentityContractNonceResponse`. pub mod get_identity_contract_nonce_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -488,8 +396,6 @@ pub mod get_identity_contract_nonce_response { } /// Nested message and enum types in `GetIdentityContractNonceResponseV0`. pub mod get_identity_contract_nonce_response_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { @@ -499,8 +405,6 @@ pub mod get_identity_contract_nonce_response { Proof(super::super::Proof), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -508,8 +412,6 @@ pub mod get_identity_contract_nonce_response { V0(GetIdentityContractNonceResponseV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive( ::dapi_grpc_macros::VersionedGrpcMessage, ::dapi_grpc_macros::VersionedGrpcResponse @@ -524,8 +426,6 @@ pub struct GetIdentityBalanceResponse { } /// Nested message and enum types in `GetIdentityBalanceResponse`. pub mod get_identity_balance_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -537,8 +437,6 @@ pub mod get_identity_balance_response { } /// Nested message and enum types in `GetIdentityBalanceResponseV0`. pub mod get_identity_balance_response_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { @@ -548,8 +446,6 @@ pub mod get_identity_balance_response { Proof(super::super::Proof), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -557,8 +453,6 @@ pub mod get_identity_balance_response { V0(GetIdentityBalanceResponseV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive( ::dapi_grpc_macros::VersionedGrpcMessage, ::dapi_grpc_macros::VersionedGrpcResponse @@ -575,8 +469,6 @@ pub struct GetIdentityBalanceAndRevisionResponse { } /// Nested message and enum types in `GetIdentityBalanceAndRevisionResponse`. pub mod get_identity_balance_and_revision_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -593,8 +485,6 @@ pub mod get_identity_balance_and_revision_response { } /// Nested message and enum types in `GetIdentityBalanceAndRevisionResponseV0`. pub mod get_identity_balance_and_revision_response_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -604,8 +494,6 @@ pub mod get_identity_balance_and_revision_response { #[prost(uint64, tag = "2")] pub revision: u64, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { @@ -615,8 +503,6 @@ pub mod get_identity_balance_and_revision_response { Proof(super::super::Proof), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -624,8 +510,6 @@ pub mod get_identity_balance_and_revision_response { V0(GetIdentityBalanceAndRevisionResponseV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -635,8 +519,6 @@ pub struct KeyRequestType { } /// Nested message and enum types in `KeyRequestType`. pub mod key_request_type { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Request { @@ -648,14 +530,10 @@ pub mod key_request_type { SearchKey(super::SearchKey), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct AllKeys {} -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -663,8 +541,6 @@ pub struct SpecificKeys { #[prost(uint32, repeated, tag = "1")] pub key_ids: ::prost::alloc::vec::Vec, } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -672,8 +548,6 @@ pub struct SearchKey { #[prost(map = "uint32, message", tag = "1")] pub purpose_map: ::std::collections::HashMap, } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -686,8 +560,6 @@ pub struct SecurityLevelMap { } /// Nested message and enum types in `SecurityLevelMap`. pub mod security_level_map { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive( Clone, Copy, @@ -727,8 +599,6 @@ pub mod security_level_map { } } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::VersionedGrpcMessage)] #[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] @@ -740,14 +610,11 @@ pub struct GetIdentityKeysRequest { } /// Nested message and enum types in `GetIdentityKeysRequest`. pub mod get_identity_keys_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetIdentityKeysRequestV0 { #[prost(bytes = "vec", tag = "1")] - #[serde(with = "serde_bytes")] pub identity_id: ::prost::alloc::vec::Vec, #[prost(message, optional, tag = "2")] pub request_type: ::core::option::Option, @@ -758,8 +625,6 @@ pub mod get_identity_keys_request { #[prost(bool, tag = "5")] pub prove: bool, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -767,8 +632,6 @@ pub mod get_identity_keys_request { V0(GetIdentityKeysRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive( ::dapi_grpc_macros::VersionedGrpcMessage, ::dapi_grpc_macros::VersionedGrpcResponse @@ -783,8 +646,6 @@ pub struct GetIdentityKeysResponse { } /// Nested message and enum types in `GetIdentityKeysResponse`. pub mod get_identity_keys_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -796,8 +657,6 @@ pub mod get_identity_keys_response { } /// Nested message and enum types in `GetIdentityKeysResponseV0`. pub mod get_identity_keys_response_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -805,8 +664,6 @@ pub mod get_identity_keys_response { #[prost(bytes = "vec", repeated, tag = "1")] pub keys_bytes: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { @@ -816,8 +673,6 @@ pub mod get_identity_keys_response { Proof(super::super::Proof), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -825,8 +680,6 @@ pub mod get_identity_keys_response { V0(GetIdentityKeysResponseV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::VersionedGrpcMessage)] #[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] @@ -838,8 +691,6 @@ pub struct GetProofsRequest { } /// Nested message and enum types in `GetProofsRequest`. pub mod get_proofs_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -853,8 +704,6 @@ pub mod get_proofs_request { } /// Nested message and enum types in `GetProofsRequestV0`. pub mod get_proofs_request_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -868,22 +717,17 @@ pub mod get_proofs_request { #[prost(bytes = "vec", tag = "4")] pub document_id: ::prost::alloc::vec::Vec, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct IdentityRequest { #[prost(bytes = "vec", tag = "1")] - #[serde(with = "serde_bytes")] pub identity_id: ::prost::alloc::vec::Vec, #[prost(enumeration = "identity_request::Type", tag = "2")] pub request_type: i32, } /// Nested message and enum types in `IdentityRequest`. pub mod identity_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive( Clone, Copy, @@ -927,8 +771,6 @@ pub mod get_proofs_request { } } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -937,8 +779,6 @@ pub mod get_proofs_request { pub contract_id: ::prost::alloc::vec::Vec, } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -946,8 +786,6 @@ pub mod get_proofs_request { V0(GetProofsRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive( ::dapi_grpc_macros::VersionedGrpcMessage, ::dapi_grpc_macros::VersionedGrpcResponse @@ -962,8 +800,6 @@ pub struct GetProofsResponse { } /// Nested message and enum types in `GetProofsResponse`. pub mod get_proofs_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -975,8 +811,6 @@ pub mod get_proofs_response { } /// Nested message and enum types in `GetProofsResponseV0`. pub mod get_proofs_response_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { @@ -984,8 +818,6 @@ pub mod get_proofs_response { Proof(super::super::Proof), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -993,8 +825,6 @@ pub mod get_proofs_response { V0(GetProofsResponseV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::VersionedGrpcMessage)] #[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] @@ -1006,20 +836,15 @@ pub struct GetDataContractRequest { } /// Nested message and enum types in `GetDataContractRequest`. pub mod get_data_contract_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetDataContractRequestV0 { #[prost(bytes = "vec", tag = "1")] - #[serde(with = "serde_bytes")] pub id: ::prost::alloc::vec::Vec, #[prost(bool, tag = "2")] pub prove: bool, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -1027,8 +852,6 @@ pub mod get_data_contract_request { V0(GetDataContractRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive( ::dapi_grpc_macros::VersionedGrpcMessage, ::dapi_grpc_macros::VersionedGrpcResponse @@ -1043,8 +866,6 @@ pub struct GetDataContractResponse { } /// Nested message and enum types in `GetDataContractResponse`. pub mod get_data_contract_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1056,8 +877,6 @@ pub mod get_data_contract_response { } /// Nested message and enum types in `GetDataContractResponseV0`. pub mod get_data_contract_response_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { @@ -1067,8 +886,6 @@ pub mod get_data_contract_response { Proof(super::super::Proof), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -1076,8 +893,6 @@ pub mod get_data_contract_response { V0(GetDataContractResponseV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::VersionedGrpcMessage)] #[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] @@ -1089,20 +904,15 @@ pub struct GetDataContractsRequest { } /// Nested message and enum types in `GetDataContractsRequest`. pub mod get_data_contracts_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetDataContractsRequestV0 { #[prost(bytes = "vec", repeated, tag = "1")] - #[serde(with = "crate::deserialization::vec_base64string")] pub ids: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, #[prost(bool, tag = "2")] pub prove: bool, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -1110,8 +920,6 @@ pub mod get_data_contracts_request { V0(GetDataContractsRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive( ::dapi_grpc_macros::VersionedGrpcMessage, ::dapi_grpc_macros::VersionedGrpcResponse @@ -1126,8 +934,6 @@ pub struct GetDataContractsResponse { } /// Nested message and enum types in `GetDataContractsResponse`. pub mod get_data_contracts_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1137,8 +943,6 @@ pub mod get_data_contracts_response { #[prost(message, optional, tag = "2")] pub data_contract: ::core::option::Option<::prost::alloc::vec::Vec>, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1146,8 +950,6 @@ pub mod get_data_contracts_response { #[prost(message, repeated, tag = "1")] pub data_contract_entries: ::prost::alloc::vec::Vec, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1159,8 +961,6 @@ pub mod get_data_contracts_response { } /// Nested message and enum types in `GetDataContractsResponseV0`. pub mod get_data_contracts_response_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { @@ -1170,8 +970,6 @@ pub mod get_data_contracts_response { Proof(super::super::Proof), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -1179,8 +977,6 @@ pub mod get_data_contracts_response { V0(GetDataContractsResponseV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::VersionedGrpcMessage)] #[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] @@ -1192,27 +988,21 @@ pub struct GetDataContractHistoryRequest { } /// Nested message and enum types in `GetDataContractHistoryRequest`. pub mod get_data_contract_history_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetDataContractHistoryRequestV0 { #[prost(bytes = "vec", tag = "1")] - #[serde(with = "serde_bytes")] pub id: ::prost::alloc::vec::Vec, #[prost(message, optional, tag = "2")] pub limit: ::core::option::Option, #[prost(message, optional, tag = "3")] pub offset: ::core::option::Option, #[prost(uint64, tag = "4")] - #[serde(with = "crate::deserialization::from_to_string")] pub start_at_ms: u64, #[prost(bool, tag = "5")] pub prove: bool, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -1220,8 +1010,6 @@ pub mod get_data_contract_history_request { V0(GetDataContractHistoryRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive( ::dapi_grpc_macros::VersionedGrpcMessage, ::dapi_grpc_macros::VersionedGrpcResponse @@ -1236,8 +1024,6 @@ pub struct GetDataContractHistoryResponse { } /// Nested message and enum types in `GetDataContractHistoryResponse`. pub mod get_data_contract_history_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1251,8 +1037,6 @@ pub mod get_data_contract_history_response { } /// Nested message and enum types in `GetDataContractHistoryResponseV0`. pub mod get_data_contract_history_response_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1262,8 +1046,6 @@ pub mod get_data_contract_history_response { #[prost(bytes = "vec", tag = "2")] pub value: ::prost::alloc::vec::Vec, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1273,8 +1055,6 @@ pub mod get_data_contract_history_response { DataContractHistoryEntry, >, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { @@ -1284,8 +1064,6 @@ pub mod get_data_contract_history_response { Proof(super::super::Proof), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -1293,8 +1071,6 @@ pub mod get_data_contract_history_response { V0(GetDataContractHistoryResponseV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::VersionedGrpcMessage)] #[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] @@ -1306,22 +1082,17 @@ pub struct GetDocumentsRequest { } /// Nested message and enum types in `GetDocumentsRequest`. pub mod get_documents_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetDocumentsRequestV0 { #[prost(bytes = "vec", tag = "1")] - #[serde(with = "serde_bytes")] pub data_contract_id: ::prost::alloc::vec::Vec, #[prost(string, tag = "2")] pub document_type: ::prost::alloc::string::String, #[prost(bytes = "vec", tag = "3")] - #[serde(with = "serde_bytes")] pub r#where: ::prost::alloc::vec::Vec, #[prost(bytes = "vec", tag = "4")] - #[serde(with = "serde_bytes")] pub order_by: ::prost::alloc::vec::Vec, #[prost(uint32, tag = "5")] pub limit: u32, @@ -1332,8 +1103,6 @@ pub mod get_documents_request { } /// Nested message and enum types in `GetDocumentsRequestV0`. pub mod get_documents_request_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Start { @@ -1343,8 +1112,6 @@ pub mod get_documents_request { StartAt(::prost::alloc::vec::Vec), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -1352,8 +1119,6 @@ pub mod get_documents_request { V0(GetDocumentsRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive( ::dapi_grpc_macros::VersionedGrpcMessage, ::dapi_grpc_macros::VersionedGrpcResponse @@ -1368,8 +1133,6 @@ pub struct GetDocumentsResponse { } /// Nested message and enum types in `GetDocumentsResponse`. pub mod get_documents_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1381,8 +1144,6 @@ pub mod get_documents_response { } /// Nested message and enum types in `GetDocumentsResponseV0`. pub mod get_documents_response_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1390,8 +1151,6 @@ pub mod get_documents_response { #[prost(bytes = "vec", repeated, tag = "1")] pub documents: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { @@ -1401,8 +1160,6 @@ pub mod get_documents_response { Proof(super::super::Proof), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -1410,8 +1167,6 @@ pub mod get_documents_response { V0(GetDocumentsResponseV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::VersionedGrpcMessage)] #[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] @@ -1425,20 +1180,15 @@ pub struct GetIdentitiesByPublicKeyHashesRequest { } /// Nested message and enum types in `GetIdentitiesByPublicKeyHashesRequest`. pub mod get_identities_by_public_key_hashes_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetIdentitiesByPublicKeyHashesRequestV0 { #[prost(bytes = "vec", repeated, tag = "1")] - #[serde(with = "crate::deserialization::vec_base64string")] pub public_key_hashes: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, #[prost(bool, tag = "2")] pub prove: bool, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -1446,8 +1196,6 @@ pub mod get_identities_by_public_key_hashes_request { V0(GetIdentitiesByPublicKeyHashesRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive( ::dapi_grpc_macros::VersionedGrpcMessage, ::dapi_grpc_macros::VersionedGrpcResponse @@ -1464,20 +1212,15 @@ pub struct GetIdentitiesByPublicKeyHashesResponse { } /// Nested message and enum types in `GetIdentitiesByPublicKeyHashesResponse`. pub mod get_identities_by_public_key_hashes_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct PublicKeyHashIdentityEntry { #[prost(bytes = "vec", tag = "1")] - #[serde(with = "serde_bytes")] pub public_key_hash: ::prost::alloc::vec::Vec, #[prost(message, optional, tag = "2")] pub value: ::core::option::Option<::prost::alloc::vec::Vec>, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1485,8 +1228,6 @@ pub mod get_identities_by_public_key_hashes_response { #[prost(message, repeated, tag = "1")] pub identity_entries: ::prost::alloc::vec::Vec, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1503,8 +1244,6 @@ pub mod get_identities_by_public_key_hashes_response { } /// Nested message and enum types in `GetIdentitiesByPublicKeyHashesResponseV0`. pub mod get_identities_by_public_key_hashes_response_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { @@ -1514,8 +1253,6 @@ pub mod get_identities_by_public_key_hashes_response { Proof(super::super::Proof), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -1523,8 +1260,6 @@ pub mod get_identities_by_public_key_hashes_response { V0(GetIdentitiesByPublicKeyHashesResponseV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::VersionedGrpcMessage)] #[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] @@ -1538,20 +1273,15 @@ pub struct GetIdentityByPublicKeyHashRequest { } /// Nested message and enum types in `GetIdentityByPublicKeyHashRequest`. pub mod get_identity_by_public_key_hash_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetIdentityByPublicKeyHashRequestV0 { #[prost(bytes = "vec", tag = "1")] - #[serde(with = "serde_bytes")] pub public_key_hash: ::prost::alloc::vec::Vec, #[prost(bool, tag = "2")] pub prove: bool, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -1559,8 +1289,6 @@ pub mod get_identity_by_public_key_hash_request { V0(GetIdentityByPublicKeyHashRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive( ::dapi_grpc_macros::VersionedGrpcMessage, ::dapi_grpc_macros::VersionedGrpcResponse @@ -1577,8 +1305,6 @@ pub struct GetIdentityByPublicKeyHashResponse { } /// Nested message and enum types in `GetIdentityByPublicKeyHashResponse`. pub mod get_identity_by_public_key_hash_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1595,8 +1321,6 @@ pub mod get_identity_by_public_key_hash_response { } /// Nested message and enum types in `GetIdentityByPublicKeyHashResponseV0`. pub mod get_identity_by_public_key_hash_response_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { @@ -1606,8 +1330,6 @@ pub mod get_identity_by_public_key_hash_response { Proof(super::super::Proof), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -1615,8 +1337,6 @@ pub mod get_identity_by_public_key_hash_response { V0(GetIdentityByPublicKeyHashResponseV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::VersionedGrpcMessage)] #[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] @@ -1630,8 +1350,6 @@ pub struct WaitForStateTransitionResultRequest { } /// Nested message and enum types in `WaitForStateTransitionResultRequest`. pub mod wait_for_state_transition_result_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1641,8 +1359,6 @@ pub mod wait_for_state_transition_result_request { #[prost(bool, tag = "2")] pub prove: bool, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -1650,8 +1366,6 @@ pub mod wait_for_state_transition_result_request { V0(WaitForStateTransitionResultRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive( ::dapi_grpc_macros::VersionedGrpcMessage, ::dapi_grpc_macros::VersionedGrpcResponse @@ -1668,8 +1382,6 @@ pub struct WaitForStateTransitionResultResponse { } /// Nested message and enum types in `WaitForStateTransitionResultResponse`. pub mod wait_for_state_transition_result_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1686,8 +1398,6 @@ pub mod wait_for_state_transition_result_response { } /// Nested message and enum types in `WaitForStateTransitionResultResponseV0`. pub mod wait_for_state_transition_result_response_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { @@ -1697,8 +1407,6 @@ pub mod wait_for_state_transition_result_response { Proof(super::super::Proof), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -1706,8 +1414,6 @@ pub mod wait_for_state_transition_result_response { V0(WaitForStateTransitionResultResponseV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1717,8 +1423,6 @@ pub struct GetConsensusParamsRequest { } /// Nested message and enum types in `GetConsensusParamsRequest`. pub mod get_consensus_params_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1728,8 +1432,6 @@ pub mod get_consensus_params_request { #[prost(bool, tag = "2")] pub prove: bool, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -1737,8 +1439,6 @@ pub mod get_consensus_params_request { V0(GetConsensusParamsRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1748,8 +1448,6 @@ pub struct GetConsensusParamsResponse { } /// Nested message and enum types in `GetConsensusParamsResponse`. pub mod get_consensus_params_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1761,8 +1459,6 @@ pub mod get_consensus_params_response { #[prost(string, tag = "3")] pub time_iota_ms: ::prost::alloc::string::String, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1774,8 +1470,6 @@ pub mod get_consensus_params_response { #[prost(string, tag = "3")] pub max_bytes: ::prost::alloc::string::String, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1785,8 +1479,6 @@ pub mod get_consensus_params_response { #[prost(message, optional, tag = "2")] pub evidence: ::core::option::Option, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -1794,8 +1486,6 @@ pub mod get_consensus_params_response { V0(GetConsensusParamsResponseV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::VersionedGrpcMessage)] #[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] @@ -1809,8 +1499,6 @@ pub struct GetProtocolVersionUpgradeStateRequest { } /// Nested message and enum types in `GetProtocolVersionUpgradeStateRequest`. pub mod get_protocol_version_upgrade_state_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1818,8 +1506,6 @@ pub mod get_protocol_version_upgrade_state_request { #[prost(bool, tag = "1")] pub prove: bool, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -1827,8 +1513,6 @@ pub mod get_protocol_version_upgrade_state_request { V0(GetProtocolVersionUpgradeStateRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive( ::dapi_grpc_macros::VersionedGrpcMessage, ::dapi_grpc_macros::VersionedGrpcResponse @@ -1845,8 +1529,6 @@ pub struct GetProtocolVersionUpgradeStateResponse { } /// Nested message and enum types in `GetProtocolVersionUpgradeStateResponse`. pub mod get_protocol_version_upgrade_state_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1863,8 +1545,6 @@ pub mod get_protocol_version_upgrade_state_response { } /// Nested message and enum types in `GetProtocolVersionUpgradeStateResponseV0`. pub mod get_protocol_version_upgrade_state_response_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1872,8 +1552,6 @@ pub mod get_protocol_version_upgrade_state_response { #[prost(message, repeated, tag = "1")] pub versions: ::prost::alloc::vec::Vec, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1883,8 +1561,6 @@ pub mod get_protocol_version_upgrade_state_response { #[prost(uint32, tag = "2")] pub vote_count: u32, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { @@ -1894,8 +1570,6 @@ pub mod get_protocol_version_upgrade_state_response { Proof(super::super::Proof), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -1903,8 +1577,6 @@ pub mod get_protocol_version_upgrade_state_response { V0(GetProtocolVersionUpgradeStateResponseV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::VersionedGrpcMessage)] #[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] @@ -1921,8 +1593,6 @@ pub struct GetProtocolVersionUpgradeVoteStatusRequest { } /// Nested message and enum types in `GetProtocolVersionUpgradeVoteStatusRequest`. pub mod get_protocol_version_upgrade_vote_status_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1934,8 +1604,6 @@ pub mod get_protocol_version_upgrade_vote_status_request { #[prost(bool, tag = "3")] pub prove: bool, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -1943,8 +1611,6 @@ pub mod get_protocol_version_upgrade_vote_status_request { V0(GetProtocolVersionUpgradeVoteStatusRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive( ::dapi_grpc_macros::VersionedGrpcMessage, ::dapi_grpc_macros::VersionedGrpcResponse @@ -1964,8 +1630,6 @@ pub struct GetProtocolVersionUpgradeVoteStatusResponse { } /// Nested message and enum types in `GetProtocolVersionUpgradeVoteStatusResponse`. pub mod get_protocol_version_upgrade_vote_status_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1982,8 +1646,6 @@ pub mod get_protocol_version_upgrade_vote_status_response { } /// Nested message and enum types in `GetProtocolVersionUpgradeVoteStatusResponseV0`. pub mod get_protocol_version_upgrade_vote_status_response_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -1991,8 +1653,6 @@ pub mod get_protocol_version_upgrade_vote_status_response { #[prost(message, repeated, tag = "1")] pub version_signals: ::prost::alloc::vec::Vec, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2002,8 +1662,6 @@ pub mod get_protocol_version_upgrade_vote_status_response { #[prost(uint32, tag = "2")] pub version: u32, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { @@ -2013,8 +1671,6 @@ pub mod get_protocol_version_upgrade_vote_status_response { Proof(super::super::Proof), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -2022,8 +1678,6 @@ pub mod get_protocol_version_upgrade_vote_status_response { V0(GetProtocolVersionUpgradeVoteStatusResponseV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2033,8 +1687,6 @@ pub struct GetEpochsInfoRequest { } /// Nested message and enum types in `GetEpochsInfoRequest`. pub mod get_epochs_info_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2048,8 +1700,6 @@ pub mod get_epochs_info_request { #[prost(bool, tag = "4")] pub prove: bool, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -2057,8 +1707,6 @@ pub mod get_epochs_info_request { V0(GetEpochsInfoRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive( ::dapi_grpc_macros::VersionedGrpcMessage, ::dapi_grpc_macros::VersionedGrpcResponse @@ -2073,8 +1721,6 @@ pub struct GetEpochsInfoResponse { } /// Nested message and enum types in `GetEpochsInfoResponse`. pub mod get_epochs_info_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2086,8 +1732,6 @@ pub mod get_epochs_info_response { } /// Nested message and enum types in `GetEpochsInfoResponseV0`. pub mod get_epochs_info_response_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2095,8 +1739,6 @@ pub mod get_epochs_info_response { #[prost(message, repeated, tag = "1")] pub epoch_infos: ::prost::alloc::vec::Vec, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2114,8 +1756,6 @@ pub mod get_epochs_info_response { #[prost(uint32, tag = "6")] pub protocol_version: u32, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { @@ -2125,8 +1765,6 @@ pub mod get_epochs_info_response { Proof(super::super::Proof), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -2134,8 +1772,6 @@ pub mod get_epochs_info_response { V0(GetEpochsInfoResponseV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2145,8 +1781,6 @@ pub struct GetContestedResourcesRequest { } /// Nested message and enum types in `GetContestedResourcesRequest`. pub mod get_contested_resources_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2164,8 +1798,6 @@ pub mod get_contested_resources_request { #[prost(bool, optional, tag = "5")] pub ascending: ::core::option::Option, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -2173,8 +1805,6 @@ pub mod get_contested_resources_request { V0(GetContestedResourcesRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2184,8 +1814,6 @@ pub struct GetContestedResourcesResponse { } /// Nested message and enum types in `GetContestedResourcesResponse`. pub mod get_contested_resources_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2197,8 +1825,6 @@ pub mod get_contested_resources_response { } /// Nested message and enum types in `GetContestedResourcesResponseV0`. pub mod get_contested_resources_response_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2208,8 +1834,6 @@ pub mod get_contested_resources_response { #[prost(bool, tag = "2")] pub finished_results: bool, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2217,8 +1841,6 @@ pub mod get_contested_resources_response { #[prost(bytes = "vec", tag = "1")] pub identifier: ::prost::alloc::vec::Vec, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { @@ -2228,8 +1850,6 @@ pub mod get_contested_resources_response { Proof(super::super::Proof), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -2237,8 +1857,6 @@ pub mod get_contested_resources_response { V0(GetContestedResourcesResponseV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2250,8 +1868,6 @@ pub struct GetContestedResourceVoteStateRequest { } /// Nested message and enum types in `GetContestedResourceVoteStateRequest`. pub mod get_contested_resource_vote_state_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2269,8 +1885,6 @@ pub mod get_contested_resource_vote_state_request { #[prost(bool, optional, tag = "6")] pub ascending: ::core::option::Option, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -2278,8 +1892,6 @@ pub mod get_contested_resource_vote_state_request { V0(GetContestedResourceVoteStateRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2291,8 +1903,6 @@ pub struct GetContestedResourceVoteStateResponse { } /// Nested message and enum types in `GetContestedResourceVoteStateResponse`. pub mod get_contested_resource_vote_state_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2309,8 +1919,6 @@ pub mod get_contested_resource_vote_state_response { } /// Nested message and enum types in `GetContestedResourceVoteStateResponseV0`. pub mod get_contested_resource_vote_state_response_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2320,8 +1928,6 @@ pub mod get_contested_resource_vote_state_response { #[prost(bool, tag = "2")] pub finished_results: bool, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2331,8 +1937,6 @@ pub mod get_contested_resource_vote_state_response { #[prost(uint32, tag = "2")] pub vote_count: u32, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { @@ -2342,8 +1946,6 @@ pub mod get_contested_resource_vote_state_response { Proof(super::super::Proof), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -2351,8 +1953,6 @@ pub mod get_contested_resource_vote_state_response { V0(GetContestedResourceVoteStateResponseV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2364,8 +1964,6 @@ pub struct GetContestedResourceVoteStatusRequest { } /// Nested message and enum types in `GetContestedResourceVoteStatusRequest`. pub mod get_contested_resource_vote_status_request { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2383,8 +1981,6 @@ pub mod get_contested_resource_vote_status_request { #[prost(bool, optional, tag = "6")] pub ascending: ::core::option::Option, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -2392,8 +1988,6 @@ pub mod get_contested_resource_vote_status_request { V0(GetContestedResourceVoteStatusRequestV0), } } -#[derive(::serde::Serialize, ::serde::Deserialize)] -#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2405,8 +1999,6 @@ pub struct GetContestedResourceVoteStatusResponse { } /// Nested message and enum types in `GetContestedResourceVoteStatusResponse`. pub mod get_contested_resource_vote_status_response { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2423,8 +2015,6 @@ pub mod get_contested_resource_vote_status_response { } /// Nested message and enum types in `GetContestedResourceVoteStatusResponseV0`. pub mod get_contested_resource_vote_status_response_v0 { - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2434,8 +2024,6 @@ pub mod get_contested_resource_vote_status_response { #[prost(bool, tag = "2")] pub finished_results: bool, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2443,8 +2031,6 @@ pub mod get_contested_resource_vote_status_response { #[prost(bytes = "vec", tag = "1")] pub identifier: ::prost::alloc::vec::Vec, } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { @@ -2454,8 +2040,6 @@ pub mod get_contested_resource_vote_status_response { Proof(super::super::Proof), } } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { @@ -2463,782 +2047,6 @@ pub mod get_contested_resource_vote_status_response { V0(GetContestedResourceVoteStatusResponseV0), } } -/// Generated client implementations. -pub mod platform_client { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; - use tonic::codegen::http::Uri; - #[derive(Debug, Clone)] - pub struct PlatformClient { - inner: tonic::client::Grpc, - } - impl PlatformClient { - /// Attempt to create a new client by connecting to a given endpoint. - pub async fn connect(dst: D) -> Result - where - D: TryInto, - D::Error: Into, - { - let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; - Ok(Self::new(conn)) - } - } - impl PlatformClient - where - T: tonic::client::GrpcService, - T::Error: Into, - T::ResponseBody: Body + Send + 'static, - ::Error: Into + Send, - { - pub fn new(inner: T) -> Self { - let inner = tonic::client::Grpc::new(inner); - Self { inner } - } - pub fn with_origin(inner: T, origin: Uri) -> Self { - let inner = tonic::client::Grpc::with_origin(inner, origin); - Self { inner } - } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> PlatformClient> - where - F: tonic::service::Interceptor, - T::ResponseBody: Default, - T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, - >, - , - >>::Error: Into + Send + Sync, - { - PlatformClient::new(InterceptedService::new(inner, interceptor)) - } - /// Compress requests with the given encoding. - /// - /// This requires the server to support it otherwise it might respond with an - /// error. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.send_compressed(encoding); - self - } - /// Enable decompressing responses. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.accept_compressed(encoding); - self - } - /// Limits the maximum size of a decoded message. - /// - /// Default: `4MB` - #[must_use] - pub fn max_decoding_message_size(mut self, limit: usize) -> Self { - self.inner = self.inner.max_decoding_message_size(limit); - self - } - /// Limits the maximum size of an encoded message. - /// - /// Default: `usize::MAX` - #[must_use] - pub fn max_encoding_message_size(mut self, limit: usize) -> Self { - self.inner = self.inner.max_encoding_message_size(limit); - self - } - pub async fn broadcast_state_transition( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/broadcastStateTransition", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Platform", - "broadcastStateTransition", - ), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_identity( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getIdentity", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new("org.dash.platform.dapi.v0.Platform", "getIdentity"), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_identities( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getIdentities", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Platform", - "getIdentities", - ), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_identity_keys( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getIdentityKeys", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Platform", - "getIdentityKeys", - ), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_identity_nonce( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getIdentityNonce", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Platform", - "getIdentityNonce", - ), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_identity_contract_nonce( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getIdentityContractNonce", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Platform", - "getIdentityContractNonce", - ), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_identity_balance( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getIdentityBalance", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Platform", - "getIdentityBalance", - ), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_identity_balance_and_revision( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getIdentityBalanceAndRevision", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Platform", - "getIdentityBalanceAndRevision", - ), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_proofs( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getProofs", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new("org.dash.platform.dapi.v0.Platform", "getProofs"), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_data_contract( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getDataContract", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Platform", - "getDataContract", - ), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_data_contract_history( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getDataContractHistory", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Platform", - "getDataContractHistory", - ), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_data_contracts( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getDataContracts", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Platform", - "getDataContracts", - ), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_documents( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getDocuments", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new("org.dash.platform.dapi.v0.Platform", "getDocuments"), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_identities_by_public_key_hashes( - &mut self, - request: impl tonic::IntoRequest< - super::GetIdentitiesByPublicKeyHashesRequest, - >, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getIdentitiesByPublicKeyHashes", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Platform", - "getIdentitiesByPublicKeyHashes", - ), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_identity_by_public_key_hash( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getIdentityByPublicKeyHash", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Platform", - "getIdentityByPublicKeyHash", - ), - ); - self.inner.unary(req, path, codec).await - } - pub async fn wait_for_state_transition_result( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/waitForStateTransitionResult", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Platform", - "waitForStateTransitionResult", - ), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_consensus_params( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getConsensusParams", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Platform", - "getConsensusParams", - ), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_protocol_version_upgrade_state( - &mut self, - request: impl tonic::IntoRequest< - super::GetProtocolVersionUpgradeStateRequest, - >, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getProtocolVersionUpgradeState", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Platform", - "getProtocolVersionUpgradeState", - ), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_protocol_version_upgrade_vote_status( - &mut self, - request: impl tonic::IntoRequest< - super::GetProtocolVersionUpgradeVoteStatusRequest, - >, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getProtocolVersionUpgradeVoteStatus", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Platform", - "getProtocolVersionUpgradeVoteStatus", - ), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_epochs_info( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getEpochsInfo", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Platform", - "getEpochsInfo", - ), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_contested_resources( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getContestedResources", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Platform", - "getContestedResources", - ), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_contested_resource_vote_state( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getContestedResourceVoteState", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Platform", - "getContestedResourceVoteState", - ), - ); - self.inner.unary(req, path, codec).await - } - pub async fn get_contested_resource_vote_status( - &mut self, - request: impl tonic::IntoRequest< - super::GetContestedResourceVoteStatusRequest, - >, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getContestedResourceVoteStatus", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "org.dash.platform.dapi.v0.Platform", - "getContestedResourceVoteStatus", - ), - ); - self.inner.unary(req, path, codec).await - } - } -} /// Generated server implementations. pub mod platform_server { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/fields.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/fields.rs index e278176f74..7c29ab10e2 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/fields.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/fields.rs @@ -2,7 +2,7 @@ use crate::state_transition::state_transitions; use crate::state_transition::masternode_vote_transition::fields::property_names::PRO_TX_HASH; pub use state_transitions::common_fields::property_names::{ - ENTROPY, SIGNATURE, SIGNATURE_PUBLIC_KEY_ID, STATE_TRANSITION_PROTOCOL_VERSION, TRANSITION_TYPE, + SIGNATURE, SIGNATURE_PUBLIC_KEY_ID, STATE_TRANSITION_PROTOCOL_VERSION, TRANSITION_TYPE, }; pub use state_transitions::identity::common_fields::property_names::IDENTITY_ID; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs index bc9b182feb..40ebf82e4c 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs @@ -18,7 +18,6 @@ use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTrans use crate::state_transition::StateTransitionFieldTypes; use crate::identity::state_transition::OptionallyAssetLockProved; -use crate::state_transition::data_contract_update_transition::DataContractUpdateTransition; use crate::ProtocolError; use bincode::{Decode, Encode}; use derive_more::From; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/state_transition_like.rs index d950bc4b42..2e4c23d607 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/state_transition_like.rs @@ -2,6 +2,7 @@ use crate::state_transition::masternode_vote_transition::MasternodeVoteTransitio use crate::state_transition::{StateTransitionLike, StateTransitionType}; use crate::version::FeatureVersion; use platform_value::{BinaryData, Identifier}; +use crate::prelude::UserFeeIncrease; impl StateTransitionLike for MasternodeVoteTransition { /// Returns ID of the credit_transferred contract @@ -52,4 +53,16 @@ impl StateTransitionLike for MasternodeVoteTransition { MasternodeVoteTransition::V0(transition) => transition.unique_identifiers(), } } + + fn user_fee_increase(&self) -> UserFeeIncrease { + match self { + MasternodeVoteTransition::V0(transition) => transition.user_fee_increase(), + } + } + + fn set_user_fee_increase(&mut self, fee_multiplier: UserFeeIncrease) { + match self { + MasternodeVoteTransition::V0(transition) => transition.set_user_fee_increase(fee_multiplier), + } + } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/state_transition_like.rs index 1e64415b0e..8841d1fd79 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/state_transition_like.rs @@ -1,9 +1,12 @@ +use base64::Engine; +use base64::prelude::BASE64_STANDARD; use platform_value::BinaryData; use crate::{ prelude::Identifier, state_transition::{StateTransitionLike, StateTransitionType}, }; +use crate::prelude::UserFeeIncrease; use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; use crate::state_transition::masternode_vote_transition::MasternodeVoteTransition; @@ -36,6 +39,16 @@ impl StateTransitionLike for MasternodeVoteTransitionV0 { fn set_signature(&mut self, signature: BinaryData) { self.signature = signature } + + fn user_fee_increase(&self) -> UserFeeIncrease { + // The user fee increase for a masternode vote is always 0 + 0 + } + + fn set_user_fee_increase(&mut self, _fee_multiplier: UserFeeIncrease) { + // Setting does nothing + } + /// Returns ID of the created contract fn modified_data_ids(&self) -> Vec { vec![self.pro_tx_hash] @@ -53,7 +66,7 @@ impl StateTransitionLike for MasternodeVoteTransitionV0 { fn unique_identifiers(&self) -> Vec { vec![format!( "{}-{:x}", - base64::encode(self.pro_tx_hash), + BASE64_STANDARD.encode(self.pro_tx_hash), self.nonce )] } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/types.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/types.rs index 59fcb2f0ed..da9ee6d3be 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/types.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/types.rs @@ -1,4 +1,3 @@ -use crate::state_transition::masternode_vote_transition::fields::property_names::*; use crate::state_transition::masternode_vote_transition::fields::*; use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; use crate::state_transition::StateTransitionFieldTypes; diff --git a/packages/rs-dpp/src/voting/mod.rs b/packages/rs-dpp/src/voting/mod.rs index f685e11e00..2854707e13 100644 --- a/packages/rs-dpp/src/voting/mod.rs +++ b/packages/rs-dpp/src/voting/mod.rs @@ -1,6 +1,3 @@ -use crate::data_contract::accessors::v0::DataContractV0Getters; -use crate::data_contract::document_type::accessors::DocumentTypeV0Getters; -use crate::prelude::DataContract; use crate::voting::resource_vote::ResourceVote; use crate::voting::Vote::ContestedDocumentResourceVote; use crate::ProtocolError; diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 61ac4a6222..14c7909b52 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -664,13 +664,13 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { transform_into_action: 0, }, masternode_vote_state_transition: DriveAbciStateTransitionValidationVersion { - base_structure: 0, + basic_structure: Some(0), + advanced_structure: None, identity_signatures: None, - balance: None, + advanced_minimum_balance_pre_check: None, nonce: Some(0), state: 0, transform_into_action: 0, - advanced_structure: None }, contract_create_state_transition: DriveAbciStateTransitionValidationVersion { basic_structure: Some(0), From 8467a192940440c812ceefa58cd9fc02b8939f56 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 15 Apr 2024 08:41:09 +0700 Subject: [PATCH 028/135] more work --- .../rs-dpp/src/data_contract/document_type/index/mod.rs | 8 +++----- .../v0/mod.rs | 2 +- .../rs-drive/src/drive/object_size_info/path_key_info.rs | 3 --- .../drive/votes/cleanup/remove_votes_for_identity/mod.rs | 2 -- .../votes/insert/add_new_masternode_vote_type/mod.rs | 2 +- .../src/drive/votes/insert/register_identity_vote/mod.rs | 8 ++++---- .../drive/votes/insert/register_identity_vote/v0/mod.rs | 8 +++++++- packages/rs-drive/src/drive/votes/mod.rs | 4 +--- .../identity/masternode_vote/v0/mod.rs | 1 - 9 files changed, 17 insertions(+), 21 deletions(-) diff --git a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs index 016aa19bb3..a582dd9543 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs @@ -264,7 +264,7 @@ impl TryFrom<&[(Value, Value)]> for Index { for (contested_key_value, contested_value) in contested_properties_value_map { let contested_key = contested_key_value .to_str() - .map_err(ProtocolError::ValueError)?; + .map_err(|e| DataContractError::ValueDecodingError(e.to_string()))?; match contested_key { "regexPattern" => { let regex = contested_value.to_str()?.to_owned(); @@ -282,13 +282,11 @@ impl TryFrom<&[(Value, Value)]> for Index { "resolution" => { let resolution_int = contested_value.to_integer::()?; contested_index_information.resolution = - resolution_int.try_into()?; + resolution_int.try_into().map_err(|e: ProtocolError| DataContractError::ValueWrongType(e.to_string()))?; } "description" => {} _ => { - return Err(ProtocolError::StructureError( - StructureError::ValueWrongType("unexpected contested key"), - )) + return Err(DataContractError::ValueWrongType("unexpected contested key".to_string())); } } } diff --git a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs index 72061606a8..298b732528 100644 --- a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -9,7 +9,7 @@ use crate::drive::object_size_info::DocumentInfo::{ }; use crate::drive::object_size_info::DriveKeyInfo::{Key, KeyRef}; use crate::drive::object_size_info::KeyElementInfo::{KeyElement, KeyUnknownElementSize}; -use crate::drive::object_size_info::{DocumentAndContractInfo, PathInfo, PathKeyElementInfo, PathKeyInfo}; +use crate::drive::object_size_info::{DocumentAndContractInfo, PathInfo, PathKeyElementInfo}; use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; diff --git a/packages/rs-drive/src/drive/object_size_info/path_key_info.rs b/packages/rs-drive/src/drive/object_size_info/path_key_info.rs index 6290f83bf7..6589cf2ce7 100644 --- a/packages/rs-drive/src/drive/object_size_info/path_key_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/path_key_info.rs @@ -132,9 +132,6 @@ impl<'a, const N: usize> PathKeyInfo<'a, N> { } /// Get the KeyInfoPath for grovedb estimated costs - #[allow(dead_code)] - #[deprecated(note = "This function is marked as unused.")] - #[allow(deprecated)] pub(crate) fn convert_to_key_info_path(self) -> Result { match self { PathKey((path, key)) => { diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs index 5ff3050774..bbc8ce49bf 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs @@ -5,8 +5,6 @@ use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; -use dpp::fee::fee_result::FeeResult; - use dpp::prelude::Identifier; use dpp::version::PlatformVersion; use grovedb::TransactionArg; diff --git a/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/mod.rs b/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/mod.rs index 6fc21ae4b7..a77c4d994e 100644 --- a/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/mod.rs @@ -41,7 +41,7 @@ impl Drive { platform_version: &PlatformVersion, ) -> Result { match platform_version.drive.methods.document.insert.add_document { - 0 => self.add_document_v0( + 0 => self.add_new_masternode_vote_type_v0( owned_document_info, data_contract_id, document_type_name, diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs index 581585c611..2e8d52effd 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs @@ -13,7 +13,7 @@ use grovedb::TransactionArg; use dpp::block::block_info::BlockInfo; impl Drive { - pub fn register_identity_vote( + pub fn register_identity_vote_for_identity_queries( &self, vote: Vote, block_info: &BlockInfo, @@ -26,11 +26,11 @@ impl Drive { .methods .vote .contested_resource_insert - .register_identity_vote + .register_identity_vote_for_identity_queries { - 0 => self.register_identity_vote_v0(vote, block_info, apply, transaction, platform_version), + 0 => self.register_identity_vote_for_identity_queries_v0(vote, block_info, apply, transaction, platform_version), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "register_identity_vote".to_string(), + method: "register_identity_vote_for_identity_queries".to_string(), known_versions: vec![0], received: version, })), diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs index b811bd05cb..a0e14a373f 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs @@ -4,13 +4,17 @@ use dpp::fee::fee_result::FeeResult; use dpp::voting::Vote; use grovedb::TransactionArg; use dpp::block::block_info::BlockInfo; +use dpp::identifier::Identifier; +use dpp::prelude::IdentityNonce; use platform_version::version::PlatformVersion; impl Drive { - pub fn register_identity_vote_v0( + pub fn register_identity_vote_for_identity_queries_v0( &self, + voter_pro_tx_hash: Identifier, vote: Vote, block_info: &BlockInfo, + identity_nonce: IdentityNonce, apply: bool, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -18,8 +22,10 @@ impl Drive { match vote { Vote::ContestedDocumentResourceVote(contested_document_resource_vote_type) => self .register_contested_resource_identity_vote( + voter_pro_tx_hash, contested_document_resource_vote_type, block_info, + identity_nonce, apply, transaction, platform_version, diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 31d45d2cf8..3415bce0d0 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -1,10 +1,8 @@ -use crate::drive::document::{contract_document_type_path, contract_document_type_path_vec}; +use crate::drive::document::contract_document_type_path; use crate::drive::RootTree; -use dpp::consensus::basic::data_contract::DuplicateIndexError; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::DataContract; -use dpp::util::vec; use dpp::voting::ContestedDocumentResourceVoteType; use dpp::ProtocolError; diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs index 4c99cd8a4d..22cc929554 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs @@ -2,7 +2,6 @@ mod transformer; use dpp::platform_value::Identifier; use dpp::voting::Vote; -use serde::{Deserialize, Serialize}; /// action v0 #[derive(Default, Debug, Clone)] From 8980d2ed0c79b4718cf04777babee3838a6298fe Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 28 Apr 2024 07:37:47 +0700 Subject: [PATCH 029/135] more work on the actions --- .../masternode_vote/structure/v0/mod.rs | 1 - .../drive/batch/drive_op_batch/identity.rs | 16 +++---- .../identity/masternode_vote_transition.rs | 32 ++++++++++++++ .../drive/batch/transitions/identity/mod.rs | 1 + .../contested_resource/individual_vote/mod.rs | 1 - .../mod.rs | 8 +--- .../v0/mod.rs | 8 ++-- .../mod.rs | 43 ------------------- .../v0/mod.rs | 1 - .../add_vote_poll_end_date_query/mod.rs | 2 +- .../insert/register_identity_vote/mod.rs | 41 +++++++++++++++--- .../insert/register_identity_vote/v0/mod.rs | 37 +++++++++++++--- .../identity/masternode_vote/mod.rs | 18 +++++++- .../identity/masternode_vote/v0/mod.rs | 3 ++ .../src/version/drive_versions.rs | 2 +- .../src/version/mocks/v2_test.rs | 2 +- .../src/version/mocks/v3_test.rs | 2 +- .../rs-platform-version/src/version/v1.rs | 2 +- 18 files changed, 135 insertions(+), 85 deletions(-) create mode 100644 packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs delete mode 100644 packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/mod.rs delete mode 100644 packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/v0/mod.rs diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/structure/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/structure/v0/mod.rs index 8eeae9535c..429a72393a 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/structure/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/structure/v0/mod.rs @@ -1,6 +1,5 @@ // use dpp::platform_value:: use crate::error::Error; -use dpp::state_transition::masternode_vote_transition::accessors::MasternodeVoteTransitionAccessorsV0; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; use dpp::validation::SimpleConsensusValidationResult; diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs index e4509b2fe6..698122549b 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs @@ -11,7 +11,7 @@ use dpp::version::PlatformVersion; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; -use dpp::voting::ContestedDocumentResourceVoteType; +use dpp::voting::{ContestedDocumentResourceVoteType, Vote}; /// Operations on Identities #[derive(Clone, Debug)] @@ -75,14 +75,12 @@ pub enum IdentityOperationType { /// The revision we are updating to revision: Revision, }, - /// Updates an identities revision. - MasternodeContestedResourceCastVote { + /// Casts a vote as a masternode. + MasternodeCastVote { /// The pro tx hash of the masternode doing the voting voter_pro_tx_hash: [u8; 32], /// Contested Vote type - contested_vote_type: ContestedDocumentResourceVoteType, - /// The nonce we are updating to - nonce: IdentityNonce, + vote: Vote, }, /// Updates an identities nonce for a specific contract. UpdateIdentityNonce { @@ -191,11 +189,11 @@ impl DriveLowLevelOperationConverter for IdentityOperationType { estimated_costs_only_with_layer_info, platform_version, )?]), - IdentityOperationType::MasternodeContestedResourceCastVote { + IdentityOperationType::MasternodeCastVote { voter_pro_tx_hash, - contested_vote_type, nonce, + vote, } => { - drive.register_contested_resource_identity_vote_operations(voter_pro_tx_hash, contested_vote_type, block_info, nonce, estimated_costs_only_with_layer_info, transaction, platform_version) + drive.register_identity_vote_operations(voter_pro_tx_hash, vote, block_info, estimated_costs_only_with_layer_info, transaction, platform_version) }, IdentityOperationType::UpdateIdentityContractNonce { identity_id, diff --git a/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs b/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs new file mode 100644 index 0000000000..06d29083b5 --- /dev/null +++ b/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs @@ -0,0 +1,32 @@ +use crate::drive::batch::transitions::DriveHighLevelOperationConverter; +use crate::drive::batch::DriveOperation::IdentityOperation; +use crate::drive::batch::{DriveOperation, IdentityOperationType}; + +use crate::error::Error; +use dpp::block::epoch::Epoch; +use dpp::version::PlatformVersion; +use crate::state_transition_action::identity::masternode_vote::MasternodeVoteTransitionAction; + +impl DriveHighLevelOperationConverter for MasternodeVoteTransitionAction { + fn into_high_level_drive_operations<'a>( + self, + _epoch: &Epoch, + _platform_version: &PlatformVersion, + ) -> Result>, Error> { + let pro_tx_hash = self.pro_tx_hash(); + let nonce = self.nonce(); + let vote = self.vote_owned(); + + let drive_operations = vec![ + IdentityOperation(IdentityOperationType::UpdateIdentityNonce { + identity_id: pro_tx_hash.into_buffer(), + nonce, + }), + IdentityOperation(IdentityOperationType::MasternodeCastVote { + voter_pro_tx_hash: pro_tx_hash.to_buffer(), + vote, + }), + ]; + Ok(drive_operations) + } +} diff --git a/packages/rs-drive/src/drive/batch/transitions/identity/mod.rs b/packages/rs-drive/src/drive/batch/transitions/identity/mod.rs index 9acf476f35..181d432043 100644 --- a/packages/rs-drive/src/drive/batch/transitions/identity/mod.rs +++ b/packages/rs-drive/src/drive/batch/transitions/identity/mod.rs @@ -3,3 +3,4 @@ mod identity_credit_transfer; mod identity_credit_withdrawal_transition; mod identity_top_up_transition; mod identity_update_transition; +mod masternode_vote_transition; diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/mod.rs index 7c11c116cf..f6a3d69e8c 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/mod.rs @@ -1,2 +1 @@ mod register_contested_resource_identity_vote; -mod register_identity_vote_for_identity_queries; diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs index 05abc4a948..025f4824f3 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs @@ -20,10 +20,9 @@ use crate::fee::op::LowLevelDriveOperation; impl Drive { pub fn register_contested_resource_identity_vote( &self, - voter_pro_tx_hash: Identifier, + voter_pro_tx_hash: [u8;32], vote: ContestedDocumentResourceVoteType, block_info: &BlockInfo, - identity_nonce: IdentityNonce, apply: bool, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -39,7 +38,6 @@ impl Drive { voter_pro_tx_hash, vote, block_info, - identity_nonce, apply, transaction, platform_version, @@ -54,10 +52,9 @@ impl Drive { pub fn register_contested_resource_identity_vote_operations( &self, - voter_pro_tx_hash: [u8; 32], + voter_pro_tx_hash: [u8;32], vote: ContestedDocumentResourceVoteType, block_info: &BlockInfo, - identity_nonce: IdentityNonce, estimated_costs_only_with_layer_info: &mut Option< HashMap, >, @@ -75,7 +72,6 @@ impl Drive { voter_pro_tx_hash, vote, block_info, - identity_nonce, estimated_costs_only_with_layer_info, transaction, platform_version, diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index d016f294d2..ae144922fc 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -6,7 +6,7 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; -use dpp::voting::{ContestedDocumentResourceVoteType, Vote}; +use dpp::voting::ContestedDocumentResourceVoteType; use grovedb::{EstimatedLayerInformation, TransactionArg}; use dpp::prelude::{Identifier, IdentityNonce}; use platform_version::version::PlatformVersion; @@ -14,10 +14,9 @@ use platform_version::version::PlatformVersion; impl Drive { pub fn register_contested_resource_identity_vote_v0( &self, - voter_pro_tx_hash: Identifier, + voter_pro_tx_hash: [u8;32], vote: ContestedDocumentResourceVoteType, block_info: &BlockInfo, - identity_nonce: IdentityNonce, apply: bool, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -39,10 +38,9 @@ impl Drive { pub fn register_contested_resource_identity_vote_operations_v0( &self, - voter_pro_tx_hash: [u8; 32], + voter_pro_tx_hash: [u8;32], vote: ContestedDocumentResourceVoteType, block_info: &BlockInfo, - identity_nonce: IdentityNonce, estimated_costs_only_with_layer_info: &mut Option< HashMap, >, diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/mod.rs deleted file mode 100644 index 736a3504e1..0000000000 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/mod.rs +++ /dev/null @@ -1,43 +0,0 @@ -mod v0; - -use crate::drive::Drive; - -use crate::error::drive::DriveError; -use crate::error::Error; - -use dpp::fee::fee_result::FeeResult; - -use dpp::prelude::Identifier; -use dpp::version::PlatformVersion; -use grovedb::TransactionArg; - -impl Drive { - /// We register the identity vote to be able to query the current votes of an identity, or to - /// be able to remove votes from a "disabled" identity (ie a masternode that was removed from - /// the list). - pub fn register_identity_vote_for_identity_queries( - &self, - identity_id: Identifier, - transaction: TransactionArg, - platform_version: &PlatformVersion, - ) -> Result { - match platform_version - .drive - .methods - .vote - .contested_resource_insert - .register_identity_vote_for_identity_queries - { - 0 => self.register_identity_vote_for_identity_queries_v0( - identity_id, - transaction, - platform_version, - ), - version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "register_identity_vote_for_identity_queries".to_string(), - known_versions: vec![0], - received: version, - })), - } - } -} diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/v0/mod.rs deleted file mode 100644 index 8b13789179..0000000000 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_identity_vote_for_identity_queries/v0/mod.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/mod.rs index 481d6ec557..acafadf0a9 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/mod.rs @@ -25,7 +25,7 @@ impl Drive { .methods .vote .contested_resource_insert - .register_identity_vote_for_identity_queries + .register_identity_vote { 0 => self.add_vote_poll_end_date_query_v0(identity_id, transaction, platform_version), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs index 2e8d52effd..b62fe22a8a 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs @@ -1,5 +1,7 @@ mod v0; +use std::collections::HashMap; +use grovedb::batch::KeyInfoPath; use crate::drive::Drive; use crate::error::drive::DriveError; @@ -9,12 +11,14 @@ use dpp::fee::fee_result::FeeResult; use dpp::version::PlatformVersion; use dpp::voting::Vote; -use grovedb::TransactionArg; +use grovedb::{EstimatedLayerInformation, TransactionArg}; use dpp::block::block_info::BlockInfo; +use crate::fee::op::LowLevelDriveOperation; impl Drive { - pub fn register_identity_vote_for_identity_queries( + pub fn register_identity_vote( &self, + voter_pro_tx_hash: [u8;32], vote: Vote, block_info: &BlockInfo, apply: bool, @@ -26,11 +30,38 @@ impl Drive { .methods .vote .contested_resource_insert - .register_identity_vote_for_identity_queries + .register_identity_vote { - 0 => self.register_identity_vote_for_identity_queries_v0(vote, block_info, apply, transaction, platform_version), + 0 => self.register_identity_vote_v0(voter_pro_tx_hash, vote, block_info, apply, transaction, platform_version), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "register_identity_vote_for_identity_queries".to_string(), + method: "register_identity_vote".to_string(), + known_versions: vec![0], + received: version, + })), + } + } + + pub fn register_identity_vote_operations( + &self, + voter_pro_tx_hash: [u8;32], + vote: Vote, + block_info: &BlockInfo, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + match platform_version + .drive + .methods + .vote + .contested_resource_insert + .register_identity_vote + { + 0 => self.register_identity_vote_operations_v0(voter_pro_tx_hash, vote, block_info, estimated_costs_only_with_layer_info, transaction, platform_version), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "register_identity_vote_operations".to_string(), known_versions: vec![0], received: version, })), diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs index a0e14a373f..85a94773f9 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs @@ -1,20 +1,20 @@ +use std::collections::HashMap; +use grovedb::batch::KeyInfoPath; use crate::drive::Drive; use crate::error::Error; use dpp::fee::fee_result::FeeResult; use dpp::voting::Vote; -use grovedb::TransactionArg; +use grovedb::{EstimatedLayerInformation, TransactionArg}; use dpp::block::block_info::BlockInfo; -use dpp::identifier::Identifier; -use dpp::prelude::IdentityNonce; use platform_version::version::PlatformVersion; +use crate::fee::op::LowLevelDriveOperation; impl Drive { - pub fn register_identity_vote_for_identity_queries_v0( + pub(super) fn register_identity_vote_v0( &self, - voter_pro_tx_hash: Identifier, + voter_pro_tx_hash: [u8;32], vote: Vote, block_info: &BlockInfo, - identity_nonce: IdentityNonce, apply: bool, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -25,11 +25,34 @@ impl Drive { voter_pro_tx_hash, contested_document_resource_vote_type, block_info, - identity_nonce, apply, transaction, platform_version, ), } } + + pub(super) fn register_identity_vote_operations_v0( + &self, + voter_pro_tx_hash: [u8;32], + vote: Vote, + block_info: &BlockInfo, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + match vote { + Vote::ContestedDocumentResourceVote(contested_document_resource_vote_type) => self + .register_contested_resource_identity_vote_operations( + voter_pro_tx_hash, + contested_document_resource_vote_type, + block_info, + estimated_costs_only_with_layer_info + transaction, + platform_version, + ), + } + } } diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs index 379c11d6fe..9705d87543 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs @@ -6,7 +6,7 @@ pub mod v0; use crate::state_transition_action::identity::masternode_vote::v0::MasternodeVoteTransitionActionV0; use derive_more::From; use dpp::platform_value::Identifier; -use dpp::voting::resource_vote::ResourceVote; +use dpp::prelude::IdentityNonce; use dpp::voting::Vote; /// action @@ -25,9 +25,23 @@ impl MasternodeVoteTransitionAction { } /// Resource vote - pub fn vote(&self) -> &Vote { + pub fn vote_ref(&self) -> &Vote { match self { MasternodeVoteTransitionAction::V0(transition) => &transition.vote, } } + + /// Resource vote as owned + pub fn vote_owned(self) -> Vote { + match self { + MasternodeVoteTransitionAction::V0(transition) => transition.vote, + } + } + + /// Nonce + pub fn nonce(&self) -> IdentityNonce { + match self { + MasternodeVoteTransitionAction::V0(transition) => transition.nonce, + } + } } diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs index 22cc929554..2c48cfc24d 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs @@ -1,6 +1,7 @@ mod transformer; use dpp::platform_value::Identifier; +use dpp::prelude::IdentityNonce; use dpp::voting::Vote; /// action v0 @@ -10,4 +11,6 @@ pub struct MasternodeVoteTransitionActionV0 { pub pro_tx_hash: Identifier, /// the resource vote pub vote: Vote, + /// nonce + pub nonce: IdentityNonce, } diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index a400552fed..0eb65adfd1 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -264,7 +264,7 @@ pub struct DriveVoteInsertMethodVersions { #[derive(Clone, Debug, Default)] pub struct DriveVoteContestedResourceInsertMethodVersions { pub register_contested_resource_identity_vote: FeatureVersion, - pub register_identity_vote_for_identity_queries: FeatureVersion, + pub register_identity_vote: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 3bfaa9bacd..67cf74498d 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -216,7 +216,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { }, contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { register_contested_resource_identity_vote: 0, - register_identity_vote_for_identity_queries: 0, + register_identity_vote: 0, }, cleanup: DriveVoteCleanupMethodVersions { remove_votes_for_identity: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index bb7d63acb9..84b154f932 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -222,7 +222,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { }, contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { register_contested_resource_identity_vote: 0, - register_identity_vote_for_identity_queries: 0, + register_identity_vote: 0, }, cleanup: DriveVoteCleanupMethodVersions { remove_votes_for_identity: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 337db0fe47..9958a3ba49 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -213,7 +213,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { }, contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { register_contested_resource_identity_vote: 0, - register_identity_vote_for_identity_queries: 0, + register_identity_vote: 0, }, cleanup: DriveVoteCleanupMethodVersions { remove_votes_for_identity: 0, From a3ca8dfb6e5fab898e76f73dee62cc57e8837293 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 28 Apr 2024 21:07:48 +0700 Subject: [PATCH 030/135] more fixes --- .../v0/nodejs/PlatformPromiseClient.spec.js | 2 +- .../getIdentityContractNonceFactory.js | 2 +- .../getIdentityKeys/getIdentityKeysFactory.js | 2 +- .../getIdentityNonceFactory.js | 2 +- ...rotocolVersionUpgradeVoteStatusResponse.js | 2 +- ...ProtocolVersionUpgradeVoteStatusFactory.js | 2 +- .../platform/PlatformMethodsFacade.spec.js | 2 +- ...olVersionUpgradeVoteStatusResponse.spec.js | 2 +- ...colVersionUpgradeVoteStatusFactory.spec.js | 2 +- packages/rs-dpp/Cargo.toml | 9 ++- .../document_type/index_level/mod.rs | 2 +- packages/rs-dpp/src/errors/protocol_error.rs | 2 +- .../accessors/mod.rs | 2 +- .../accessors/v0/mod.rs | 2 +- .../masternode_vote_transition/v0/mod.rs | 12 +-- .../v0/state_transition_like.rs | 2 +- packages/rs-dpp/src/version/mod.rs | 2 +- packages/rs-dpp/src/voting/mod.rs | 74 +----------------- .../rs-dpp/src/voting/vote_choices/mod.rs | 5 ++ .../resource_vote_choice}/mod.rs | 12 +-- .../yes_no_abstain_vote_choice}/mod.rs | 2 +- .../mod.rs | 27 +++++++ packages/rs-dpp/src/voting/vote_polls/mod.rs | 1 + .../accessors/mod.rs | 26 +++++++ .../accessors/v0/mod.rs | 14 ++++ .../contested_document_resource_vote/mod.rs | 34 +++++++++ .../v0/mod.rs | 27 +++++++ packages/rs-dpp/src/voting/votes/mod.rs | 21 +++++ packages/rs-drive-abci/src/abci/error.rs | 10 +-- .../src/abci/handler/extend_vote.rs | 6 +- .../src/abci/handler/verify_vote_extension.rs | 16 ++-- .../engine/finalize_block_proposal/mod.rs | 2 +- .../engine/finalize_block_proposal/v0/mod.rs | 8 +- .../upgrade_protocol_version/v0/mod.rs | 2 +- .../types/block_execution_context/v0/mod.rs | 2 +- .../state_transitions/masternode_vote/mod.rs | 6 +- packages/rs-drive-abci/src/mimic/mod.rs | 8 +- .../cleaned_commit_info/v0/mod.rs | 2 +- .../unsigned_withdrawal_txs/v0/mod.rs | 2 +- .../system/version_upgrade_vote_status/mod.rs | 2 +- .../strategy_tests/upgrade_fork_tests.rs | 2 +- .../tests/strategy_tests/voting_tests.rs | 76 +++++++------------ packages/rs-drive-proof-verifier/src/types.rs | 4 +- .../drive/batch/drive_op_batch/identity.rs | 4 +- packages/rs-drive/src/drive/cache.rs | 2 +- .../v0/mod.rs | 6 +- .../src/drive/initialization/v0/mod.rs | 2 +- packages/rs-drive/src/drive/mod.rs | 2 +- .../mod.rs | 4 +- .../v0/mod.rs | 2 +- .../fetch_validator_version_votes/mod.rs | 6 +- .../fetch_validator_version_votes/v0/mod.rs | 2 +- .../system/verify_upgrade_state/v0/mod.rs | 2 +- .../cleanup/remove_votes_for_identity/mod.rs | 2 +- .../remove_votes_for_identity/v0/mod.rs | 12 +-- .../add_new_masternode_vote_type/v0/mod.rs | 23 ++++++ .../mod.rs | 6 +- .../v0/mod.rs | 6 +- .../add_vote_poll_end_date_query/mod.rs | 8 +- .../add_vote_poll_end_date_query/v0/mod.rs | 21 +++++ .../insert/register_identity_vote/mod.rs | 2 +- .../insert/register_identity_vote/v0/mod.rs | 2 +- packages/rs-drive/src/drive/votes/mod.rs | 12 +-- .../identity/masternode_vote/mod.rs | 6 +- .../identity/masternode_vote/v0/mod.rs | 4 +- .../state_transition_action/identity/mod.rs | 2 +- .../src/version/drive_versions.rs | 1 + .../src/version/mocks/v2_test.rs | 1 + .../src/version/mocks/v3_test.rs | 1 + .../rs-platform-version/src/version/v1.rs | 1 + packages/rs-sdk/src/platform/fetch_many.rs | 2 +- .../src/platform/types/version_votes.rs | 8 +- .../fetch/protocol_version_vote_count.rs | 2 +- .../tests/fetch/protocol_version_votes.rs | 18 ++--- packages/wallet-lib/src/types/types.d.ts | 2 +- 75 files changed, 372 insertions(+), 244 deletions(-) create mode 100644 packages/rs-dpp/src/voting/vote_choices/mod.rs rename packages/rs-dpp/src/voting/{resource_vote => vote_choices/resource_vote_choice}/mod.rs (67%) rename packages/rs-dpp/src/voting/{common_vote => vote_choices/yes_no_abstain_vote_choice}/mod.rs (90%) create mode 100644 packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs create mode 100644 packages/rs-dpp/src/voting/vote_polls/mod.rs create mode 100644 packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/mod.rs create mode 100644 packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/v0/mod.rs create mode 100644 packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs create mode 100644 packages/rs-dpp/src/voting/votes/contested_document_resource_vote/v0/mod.rs create mode 100644 packages/rs-dpp/src/voting/votes/mod.rs diff --git a/packages/dapi-grpc/test/unit/clients/platform/v0/nodejs/PlatformPromiseClient.spec.js b/packages/dapi-grpc/test/unit/clients/platform/v0/nodejs/PlatformPromiseClient.spec.js index 8633267544..5987cbfd0f 100644 --- a/packages/dapi-grpc/test/unit/clients/platform/v0/nodejs/PlatformPromiseClient.spec.js +++ b/packages/dapi-grpc/test/unit/clients/platform/v0/nodejs/PlatformPromiseClient.spec.js @@ -122,7 +122,7 @@ describe('PlatformPromiseClient', () => { }); describe('#getProtocolVersionUpgradeVoteStatus', () => { - it('should get version upgrade vote status', async () => { + it('should get version upgrade votes status', async () => { const result = await platformPromiseClient.getProtocolVersionUpgradeVoteStatus(request); expect(result).to.equal(response); diff --git a/packages/js-dapi-client/lib/methods/platform/getIdentityContractNonce/getIdentityContractNonceFactory.js b/packages/js-dapi-client/lib/methods/platform/getIdentityContractNonce/getIdentityContractNonceFactory.js index 00ae1a93ef..59aec51dc8 100644 --- a/packages/js-dapi-client/lib/methods/platform/getIdentityContractNonce/getIdentityContractNonceFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getIdentityContractNonce/getIdentityContractNonceFactory.js @@ -14,7 +14,7 @@ const InvalidResponseError = require('../response/errors/InvalidResponseError'); */ function getIdentityContractNonceFactory(grpcTransport) { /** - * Fetch the version upgrade vote status + * Fetch the version upgrade votes status * @typedef {getIdentityContractNonce} * @param {Buffer} identityId * @param {Buffer} contractId diff --git a/packages/js-dapi-client/lib/methods/platform/getIdentityKeys/getIdentityKeysFactory.js b/packages/js-dapi-client/lib/methods/platform/getIdentityKeys/getIdentityKeysFactory.js index d54b660106..68b20db334 100644 --- a/packages/js-dapi-client/lib/methods/platform/getIdentityKeys/getIdentityKeysFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getIdentityKeys/getIdentityKeysFactory.js @@ -17,7 +17,7 @@ const InvalidResponseError = require('../response/errors/InvalidResponseError'); */ function getIdentityKeysFactory(grpcTransport) { /** - * Fetch the version upgrade vote status + * Fetch the version upgrade votes status * @typedef {getIdentityKeys} * @param {Buffer} identityId * @param {number[]} keyIds diff --git a/packages/js-dapi-client/lib/methods/platform/getIdentityNonce/getIdentityNonceFactory.js b/packages/js-dapi-client/lib/methods/platform/getIdentityNonce/getIdentityNonceFactory.js index 4c0193889f..217cfe48c3 100644 --- a/packages/js-dapi-client/lib/methods/platform/getIdentityNonce/getIdentityNonceFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getIdentityNonce/getIdentityNonceFactory.js @@ -14,7 +14,7 @@ const InvalidResponseError = require('../response/errors/InvalidResponseError'); */ function getIdentityNonceFactory(grpcTransport) { /** - * Fetch the version upgrade vote status + * Fetch the version upgrade votes status * @typedef {getIdentityNonce} * @param {Buffer} identityId * @param {DAPIClientOptions & {prove: boolean}} [options] diff --git a/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/GetProtocolVersionUpgradeVoteStatusResponse.js b/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/GetProtocolVersionUpgradeVoteStatusResponse.js index 4b8fe08e2a..a28ec23e6c 100644 --- a/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/GetProtocolVersionUpgradeVoteStatusResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/GetProtocolVersionUpgradeVoteStatusResponse.js @@ -32,7 +32,7 @@ class GetProtocolVersionUpgradeVoteStatusResponse extends AbstractResponse { ); if (!versions && !proof) { - throw new InvalidResponseError('Version upgrade vote status is not defined'); + throw new InvalidResponseError('Version upgrade votes status is not defined'); } let versionSignals = []; diff --git a/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory.js b/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory.js index fa7c87cda2..bc79c54315 100644 --- a/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory.js @@ -14,7 +14,7 @@ const InvalidResponseError = require('../response/errors/InvalidResponseError'); */ function getProtocolVersionUpgradeVoteStatusFactory(grpcTransport) { /** - * Fetch the version upgrade vote status + * Fetch the version upgrade votes status * @typedef {getProtocolVersionUpgradeVoteStatus} * @param {string} startProTxHash * @param {number} count diff --git a/packages/js-dapi-client/test/integration/methods/platform/PlatformMethodsFacade.spec.js b/packages/js-dapi-client/test/integration/methods/platform/PlatformMethodsFacade.spec.js index eea314d64a..cb2c2dd0fa 100644 --- a/packages/js-dapi-client/test/integration/methods/platform/PlatformMethodsFacade.spec.js +++ b/packages/js-dapi-client/test/integration/methods/platform/PlatformMethodsFacade.spec.js @@ -215,7 +215,7 @@ describe('PlatformMethodsFacade', () => { }); describe('#getProtocolVersionUpgradeVoteStatus', () => { - it('should get version upgrade vote status', async () => { + it('should get version upgrade votes status', async () => { const startProTxHash = Buffer.alloc(32).fill('a').toString('hex'); const proTxHash = Buffer.alloc(32).fill('b').toString('hex'); diff --git a/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeVoteStatus/GetProtocolVersionUpgradeVoteStatusResponse.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeVoteStatus/GetProtocolVersionUpgradeVoteStatusResponse.spec.js index 0ee46a856d..99d6cf812d 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeVoteStatus/GetProtocolVersionUpgradeVoteStatusResponse.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeVoteStatus/GetProtocolVersionUpgradeVoteStatusResponse.spec.js @@ -54,7 +54,7 @@ describe('GetProtocolVersionUpgradeVoteStatusResponse', () => { ); }); - it('should return vote statuses', () => { + it('should return votes statuses', () => { const versionSignals = getProtocolVersionUpgradeVoteStatus.getVersionSignals(); const proof = getProtocolVersionUpgradeVoteStatus.getProof(); diff --git a/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory.spec.js index 0df9748942..24cbc95a1f 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory.spec.js @@ -75,7 +75,7 @@ describe('getProtocolVersionUpgradeVoteStatusFactory', () => { }; }); - it('should return vote statuses', async () => { + it('should return votes statuses', async () => { const result = await getProtocolVersionUpgradeVoteStatus(startProTxHash, 1, options); const { diff --git a/packages/rs-dpp/Cargo.toml b/packages/rs-dpp/Cargo.toml index 8d71a08206..a216e1f8bd 100644 --- a/packages/rs-dpp/Cargo.toml +++ b/packages/rs-dpp/Cargo.toml @@ -112,6 +112,7 @@ all_features = [ "random-document-types", "fee-distribution", "client", + "vote-serialization", ] dash-sdk-features = [ @@ -122,6 +123,7 @@ dash-sdk-features = [ "validation", "identity-hashing", "identity-serialization", + "vote-serialization", "document-value-conversion", "data-contract-value-conversion", "identity-value-conversion", @@ -171,6 +173,8 @@ all_features_without_client = [ "random-documents", "random-document-types", "fee-distribution", + "vote-serialization", + "vote-serde-conversion", ] abci = [ "state-transitions", @@ -178,6 +182,7 @@ abci = [ "validation", "random-public-keys", "identity-serialization", + "vote-serialization", "platform-value-cbor", ] cbor = ["ciborium"] @@ -224,7 +229,7 @@ identity-cbor-conversion = [ "cbor", "platform-value-cbor", ] -state-transition-serde-conversion = ["data-contract-serde-conversion"] +state-transition-serde-conversion = ["data-contract-serde-conversion", "vote-serde-conversion"] state-transition-value-conversion = [ "platform-value", "state-transition-serde-conversion", @@ -245,6 +250,8 @@ state-transition-signing = [ "message-signing", "state-transition-validation", ] +vote-serialization = [] +vote-serde-conversion = [] state-transitions = [] system_contracts = ["factories", "data-contracts", "platform-value-json"] fixtures-and-mocks = ["system_contracts", "platform-value/json"] diff --git a/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs b/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs index 67a3525cd8..4187c09d54 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs @@ -17,7 +17,7 @@ pub enum IndexType { /// As long as one of the values is not nil UniqueIndex, /// A contested resource: This is a unique index but that can be contested through a resolution - /// The simplest to understand resolution is a masternode vote, but could also be something + /// The simplest to understand resolution is a masternode votes, but could also be something /// like a bidding war. /// For example the path/name in the dpns contract must be unique but it is a contested potentially /// valuable resource. diff --git a/packages/rs-dpp/src/errors/protocol_error.rs b/packages/rs-dpp/src/errors/protocol_error.rs index 69a49a4e5d..78b82b9761 100644 --- a/packages/rs-dpp/src/errors/protocol_error.rs +++ b/packages/rs-dpp/src/errors/protocol_error.rs @@ -223,7 +223,7 @@ pub enum ProtocolError { raw_identity: Value, }, - #[error("vote error {0}")] + #[error("votes error {0}")] VoteError(String), #[error("Public key generation error {0}")] diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/mod.rs index acdf95c6f2..6bbbebb480 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/mod.rs @@ -1,7 +1,7 @@ mod v0; use crate::state_transition::masternode_vote_transition::MasternodeVoteTransition; -use crate::voting::Vote; +use crate::voting::votes::Vote; use platform_value::Identifier; pub use v0::*; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/v0/mod.rs index 319cc487cc..baca561024 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/v0/mod.rs @@ -1,4 +1,4 @@ -use crate::voting::Vote; +use crate::voting::votes::Vote; use platform_value::Identifier; pub trait MasternodeVoteTransitionAccessorsV0 { diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs index 3e1197f4ed..6542d56c60 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs @@ -13,7 +13,7 @@ use crate::identity::KeyID; use crate::prelude::{Identifier, IdentityNonce}; use crate::protocol_error::ProtocolError; -use crate::voting::Vote; +use crate::voting::votes::Vote; use bincode::{Decode, Encode}; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize, PlatformSignable}; use platform_value::BinaryData; @@ -54,12 +54,12 @@ mod test { use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; use crate::voting::resource_vote::ResourceVote; - use crate::voting::{ - ContestedDocumentResourceVotePoll, ContestedDocumentResourceVoteType, Vote, - }; + use crate::voting::ContestedDocumentResourceVote; use platform_value::Identifier; use rand::Rng; use std::fmt::Debug; + use crate::voting::votes::Vote; + use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; fn test_masternode_vote_transition< T: PlatformSerializable + PlatformDeserializable + Debug + PartialEq, @@ -79,14 +79,14 @@ mod test { let mut rng = rand::thread_rng(); let transition = MasternodeVoteTransitionV0 { pro_tx_hash: Identifier::random(), - vote: Vote::ContestedDocumentResourceVote(ContestedDocumentResourceVoteType { + vote: Vote::ContestedDocumentResourceVote(ContestedDocumentResourceVote { vote_poll: ContestedDocumentResourceVotePoll { contract_id: Default::default(), document_type_name: "hello".to_string(), index_name: "index_1".to_string(), index_values: vec![], }, - resource_vote: ResourceVote::TowardsIdentity(Identifier::random()), + resource_vote_choice: ResourceVote::TowardsIdentity(Identifier::random()), }), nonce: 1, signature_public_key_id: rng.gen(), diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/state_transition_like.rs index 8841d1fd79..03b40becc8 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/state_transition_like.rs @@ -41,7 +41,7 @@ impl StateTransitionLike for MasternodeVoteTransitionV0 { } fn user_fee_increase(&self) -> UserFeeIncrease { - // The user fee increase for a masternode vote is always 0 + // The user fee increase for a masternode votes is always 0 0 } diff --git a/packages/rs-dpp/src/version/mod.rs b/packages/rs-dpp/src/version/mod.rs index 7134764321..9bf84a8e80 100644 --- a/packages/rs-dpp/src/version/mod.rs +++ b/packages/rs-dpp/src/version/mod.rs @@ -10,7 +10,7 @@ lazy_static! { RwLock::new(None); } -/// Number of votes for a protocol version upgrade. +/// Number of vote_choices for a protocol version upgrade. pub type ProtocolVersionVoteCount = u64; pub trait PlatformVersionCurrentVersion { diff --git a/packages/rs-dpp/src/voting/mod.rs b/packages/rs-dpp/src/voting/mod.rs index 2854707e13..88058064ae 100644 --- a/packages/rs-dpp/src/voting/mod.rs +++ b/packages/rs-dpp/src/voting/mod.rs @@ -1,71 +1,3 @@ -use crate::voting::resource_vote::ResourceVote; -use crate::voting::Vote::ContestedDocumentResourceVote; -use crate::ProtocolError; -use bincode::{Decode, Encode}; -use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; -use platform_value::{Identifier, Value}; -use serde::{Deserialize, Serialize}; - -pub mod common_vote; -pub mod resource_vote; - -#[derive(Debug, Clone, Encode, Decode, PartialEq)] -#[cfg_attr( - feature = "state-transition-serde-conversion", - derive(Serialize, Deserialize), - serde(rename_all = "camelCase") -)] -pub struct ContestedDocumentResourceVotePoll { - pub contract_id: Identifier, - pub document_type_name: String, - pub index_name: String, - pub index_values: Vec, -} - -impl Default for ContestedDocumentResourceVotePoll { - fn default() -> Self { - ContestedDocumentResourceVotePoll { - contract_id: Default::default(), - document_type_name: "".to_string(), - index_name: "".to_string(), - index_values: vec![], - } - } -} - -#[derive(Debug, Clone, Encode, Decode, PlatformDeserialize, PlatformSerialize, PartialEq)] -#[cfg_attr( - feature = "state-transition-serde-conversion", - derive(Serialize, Deserialize), - serde(rename_all = "camelCase") -)] -#[platform_serialize(unversioned)] -pub struct ContestedDocumentResourceVoteType { - pub vote_poll: ContestedDocumentResourceVotePoll, - pub resource_vote: ResourceVote, -} - -impl Default for ContestedDocumentResourceVoteType { - fn default() -> Self { - ContestedDocumentResourceVoteType { - vote_poll: ContestedDocumentResourceVotePoll::default(), - resource_vote: ResourceVote::Abstain, - } - } -} - -#[derive(Debug, Clone, Encode, Decode, PartialEq)] -#[cfg_attr( - feature = "state-transition-serde-conversion", - derive(Serialize, Deserialize), - serde(rename_all = "camelCase") -)] -pub enum Vote { - ContestedDocumentResourceVote(ContestedDocumentResourceVoteType), -} - -impl Default for Vote { - fn default() -> Self { - ContestedDocumentResourceVote(ContestedDocumentResourceVoteType::default()) - } -} +pub mod votes; +pub mod vote_polls; +pub mod vote_choices; \ No newline at end of file diff --git a/packages/rs-dpp/src/voting/vote_choices/mod.rs b/packages/rs-dpp/src/voting/vote_choices/mod.rs new file mode 100644 index 0000000000..6b0a91d628 --- /dev/null +++ b/packages/rs-dpp/src/voting/vote_choices/mod.rs @@ -0,0 +1,5 @@ + +/// The various vote choices a vote could have + +pub mod yes_no_abstain_vote_choice; +pub mod resource_vote_choice; diff --git a/packages/rs-dpp/src/voting/resource_vote/mod.rs b/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs similarity index 67% rename from packages/rs-dpp/src/voting/resource_vote/mod.rs rename to packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs index cfa9716416..6889d9ce79 100644 --- a/packages/rs-dpp/src/voting/resource_vote/mod.rs +++ b/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs @@ -2,13 +2,13 @@ use bincode::{Decode, Encode}; use platform_value::Identifier; use serde::{Deserialize, Serialize}; -/// A resource vote is a vote determining what we should do with a contested resource. +/// A resource votes is a votes determining what we should do with a contested resource. /// For example Alice and Bob both want the username "Malaka" -/// Some would vote for Alice to get it by putting in her Identifier. -/// Some would vote for Bob to get it by putting in Bob's Identifier. -/// Let's say someone voted, but is now not quite sure of their vote, they can abstain. +/// Some would votes for Alice to get it by putting in her Identifier. +/// Some would votes for Bob to get it by putting in Bob's Identifier. +/// Let's say someone voted, but is now not quite sure of their votes, they can abstain. /// Lock is there to signal that the shared resource should be given to no one. -/// In this case Malaka might have a bad connotation in Greek, hence some might vote to Lock +/// In this case Malaka might have a bad connotation in Greek, hence some might votes to Lock /// the name. /// #[derive(Debug, Clone, Copy, Encode, Decode, PartialEq, Default)] @@ -17,7 +17,7 @@ use serde::{Deserialize, Serialize}; derive(Serialize, Deserialize), serde(rename_all = "camelCase") )] -pub enum ResourceVote { +pub enum ResourceVoteChoice { TowardsIdentity(Identifier), #[default] Abstain, diff --git a/packages/rs-dpp/src/voting/common_vote/mod.rs b/packages/rs-dpp/src/voting/vote_choices/yes_no_abstain_vote_choice/mod.rs similarity index 90% rename from packages/rs-dpp/src/voting/common_vote/mod.rs rename to packages/rs-dpp/src/voting/vote_choices/yes_no_abstain_vote_choice/mod.rs index 89336f16aa..185928fc76 100644 --- a/packages/rs-dpp/src/voting/common_vote/mod.rs +++ b/packages/rs-dpp/src/voting/vote_choices/yes_no_abstain_vote_choice/mod.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; derive(Serialize, Deserialize), serde(rename_all = "camelCase") )] -pub enum CommonVote { +pub enum YesNoAbstainVoteChoice { YES, NO, #[default] diff --git a/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs b/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs new file mode 100644 index 0000000000..9bce95c731 --- /dev/null +++ b/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs @@ -0,0 +1,27 @@ +use serde::{Deserialize, Serialize}; +use platform_value::{Identifier, Value}; +use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; + +#[derive(Debug, Clone, Encode, Decode, PartialEq)] +#[cfg_attr( + feature = "state-transition-serde-conversion", + derive(Serialize, Deserialize), + serde(rename_all = "camelCase") +)] +pub struct ContestedDocumentResourceVotePoll { + pub contract_id: Identifier, + pub document_type_name: String, + pub index_name: String, + pub index_values: Vec, +} + +impl Default for ContestedDocumentResourceVotePoll { + fn default() -> Self { + ContestedDocumentResourceVotePoll { + contract_id: Default::default(), + document_type_name: "".to_string(), + index_name: "".to_string(), + index_values: vec![], + } + } +} diff --git a/packages/rs-dpp/src/voting/vote_polls/mod.rs b/packages/rs-dpp/src/voting/vote_polls/mod.rs new file mode 100644 index 0000000000..0ef62653cb --- /dev/null +++ b/packages/rs-dpp/src/voting/vote_polls/mod.rs @@ -0,0 +1 @@ +pub mod contested_document_resource_vote_poll; \ No newline at end of file diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/mod.rs b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/mod.rs new file mode 100644 index 0000000000..414bdf1437 --- /dev/null +++ b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/mod.rs @@ -0,0 +1,26 @@ +use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use crate::voting::votes::contested_document_resource_vote::accessors::v0::ContestedDocumentResourceVoteGettersV0; +use crate::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; + +mod v0; + +impl ContestedDocumentResourceVoteGettersV0 for ContestedDocumentResourceVote { + fn vote_poll(&self) -> &ContestedDocumentResourceVotePoll { + match self { + ContestedDocumentResourceVote::V0(v0) => &v0.vote_poll + } + } + + fn vote_poll_owned(self) -> ContestedDocumentResourceVotePoll { + match self { + ContestedDocumentResourceVote::V0(v0) => v0.vote_poll + } + } + + fn resource_vote_choice(&self) -> ResourceVoteChoice { + match self { + ContestedDocumentResourceVote::V0(v0) => v0.resource_vote_choice + } + } +} \ No newline at end of file diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/v0/mod.rs b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/v0/mod.rs new file mode 100644 index 0000000000..b3d98005f3 --- /dev/null +++ b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/v0/mod.rs @@ -0,0 +1,14 @@ +use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; + +/// Trait for getters in Contested Document Resource Vote +pub trait ContestedDocumentResourceVoteGettersV0 { + /// The vote poll + fn vote_poll(&self) -> &ContestedDocumentResourceVotePoll; + + /// The vote poll as owned + fn vote_poll_owned(self) -> ContestedDocumentResourceVotePoll; + + /// The choice made in the vote + fn resource_vote_choice(&self) -> ResourceVoteChoice; +} \ No newline at end of file diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs new file mode 100644 index 0000000000..b6f82be02d --- /dev/null +++ b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs @@ -0,0 +1,34 @@ +use derive_more::From; +#[cfg(feature = "vote-serde-conversion")] +use serde::{Deserialize, Serialize}; +#[cfg(feature = "vote-serialization")] +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; +use crate::voting::votes::contested_document_resource_vote::v0::ContestedDocumentResourceVoteV0; +use crate::ProtocolError; +use crate::voting::votes::Vote; + +mod v0; +mod accessors; + +#[derive(Debug, Clone, PartialEq, From)] +#[cfg_attr( +feature = "vote-serde-conversion", +derive(Serialize, Deserialize), +serde(tag = "$version"), +)] +#[cfg_attr( +feature = "vote-serialization", +derive(Encode, Decode, PlatformDeserialize, PlatformSerialize), +platform_serialize(limit = 15000, unversioned) +)] +pub enum ContestedDocumentResourceVote { + #[cfg_attr(feature = "vote-serde-conversion", serde(rename = "0"))] + V0(ContestedDocumentResourceVoteV0) +} + +impl Default for ContestedDocumentResourceVote { + fn default() -> Self { + Self::V0(ContestedDocumentResourceVoteV0::default()) + } +} diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/v0/mod.rs b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/v0/mod.rs new file mode 100644 index 0000000000..6769bc458a --- /dev/null +++ b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/v0/mod.rs @@ -0,0 +1,27 @@ +use crate::ProtocolError; +use bincode::{Decode, Encode}; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +use serde::{Deserialize, Serialize}; +use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; + +#[derive(Debug, Clone, Encode, Decode, PlatformDeserialize, PlatformSerialize, PartialEq)] +#[cfg_attr( +feature = "state-transition-serde-conversion", +derive(Serialize, Deserialize), +serde(rename_all = "camelCase") +)] +#[platform_serialize(unversioned)] +pub struct ContestedDocumentResourceVoteV0 { + pub vote_poll: ContestedDocumentResourceVotePoll, + pub resource_vote_choice: ResourceVoteChoice, +} + +impl Default for ContestedDocumentResourceVoteV0 { + fn default() -> Self { + ContestedDocumentResourceVoteV0 { + vote_poll: ContestedDocumentResourceVotePoll::default(), + resource_vote_choice: ResourceVoteChoice::Abstain, + } + } +} diff --git a/packages/rs-dpp/src/voting/votes/mod.rs b/packages/rs-dpp/src/voting/votes/mod.rs new file mode 100644 index 0000000000..5a7ede8af5 --- /dev/null +++ b/packages/rs-dpp/src/voting/votes/mod.rs @@ -0,0 +1,21 @@ +pub mod contested_document_resource_vote; + +use serde::{Deserialize, Serialize}; +use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; +use crate::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; + +#[derive(Debug, Clone, Encode, Decode, PartialEq)] +#[cfg_attr( + feature = "vote-serde-conversion", + derive(Serialize, Deserialize), + serde(rename_all = "camelCase") +)] +pub enum Vote { + ContestedDocumentResourceVote(ContestedDocumentResourceVote), +} + +impl Default for Vote { + fn default() -> Self { + Vote::ContestedDocumentResourceVote(ContestedDocumentResourceVote::default()) + } +} diff --git a/packages/rs-drive-abci/src/abci/error.rs b/packages/rs-drive-abci/src/abci/error.rs index 2b19bd97fb..857321a16e 100644 --- a/packages/rs-drive-abci/src/abci/error.rs +++ b/packages/rs-drive-abci/src/abci/error.rs @@ -13,18 +13,18 @@ pub enum AbciError { /// Request does not match currently processed block #[error("request does not match current block: {0}")] RequestForWrongBlockReceived(String), - /// Withdrawal vote extensions mismatch - #[error("vote extensions mismatch: got {got:?}, expected {expected:?}")] + /// Withdrawal votes extensions mismatch + #[error("votes extensions mismatch: got {got:?}, expected {expected:?}")] #[allow(missing_docs)] VoteExtensionMismatchReceived { got: Vec, expected: Vec, }, /// Vote extensions signature is invalid - #[error("one of vote extension signatures is invalid")] + #[error("one of votes extension signatures is invalid")] VoteExtensionsSignatureInvalid, - /// Invalid vote extensions verification - #[error("invalid vote extensions verification")] + /// Invalid votes extensions verification + #[error("invalid votes extensions verification")] InvalidVoteExtensionsVerification, /// Cannot load withdrawal transactions #[error("cannot load withdrawal transactions: {0}")] diff --git a/packages/rs-drive-abci/src/abci/handler/extend_vote.rs b/packages/rs-drive-abci/src/abci/handler/extend_vote.rs index b000deea6b..4dc4e26edf 100644 --- a/packages/rs-drive-abci/src/abci/handler/extend_vote.rs +++ b/packages/rs-drive-abci/src/abci/handler/extend_vote.rs @@ -29,7 +29,7 @@ where block_execution_context_guard .as_ref() .ok_or(Error::Execution(ExecutionError::CorruptedCodeExecution( - "block execution context must be set in block begin handler for extend vote", + "block execution context must be set in block begin handler for extend votes", )))?; // Verify Tenderdash that it called this handler correctly @@ -37,13 +37,13 @@ where if !block_state_info.matches_current_block(height as u64, round as u32, block_hash.clone())? { return Err(AbciError::RequestForWrongBlockReceived(format!( - "received extend vote request for height: {} round: {}, block: {}; expected height: {} round: {}, block: {}", + "received extend votes request for height: {} round: {}, block: {}; expected height: {} round: {}, block: {}", height, round, hex::encode(block_hash), block_state_info.height(), block_state_info.round(), block_state_info.block_hash().map(hex::encode).unwrap_or("None".to_string()) )).into()); } - // Extend vote with unsigned withdrawal transactions + // Extend votes with unsigned withdrawal transactions // we only want to sign the hash of the transaction let vote_extensions = block_execution_context .unsigned_withdrawal_transactions() diff --git a/packages/rs-drive-abci/src/abci/handler/verify_vote_extension.rs b/packages/rs-drive-abci/src/abci/handler/verify_vote_extension.rs index 47d7e27e3b..53d0ec3e3b 100644 --- a/packages/rs-drive-abci/src/abci/handler/verify_vote_extension.rs +++ b/packages/rs-drive-abci/src/abci/handler/verify_vote_extension.rs @@ -7,7 +7,7 @@ use tenderdash_abci::proto::abci as proto; use tenderdash_abci::proto::abci::response_verify_vote_extension::VerifyStatus; use tenderdash_abci::proto::abci::ExtendVoteExtension; -/// Todo: Verify vote extension not really needed because extend vote is deterministic +/// Todo: Verify votes extension not really needed because extend votes is deterministic pub fn verify_vote_extension( app: &A, request: proto::RequestVerifyVoteExtension, @@ -18,7 +18,7 @@ where { let _timer = crate::metrics::abci_request_duration("verify_vote_extension"); - // Verify that this is a vote extension for our current executed block and our proposer + // Verify that this is a votes extension for our current executed block and our proposer let proto::RequestVerifyVoteExtension { height, round, @@ -33,7 +33,7 @@ where let block_execution_context_ref = app.block_execution_context().read().unwrap(); let Some(block_execution_context) = block_execution_context_ref.as_ref() else { tracing::warn!( - "vote extensions for height: {}, round: {} are rejected because we are not in a block execution phase", + "votes extensions for height: {}, round: {} are rejected because we are not in a block execution phase", height, round, ); @@ -43,17 +43,17 @@ where }); }; - // Make sure vote extension is for our currently executing block + // Make sure votes extension is for our currently executing block let block_state_info = block_execution_context.block_state_info(); - // We might get vote extension to verify for previous (in case if other node is behind) + // We might get votes extension to verify for previous (in case if other node is behind) // or future round (in case if the current node is behind), so we make sure that only height // is matching. It's fine because withdrawal transactions to sign are the same for any round // of the same height if block_state_info.height() != height { tracing::warn!( - "vote extensions for height: {}, round: {} are rejected because we are at height: {}", + "votes extensions for height: {}, round: {} are rejected because we are at height: {}", height, round, block_state_info.height(), @@ -75,7 +75,7 @@ where tracing::error!( received_extensions = ?vote_extensions, ?expected_extensions, - "vote extensions for height: {}, round: {} mismatch", + "votes extensions for height: {}, round: {} mismatch", height, round ); @@ -85,7 +85,7 @@ where } tracing::debug!( - "vote extensions for height: {}, round: {} are successfully verified", + "votes extensions for height: {}, round: {} are successfully verified", height, round, ); diff --git a/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/mod.rs b/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/mod.rs index 31a95672c6..2afab0f58a 100644 --- a/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/mod.rs @@ -18,7 +18,7 @@ where /// /// This function first retrieves the block execution context and decomposes the request. It then checks /// if the received block matches the expected block information (height, round, hash, etc.). If everything - /// matches, the function verifies the commit signature (if enabled) and the vote extensions. If all checks + /// matches, the function verifies the commit signature (if enabled) and the votes extensions. If all checks /// pass, the block is committed to the state. /// /// # Arguments diff --git a/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs index ae78f60361..ad8859b26a 100644 --- a/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs @@ -46,7 +46,7 @@ where /// /// This function first retrieves the block execution context and decomposes the request. It then checks /// if the received block matches the expected block information (height, round, hash, etc.). If everything - /// matches, the function verifies the commit signature (if enabled) and the vote extensions. If all checks + /// matches, the function verifies the commit signature (if enabled) and the votes extensions. If all checks /// pass, the block is committed to the state. /// /// # Arguments @@ -136,8 +136,8 @@ where return Ok(validation_result.into()); } - // Verify vote extensions - // We don't need to verify vote extension signatures once again after tenderdash + // Verify votes extensions + // We don't need to verify votes extension signatures once again after tenderdash // here, because we will do it bellow broadcasting withdrawal transactions. // The sendrawtransaction RPC method returns an error if quorum signature is invalid let expected_withdrawal_transactions = @@ -213,7 +213,7 @@ where let signature_bytes: [u8; 96] = vote_extension.signature.try_into().map_err(|e| { AbciError::BadRequestDataSize(format!( - "invalid vote extension signature size: {}", + "invalid votes extension signature size: {}", hex::encode(e) )) })?; diff --git a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs index 46b793e4ff..c0c106ce7e 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/upgrade_protocol_version/v0/mod.rs @@ -79,7 +79,7 @@ impl Platform { // We clean voting counter cache only on finalize block because: // 1. The voting counter global cache uses for querying of voting information in Drive queries - // 2. There might be multiple rounds so on the next round we will lose all previous epoch votes + // 2. There might be multiple rounds so on the next round we will lose all previous epoch vote_choices // // Instead of clearing cache, the further block processing logic is using `get_if_enabled` // to get a version counter from the global cache. We disable this getter here to prevent diff --git a/packages/rs-drive-abci/src/execution/types/block_execution_context/v0/mod.rs b/packages/rs-drive-abci/src/execution/types/block_execution_context/v0/mod.rs index 9f6aaa8f4e..9276f1ff8a 100644 --- a/packages/rs-drive-abci/src/execution/types/block_execution_context/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/types/block_execution_context/v0/mod.rs @@ -44,7 +44,7 @@ pub struct BlockExecutionContextV0 { pub epoch_info: EpochInfo, /// Total hpmn count pub hpmn_count: u32, - /// Unsigned withdrawal transactions to be available for extend and verify vote handlers + /// Unsigned withdrawal transactions to be available for extend and verify votes handlers pub unsigned_withdrawal_transactions: UnsignedWithdrawalTxs, /// Block state pub block_platform_state: PlatformState, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index af4801efd2..6c6d188f9a 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -39,7 +39,7 @@ impl StateTransitionActionTransformerV0 for MasternodeVoteTransition { { 0 => self.transform_into_action_v0(), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { - method: "masternode vote state transition: transform_into_action".to_string(), + method: "masternode votes state transition: transform_into_action".to_string(), known_versions: vec![0], received: version, })), @@ -64,7 +64,7 @@ impl StateTransitionStructureValidationV0 for MasternodeVoteTransition { { 0 => self.validate_base_structure_v0(), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { - method: "masternode vote state transition: validate_structure".to_string(), + method: "masternode votes state transition: validate_structure".to_string(), known_versions: vec![0], received: version, })), @@ -90,7 +90,7 @@ impl StateTransitionStateValidationV0 for MasternodeVoteTransition { { 0 => self.validate_state_v0(platform, tx, platform_version), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { - method: "masternode vote state transition: validate_state".to_string(), + method: "masternode votes state transition: validate_state".to_string(), known_versions: vec![0], received: version, })), diff --git a/packages/rs-drive-abci/src/mimic/mod.rs b/packages/rs-drive-abci/src/mimic/mod.rs index d548590106..6e24e39515 100644 --- a/packages/rs-drive-abci/src/mimic/mod.rs +++ b/packages/rs-drive-abci/src/mimic/mod.rs @@ -392,14 +392,14 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { let response_extend_vote = self.extend_vote(request_extend_vote).unwrap_or_else(|e| { panic!( - "should extend vote #{} at time #{} : {:?}", + "should extend votes #{} at time #{} : {:?}", block_info.height, block_info.time_ms, e ) }); let vote_extensions = response_extend_vote.vote_extensions; - // for all proposers in the quorum we much verify each vote extension + // for all proposers in the quorum we much verify each votes extension for validator in current_quorum.validator_set.iter() { let request_verify_vote_extension = RequestVerifyVoteExtension { @@ -413,7 +413,7 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { .verify_vote_extension(request_verify_vote_extension) .unwrap_or_else(|e| { panic!( - "should verify vote extension #{} at time #{} : {:?}", + "should verify votes extension #{} at time #{} : {:?}", block_info.height, block_info.time_ms, e ) }); @@ -424,7 +424,7 @@ impl<'a, C: CoreRPCLike> FullAbciApplication<'a, C> { } } - //FixMe: This is not correct for the threshold vote extension (we need to sign and do + //FixMe: This is not correct for the threshold votes extension (we need to sign and do // things differently let block_execution_context_ref = self.block_execution_context.read().unwrap(); diff --git a/packages/rs-drive-abci/src/platform_types/cleaned_abci_messages/cleaned_commit_info/v0/mod.rs b/packages/rs-drive-abci/src/platform_types/cleaned_abci_messages/cleaned_commit_info/v0/mod.rs index a35e8960f2..71092b34d4 100644 --- a/packages/rs-drive-abci/src/platform_types/cleaned_abci_messages/cleaned_commit_info/v0/mod.rs +++ b/packages/rs-drive-abci/src/platform_types/cleaned_abci_messages/cleaned_commit_info/v0/mod.rs @@ -15,7 +15,7 @@ pub struct CleanedCommitInfo { pub quorum_hash: [u8; 32], /// The aggregated BLS signature for the block pub block_signature: [u8; 96], - /// The list of additional vote extensions, if any + /// The list of additional votes extensions, if any pub threshold_vote_extensions: Vec, } diff --git a/packages/rs-drive-abci/src/platform_types/withdrawal/unsigned_withdrawal_txs/v0/mod.rs b/packages/rs-drive-abci/src/platform_types/withdrawal/unsigned_withdrawal_txs/v0/mod.rs index feb02c4453..0d61d4e471 100644 --- a/packages/rs-drive-abci/src/platform_types/withdrawal/unsigned_withdrawal_txs/v0/mod.rs +++ b/packages/rs-drive-abci/src/platform_types/withdrawal/unsigned_withdrawal_txs/v0/mod.rs @@ -47,7 +47,7 @@ impl UnsignedWithdrawalTxs { self.0.append(&mut other.0); } - /// Verifies that the collection of unsigned withdrawal transactions matches the given vote extensions + /// Verifies that the collection of unsigned withdrawal transactions matches the given votes extensions /// created based on these transactions pub fn are_matching_with_vote_extensions(&self, other: &[VoteExtension]) -> bool { if self.0.len() != other.len() { diff --git a/packages/rs-drive-abci/src/query/system/version_upgrade_vote_status/mod.rs b/packages/rs-drive-abci/src/query/system/version_upgrade_vote_status/mod.rs index b99caf6f49..48dbacbd9b 100644 --- a/packages/rs-drive-abci/src/query/system/version_upgrade_vote_status/mod.rs +++ b/packages/rs-drive-abci/src/query/system/version_upgrade_vote_status/mod.rs @@ -13,7 +13,7 @@ use dapi_grpc::platform::v0::{ use dpp::version::PlatformVersion; impl Platform { - /// Querying of version upgrade vote status + /// Querying of version upgrade votes status pub fn query_version_upgrade_vote_status( &self, GetProtocolVersionUpgradeVoteStatusRequest { version } : GetProtocolVersionUpgradeVoteStatusRequest, diff --git a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs index 7b58873451..2d4dac2e7e 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/upgrade_fork_tests.rs @@ -504,7 +504,7 @@ mod tests { #[test] fn run_chain_on_epoch_change_with_new_version_and_removing_votes() { - // Add a new version to upgrade to new protocol version only with one vote + // Add a new version to upgrade to new protocol version only with one votes const TEST_PROTOCOL_VERSION_4_WITH_1_HPMN_UPGRADE: u32 = (1 << TEST_PROTOCOL_VERSION_SHIFT_BYTES) + 4; diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index 246e4a9af6..6e69c46369 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -20,6 +20,7 @@ mod tests { use strategy_tests::operations::{DocumentAction, DocumentOp, Operation, OperationType}; use strategy_tests::transitions::create_state_transitions_for_identities; use tenderdash_abci::proto::types::CoreChainLock; + use strategy_tests::{IdentityInsertInfo, StartIdentities}; #[test] fn run_chain_block_two_state_transitions_conflicting_unique_index() { @@ -27,15 +28,16 @@ mod tests { // We use the dpns contract and we insert two documents both with the same "name" // This is a common scenario we should see quite often let config = PlatformConfig { - quorum_size: 100, + validator_set_quorum_size: 100, + validator_set_quorum_type: "llmq_100_67".to_string(), + chain_lock_quorum_type: "llmq_100_67".to_string(), execution: ExecutionConfig { //we disable document triggers because we are using dpns and dpns needs a preorder use_document_triggers: false, - validator_set_quorum_rotation_block_count: 25, + validator_set_rotation_block_count: 25, ..Default::default() }, block_spacing_ms: 3000, - testing_configs: PlatformTestConfig::default_with_no_block_signing(), ..Default::default() }; let mut platform = TestPlatformBuilder::new() @@ -74,9 +76,15 @@ mod tests { &mut rng, platform_version, ); + + let dpns_contract = platform.drive.cache.system_data_contracts.load_dpns().as_ref().clone(); + let document_type = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type") + .to_owned_document_type(); let document_op_1 = DocumentOp { - contract: platform.drive.system_contracts.dpns_contract.clone(), + contract: dpns_contract.clone(), action: DocumentAction::DocumentActionInsertSpecific( BTreeMap::from([ ("label".into(), "quantum".into()), @@ -95,17 +103,11 @@ mod tests { DocumentFieldFillType::FillIfNotRequired, DocumentFieldFillSize::AnyDocumentFillSize, ), - document_type: platform - .drive - .system_contracts - .dpns_contract - .document_type_for_name("domain") - .expect("expected a profile document type") - .to_owned_document_type(), + document_type: document_type.clone(), }; let document_op_2 = DocumentOp { - contract: platform.drive.system_contracts.dpns_contract.clone(), + contract: dpns_contract, action: DocumentAction::DocumentActionInsertSpecific( BTreeMap::from([ ("label".into(), "quantum".into()), @@ -124,18 +126,12 @@ mod tests { DocumentFieldFillType::FillIfNotRequired, DocumentFieldFillSize::AnyDocumentFillSize, ), - document_type: platform - .drive - .system_contracts - .dpns_contract - .document_type_for_name("domain") - .expect("expected a profile document type") - .to_owned_document_type(), + document_type: document_type.clone(), }; let strategy = NetworkStrategy { strategy: Strategy { - contracts_with_updates: vec![], + start_contracts: vec![], operations: vec![ Operation { op_type: OperationType::Document(document_op_1), @@ -152,46 +148,32 @@ mod tests { }, }, ], - start_identities, - identities_inserts: Frequency { - times_per_block_range: Default::default(), - chance_per_block: None, + start_identities: StartIdentities::default(), + identity_inserts: IdentityInsertInfo { + frequency: Frequency { + times_per_block_range: 1..2, + chance_per_block: None, + }, + ..Default::default() }, - signer: Some(simple_signer), + + identity_contract_nonce_gaps: None, + signer: None, }, total_hpmns: 100, extra_normal_mns: 0, - quorum_count: 24, + validator_quorum_count: 24, + chain_lock_quorum_count: 24, upgrading_info: None, - core_height_increase: Frequency { - times_per_block_range: Default::default(), - chance_per_block: None, - }, proposer_strategy: Default::default(), rotate_quorums: false, failure_testing: None, query_testing: None, verify_state_transition_results: true, + ..Default::default() }; - let mut core_block_heights = vec![10, 11]; - - platform - .core_rpc - .expect_get_best_chain_lock() - .returning(move || { - let core_block_height = if core_block_heights.len() == 1 { - *core_block_heights.first().unwrap() - } else { - core_block_heights.remove(0) - }; - Ok(CoreChainLock { - core_block_height, - core_block_hash: [1; 32].to_vec(), - signature: [2; 96].to_vec(), - }) - }); // On the first block we only have identities and contracts let outcome = run_chain_for_strategy(&mut platform, 2, strategy.clone(), config.clone(), 15); diff --git a/packages/rs-drive-proof-verifier/src/types.rs b/packages/rs-drive-proof-verifier/src/types.rs index 42b6f531c8..592ccd7997 100644 --- a/packages/rs-drive-proof-verifier/src/types.rs +++ b/packages/rs-drive-proof-verifier/src/types.rs @@ -77,13 +77,13 @@ pub type ExtendedEpochInfos = RetrievedObjects; /// Results of protocol version upgrade voting. /// -/// Information about the protocol version upgrade states and number of received votes, indexed by protocol version. +/// Information about the protocol version upgrade states and number of received vote_choices, indexed by protocol version. /// Returned by [ProtocolVersionVoteCount::fetch_many()]. /// /// ## Data Structure /// /// * [`ProtocolVersion`] - key determining protocol version -/// * [`ProtocolVersionVoteCount`] - value, number of votes for the protocol version upgrade +/// * [`ProtocolVersionVoteCount`] - value, number of vote_choices for the protocol version upgrade pub type ProtocolVersionUpgrades = RetrievedObjects; /// Vote of a masternode for a protocol version. diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs index 698122549b..80706cb91e 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs @@ -11,7 +11,7 @@ use dpp::version::PlatformVersion; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; -use dpp::voting::{ContestedDocumentResourceVoteType, Vote}; +use dpp::voting::votes::Vote; /// Operations on Identities #[derive(Clone, Debug)] @@ -75,7 +75,7 @@ pub enum IdentityOperationType { /// The revision we are updating to revision: Revision, }, - /// Casts a vote as a masternode. + /// Casts a votes as a masternode. MasternodeCastVote { /// The pro tx hash of the masternode doing the voting voter_pro_tx_hash: [u8; 32], diff --git a/packages/rs-drive/src/drive/cache.rs b/packages/rs-drive/src/drive/cache.rs index 936869cf04..5cda6dd097 100644 --- a/packages/rs-drive/src/drive/cache.rs +++ b/packages/rs-drive/src/drive/cache.rs @@ -16,7 +16,7 @@ pub struct DriveCache { /// Genesis time in ms pub genesis_time_ms: parking_lot::RwLock>, // TODO: Make protocol versions cache thread-safe - /// Lazy loaded counter of votes to upgrade protocol version + /// Lazy loaded counter of vote_choices to upgrade protocol version pub protocol_versions_counter: parking_lot::RwLock, /// Versioned system data contracts pub system_data_contracts: SystemDataContracts, diff --git a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs index 298b732528..fadd5a5dfe 100644 --- a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -291,9 +291,13 @@ impl Drive { if !inserted { return Err(Error::Drive(DriveError::CorruptedContractIndexes( - "contested vote tree already exists", + "contested votes tree already exists", ))); } + + // Now we need to add a reference to this votes, so we can keep track of it more easily + + self.add_new_masternode_vote_type() } } else { let key_element_info = diff --git a/packages/rs-drive/src/drive/initialization/v0/mod.rs b/packages/rs-drive/src/drive/initialization/v0/mod.rs index 8f182d4e66..1f9ef3a882 100644 --- a/packages/rs-drive/src/drive/initialization/v0/mod.rs +++ b/packages/rs-drive/src/drive/initialization/v0/mod.rs @@ -195,7 +195,7 @@ impl Drive { // For Versioning via forks Drive::add_initial_fork_update_structure_operations(&mut batch); - // For the vote tree structure + // For the votes tree structure Drive::add_initial_vote_tree_main_structure_operations(&mut batch, platform_version)?; diff --git a/packages/rs-drive/src/drive/mod.rs b/packages/rs-drive/src/drive/mod.rs index c4bab2ad1f..82a83bf87e 100644 --- a/packages/rs-drive/src/drive/mod.rs +++ b/packages/rs-drive/src/drive/mod.rs @@ -151,7 +151,7 @@ pub enum RootTree { TokenBalances = 16, /// Versions desired by proposers Versions = 120, - /// Registered votes + /// Registered vote_choices Votes = 112, } diff --git a/packages/rs-drive/src/drive/protocol_upgrade/fetch_proved_validator_version_votes/mod.rs b/packages/rs-drive/src/drive/protocol_upgrade/fetch_proved_validator_version_votes/mod.rs index 34667e8c16..aba2c52abb 100644 --- a/packages/rs-drive/src/drive/protocol_upgrade/fetch_proved_validator_version_votes/mod.rs +++ b/packages/rs-drive/src/drive/protocol_upgrade/fetch_proved_validator_version_votes/mod.rs @@ -8,11 +8,11 @@ use dpp::version::drive_versions::DriveVersion; use grovedb::TransactionArg; impl Drive { - /// Fetch validator votes for versions + /// Fetch validator vote_choices for versions /// /// # Arguments /// - /// * `start_protx_hash` - The first identifier to get votes from. If none is set start from the + /// * `start_protx_hash` - The first identifier to get vote_choices from. If none is set start from the /// first item by ordered hash. /// * `count` - How many max items to retrieve. /// * `transaction` - A `TransactionArg` object representing the transaction. diff --git a/packages/rs-drive/src/drive/protocol_upgrade/fetch_proved_validator_version_votes/v0/mod.rs b/packages/rs-drive/src/drive/protocol_upgrade/fetch_proved_validator_version_votes/v0/mod.rs index ab4b2f7186..2a6449ada3 100644 --- a/packages/rs-drive/src/drive/protocol_upgrade/fetch_proved_validator_version_votes/v0/mod.rs +++ b/packages/rs-drive/src/drive/protocol_upgrade/fetch_proved_validator_version_votes/v0/mod.rs @@ -19,7 +19,7 @@ impl Drive { ) -> Result, Error> { if count == 0 { return Err(Error::Query(QuerySyntaxError::NoQueryItems( - "We did not ask for the votes of any validators", + "We did not ask for the vote_choices of any validators", ))); } let path = desired_version_for_validators_path_vec(); diff --git a/packages/rs-drive/src/drive/protocol_upgrade/fetch_validator_version_votes/mod.rs b/packages/rs-drive/src/drive/protocol_upgrade/fetch_validator_version_votes/mod.rs index f2bd0b430a..1b0bec6973 100644 --- a/packages/rs-drive/src/drive/protocol_upgrade/fetch_validator_version_votes/mod.rs +++ b/packages/rs-drive/src/drive/protocol_upgrade/fetch_validator_version_votes/mod.rs @@ -10,18 +10,18 @@ use dpp::util::deserializer::ProtocolVersion; use grovedb::TransactionArg; impl Drive { - /// Fetch validator votes for versions + /// Fetch validator vote_choices for versions /// /// # Arguments /// - /// * `start_protx_hash` - The first identifier to get votes from. If none is set start from the + /// * `start_protx_hash` - The first identifier to get vote_choices from. If none is set start from the /// first item by ordered hash. /// * `count` - How many max items to retrieve. /// * `transaction` - A `TransactionArg` object representing the transaction. /// /// # Returns /// - /// * `Result, Error>` - If successful, returns an `Ok(BTreeMap<[u8;32], ProtocolVersion>)` which contains the versions votes by validators. If an error occurs during the operation, returns an `Error`. + /// * `Result, Error>` - If successful, returns an `Ok(BTreeMap<[u8;32], ProtocolVersion>)` which contains the versions vote_choices by validators. If an error occurs during the operation, returns an `Error`. /// /// # Errors /// diff --git a/packages/rs-drive/src/drive/protocol_upgrade/fetch_validator_version_votes/v0/mod.rs b/packages/rs-drive/src/drive/protocol_upgrade/fetch_validator_version_votes/v0/mod.rs index b3de731328..fadd0e3e41 100644 --- a/packages/rs-drive/src/drive/protocol_upgrade/fetch_validator_version_votes/v0/mod.rs +++ b/packages/rs-drive/src/drive/protocol_upgrade/fetch_validator_version_votes/v0/mod.rs @@ -24,7 +24,7 @@ impl Drive { ) -> Result, Error> { if count == 0 { return Err(Error::Query(QuerySyntaxError::NoQueryItems( - "We did not ask for the votes of any validators", + "We did not ask for the vote_choices of any validators", ))); } let path = desired_version_for_validators_path_vec(); diff --git a/packages/rs-drive/src/drive/verify/system/verify_upgrade_state/v0/mod.rs b/packages/rs-drive/src/drive/verify/system/verify_upgrade_state/v0/mod.rs index be917455bf..e1e1cfe38e 100644 --- a/packages/rs-drive/src/drive/verify/system/verify_upgrade_state/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/system/verify_upgrade_state/v0/mod.rs @@ -20,7 +20,7 @@ impl Drive { /// # Returns /// /// Returns a `Result` with a tuple of `RootHash` and `IntMap`. The `IntMap` - /// represents vote count of each version in the current epoch. + /// represents votes count of each version in the current epoch. /// /// # Errors /// diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs index bbc8ce49bf..0d5b38b5c1 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs @@ -10,7 +10,7 @@ use dpp::version::PlatformVersion; use grovedb::TransactionArg; impl Drive { - /// We remove votes for an identity when that identity is somehow disabled. Currently there is + /// We remove vote_choices for an identity when that identity is somehow disabled. Currently there is /// no way to "disable" identities except for masternodes being removed from the list pub fn remove_votes_for_identity( &self, diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs index b6ea84fc29..df234efa41 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs @@ -10,14 +10,14 @@ use crate::query::QueryItem; use dpp::prelude::Identifier; use dpp::serialization::PlatformDeserializable; use dpp::version::PlatformVersion; -use dpp::voting::ContestedDocumentResourceVoteType; +use dpp::voting::ContestedDocumentResourceVote; use grovedb::query_result_type::QueryResultType::QueryElementResultType; use grovedb::{Element, PathQuery, Query, SizedQuery, TransactionArg}; use grovedb_path::SubtreePath; use crate::drive::votes::TreePath; impl Drive { - /// We remove votes for an identity when that identity is somehow disabled. Currently there is + /// We remove vote_choices for an identity when that identity is somehow disabled. Currently there is /// no way to "disable" identities except for masternodes being removed from the list pub(super) fn remove_votes_for_identity_v0( &self, @@ -25,7 +25,7 @@ impl Drive { transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { - // We first query for all votes that the identity has + // We first query for all vote_choices that the identity has let vote_path = vote_contested_resource_identity_votes_tree_path_for_identity_vec( identity_id.as_bytes(), @@ -51,19 +51,19 @@ impl Drive { .0 .to_elements(); - // Then we take each vote and go looking for it (to remove it) + // Then we take each votes and go looking for it (to remove it) let mut deletion_batch = vec![]; for vote_to_remove in votes_to_remove_elements { let Element::Item(vote, ..) = vote_to_remove else { return Err(Error::Drive(DriveError::CorruptedDriveState(format!( - "vote {:?} for identity {} is not an item", + "votes {:?} for identity {} is not an item", vote_to_remove, identity_id )))); }; - let vote = ContestedDocumentResourceVoteType::deserialize_from_bytes(vote.as_slice())?; + let vote = ContestedDocumentResourceVote::deserialize_from_bytes(vote.as_slice())?; // we then need to add to the batch the deletion diff --git a/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs index 8b13789179..ac341b7343 100644 --- a/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs @@ -1 +1,24 @@ +use grovedb::TransactionArg; +use dpp::block::block_info::BlockInfo; +use dpp::fee::fee_result::FeeResult; +use dpp::identifier::Identifier; +use platform_version::version::PlatformVersion; +use crate::drive::Drive; +use crate::drive::object_size_info::OwnedDocumentInfo; +use crate::error::Error; +impl Drive { + pub(super) fn add_new_masternode_vote_type_v0( + &self, + owned_document_info: OwnedDocumentInfo, + data_contract_id: Identifier, + document_type_name: &str, + override_document: bool, + block_info: &BlockInfo, + apply: bool, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + + } +} diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs index 025f4824f3..af36e1114c 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs @@ -11,7 +11,7 @@ use dpp::fee::fee_result::FeeResult; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; -use dpp::voting::ContestedDocumentResourceVoteType; +use dpp::voting::ContestedDocumentResourceVote; use grovedb::{EstimatedLayerInformation, TransactionArg}; use dpp::identifier::Identifier; use dpp::prelude::IdentityNonce; @@ -21,7 +21,7 @@ impl Drive { pub fn register_contested_resource_identity_vote( &self, voter_pro_tx_hash: [u8;32], - vote: ContestedDocumentResourceVoteType, + vote: ContestedDocumentResourceVote, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, @@ -53,7 +53,7 @@ impl Drive { pub fn register_contested_resource_identity_vote_operations( &self, voter_pro_tx_hash: [u8;32], - vote: ContestedDocumentResourceVoteType, + vote: ContestedDocumentResourceVote, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< HashMap, diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index ae144922fc..cc762748a0 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -6,7 +6,7 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; -use dpp::voting::ContestedDocumentResourceVoteType; +use dpp::voting::ContestedDocumentResourceVote; use grovedb::{EstimatedLayerInformation, TransactionArg}; use dpp::prelude::{Identifier, IdentityNonce}; use platform_version::version::PlatformVersion; @@ -15,7 +15,7 @@ impl Drive { pub fn register_contested_resource_identity_vote_v0( &self, voter_pro_tx_hash: [u8;32], - vote: ContestedDocumentResourceVoteType, + vote: ContestedDocumentResourceVote, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, @@ -39,7 +39,7 @@ impl Drive { pub fn register_contested_resource_identity_vote_operations_v0( &self, voter_pro_tx_hash: [u8;32], - vote: ContestedDocumentResourceVoteType, + vote: ContestedDocumentResourceVote, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< HashMap, diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/mod.rs index acafadf0a9..56971ec259 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/mod.rs @@ -12,8 +12,8 @@ use dpp::version::PlatformVersion; use grovedb::TransactionArg; impl Drive { - /// We add vote poll references by end date in order to be able to check on every new block if - /// any vote poll should be closed. + /// We add votes poll references by end date in order to be able to check on every new block if + /// any votes poll should be closed. pub fn add_vote_poll_end_date_query( &self, identity_id: Identifier, @@ -25,11 +25,11 @@ impl Drive { .methods .vote .contested_resource_insert - .register_identity_vote + .add_vote_poll_end_date_query { 0 => self.add_vote_poll_end_date_query_v0(identity_id, transaction, platform_version), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "register_identity_vote_for_identity_queries".to_string(), + method: "add_vote_poll_end_date_query".to_string(), known_versions: vec![0], received: version, })), diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs index 8b13789179..28fe66d1c5 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs @@ -1 +1,22 @@ +use grovedb::TransactionArg; +use dpp::fee::fee_result::FeeResult; +use dpp::identifier::Identifier; +use dpp::identity::TimestampMillis; +use dpp::voting::votes::Vote; +use platform_version::version::PlatformVersion; +use crate::drive::Drive; +use crate::error::Error; +impl Drive { + /// We add votes poll references by end date in order to be able to check on every new block if + /// any votes poll should be closed. + pub(super) fn add_vote_poll_end_date_query_v0( + &self, + contract_id: Vote, + end_date: TimestampMillis, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + + } +} diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs index b62fe22a8a..e4e3bbf3b2 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs @@ -10,7 +10,7 @@ use crate::error::Error; use dpp::fee::fee_result::FeeResult; use dpp::version::PlatformVersion; -use dpp::voting::Vote; +use dpp::voting::votes::Vote; use grovedb::{EstimatedLayerInformation, TransactionArg}; use dpp::block::block_info::BlockInfo; use crate::fee::op::LowLevelDriveOperation; diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs index 85a94773f9..11120a1e13 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs @@ -3,7 +3,7 @@ use grovedb::batch::KeyInfoPath; use crate::drive::Drive; use crate::error::Error; use dpp::fee::fee_result::FeeResult; -use dpp::voting::Vote; +use dpp::voting::votes::Vote; use grovedb::{EstimatedLayerInformation, TransactionArg}; use dpp::block::block_info::BlockInfo; use platform_version::version::PlatformVersion; diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 3415bce0d0..d6aa86aa02 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -3,14 +3,14 @@ use crate::drive::RootTree; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::DataContract; -use dpp::voting::ContestedDocumentResourceVoteType; +use dpp::voting::ContestedDocumentResourceVote; use dpp::ProtocolError; mod cleanup; mod insert; mod setup; -/// The vote tree structure looks likes this +/// The votes tree structure looks likes this /// /// Votes /// @@ -128,11 +128,11 @@ pub trait TreePath { fn tree_path(&self, contract: &DataContract) -> Result, ProtocolError>; } -impl TreePath for ContestedDocumentResourceVoteType { +impl TreePath for ContestedDocumentResourceVote { fn tree_path(&self, contract: &DataContract) -> Result, ProtocolError> { if contract.id() != self.vote_poll.contract_id { return Err(ProtocolError::VoteError(format!( - "contract id of vote {} does not match supplied contract {}", + "contract id of votes {} does not match supplied contract {}", self.vote_poll.contract_id, contract.id() ))); @@ -143,7 +143,7 @@ impl TreePath for ContestedDocumentResourceVoteType { .iter() .find(|index| &index.name == &self.vote_poll.index_name) .ok_or(ProtocolError::VoteError(format!( - "vote index name {} not found", + "votes index name {} not found", &self.vote_poll.index_name )))?; let mut path = contract_document_type_path( @@ -156,7 +156,7 @@ impl TreePath for ContestedDocumentResourceVoteType { let Some(contested_index) = &index.contested_index else { return Err(ProtocolError::VoteError( - "we expect the index in a contested document resource vote type to be contested" + "we expect the index in a contested document resource votes type to be contested" .to_string(), )); }; diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs index 9705d87543..f0f27144d7 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs @@ -7,7 +7,7 @@ use crate::state_transition_action::identity::masternode_vote::v0::MasternodeVot use derive_more::From; use dpp::platform_value::Identifier; use dpp::prelude::IdentityNonce; -use dpp::voting::Vote; +use dpp::voting::votes::Vote; /// action #[derive(Debug, Clone, From)] @@ -24,14 +24,14 @@ impl MasternodeVoteTransitionAction { } } - /// Resource vote + /// Resource votes pub fn vote_ref(&self) -> &Vote { match self { MasternodeVoteTransitionAction::V0(transition) => &transition.vote, } } - /// Resource vote as owned + /// Resource votes as owned pub fn vote_owned(self) -> Vote { match self { MasternodeVoteTransitionAction::V0(transition) => transition.vote, diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs index 2c48cfc24d..3658568838 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs @@ -2,14 +2,14 @@ mod transformer; use dpp::platform_value::Identifier; use dpp::prelude::IdentityNonce; -use dpp::voting::Vote; +use dpp::voting::votes::Vote; /// action v0 #[derive(Default, Debug, Clone)] pub struct MasternodeVoteTransitionActionV0 { /// the pro tx hash identifier of the masternode pub pro_tx_hash: Identifier, - /// the resource vote + /// the resource votes pub vote: Vote, /// nonce pub nonce: IdentityNonce, diff --git a/packages/rs-drive/src/state_transition_action/identity/mod.rs b/packages/rs-drive/src/state_transition_action/identity/mod.rs index 5c03b202ad..b2be1f236b 100644 --- a/packages/rs-drive/src/state_transition_action/identity/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/mod.rs @@ -8,5 +8,5 @@ pub mod identity_credit_withdrawal; pub mod identity_topup; /// identity update pub mod identity_update; -/// masternode vote +/// masternode votes pub mod masternode_vote; diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 0eb65adfd1..ed2717b5a9 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -265,6 +265,7 @@ pub struct DriveVoteInsertMethodVersions { pub struct DriveVoteContestedResourceInsertMethodVersions { pub register_contested_resource_identity_vote: FeatureVersion, pub register_identity_vote: FeatureVersion, + pub add_vote_poll_end_date_query: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 67cf74498d..eff8ae688c 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -217,6 +217,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { register_contested_resource_identity_vote: 0, register_identity_vote: 0, + add_vote_poll_end_date_query: 0, }, cleanup: DriveVoteCleanupMethodVersions { remove_votes_for_identity: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 84b154f932..2ef043d94f 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -223,6 +223,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { register_contested_resource_identity_vote: 0, register_identity_vote: 0, + add_vote_poll_end_date_query: 0, }, cleanup: DriveVoteCleanupMethodVersions { remove_votes_for_identity: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 9958a3ba49..4f6c6f6c68 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -214,6 +214,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { register_contested_resource_identity_vote: 0, register_identity_vote: 0, + add_vote_poll_end_date_query: 0, }, cleanup: DriveVoteCleanupMethodVersions { remove_votes_for_identity: 0, diff --git a/packages/rs-sdk/src/platform/fetch_many.rs b/packages/rs-sdk/src/platform/fetch_many.rs index 6bfc96f92f..d6ecf07c5a 100644 --- a/packages/rs-sdk/src/platform/fetch_many.rs +++ b/packages/rs-sdk/src/platform/fetch_many.rs @@ -261,7 +261,7 @@ impl FetchMany for ExtendedEpochInfo { type Request = GetEpochsInfoRequest; } -/// Fetch information about number of votes for each protocol version upgrade. +/// Fetch information about number of vote_choices for each protocol version upgrade. /// /// Returns [ProtocolVersionUpgrades](drive_proof_verifier::types::ProtocolVersionUpgrades) /// indexed by [ProtocolVersion](dpp::util::deserializer::ProtocolVersion). diff --git a/packages/rs-sdk/src/platform/types/version_votes.rs b/packages/rs-sdk/src/platform/types/version_votes.rs index 651472cb05..8261e38ca2 100644 --- a/packages/rs-sdk/src/platform/types/version_votes.rs +++ b/packages/rs-sdk/src/platform/types/version_votes.rs @@ -1,4 +1,4 @@ -//! Helpers for managing platform version votes +//! Helpers for managing platform version vote_choices use crate::platform::fetch_many::FetchMany; use crate::{platform::LimitQuery, Error, Sdk}; @@ -11,14 +11,14 @@ use drive_proof_verifier::types::{MasternodeProtocolVote, MasternodeProtocolVote /// Helper trait for managing MasternodeProtocolVote objects #[async_trait] pub trait MasternodeProtocolVoteEx { - /// Fetch masternode votes for version update from the platform. + /// Fetch masternode vote_choices for version update from the platform. /// /// ## Parameters /// /// - `sdk`: An instance of [Sdk]. - /// - `start_protxhash`: [ProTxHash] of the first masternode to fetch votes for. + /// - `start_protxhash`: [ProTxHash] of the first masternode to fetch vote_choices for. /// Use `None` to start from the beginning. - /// - `limit`: Maximum number of votes to fetch. Defaults to + /// - `limit`: Maximum number of vote_choices to fetch. Defaults to /// [DEFAULT_NODES_VOTING_LIMIT](crate::platform::query::DEFAULT_NODES_VOTING_LIMIT) /// /// ## See also diff --git a/packages/rs-sdk/tests/fetch/protocol_version_vote_count.rs b/packages/rs-sdk/tests/fetch/protocol_version_vote_count.rs index 2c31ca7c2f..f3af50edad 100644 --- a/packages/rs-sdk/tests/fetch/protocol_version_vote_count.rs +++ b/packages/rs-sdk/tests/fetch/protocol_version_vote_count.rs @@ -12,7 +12,7 @@ async fn test_protocol_version_vote_count() { let votings = ProtocolVersionVoteCount::fetch_many(&sdk, ()) .await - .expect("fetch protocol version votes"); + .expect("fetch protocol version vote_choices"); println!("votings: {:?}", votings); diff --git a/packages/rs-sdk/tests/fetch/protocol_version_votes.rs b/packages/rs-sdk/tests/fetch/protocol_version_votes.rs index 558534ebbd..e4ac4bea64 100644 --- a/packages/rs-sdk/tests/fetch/protocol_version_votes.rs +++ b/packages/rs-sdk/tests/fetch/protocol_version_votes.rs @@ -3,7 +3,7 @@ use dash_sdk::platform::{types::version_votes::MasternodeProtocolVoteEx, FetchMa use dashcore_rpc::dashcore::{hashes::Hash, ProTxHash}; use drive_proof_verifier::types::MasternodeProtocolVote; -/// Given protxhash with only zeros, when I fetch protocol version votes for nodes, I can retrieve them. +/// Given protxhash with only zeros, when I fetch protocol version vote_choices for nodes, I can retrieve them. #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn test_protocol_version_votes_zeros() { setup_logs(); @@ -14,14 +14,14 @@ async fn test_protocol_version_votes_zeros() { let starting_protxhash = ProTxHash::from_slice(&[0u8; 32]).expect("zero protxhash"); let votings = MasternodeProtocolVote::fetch_many(&sdk, starting_protxhash) .await - .expect("fetch protocol version votes by node"); + .expect("fetch protocol version vote_choices by node"); println!("votings: {:?}", votings); assert!(!votings.is_empty()); } -/// Given protxhash with only zeros, when I fetch protocol version votes for nodes, I can retrieve them. +/// Given protxhash with only zeros, when I fetch protocol version vote_choices for nodes, I can retrieve them. #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn test_protocol_version_votes_none() { setup_logs(); @@ -31,14 +31,14 @@ async fn test_protocol_version_votes_none() { let votings = MasternodeProtocolVote::fetch_many(&sdk, None) .await - .expect("fetch protocol version votes by node"); + .expect("fetch protocol version vote_choices by node"); println!("votings: {:?}", votings); assert!(!votings.is_empty()); } -/// Given protxhash with only zeros, when I fetcg protocol version votes for nodes with limit 2, I get exactly 2 items. +/// Given protxhash with only zeros, when I fetcg protocol version vote_choices for nodes with limit 2, I get exactly 2 items. #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn test_protocol_version_votes_limit_2() { setup_logs(); @@ -49,14 +49,14 @@ async fn test_protocol_version_votes_limit_2() { let starting_protxhash = ProTxHash::from_slice(&[0u8; 32]).expect("zero protxhash"); let votings = MasternodeProtocolVote::fetch_many_with_limit(&sdk, starting_protxhash, 2) .await - .expect("fetch protocol version votes by node"); + .expect("fetch protocol version vote_choices by node"); println!("votings: {:?}", votings); assert!(votings.len() == 2); } -/// Given protxhash with only `0xFF`s, when I fetch protocol version votes for nodes, I get nothing. +/// Given protxhash with only `0xFF`s, when I fetch protocol version vote_choices for nodes, I get nothing. #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn test_protocol_version_votes_nx() { setup_logs(); @@ -67,14 +67,14 @@ async fn test_protocol_version_votes_nx() { let starting_protxhash = Some(ProTxHash::from_slice(&[0xffu8; 32]).expect("zero protxhash")); let votings = MasternodeProtocolVote::fetch_votes(&sdk, starting_protxhash, Some(2)) .await - .expect("fetch protocol version votes by node"); + .expect("fetch protocol version vote_choices by node"); println!("votings: {:?}", votings); assert!(votings.is_empty()); } -/// Given None as a protxhash, when I fetch protocol version votes for 0 nodes, I get error. +/// Given None as a protxhash, when I fetch protocol version vote_choices for 0 nodes, I get error. #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn test_protocol_version_votes_limit_0() { setup_logs(); diff --git a/packages/wallet-lib/src/types/types.d.ts b/packages/wallet-lib/src/types/types.d.ts index 950c5491b3..063ca3912e 100644 --- a/packages/wallet-lib/src/types/types.d.ts +++ b/packages/wallet-lib/src/types/types.d.ts @@ -106,7 +106,7 @@ export declare type Strategy = "simpleDescendingAccumulator" | 'simpleTransactionOptimizedAccumulator' | Function; export declare type AddressType = "external" | "internal" | "misc"; -// todo: actually, I would vote to move hdextpublic to hdextpubkey +// todo: actually, I would votes to move hdextpublic to hdextpubkey export declare type WalletType = "single_address" | "hdwallet" | "hdextpublic"; export declare type WalletObj = { network?: Network; From 82e128e625181f46217f23e17e3375feef057366 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 29 Apr 2024 17:35:05 +0700 Subject: [PATCH 031/135] more work --- .../document_type/accessors/mod.rs | 4 +-- .../document_type/accessors/v0/mod.rs | 4 +-- .../class_methods/try_from_schema/v0/mod.rs | 8 +++--- .../document_type/index_level/mod.rs | 24 ++++++++++++----- .../methods/index_for_types/v0/mod.rs | 2 +- .../document_type/methods/mod.rs | 2 +- .../document_type/v0/accessors.rs | 4 +-- .../src/data_contract/document_type/v0/mod.rs | 5 ++-- .../methods/mod.rs | 16 +++++++++++ .../methods/v0/mod.rs | 3 +++ .../contested_document_resource_vote/mod.rs | 1 + .../v0/mod.rs | 27 +++++++++++++++---- .../remove_votes_for_identity/v0/mod.rs | 2 +- .../mod.rs | 1 + .../v0/mod.rs | 18 +++++-------- .../insert/register_identity_vote/v0/mod.rs | 2 +- packages/rs-drive/src/drive/votes/mod.rs | 17 ++++++------ 17 files changed, 92 insertions(+), 48 deletions(-) create mode 100644 packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/mod.rs create mode 100644 packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/v0/mod.rs diff --git a/packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs b/packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs index 3dea66c691..ff3754afdb 100644 --- a/packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs @@ -13,7 +13,7 @@ use crate::document::transfer::Transferable; use crate::identity::SecurityLevel; use crate::nft::TradeMode; use indexmap::IndexMap; -use std::collections::BTreeSet; +use std::collections::{BTreeMap, BTreeSet}; pub use v0::*; impl DocumentTypeV0Getters for DocumentType { @@ -157,7 +157,7 @@ impl<'a> DocumentTypeV0Getters for DocumentTypeRef<'a> { } } - fn indices(&self) -> &Vec { + fn indices(&self) -> &BTreeMap { match self { DocumentTypeRef::V0(v0) => v0.indices(), } diff --git a/packages/rs-dpp/src/data_contract/document_type/accessors/v0/mod.rs b/packages/rs-dpp/src/data_contract/document_type/accessors/v0/mod.rs index c577029668..460610f625 100644 --- a/packages/rs-dpp/src/data_contract/document_type/accessors/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/accessors/v0/mod.rs @@ -10,7 +10,7 @@ use crate::document::transfer::Transferable; use crate::identity::SecurityLevel; use crate::nft::TradeMode; use indexmap::IndexMap; -use std::collections::BTreeSet; +use std::collections::{BTreeMap, BTreeSet}; pub trait DocumentTypeV0Getters { /// Returns the name of the document type. @@ -21,7 +21,7 @@ pub trait DocumentTypeV0Getters { fn schema_owned(self) -> Value; /// Returns the indices of the document type. - fn indices(&self) -> &Vec; + fn indices(&self) -> &BTreeMap; /// Returns the index structure of the document type. fn index_structure(&self) -> &IndexLevel; diff --git a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v0/mod.rs b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v0/mod.rs index 00d16d6fcf..cb481a4706 100644 --- a/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v0/mod.rs @@ -334,7 +334,7 @@ impl DocumentTypeV0 { #[cfg(feature = "validation")] let mut unique_indices_count = 0; - let indices: Vec = index_values + let indices: BTreeMap = index_values .map(|index_values| { index_values .iter() @@ -473,15 +473,15 @@ impl DocumentTypeV0 { })?; } - Ok(index) + Ok((index.name.clone(), index)) }) - .collect::, ProtocolError>>() + .collect::, ProtocolError>>() }) .transpose()? .unwrap_or_default(); let index_structure = - IndexLevel::try_from_indices(indices.as_slice(), name, platform_version)?; + IndexLevel::try_from_indices(indices.values(), name, platform_version)?; // Collect binary and identifier properties let (identifier_paths, binary_paths) = DocumentType::find_identifier_and_binary_paths( diff --git a/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs b/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs index 4187c09d54..b137798148 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs @@ -1,3 +1,4 @@ +use std::borrow::Borrow; use crate::consensus::basic::data_contract::DuplicateIndexError; use crate::consensus::basic::BasicError; use crate::consensus::ConsensusError; @@ -102,11 +103,15 @@ impl IndexLevel { None } - pub fn try_from_indices( - indices: &[Index], + pub fn try_from_indices( + indices: I, document_type_name: &str, // TODO: We shouldn't pass document type, it's only for errors platform_version: &PlatformVersion, - ) -> Result { + ) -> Result + where + I: IntoIterator, // T is the type of elements in the collection + T: Borrow, // Assuming Index is the type stored in the collection + { match platform_version .dpp .contract_versions @@ -123,10 +128,14 @@ impl IndexLevel { } } - fn try_from_indices_v0( - indices: &[Index], + fn try_from_indices_v0( + indices: I, document_type_name: &str, - ) -> Result { + ) -> Result + where + I: IntoIterator, // T is the type of elements in the collection + T: Borrow, // Assuming Index is the type stored in the collection + { let mut index_level = IndexLevel { sub_index_levels: Default::default(), has_index_with_type: None, @@ -135,7 +144,8 @@ impl IndexLevel { let mut counter: u64 = 0; - for index in indices { + for index_to_borrow in indices { + let index = index_to_borrow.borrow(); let mut current_level = &mut index_level; let mut properties_iter = index.properties.iter().peekable(); diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/index_for_types/v0/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/index_for_types/v0/mod.rs index 8b1e372a16..72c582b890 100644 --- a/packages/rs-dpp/src/data_contract/document_type/methods/index_for_types/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/methods/index_for_types/v0/mod.rs @@ -12,7 +12,7 @@ impl DocumentTypeV0 { ) -> Option<(&Index, u16)> { let mut best_index: Option<(&Index, u16)> = None; let mut best_difference = u16::MAX; - for index in self.indices.iter() { + for (_, index) in self.indices.iter() { let difference_option = index.matches(index_names, in_field_name, order_by); if let Some(difference) = difference_option { if difference == 0 { diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs index 47df2fd0f4..c2d8044aa0 100644 --- a/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs @@ -222,7 +222,7 @@ impl DocumentTypeV0Methods for DocumentTypeV0 { fn top_level_indices(&self) -> Vec<&IndexProperty> { let mut index_properties: Vec<&IndexProperty> = Vec::with_capacity(self.indices.len()); - for index in &self.indices { + for (_, index) in &self.indices { if let Some(property) = index.properties.first() { index_properties.push(property); } diff --git a/packages/rs-dpp/src/data_contract/document_type/v0/accessors.rs b/packages/rs-dpp/src/data_contract/document_type/v0/accessors.rs index ad0cb272b3..6b8165e884 100644 --- a/packages/rs-dpp/src/data_contract/document_type/v0/accessors.rs +++ b/packages/rs-dpp/src/data_contract/document_type/v0/accessors.rs @@ -12,7 +12,7 @@ use crate::document::transfer::Transferable; use crate::identity::SecurityLevel; use crate::nft::TradeMode; use indexmap::IndexMap; -use std::collections::BTreeSet; +use std::collections::{BTreeMap, BTreeSet}; impl DocumentTypeV0Getters for DocumentTypeV0 { fn name(&self) -> &String { @@ -27,7 +27,7 @@ impl DocumentTypeV0Getters for DocumentTypeV0 { self.schema } - fn indices(&self) -> &Vec { + fn indices(&self) -> &BTreeMap { &self.indices } diff --git a/packages/rs-dpp/src/data_contract/document_type/v0/mod.rs b/packages/rs-dpp/src/data_contract/document_type/v0/mod.rs index 147614713c..8f643c6b2d 100644 --- a/packages/rs-dpp/src/data_contract/document_type/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/v0/mod.rs @@ -1,5 +1,6 @@ use indexmap::IndexMap; -use std::collections::BTreeSet; +use std::collections::{BTreeMap, BTreeSet}; +use serde_json::map::BTreeMap; use crate::data_contract::document_type::index::Index; use crate::data_contract::document_type::index_level::IndexLevel; @@ -41,7 +42,7 @@ pub const STORAGE_FLAGS_SIZE: usize = 2; pub struct DocumentTypeV0 { pub(in crate::data_contract) name: String, pub(in crate::data_contract) schema: Value, - pub(in crate::data_contract) indices: Vec, + pub(in crate::data_contract) indices: BTreeMap, pub(in crate::data_contract) index_structure: IndexLevel, /// Flattened properties flatten all objects for quick lookups for indexes /// Document field should not contain sub objects. diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/mod.rs b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/mod.rs new file mode 100644 index 0000000000..e26d8f2ca3 --- /dev/null +++ b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/mod.rs @@ -0,0 +1,16 @@ +use crate::data_contract::accessors::v0::DataContractV0Getters; +use crate::data_contract::document_type::accessors::DocumentTypeV0Getters; +use crate::prelude::DataContract; +use crate::ProtocolError; +use crate::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; +use crate::voting::votes::contested_document_resource_vote::methods::v0::ContestedDocumentResourceVoteMethodsV0; + +mod v0; + +impl ContestedDocumentResourceVoteMethodsV0 for ContestedDocumentResourceVote { + fn index_path(&self, contract: &DataContract) -> Result>, ProtocolError> { + let vote_poll = self.vote_poll(); + let document_type = contract.document_type_for_name(vote_poll.document_type_name.as_str())?; + let index = document_type.indices().get(&vote_poll.index_name).ok_or(ProtocolError::); + } +} \ No newline at end of file diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/v0/mod.rs b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/v0/mod.rs new file mode 100644 index 0000000000..8ff91d2250 --- /dev/null +++ b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/v0/mod.rs @@ -0,0 +1,3 @@ +pub trait ContestedDocumentResourceVoteMethodsV0 { + fn index_path(&self) -> Vec>; +} \ No newline at end of file diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs index b6f82be02d..c7a11f7f68 100644 --- a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs +++ b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs @@ -10,6 +10,7 @@ use crate::voting::votes::Vote; mod v0; mod accessors; +mod methods; #[derive(Debug, Clone, PartialEq, From)] #[cfg_attr( diff --git a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs index fadd5a5dfe..5f26d9991e 100644 --- a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -9,7 +9,7 @@ use crate::drive::object_size_info::DocumentInfo::{ }; use crate::drive::object_size_info::DriveKeyInfo::{Key, KeyRef}; use crate::drive::object_size_info::KeyElementInfo::{KeyElement, KeyUnknownElementSize}; -use crate::drive::object_size_info::{DocumentAndContractInfo, PathInfo, PathKeyElementInfo}; +use crate::drive::object_size_info::{DocumentAndContractInfo, PathInfo, PathKeyElementInfo, PathKeyInfo}; use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; @@ -203,14 +203,31 @@ impl Drive { // here we are the tree that will contain the ref // We are inserting this at item name contested / Goblet of Fire / 0 with the key of // document_key_path_info - self.batch_insert_empty_tree( - index_path_info, - KeyRef(document_id.as_slice()), + + let document_id_key_path_info = KeyRef(document_id.as_slice()); + + let path_key_info = document_id_key_path_info.add_path_info(index_path_info.clone()); + + index_path_info.push(Key(document_id.to_vec()))?; + + // We check to make sure we are not overridding the tree + let inserted = self.batch_insert_empty_tree_if_not_exists( + path_key_info, + false, *storage_flags, + apply_type, + transaction, + previous_batch_operations, batch_operations, drive_version, )?; + if !inserted { + return Err(Error::Drive(DriveError::CorruptedContractIndexes( + "contested votes sub tree document already exists", + ))); + } + let mut document_path_info = index_path_info.clone(); document_path_info.push(KeyRef(document_id.as_slice()))?; @@ -297,7 +314,7 @@ impl Drive { // Now we need to add a reference to this votes, so we can keep track of it more easily - self.add_new_masternode_vote_type() + // self.add_new_masternode_vote_type() } } else { let key_element_info = diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs index df234efa41..91ad9177c9 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs @@ -10,10 +10,10 @@ use crate::query::QueryItem; use dpp::prelude::Identifier; use dpp::serialization::PlatformDeserializable; use dpp::version::PlatformVersion; -use dpp::voting::ContestedDocumentResourceVote; use grovedb::query_result_type::QueryResultType::QueryElementResultType; use grovedb::{Element, PathQuery, Query, SizedQuery, TransactionArg}; use grovedb_path::SubtreePath; +use dpp::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; use crate::drive::votes::TreePath; impl Drive { diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs index af36e1114c..f4efc0cbb0 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs @@ -15,6 +15,7 @@ use dpp::voting::ContestedDocumentResourceVote; use grovedb::{EstimatedLayerInformation, TransactionArg}; use dpp::identifier::Identifier; use dpp::prelude::IdentityNonce; +use dpp::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; use crate::fee::op::LowLevelDriveOperation; impl Drive { diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index cc762748a0..5522839a38 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -6,9 +6,9 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; -use dpp::voting::ContestedDocumentResourceVote; use grovedb::{EstimatedLayerInformation, TransactionArg}; use dpp::prelude::{Identifier, IdentityNonce}; +use dpp::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; use platform_version::version::PlatformVersion; impl Drive { @@ -21,12 +21,13 @@ impl Drive { transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { + let vote_poll = vote.vote_poll(); // let's start by creating a batch of operations let mut drive_operations: Vec = vec![]; let contract_fetch_info = self .get_contract_with_fetch_info_and_add_to_operations( - vote.vote_poll.contract_id.to_buffer(), + vote.vote_poll().contract_id.to_buffer(), Some(&block_info.epoch), true, transaction, @@ -50,15 +51,8 @@ impl Drive { // let's start by creating a batch of operations let mut drive_operations: Vec = vec![]; - let contract_fetch_info = self - .get_contract_with_fetch_info_and_add_to_operations( - vote.vote_poll.contract_id.to_buffer(), - Some(&block_info.epoch), - true, - transaction, - &mut drive_operations, - platform_version, - )? - .ok_or(Error::Document(DocumentError::DataContractNotFound))?; + // The vote at this point will have been verified as valid by rs-drive-abci + + } } diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs index 11120a1e13..355ed9439c 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs @@ -49,7 +49,7 @@ impl Drive { voter_pro_tx_hash, contested_document_resource_vote_type, block_info, - estimated_costs_only_with_layer_info + estimated_costs_only_with_layer_info, transaction, platform_version, ), diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index d6aa86aa02..7388ba54eb 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -3,8 +3,8 @@ use crate::drive::RootTree; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::DataContract; -use dpp::voting::ContestedDocumentResourceVote; use dpp::ProtocolError; +use dpp::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; mod cleanup; mod insert; @@ -130,25 +130,26 @@ pub trait TreePath { impl TreePath for ContestedDocumentResourceVote { fn tree_path(&self, contract: &DataContract) -> Result, ProtocolError> { - if contract.id() != self.vote_poll.contract_id { + let vote_poll = self.vote_poll(); + if contract.id() != vote_poll.contract_id { return Err(ProtocolError::VoteError(format!( "contract id of votes {} does not match supplied contract {}", - self.vote_poll.contract_id, + self.vote_poll().contract_id, contract.id() ))); } - let document_type = contract.document_type_for_name(&self.vote_poll.document_type_name)?; + let document_type = contract.document_type_for_name(&vote_poll.document_type_name)?; let index = document_type .indices() .iter() - .find(|index| &index.name == &self.vote_poll.index_name) + .find(|index| &index.name == &vote_poll.index_name) .ok_or(ProtocolError::VoteError(format!( "votes index name {} not found", - &self.vote_poll.index_name + &vote_poll.index_name )))?; let mut path = contract_document_type_path( - &self.vote_poll.contract_id.as_bytes(), - &self.vote_poll.document_type_name, + &vote_poll.contract_id.as_bytes(), + &vote_poll.document_type_name, ) .to_vec(); From fcabf19e35bdf1d6db497efb4c12551d0a4961e6 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 3 May 2024 02:38:42 +0700 Subject: [PATCH 032/135] more work --- .../document_type/accessors/mod.rs | 4 +-- .../document_type/index/random_index.rs | 15 ++++++---- .../src/data_contract/document_type/v0/mod.rs | 1 - .../document_type/v0/random_document_type.rs | 24 ++++++++------- .../accessors/mod.rs | 2 +- .../methods/mod.rs | 1 + .../methods/v0/mod.rs | 5 +++- .../contested_document_resource_vote/mod.rs | 1 - .../state_transition/state_transitions/mod.rs | 1 - .../tests/strategy_tests/voting_tests.rs | 12 ++++++-- .../drive/batch/drive_op_batch/identity.rs | 13 +++++--- .../identity/masternode_vote_transition.rs | 2 +- .../v0/mod.rs | 2 +- .../v0/mod.rs | 23 +++++++------- .../src/drive/identity/withdrawals/paths.rs | 2 -- .../src/drive/initialization/v0/mod.rs | 1 - .../remove_votes_for_identity/v0/mod.rs | 4 +-- .../add_new_masternode_vote_type/v0/mod.rs | 9 +++--- .../mod.rs | 16 +++++----- .../v0/mod.rs | 12 ++++---- .../add_vote_poll_end_date_query/v0/mod.rs | 7 ++--- .../insert/register_identity_vote/mod.rs | 30 ++++++++++++++----- .../insert/register_identity_vote/v0/mod.rs | 12 ++++---- packages/rs-drive/src/drive/votes/mod.rs | 13 ++++---- .../mod.rs | 2 +- .../v0/mod.rs | 23 ++++++++++---- packages/rs-drive/src/fee_pools/mod.rs | 2 +- .../src/version/mocks/v2_test.rs | 3 +- .../src/version/mocks/v3_test.rs | 3 +- .../rs-platform-version/src/version/v1.rs | 3 +- 30 files changed, 145 insertions(+), 103 deletions(-) diff --git a/packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs b/packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs index ff3754afdb..83d9c64926 100644 --- a/packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs @@ -35,7 +35,7 @@ impl DocumentTypeV0Getters for DocumentType { } } - fn indices(&self) -> &Vec { + fn indices(&self) -> &BTreeMap { match self { DocumentType::V0(v0) => v0.indices(), } @@ -279,7 +279,7 @@ impl<'a> DocumentTypeV0Getters for DocumentTypeMutRef<'a> { } } - fn indices(&self) -> &Vec { + fn indices(&self) -> &BTreeMap { match self { DocumentTypeMutRef::V0(v0) => v0.indices(), } diff --git a/packages/rs-dpp/src/data_contract/document_type/index/random_index.rs b/packages/rs-dpp/src/data_contract/document_type/index/random_index.rs index e44c409933..3aff79a996 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index/random_index.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index/random_index.rs @@ -1,3 +1,4 @@ +use std::borrow::Borrow; use crate::data_contract::document_type::index::{Index, IndexProperty}; use crate::ProtocolError; use rand::prelude::StdRng; @@ -5,11 +6,15 @@ use rand::seq::SliceRandom; use rand::Rng; impl Index { - pub fn random( + pub fn random( field_names: &[String], - existing_indices: &[Index], + existing_indices: &I, rng: &mut StdRng, - ) -> Result { + ) -> Result + where + I: IntoIterator, // T is the type of elements in the collection + T: Borrow, // Assuming Index is the type stored in the collection + { let index_name = format!("index_{}", rng.gen::()); let mut properties; @@ -32,8 +37,8 @@ impl Index { .collect::>(); if !existing_indices - .iter() - .any(|index| index.properties == properties) + .into_iter() + .any(|index| index.borrow().properties == properties) { break; } diff --git a/packages/rs-dpp/src/data_contract/document_type/v0/mod.rs b/packages/rs-dpp/src/data_contract/document_type/v0/mod.rs index 8f643c6b2d..4257aa0a2c 100644 --- a/packages/rs-dpp/src/data_contract/document_type/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/v0/mod.rs @@ -1,6 +1,5 @@ use indexmap::IndexMap; use std::collections::{BTreeMap, BTreeSet}; -use serde_json::map::BTreeMap; use crate::data_contract::document_type::index::Index; use crate::data_contract::document_type::index_level::IndexLevel; diff --git a/packages/rs-dpp/src/data_contract/document_type/v0/random_document_type.rs b/packages/rs-dpp/src/data_contract/document_type/v0/random_document_type.rs index 3e46c291ea..53ed0cf9cf 100644 --- a/packages/rs-dpp/src/data_contract/document_type/v0/random_document_type.rs +++ b/packages/rs-dpp/src/data_contract/document_type/v0/random_document_type.rs @@ -119,7 +119,7 @@ use rand::rngs::StdRng; use rand::seq::SliceRandom; use rand::Rng; use serde_json::json; -use std::collections::BTreeSet; +use std::collections::{BTreeMap, BTreeSet}; use std::ops::Range; impl DocumentTypeV0 { @@ -234,11 +234,13 @@ impl DocumentTypeV0 { .cloned() .collect_vec(); - let mut indices = Vec::with_capacity(index_count as usize); + let mut indices = BTreeMap::new(); for _ in 0..index_count { - match Index::random(&ten_field_names, &indices, rng) { - Ok(index) => indices.push(index), + match Index::random(&ten_field_names, &indices.values(), rng) { + Ok(index) => { + indices.insert(index.name.clone(), index); + }, Err(_) => break, } } @@ -250,7 +252,7 @@ impl DocumentTypeV0 { let name = format!("doc_type_{}", rng.gen::()); let index_structure = - IndexLevel::try_from_indices(indices.as_slice(), name.as_str(), platform_version)?; + IndexLevel::try_from_indices(indices.values(), name.as_str(), platform_version)?; let (identifier_paths, binary_paths) = DocumentType::find_identifier_and_binary_paths( &properties, &PlatformVersion::latest() @@ -387,7 +389,7 @@ impl DocumentTypeV0 { // Generate indices let indices_json_schema = indices .iter() - .map(|index| { + .map(|(_, index)| { let properties_schema = index .properties .iter() @@ -552,11 +554,13 @@ impl DocumentTypeV0 { .cloned() .collect_vec(); - let mut indices = Vec::with_capacity(index_count as usize); + let mut indices = BTreeMap::new(); for _ in 0..index_count { - match Index::random(&ten_field_names, &indices, rng) { - Ok(index) => indices.push(index), + match Index::random(&ten_field_names, &indices.values(), rng) { + Ok(index) => { + indices.insert(index.name.clone(), index); + }, Err(_) => break, } } @@ -568,7 +572,7 @@ impl DocumentTypeV0 { let name = format!("doc_type_{}", rng.gen::()); let index_structure = - IndexLevel::try_from_indices(indices.as_slice(), name.as_str(), platform_version)?; + IndexLevel::try_from_indices(indices.values(), name.as_str(), platform_version)?; let (identifier_paths, binary_paths) = DocumentType::find_identifier_and_binary_paths( &properties, &PlatformVersion::latest() diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/mod.rs b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/mod.rs index 414bdf1437..9d9d45377e 100644 --- a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/mod.rs +++ b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/mod.rs @@ -3,7 +3,7 @@ use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedD use crate::voting::votes::contested_document_resource_vote::accessors::v0::ContestedDocumentResourceVoteGettersV0; use crate::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; -mod v0; +pub(crate) mod v0; impl ContestedDocumentResourceVoteGettersV0 for ContestedDocumentResourceVote { fn vote_poll(&self) -> &ContestedDocumentResourceVotePoll { diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/mod.rs b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/mod.rs index e26d8f2ca3..9db24187d7 100644 --- a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/mod.rs +++ b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/mod.rs @@ -4,6 +4,7 @@ use crate::prelude::DataContract; use crate::ProtocolError; use crate::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; use crate::voting::votes::contested_document_resource_vote::methods::v0::ContestedDocumentResourceVoteMethodsV0; +use crate::voting::votes::contested_document_resource_vote::accessors::v0::ContestedDocumentResourceVoteGettersV0; mod v0; diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/v0/mod.rs b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/v0/mod.rs index 8ff91d2250..2a329f8256 100644 --- a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/v0/mod.rs +++ b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/v0/mod.rs @@ -1,3 +1,6 @@ +use crate::prelude::DataContract; +use crate::ProtocolError; + pub trait ContestedDocumentResourceVoteMethodsV0 { - fn index_path(&self) -> Vec>; + fn index_path(&self, contract: &DataContract) -> Result>, ProtocolError>; } \ No newline at end of file diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs index c7a11f7f68..2942d36f90 100644 --- a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs +++ b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs @@ -6,7 +6,6 @@ use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; use crate::voting::votes::contested_document_resource_vote::v0::ContestedDocumentResourceVoteV0; use crate::ProtocolError; -use crate::voting::votes::Vote; mod v0; mod accessors; 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 b07e5aa00a..4f6b16223d 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 @@ -49,4 +49,3 @@ impl ValidationMode { } } } - diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index 6e69c46369..bdb8ec18d9 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -19,8 +19,8 @@ mod tests { use strategy_tests::frequency::Frequency; use strategy_tests::operations::{DocumentAction, DocumentOp, Operation, OperationType}; use strategy_tests::transitions::create_state_transitions_for_identities; - use tenderdash_abci::proto::types::CoreChainLock; use strategy_tests::{IdentityInsertInfo, StartIdentities}; + use tenderdash_abci::proto::types::CoreChainLock; #[test] fn run_chain_block_two_state_transitions_conflicting_unique_index() { @@ -76,8 +76,14 @@ mod tests { &mut rng, platform_version, ); - - let dpns_contract = platform.drive.cache.system_data_contracts.load_dpns().as_ref().clone(); + + let dpns_contract = platform + .drive + .cache + .system_data_contracts + .load_dpns() + .as_ref() + .clone(); let document_type = dpns_contract .document_type_for_name("domain") diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs index 80706cb91e..d89d7bcf01 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs @@ -8,10 +8,10 @@ use dpp::prelude::{IdentityNonce, Revision}; use crate::drive::identity::update::methods::merge_identity_nonce::MergeIdentityContractNonceResultToResult; use dpp::version::PlatformVersion; +use dpp::voting::votes::Vote; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; -use dpp::voting::votes::Vote; /// Operations on Identities #[derive(Clone, Debug)] @@ -192,9 +192,14 @@ impl DriveLowLevelOperationConverter for IdentityOperationType { IdentityOperationType::MasternodeCastVote { voter_pro_tx_hash, vote, - } => { - drive.register_identity_vote_operations(voter_pro_tx_hash, vote, block_info, estimated_costs_only_with_layer_info, transaction, platform_version) - }, + } => drive.register_identity_vote_operations( + voter_pro_tx_hash, + vote, + block_info, + estimated_costs_only_with_layer_info, + transaction, + platform_version, + ), IdentityOperationType::UpdateIdentityContractNonce { identity_id, contract_id, diff --git a/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs b/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs index 06d29083b5..c8f6dff36b 100644 --- a/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs +++ b/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs @@ -3,9 +3,9 @@ use crate::drive::batch::DriveOperation::IdentityOperation; use crate::drive::batch::{DriveOperation, IdentityOperationType}; use crate::error::Error; +use crate::state_transition_action::identity::masternode_vote::MasternodeVoteTransitionAction; use dpp::block::epoch::Epoch; use dpp::version::PlatformVersion; -use crate::state_transition_action::identity::masternode_vote::MasternodeVoteTransitionAction; impl DriveHighLevelOperationConverter for MasternodeVoteTransitionAction { fn into_high_level_drive_operations<'a>( diff --git a/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/v0/mod.rs index 3297b9ac7c..61012f82dc 100644 --- a/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/remove_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -6,9 +6,9 @@ use grovedb::EstimatedLayerSizes::{AllReference, AllSubtrees}; use grovedb::{EstimatedLayerInformation, TransactionArg}; use dpp::data_contract::document_type::IndexType; +use dpp::data_contract::document_type::IndexType::{ContestedResourceIndex, NonUniqueIndex}; use grovedb::EstimatedSumTrees::NoSumTrees; use std::collections::HashMap; -use dpp::data_contract::document_type::IndexType::{ContestedResourceIndex, NonUniqueIndex}; use crate::drive::defaults::{CONTRACT_DOCUMENTS_PATH_HEIGHT, DEFAULT_HASH_SIZE_U8}; use crate::drive::document::document_reference_size; diff --git a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs index 5f26d9991e..5317ab6226 100644 --- a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -9,7 +9,9 @@ use crate::drive::object_size_info::DocumentInfo::{ }; use crate::drive::object_size_info::DriveKeyInfo::{Key, KeyRef}; use crate::drive::object_size_info::KeyElementInfo::{KeyElement, KeyUnknownElementSize}; -use crate::drive::object_size_info::{DocumentAndContractInfo, PathInfo, PathKeyElementInfo, PathKeyInfo}; +use crate::drive::object_size_info::{ + DocumentAndContractInfo, PathInfo, PathKeyElementInfo, PathKeyInfo, +}; use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; @@ -206,10 +208,11 @@ impl Drive { let document_id_key_path_info = KeyRef(document_id.as_slice()); - let path_key_info = document_id_key_path_info.add_path_info(index_path_info.clone()); + let path_key_info = + document_id_key_path_info.add_path_info(index_path_info.clone()); index_path_info.push(Key(document_id.to_vec()))?; - + // We check to make sure we are not overridding the tree let inserted = self.batch_insert_empty_tree_if_not_exists( path_key_info, @@ -269,10 +272,11 @@ impl Drive { ); } - let reference_path_key_element_info = PathKeyElementInfo::from_path_info_and_key_element( - document_path_info.clone(), - ref_key_element_info, - )?; + let reference_path_key_element_info = + PathKeyElementInfo::from_path_info_and_key_element( + document_path_info.clone(), + ref_key_element_info, + )?; // here we are inserting the ref self.batch_insert( @@ -293,7 +297,6 @@ impl Drive { } }; - // here we are the tree that will contain the voting tree let inserted = self.batch_insert_empty_tree_if_not_exists( votes_path_key_info, @@ -311,9 +314,9 @@ impl Drive { "contested votes tree already exists", ))); } - + // Now we need to add a reference to this votes, so we can keep track of it more easily - + // self.add_new_masternode_vote_type() } } else { diff --git a/packages/rs-drive/src/drive/identity/withdrawals/paths.rs b/packages/rs-drive/src/drive/identity/withdrawals/paths.rs index b89f2f7a07..9ea24675d3 100644 --- a/packages/rs-drive/src/drive/identity/withdrawals/paths.rs +++ b/packages/rs-drive/src/drive/identity/withdrawals/paths.rs @@ -24,8 +24,6 @@ impl Drive { } } - - /// Helper function to get root path pub fn get_withdrawal_root_path_vec() -> Vec> { vec![vec![RootTree::WithdrawalTransactions as u8]] diff --git a/packages/rs-drive/src/drive/initialization/v0/mod.rs b/packages/rs-drive/src/drive/initialization/v0/mod.rs index 1f9ef3a882..83165693c5 100644 --- a/packages/rs-drive/src/drive/initialization/v0/mod.rs +++ b/packages/rs-drive/src/drive/initialization/v0/mod.rs @@ -198,7 +198,6 @@ impl Drive { // For the votes tree structure Drive::add_initial_vote_tree_main_structure_operations(&mut batch, platform_version)?; - self.grove_apply_batch(batch, false, transaction, drive_version)?; Ok(()) diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs index 91ad9177c9..188fd74707 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs @@ -6,15 +6,15 @@ use crate::error::Error; use crate::drive::grove_operations::BatchDeleteApplyType; use crate::drive::votes::vote_contested_resource_identity_votes_tree_path_for_identity_vec; +use crate::drive::votes::TreePath; use crate::query::QueryItem; use dpp::prelude::Identifier; use dpp::serialization::PlatformDeserializable; use dpp::version::PlatformVersion; +use dpp::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; use grovedb::query_result_type::QueryResultType::QueryElementResultType; use grovedb::{Element, PathQuery, Query, SizedQuery, TransactionArg}; use grovedb_path::SubtreePath; -use dpp::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; -use crate::drive::votes::TreePath; impl Drive { /// We remove vote_choices for an identity when that identity is somehow disabled. Currently there is diff --git a/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs index ac341b7343..29c53a5461 100644 --- a/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs @@ -1,11 +1,11 @@ -use grovedb::TransactionArg; +use crate::drive::object_size_info::OwnedDocumentInfo; +use crate::drive::Drive; +use crate::error::Error; use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; use dpp::identifier::Identifier; +use grovedb::TransactionArg; use platform_version::version::PlatformVersion; -use crate::drive::Drive; -use crate::drive::object_size_info::OwnedDocumentInfo; -use crate::error::Error; impl Drive { pub(super) fn add_new_masternode_vote_type_v0( @@ -19,6 +19,5 @@ impl Drive { transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { - } } diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs index f4efc0cbb0..ddecdfa8d4 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs @@ -1,27 +1,27 @@ mod v0; -use std::collections::HashMap; -use grovedb::batch::KeyInfoPath; use crate::drive::Drive; +use grovedb::batch::KeyInfoPath; +use std::collections::HashMap; use crate::error::drive::DriveError; use crate::error::Error; use dpp::fee::fee_result::FeeResult; +use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; -use dpp::version::PlatformVersion; -use dpp::voting::ContestedDocumentResourceVote; -use grovedb::{EstimatedLayerInformation, TransactionArg}; use dpp::identifier::Identifier; use dpp::prelude::IdentityNonce; +use dpp::version::PlatformVersion; use dpp::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; -use crate::fee::op::LowLevelDriveOperation; +use dpp::voting::ContestedDocumentResourceVote; +use grovedb::{EstimatedLayerInformation, TransactionArg}; impl Drive { pub fn register_contested_resource_identity_vote( &self, - voter_pro_tx_hash: [u8;32], + voter_pro_tx_hash: [u8; 32], vote: ContestedDocumentResourceVote, block_info: &BlockInfo, apply: bool, @@ -53,7 +53,7 @@ impl Drive { pub fn register_contested_resource_identity_vote_operations( &self, - voter_pro_tx_hash: [u8;32], + voter_pro_tx_hash: [u8; 32], vote: ContestedDocumentResourceVote, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index 5522839a38..05a4657cce 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -1,20 +1,20 @@ -use std::collections::HashMap; -use grovedb::batch::KeyInfoPath; use crate::drive::Drive; use crate::error::document::DocumentError; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; -use grovedb::{EstimatedLayerInformation, TransactionArg}; use dpp::prelude::{Identifier, IdentityNonce}; use dpp::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; +use grovedb::batch::KeyInfoPath; +use grovedb::{EstimatedLayerInformation, TransactionArg}; use platform_version::version::PlatformVersion; +use std::collections::HashMap; impl Drive { pub fn register_contested_resource_identity_vote_v0( &self, - voter_pro_tx_hash: [u8;32], + voter_pro_tx_hash: [u8; 32], vote: ContestedDocumentResourceVote, block_info: &BlockInfo, apply: bool, @@ -39,7 +39,7 @@ impl Drive { pub fn register_contested_resource_identity_vote_operations_v0( &self, - voter_pro_tx_hash: [u8;32], + voter_pro_tx_hash: [u8; 32], vote: ContestedDocumentResourceVote, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< @@ -52,7 +52,5 @@ impl Drive { let mut drive_operations: Vec = vec![]; // The vote at this point will have been verified as valid by rs-drive-abci - - } } diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs index 28fe66d1c5..47752fdb6a 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs @@ -1,11 +1,11 @@ -use grovedb::TransactionArg; +use crate::drive::Drive; +use crate::error::Error; use dpp::fee::fee_result::FeeResult; use dpp::identifier::Identifier; use dpp::identity::TimestampMillis; use dpp::voting::votes::Vote; +use grovedb::TransactionArg; use platform_version::version::PlatformVersion; -use crate::drive::Drive; -use crate::error::Error; impl Drive { /// We add votes poll references by end date in order to be able to check on every new block if @@ -17,6 +17,5 @@ impl Drive { transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { - } } diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs index e4e3bbf3b2..6d478f8a91 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs @@ -1,24 +1,24 @@ mod v0; -use std::collections::HashMap; -use grovedb::batch::KeyInfoPath; use crate::drive::Drive; +use grovedb::batch::KeyInfoPath; +use std::collections::HashMap; use crate::error::drive::DriveError; use crate::error::Error; use dpp::fee::fee_result::FeeResult; +use crate::fee::op::LowLevelDriveOperation; +use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; use dpp::voting::votes::Vote; use grovedb::{EstimatedLayerInformation, TransactionArg}; -use dpp::block::block_info::BlockInfo; -use crate::fee::op::LowLevelDriveOperation; impl Drive { pub fn register_identity_vote( &self, - voter_pro_tx_hash: [u8;32], + voter_pro_tx_hash: [u8; 32], vote: Vote, block_info: &BlockInfo, apply: bool, @@ -32,7 +32,14 @@ impl Drive { .contested_resource_insert .register_identity_vote { - 0 => self.register_identity_vote_v0(voter_pro_tx_hash, vote, block_info, apply, transaction, platform_version), + 0 => self.register_identity_vote_v0( + voter_pro_tx_hash, + vote, + block_info, + apply, + transaction, + platform_version, + ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "register_identity_vote".to_string(), known_versions: vec![0], @@ -43,7 +50,7 @@ impl Drive { pub fn register_identity_vote_operations( &self, - voter_pro_tx_hash: [u8;32], + voter_pro_tx_hash: [u8; 32], vote: Vote, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< @@ -59,7 +66,14 @@ impl Drive { .contested_resource_insert .register_identity_vote { - 0 => self.register_identity_vote_operations_v0(voter_pro_tx_hash, vote, block_info, estimated_costs_only_with_layer_info, transaction, platform_version), + 0 => self.register_identity_vote_operations_v0( + voter_pro_tx_hash, + vote, + block_info, + estimated_costs_only_with_layer_info, + transaction, + platform_version, + ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "register_identity_vote_operations".to_string(), known_versions: vec![0], diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs index 355ed9439c..ae77c6aef8 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs @@ -1,18 +1,18 @@ -use std::collections::HashMap; -use grovedb::batch::KeyInfoPath; use crate::drive::Drive; use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; use dpp::voting::votes::Vote; +use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; -use dpp::block::block_info::BlockInfo; use platform_version::version::PlatformVersion; -use crate::fee::op::LowLevelDriveOperation; +use std::collections::HashMap; impl Drive { pub(super) fn register_identity_vote_v0( &self, - voter_pro_tx_hash: [u8;32], + voter_pro_tx_hash: [u8; 32], vote: Vote, block_info: &BlockInfo, apply: bool, @@ -34,7 +34,7 @@ impl Drive { pub(super) fn register_identity_vote_operations_v0( &self, - voter_pro_tx_hash: [u8;32], + voter_pro_tx_hash: [u8; 32], vote: Vote, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 7388ba54eb..9c5a0b98a9 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -3,8 +3,8 @@ use crate::drive::RootTree; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::DataContract; -use dpp::ProtocolError; use dpp::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; +use dpp::ProtocolError; mod cleanup; mod insert; @@ -34,9 +34,7 @@ pub(in crate::drive::votes) fn vote_root_path<'a>() -> [&'a [u8]; 1] { } pub(in crate::drive::votes) fn vote_root_path_vec() -> Vec> { - vec![ - vec![RootTree::Votes as u8], - ] + vec![vec![RootTree::Votes as u8]] } pub(in crate::drive::votes) fn vote_decisions_tree_path<'a>() -> [&'a [u8]; 2] { @@ -76,7 +74,8 @@ pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_tree_pat ] } -pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_tree_path_vec() -> Vec> { +pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_tree_path_vec( +) -> Vec> { vec![ vec![RootTree::Votes as u8], vec![CONTESTED_RESOURCE_TREE_KEY as u8], @@ -93,7 +92,8 @@ pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path< ] } -pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_vec() -> Vec> { +pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_vec() -> Vec> +{ vec![ vec![RootTree::Votes as u8], vec![CONTESTED_RESOURCE_TREE_KEY as u8], @@ -101,7 +101,6 @@ pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_ ] } - pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_for_identity<'a>( identity_id: &[u8; 32], ) -> [&'a [u8]; 4] { diff --git a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs index dc1fd3c9ab..d67ac9f152 100644 --- a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs +++ b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs @@ -5,8 +5,8 @@ use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; -use dpp::version::PlatformVersion; use crate::drive::batch::GroveDbOpBatch; +use dpp::version::PlatformVersion; impl Drive { pub fn add_initial_vote_tree_main_structure_operations( diff --git a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs index 19debd8f46..4d7f5f0c46 100644 --- a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs @@ -1,21 +1,32 @@ -use crate::error::Error; use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; use crate::drive::batch::GroveDbOpBatch; +use crate::drive::votes::{ + vote_contested_resource_tree_path_vec, vote_root_path_vec, CONTESTED_RESOURCE_TREE_KEY, + END_DATE_QUERIES_TREE_KEY, IDENTITY_VOTES_TREE_KEY, VOTE_DECISIONS_TREE_KEY, +}; use crate::drive::Drive; -use crate::drive::votes::{CONTESTED_RESOURCE_TREE_KEY, END_DATE_QUERIES_TREE_KEY, IDENTITY_VOTES_TREE_KEY, vote_contested_resource_tree_path_vec, VOTE_DECISIONS_TREE_KEY, vote_root_path_vec}; +use crate::error::Error; impl Drive { pub(super) fn add_initial_vote_tree_main_structure_operations_v0( batch: &mut GroveDbOpBatch, ) -> Result<(), Error> { - batch.add_insert_empty_tree(vote_root_path_vec(), vec![VOTE_DECISIONS_TREE_KEY as u8]); - batch.add_insert_empty_tree(vote_root_path_vec(), vec![CONTESTED_RESOURCE_TREE_KEY as u8]); + batch.add_insert_empty_tree( + vote_root_path_vec(), + vec![CONTESTED_RESOURCE_TREE_KEY as u8], + ); - batch.add_insert_empty_tree(vote_contested_resource_tree_path_vec(), vec![END_DATE_QUERIES_TREE_KEY as u8]); + batch.add_insert_empty_tree( + vote_contested_resource_tree_path_vec(), + vec![END_DATE_QUERIES_TREE_KEY as u8], + ); - batch.add_insert_empty_tree(vote_contested_resource_tree_path_vec(), vec![IDENTITY_VOTES_TREE_KEY as u8]); + batch.add_insert_empty_tree( + vote_contested_resource_tree_path_vec(), + vec![IDENTITY_VOTES_TREE_KEY as u8], + ); Ok(()) } diff --git a/packages/rs-drive/src/fee_pools/mod.rs b/packages/rs-drive/src/fee_pools/mod.rs index 0fccf0f736..c7d9b02bf3 100644 --- a/packages/rs-drive/src/fee_pools/mod.rs +++ b/packages/rs-drive/src/fee_pools/mod.rs @@ -33,6 +33,7 @@ use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; use crate::drive::batch::GroveDbOpBatch; #[cfg(feature = "server")] use crate::drive::credit_pools::paths::pools_vec_path; +use crate::drive::Drive; #[cfg(feature = "server")] use crate::error::Error; #[cfg(feature = "server")] @@ -54,7 +55,6 @@ use dpp::util::deserializer::ProtocolVersion; use grovedb::batch::GroveDbOp; #[cfg(feature = "server")] use grovedb::Element; -use crate::drive::Drive; #[cfg(any(feature = "server", feature = "verify"))] /// Epochs module diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index eff8ae688c..a70c6d09c8 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -64,10 +64,9 @@ use crate::version::drive_versions::{ DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVerifyStateTransitionMethodVersions, - DriveVerifySystemMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, + DriveVerifySystemMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions, - }; use crate::version::fee::v1::FEE_VERSION1; use crate::version::mocks::TEST_PROTOCOL_VERSION_SHIFT_BYTES; diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 2ef043d94f..4c7207c653 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -64,7 +64,8 @@ use crate::version::drive_versions::{ DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVerifyStateTransitionMethodVersions, - DriveVerifySystemMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, + DriveVerifySystemMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, + DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions, }; use crate::version::fee::v1::FEE_VERSION1; diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 4f6c6f6c68..9f41147ebd 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -64,7 +64,8 @@ use crate::version::drive_versions::{ DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVerifyStateTransitionMethodVersions, - DriveVerifySystemMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, + DriveVerifySystemMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, + DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions, }; use crate::version::fee::v1::FEE_VERSION1; From b0aa04e0f63900c6c3ee85ffff64a998719973ef Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 7 May 2024 01:30:32 +0200 Subject: [PATCH 033/135] more fixes --- .../protos/platform/v0/platform.proto | 25 +++ .../proto/org.dash.platform.dapi.v0.rs | 173 ++++++++++++++++++ packages/rs-dpp/Cargo.toml | 2 +- .../document_type/accessors/mod.rs | 12 +- .../document_type/accessors/v0/mod.rs | 2 +- .../data_contract/document_type/index/mod.rs | 65 ++++++- .../document_type/index/random_index.rs | 6 +- .../document_type/v0/accessors.rs | 2 +- .../document_type/v0/random_document_type.rs | 4 +- .../src/data_contract/errors/contract.rs | 5 +- .../data_contract/extra/drive_api_tests.rs | 4 +- .../src/errors/consensus/basic/basic_error.rs | 4 + .../rs-dpp/src/errors/consensus/basic/mod.rs | 1 + .../errors/consensus/basic/overflow_error.rs | 37 ++++ packages/rs-dpp/src/errors/consensus/codes.rs | 4 + .../v0/from_document.rs | 12 ++ .../document_create_transition/v0/mod.rs | 67 ++----- .../v0/v0_methods.rs | 21 +++ .../document_create_transition/v0_methods.rs | 27 +++ .../documents_batch_transition/methods/mod.rs | 8 +- .../methods/v0/mod.rs | 4 +- .../v0/v0_methods.rs | 48 ++++- packages/rs-dpp/src/util/json_schema.rs | 2 +- .../methods/mod.rs | 17 -- .../methods/v0/mod.rs | 6 - .../contested_document_resource_vote/mod.rs | 1 - .../state_transition/processor/v0/mod.rs | 4 + .../state_v0/mod.rs | 2 +- .../state_v0/mod.rs | 2 +- .../state_v0/mod.rs | 2 +- .../state_v0/mod.rs | 2 +- .../state_v0/mod.rs | 2 +- .../documents_batch/balance/v0/mod.rs | 35 +++- .../validate_uniqueness_of_data/v0/mod.rs | 2 +- .../v0/mod.rs | 2 +- .../v0/mod.rs | 4 +- .../v0/mod.rs | 2 +- .../src/drive/initialization/v0/mod.rs | 43 ++--- packages/rs-drive/src/drive/mod.rs | 21 ++- .../pre_funded_specialized_balances/mod.rs | 21 +++ .../mod.rs | 3 - packages/rs-drive/src/drive/votes/mod.rs | 9 +- packages/rs-drive/src/query/test_index.rs | 4 +- .../document_base_transition_action/mod.rs | 13 +- .../document_base_transition_action/v0/mod.rs | 2 + .../document_create_transition_action/mod.rs | 8 + .../v0/mod.rs | 11 ++ .../v0/transformer.rs | 28 ++- .../document/documents_batch/v0/mod.rs | 46 ++++- .../btreemap_removal_extensions.rs | 72 ++++++++ ...btreemap_removal_inner_value_extensions.rs | 22 ++- packages/rs-platform-value/src/lib.rs | 21 +-- packages/rs-platform-value/src/value_map.rs | 10 +- .../src/version/fee/mod.rs | 3 + .../rs-platform-version/src/version/fee/v1.rs | 2 + .../fee/vote_resolution_fund_fees/mod.rs | 6 + .../fee/vote_resolution_fund_fees/v1.rs | 5 + 57 files changed, 764 insertions(+), 204 deletions(-) create mode 100644 packages/rs-dpp/src/errors/consensus/basic/overflow_error.rs delete mode 100644 packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/mod.rs delete mode 100644 packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/pre_funded_specialized_balances/mod.rs create mode 100644 packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/mod.rs create mode 100644 packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index d07e094bc2..23925a6038 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -37,6 +37,7 @@ service Platform { rpc getContestedResources(GetContestedResourcesRequest) returns (GetContestedResourcesResponse); rpc getContestedResourceVoteState(GetContestedResourceVoteStateRequest) returns (GetContestedResourceVoteStateResponse); rpc getContestedResourceVoteStatus(GetContestedResourceVoteStatusRequest) returns (GetContestedResourceVoteStatusResponse); + rpc getPreFundedSpecializedBalances(GetPreFundedSpecializedBalancesRequest) returns (GetPreFundedSpecializedBalancesResponse); rpc getPathElements(GetPathElementsRequest) returns (GetPathElementsResponse); } @@ -725,6 +726,30 @@ message GetContestedResourceVoteStatusResponse { } } +message GetPreFundedSpecializedBalancesRequest { + + message GetPreFundedSpecializedBalancesRequestV0 { + bytes id = 1; + bool prove = 2; + } + + oneof version { GetPreFundedSpecializedBalancesRequestV0 v0 = 1; } +} + +message GetPreFundedSpecializedBalancesResponse { + + message GetPreFundedSpecializedBalancesResponseV0 { + oneof result { + uint64 balance = 1; + Proof proof = 2; + } + ResponseMetadata metadata = 3; + } + + oneof version { GetPreFundedSpecializedBalancesResponseV0 v0 = 1; } +} + + message GetPathElementsRequest { message GetPathElementsRequestV0 { repeated bytes path = 1; diff --git a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs index 24a0a5b3e3..c9d31406bf 100644 --- a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs +++ b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs @@ -2365,6 +2365,91 @@ pub mod get_contested_resource_vote_status_response { } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] +#[derive(::dapi_grpc_macros::Mockable)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetPreFundedSpecializedBalancesRequest { + #[prost(oneof = "get_pre_funded_specialized_balances_request::Version", tags = "1")] + pub version: ::core::option::Option< + get_pre_funded_specialized_balances_request::Version, + >, +} +/// Nested message and enum types in `GetPreFundedSpecializedBalancesRequest`. +pub mod get_pre_funded_specialized_balances_request { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct GetPreFundedSpecializedBalancesRequestV0 { + #[prost(bytes = "vec", tag = "1")] + #[serde(with = "serde_bytes")] + pub id: ::prost::alloc::vec::Vec, + #[prost(bool, tag = "2")] + pub prove: bool, + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Version { + #[prost(message, tag = "1")] + V0(GetPreFundedSpecializedBalancesRequestV0), + } +} +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(rename_all = "snake_case")] +#[derive(::dapi_grpc_macros::Mockable)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetPreFundedSpecializedBalancesResponse { + #[prost(oneof = "get_pre_funded_specialized_balances_response::Version", tags = "1")] + pub version: ::core::option::Option< + get_pre_funded_specialized_balances_response::Version, + >, +} +/// Nested message and enum types in `GetPreFundedSpecializedBalancesResponse`. +pub mod get_pre_funded_specialized_balances_response { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct GetPreFundedSpecializedBalancesResponseV0 { + #[prost(message, optional, tag = "3")] + pub metadata: ::core::option::Option, + #[prost( + oneof = "get_pre_funded_specialized_balances_response_v0::Result", + tags = "1, 2" + )] + pub result: ::core::option::Option< + get_pre_funded_specialized_balances_response_v0::Result, + >, + } + /// Nested message and enum types in `GetPreFundedSpecializedBalancesResponseV0`. + pub mod get_pre_funded_specialized_balances_response_v0 { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Result { + #[prost(uint64, tag = "1")] + Balance(u64), + #[prost(message, tag = "2")] + Proof(super::super::Proof), + } + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Version { + #[prost(message, tag = "1")] + V0(GetPreFundedSpecializedBalancesResponseV0), + } +} +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::VersionedGrpcMessage)] #[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] @@ -3235,6 +3320,38 @@ pub mod platform_client { ); self.inner.unary(req, path, codec).await } + pub async fn get_pre_funded_specialized_balances( + &mut self, + request: impl tonic::IntoRequest< + super::GetPreFundedSpecializedBalancesRequest, + >, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/org.dash.platform.dapi.v0.Platform/getPreFundedSpecializedBalances", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "org.dash.platform.dapi.v0.Platform", + "getPreFundedSpecializedBalances", + ), + ); + self.inner.unary(req, path, codec).await + } pub async fn get_path_elements( &mut self, request: impl tonic::IntoRequest, @@ -3428,6 +3545,13 @@ pub mod platform_server { tonic::Response, tonic::Status, >; + async fn get_pre_funded_specialized_balances( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_path_elements( &self, request: tonic::Request, @@ -4557,6 +4681,55 @@ pub mod platform_server { }; Box::pin(fut) } + "/org.dash.platform.dapi.v0.Platform/getPreFundedSpecializedBalances" => { + #[allow(non_camel_case_types)] + struct getPreFundedSpecializedBalancesSvc(pub Arc); + impl< + T: Platform, + > tonic::server::UnaryService< + super::GetPreFundedSpecializedBalancesRequest, + > for getPreFundedSpecializedBalancesSvc { + type Response = super::GetPreFundedSpecializedBalancesResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + super::GetPreFundedSpecializedBalancesRequest, + >, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + (*inner).get_pre_funded_specialized_balances(request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = getPreFundedSpecializedBalancesSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } "/org.dash.platform.dapi.v0.Platform/getPathElements" => { #[allow(non_camel_case_types)] struct getPathElementsSvc(pub Arc); diff --git a/packages/rs-dpp/Cargo.toml b/packages/rs-dpp/Cargo.toml index a216e1f8bd..f5a55154d9 100644 --- a/packages/rs-dpp/Cargo.toml +++ b/packages/rs-dpp/Cargo.toml @@ -43,7 +43,7 @@ log = { version = "0.4.6" } num_enum = "0.5.7" bincode = { version = "2.0.0-rc.3", features = ["serde"] } rand = { version = "0.8.4", features = ["small_rng"] } -regex = { version = "1.5" } +regex = { version = "1.10.4" } serde = { version = "1.0.197", features = ["derive"] } serde_json = { version = "1.0", features = ["preserve_order"] } serde_repr = { version = "0.1.7" } diff --git a/packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs b/packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs index 83d9c64926..87759b0ee0 100644 --- a/packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs @@ -35,9 +35,9 @@ impl DocumentTypeV0Getters for DocumentType { } } - fn indices(&self) -> &BTreeMap { + fn indexes(&self) -> &BTreeMap { match self { - DocumentType::V0(v0) => v0.indices(), + DocumentType::V0(v0) => v0.indexes(), } } @@ -157,9 +157,9 @@ impl<'a> DocumentTypeV0Getters for DocumentTypeRef<'a> { } } - fn indices(&self) -> &BTreeMap { + fn indexes(&self) -> &BTreeMap { match self { - DocumentTypeRef::V0(v0) => v0.indices(), + DocumentTypeRef::V0(v0) => v0.indexes(), } } @@ -279,9 +279,9 @@ impl<'a> DocumentTypeV0Getters for DocumentTypeMutRef<'a> { } } - fn indices(&self) -> &BTreeMap { + fn indexes(&self) -> &BTreeMap { match self { - DocumentTypeMutRef::V0(v0) => v0.indices(), + DocumentTypeMutRef::V0(v0) => v0.indexes(), } } diff --git a/packages/rs-dpp/src/data_contract/document_type/accessors/v0/mod.rs b/packages/rs-dpp/src/data_contract/document_type/accessors/v0/mod.rs index 460610f625..342e109e33 100644 --- a/packages/rs-dpp/src/data_contract/document_type/accessors/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/accessors/v0/mod.rs @@ -21,7 +21,7 @@ pub trait DocumentTypeV0Getters { fn schema_owned(self) -> Value; /// Returns the indices of the document type. - fn indices(&self) -> &BTreeMap; + fn indexes(&self) -> &BTreeMap; /// Returns the index structure of the document type. fn index_structure(&self) -> &IndexLevel; diff --git a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs index a582dd9543..2466012fcd 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs @@ -18,6 +18,7 @@ use crate::data_contract::document_type::ContestedIndexResolution::MasternodeVot use platform_value::{Value, ValueMap}; use rand::distributions::{Alphanumeric, DistString}; use std::{collections::BTreeMap, convert::TryFrom}; +use crate::data_contract::errors::DataContractError::RegexError; pub mod random_index; @@ -42,9 +43,65 @@ impl TryFrom for ContestedIndexResolution { } #[repr(u8)] -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Debug)] pub enum ContestedIndexFieldMatch { - Regex(String), + Regex(regex::Regex), + PositiveIntegerMatch(u128), + All, +} + +impl Clone for ContestedIndexFieldMatch { + fn clone(&self) -> Self { + match self { Regex(regex) => { + Regex(regex::Regex::new(regex.as_str()).unwrap()) + } + ContestedIndexFieldMatch::All => ContestedIndexFieldMatch::All, + ContestedIndexFieldMatch::PositiveIntegerMatch(int) => ContestedIndexFieldMatch::PositiveIntegerMatch(*int) + } + } +} + +impl PartialEq for ContestedIndexFieldMatch { + fn eq(&self, other: &Self) -> bool { + match self { Regex(regex) => { + match other { Regex(other_regex) => { + regex.as_str() == other_regex.as_str() + } + _ => false + } + } + ContestedIndexFieldMatch::All => { + match other { ContestedIndexFieldMatch::All => true, + _ => false + } + } + ContestedIndexFieldMatch::PositiveIntegerMatch(int) => { + match other { ContestedIndexFieldMatch::PositiveIntegerMatch(other_int) => int == other_int, + _ => false + } + } + } + } +} + +impl Eq for ContestedIndexFieldMatch {} + +impl ContestedIndexFieldMatch { + pub fn matches(&self, value: &Value) -> bool { + match self { Regex(regex) => { + if let Some(string) = value.as_str() { + regex.is_match(string) + } else { + false + } + + } + ContestedIndexFieldMatch::All => true, + ContestedIndexFieldMatch::PositiveIntegerMatch(int) => { + value.as_integer::().map(|i| i == *int).unwrap_or(false) + } + } + } } #[derive(Clone, Debug, PartialEq, Eq)] @@ -60,7 +117,7 @@ impl Default for ContestedIndexInformation { ContestedIndexInformation { contested_field_temp_replacement_name: "".to_string(), contested_field_name: "".to_string(), - field_match: Regex(String::new()), + field_match: ContestedIndexFieldMatch::All, //by default always contest resolution: ContestedIndexResolution::MasternodeVote, } } @@ -268,7 +325,7 @@ impl TryFrom<&[(Value, Value)]> for Index { match contested_key { "regexPattern" => { let regex = contested_value.to_str()?.to_owned(); - contested_index_information.field_match = Regex(regex); + contested_index_information.field_match = Regex(regex::Regex::new(®ex).map_err(|e| RegexError(format!("invalid field match regex: {}", e.to_string())))?); } "name" => { let field = contested_value.to_str()?.to_owned(); diff --git a/packages/rs-dpp/src/data_contract/document_type/index/random_index.rs b/packages/rs-dpp/src/data_contract/document_type/index/random_index.rs index 3aff79a996..8780fa0abd 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index/random_index.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index/random_index.rs @@ -8,11 +8,11 @@ use rand::Rng; impl Index { pub fn random( field_names: &[String], - existing_indices: &I, + existing_indices: I, rng: &mut StdRng, ) -> Result where - I: IntoIterator, // T is the type of elements in the collection + I: Clone + IntoIterator, // T is the type of elements in the collection T: Borrow, // Assuming Index is the type stored in the collection { let index_name = format!("index_{}", rng.gen::()); @@ -36,7 +36,7 @@ impl Index { }) .collect::>(); - if !existing_indices + if !existing_indices.clone() .into_iter() .any(|index| index.borrow().properties == properties) { diff --git a/packages/rs-dpp/src/data_contract/document_type/v0/accessors.rs b/packages/rs-dpp/src/data_contract/document_type/v0/accessors.rs index 6b8165e884..99353db701 100644 --- a/packages/rs-dpp/src/data_contract/document_type/v0/accessors.rs +++ b/packages/rs-dpp/src/data_contract/document_type/v0/accessors.rs @@ -27,7 +27,7 @@ impl DocumentTypeV0Getters for DocumentTypeV0 { self.schema } - fn indices(&self) -> &BTreeMap { + fn indexes(&self) -> &BTreeMap { &self.indices } diff --git a/packages/rs-dpp/src/data_contract/document_type/v0/random_document_type.rs b/packages/rs-dpp/src/data_contract/document_type/v0/random_document_type.rs index 53ed0cf9cf..329ae89b85 100644 --- a/packages/rs-dpp/src/data_contract/document_type/v0/random_document_type.rs +++ b/packages/rs-dpp/src/data_contract/document_type/v0/random_document_type.rs @@ -237,7 +237,7 @@ impl DocumentTypeV0 { let mut indices = BTreeMap::new(); for _ in 0..index_count { - match Index::random(&ten_field_names, &indices.values(), rng) { + match Index::random(&ten_field_names, indices.values(), rng) { Ok(index) => { indices.insert(index.name.clone(), index); }, @@ -557,7 +557,7 @@ impl DocumentTypeV0 { let mut indices = BTreeMap::new(); for _ in 0..index_count { - match Index::random(&ten_field_names, &indices.values(), rng) { + match Index::random(&ten_field_names, indices.values(), rng) { Ok(index) => { indices.insert(index.name.clone(), index); }, diff --git a/packages/rs-dpp/src/data_contract/errors/contract.rs b/packages/rs-dpp/src/data_contract/errors/contract.rs index a9d13520b1..59ae401bc4 100644 --- a/packages/rs-dpp/src/data_contract/errors/contract.rs +++ b/packages/rs-dpp/src/data_contract/errors/contract.rs @@ -27,6 +27,9 @@ pub enum DataContractError { #[error("field requirement unmet: {0}")] FieldRequirementUnmet(String), + #[error("regex error: {0}")] + RegexError(String), + #[error("key wrong type error: {0}")] KeyWrongType(String), @@ -74,7 +77,7 @@ pub enum DataContractError { #[error("Corrupted Serialization: {0}")] CorruptedSerialization(String), - #[error("Corrupted Code Execution: {0}")] + #[error("Json schema error: {0}")] JsonSchema(JsonSchemaError), } diff --git a/packages/rs-dpp/src/data_contract/extra/drive_api_tests.rs b/packages/rs-dpp/src/data_contract/extra/drive_api_tests.rs index e1cd6308ce..394245a5b4 100644 --- a/packages/rs-dpp/src/data_contract/extra/drive_api_tests.rs +++ b/packages/rs-dpp/src/data_contract/extra/drive_api_tests.rs @@ -128,7 +128,7 @@ mod test { let document_type = data_contract .document_type_for_name(expect.document_name) .unwrap(); - assert_eq!(expect.indexes.len(), document_type.indices().len()); + assert_eq!(expect.indexes.len(), document_type.indexes().len()); } } @@ -174,7 +174,7 @@ mod test { .document_types .get("contactInfo") .unwrap() - .indices(); + .indexes(); assert_eq!(contact_info_indices.len(), 2); assert!(contact_info_indices[0].unique); assert!(!contact_info_indices[1].unique); diff --git a/packages/rs-dpp/src/errors/consensus/basic/basic_error.rs b/packages/rs-dpp/src/errors/consensus/basic/basic_error.rs index f78903696a..3c30796f0d 100644 --- a/packages/rs-dpp/src/errors/consensus/basic/basic_error.rs +++ b/packages/rs-dpp/src/errors/consensus/basic/basic_error.rs @@ -66,6 +66,7 @@ use crate::consensus::basic::value_error::ValueError; use crate::consensus::basic::{ json_schema_compilation_error::JsonSchemaCompilationError, json_schema_error::JsonSchemaError, }; +use crate::consensus::basic::overflow_error::OverflowError; use crate::consensus::state::identity::master_public_key_update_error::MasterPublicKeyUpdateError; use crate::data_contract::errors::DataContractError; @@ -372,6 +373,9 @@ pub enum BasicError { #[error(transparent)] InvalidDocumentTypeNameError(InvalidDocumentTypeNameError), + + #[error(transparent)] + OverflowError(OverflowError), } impl From for ConsensusError { diff --git a/packages/rs-dpp/src/errors/consensus/basic/mod.rs b/packages/rs-dpp/src/errors/consensus/basic/mod.rs index d38bbe0938..dd7bba84b2 100644 --- a/packages/rs-dpp/src/errors/consensus/basic/mod.rs +++ b/packages/rs-dpp/src/errors/consensus/basic/mod.rs @@ -19,3 +19,4 @@ pub mod json_schema_error; pub mod state_transition; pub mod unsupported_version_error; pub mod value_error; +pub mod overflow_error; diff --git a/packages/rs-dpp/src/errors/consensus/basic/overflow_error.rs b/packages/rs-dpp/src/errors/consensus/basic/overflow_error.rs new file mode 100644 index 0000000000..e80c98d0c7 --- /dev/null +++ b/packages/rs-dpp/src/errors/consensus/basic/overflow_error.rs @@ -0,0 +1,37 @@ +use crate::consensus::basic::BasicError; +use crate::consensus::ConsensusError; +use crate::errors::ProtocolError; +use bincode::{Decode, Encode}; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +use thiserror::Error; + +#[derive( +Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] +#[error("Overflow error")] +#[platform_serialize(unversioned)] +pub struct OverflowError { + /* + + DO NOT CHANGE ORDER OF FIELDS WITHOUT INTRODUCING OF NEW VERSION + + */ + message: String, +} + +impl OverflowError { + pub fn new(message: String) -> Self { + Self { + message + } + } + + pub fn message(&self) -> &str { + self.message.as_str() + } +} +impl From for ConsensusError { + fn from(err: OverflowError) -> Self { + Self::BasicError(BasicError::OverflowError(err)) + } +} diff --git a/packages/rs-dpp/src/errors/consensus/codes.rs b/packages/rs-dpp/src/errors/consensus/codes.rs index 93544fc1d3..cd3dfab988 100644 --- a/packages/rs-dpp/src/errors/consensus/codes.rs +++ b/packages/rs-dpp/src/errors/consensus/codes.rs @@ -93,6 +93,7 @@ impl ErrorWithCode for BasicError { Self::UnknownTransferableTypeError { .. } => 10243, Self::UnknownTradeModeError { .. } => 10244, Self::UnknownDocumentCreationRestrictionModeError { .. } => 10245, + Self::ContractError(DataContractError::RegexError(_)) => 10246, // Document Errors: 10400-10499 Self::DataContractNotPresentError { .. } => 10400, @@ -151,6 +152,9 @@ impl ErrorWithCode for BasicError { Self::InvalidStateTransitionTypeError { .. } => 10600, Self::MissingStateTransitionTypeError { .. } => 10601, Self::StateTransitionMaxSizeExceededError { .. } => 10602, + + // General Errors 10700-10799 + Self::OverflowError(_) => 10700, } } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/from_document.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/from_document.rs index ea399612f4..55cf317d5b 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/from_document.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/from_document.rs @@ -5,6 +5,7 @@ use crate::state_transition::documents_batch_transition::document_base_transitio use crate::state_transition::documents_batch_transition::document_create_transition::DocumentCreateTransitionV0; use crate::ProtocolError; use platform_version::version::{FeatureVersion, PlatformVersion}; +use crate::data_contract::document_type::accessors::DocumentTypeV0Getters; impl DocumentCreateTransitionV0 { pub(crate) fn from_document( @@ -15,6 +16,16 @@ impl DocumentCreateTransitionV0 { platform_version: &PlatformVersion, base_feature_version: Option, ) -> Result { + let prefunded_voting_balances = document_type.indexes().iter().filter_map(|(name, index)| { + if let Some(contested_index_info) = &index.contested_index { + if let Some(value) = document.get(&contested_index_info.contested_field_name) { + if contested_index_info.field_match.matches(value) { + return Some((name.clone(), platform_version.fee_version.vote_resolution_fund_fees.conflicting_vote_resolution_fund_required_amount)); + } + } + } + None + }).collect(); Ok(DocumentCreateTransitionV0 { base: DocumentBaseTransition::from_document( &document, @@ -25,6 +36,7 @@ impl DocumentCreateTransitionV0 { )?, entropy, data: document.properties_consumed(), + prefunded_voting_balances, }) } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs index 63e03389fa..f97321b8cd 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs @@ -29,12 +29,14 @@ use crate::state_transition::documents_batch_transition::document_base_transitio use crate::state_transition::documents_batch_transition::document_base_transition::DocumentBaseTransition; use derive_more::Display; use platform_version::version::PlatformVersion; +use crate::fee::Credits; #[cfg(feature = "state-transition-value-conversion")] use crate::state_transition::documents_batch_transition; mod property_names { pub const ENTROPY: &str = "$entropy"; + pub const PREFUNDED_VOTING_BALANCES: &str = "$prefundedVotingBalances"; } /// The Binary fields in [`DocumentCreateTransition`] @@ -63,59 +65,14 @@ pub struct DocumentCreateTransitionV0 { #[cfg_attr(feature = "state-transition-serde-conversion", serde(flatten))] pub data: BTreeMap, + + #[cfg_attr(feature = "state-transition-serde-conversion", serde(rename = "$prefundedVotingBalances"))] + /// Pre funded balance (for unique index conflict resolution voting - the identity will put money + /// aside that will be used by voters to vote) + /// This is a map of index names to the amount we want to prefund them for + /// Since index conflict resolution is not a common feature most often nothing should be added here. + pub prefunded_voting_balances: BTreeMap, } -// -// impl DocumentCreateTransitionV0 { -// pub fn get_revision(&self) -> Option { -// //todo: fix this -// Some(INITIAL_REVISION) -// } -// -// pub(crate) fn to_document(&self, owner_id: Identifier) -> Result { -// let properties = self.data.clone().unwrap_or_default(); -// Ok(Document { -// id: self.base.id, -// owner_id, -// properties, -// created_at: self.created_at, -// updated_at: self.updated_at, -// revision: self.get_revision(), -// }) -// } -// -// pub(crate) fn to_extended_document( -// &self, -// owner_id: Identifier, -// ) -> Result { -// Ok(ExtendedDocument { -// feature_version: LATEST_PLATFORM_VERSION -// .extended_document -// .default_current_version, -// document_type_name: self.base.document_type_name.clone(), -// data_contract_id: self.base.data_contract_id, -// document: self.to_document(owner_id)?, -// data_contract: self.base.data_contract.clone(), -// metadata: None, -// entropy: Bytes32::new(self.entropy), -// }) -// } -// -// pub(crate) fn into_document(self, owner_id: Identifier) -> Result { -// let id = self.base.id; -// let revision = self.get_revision(); -// let created_at = self.created_at; -// let updated_at = self.updated_at; -// let properties = self.data.unwrap_or_default(); -// Ok(Document { -// id, -// owner_id, -// properties, -// created_at, -// updated_at, -// revision, -// }) -// } -// } impl DocumentCreateTransitionV0 { #[cfg(feature = "state-transition-value-conversion")] @@ -135,6 +92,7 @@ impl DocumentCreateTransitionV0 { entropy: map .remove_hash256_bytes(property_names::ENTROPY) .map_err(ProtocolError::ValueError)?, + prefunded_voting_balances: map.remove_map_as_btree_map(property_names::PREFUNDED_VOTING_BALANCES)?, data: map, }) } @@ -147,6 +105,11 @@ impl DocumentCreateTransitionV0 { Value::Bytes(self.entropy.to_vec()), ); + transition_base_map.insert( + property_names::PREFUNDED_VOTING_BALANCES.to_string(), + Value::Map(ValueMap::from_btree_map(self.prefunded_voting_balances.clone())), + ); + transition_base_map.extend(self.data.clone()); Ok(transition_base_map) diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/v0_methods.rs index e15c8b6dc2..9d48401fad 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/v0_methods.rs @@ -4,6 +4,7 @@ use crate::state_transition::documents_batch_transition::document_create_transit use platform_value::Value; use std::collections::BTreeMap; +use crate::fee::Credits; pub trait DocumentCreateTransitionV0Methods { /// Returns a reference to the `base` field of the `DocumentCreateTransitionV0`. @@ -41,6 +42,10 @@ pub trait DocumentCreateTransitionV0Methods { /// /// * `data` - An `Option` containing a `BTreeMap` to set. fn set_data(&mut self, data: BTreeMap); + fn prefunded_voting_balances(&self) -> &BTreeMap; + fn prefunded_voting_balances_mut(&mut self) -> &mut BTreeMap; + fn add_prefunded_voting_balance(&mut self, index_name: String, amount: Credits); + fn clear_prefunded_voting_balances(&mut self); } impl DocumentCreateTransitionV0Methods for DocumentCreateTransitionV0 { @@ -75,4 +80,20 @@ impl DocumentCreateTransitionV0Methods for DocumentCreateTransitionV0 { fn set_data(&mut self, data: BTreeMap) { self.data = data; } + + fn prefunded_voting_balances(&self) -> &BTreeMap { + &self.prefunded_voting_balances + } + + fn prefunded_voting_balances_mut(&mut self) -> &mut BTreeMap { + &mut self.prefunded_voting_balances + } + + fn add_prefunded_voting_balance(&mut self, index_name: String, amount: Credits) { + self.prefunded_voting_balances.insert(index_name, amount); + } + + fn clear_prefunded_voting_balances(&mut self) { + self.prefunded_voting_balances.clear() + } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0_methods.rs index ac937493d7..2998fd2d23 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0_methods.rs @@ -1,5 +1,6 @@ use std::collections::BTreeMap; use platform_value::{Value}; +use crate::fee::Credits; use crate::state_transition::documents_batch_transition::document_base_transition::DocumentBaseTransition; use crate::state_transition::documents_batch_transition::document_create_transition::DocumentCreateTransition; use crate::state_transition::documents_batch_transition::document_create_transition::v0::v0_methods::DocumentCreateTransitionV0Methods; @@ -52,4 +53,30 @@ impl DocumentCreateTransitionV0Methods for DocumentCreateTransition { DocumentCreateTransition::V0(v0) => v0.data = data, } } + + fn prefunded_voting_balances(&self) -> &BTreeMap { + match self { + DocumentCreateTransition::V0(v0) => &v0.prefunded_voting_balances, + } + } + + fn prefunded_voting_balances_mut(&mut self) -> &mut BTreeMap { + match self { + DocumentCreateTransition::V0(v0) => &mut v0.prefunded_voting_balances, + } + } + + fn add_prefunded_voting_balance(&mut self, index_name: String, amount: Credits) { + match self { + DocumentCreateTransition::V0(v0) => { + v0.prefunded_voting_balances.insert(index_name, amount); + }, + } + } + + fn clear_prefunded_voting_balances(&mut self) { + match self { + DocumentCreateTransition::V0(v0) => v0.prefunded_voting_balances.clear(), + } + } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/mod.rs index 6d2b9a451a..b1c3dcdd94 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/mod.rs @@ -27,12 +27,18 @@ use platform_version::version::{FeatureVersion, PlatformVersion}; pub mod v0; impl DocumentsBatchTransitionMethodsV0 for DocumentsBatchTransition { - fn all_purchases_amount(&self) -> Option { + fn all_purchases_amount(&self) -> Result, ProtocolError> { match self { DocumentsBatchTransition::V0(v0) => v0.all_purchases_amount(), } } + fn all_conflicting_index_collateral_voting_funds(&self) -> Result, ProtocolError> { + match self { + DocumentsBatchTransition::V0(v0) => v0.all_conflicting_index_collateral_voting_funds(), + } + } + fn set_transitions(&mut self, transitions: Vec) { match self { DocumentsBatchTransition::V0(v0) => v0.set_transitions(transitions), diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/v0/mod.rs index a21448ea48..b40bec179f 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/v0/mod.rs @@ -156,5 +156,7 @@ pub trait DocumentsBatchTransitionMethodsV0: DocumentsBatchTransitionAccessorsV0 fn set_identity_contract_nonce(&mut self, identity_contract_nonce: IdentityNonce); - fn all_purchases_amount(&self) -> Option; + fn all_conflicting_index_collateral_voting_funds(&self) -> Result, ProtocolError>; + + fn all_purchases_amount(&self) -> Result, ProtocolError>; } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs index 397de6c5e5..3d9a643da8 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs @@ -36,6 +36,7 @@ use crate::ProtocolError; use platform_value::Identifier; #[cfg(feature = "state-transition-signing")] use platform_version::version::{FeatureVersion, PlatformVersion}; +use crate::state_transition::documents_batch_transition::document_create_transition::v0::v0_methods::DocumentCreateTransitionV0Methods; use crate::state_transition::documents_batch_transition::document_transition::document_purchase_transition::v0::v0_methods::DocumentPurchaseTransitionV0Methods; impl DocumentsBatchTransitionAccessorsV0 for DocumentsBatchTransitionV0 { @@ -301,8 +302,8 @@ impl DocumentsBatchTransitionMethodsV0 for DocumentsBatchTransitionV0 { .for_each(|transition| transition.set_identity_contract_nonce(identity_contract_nonce)); } - fn all_purchases_amount(&self) -> Option { - let (total, any_purchases) = self + fn all_purchases_amount(&self) -> Result, ProtocolError> { + let (total, any_purchases): (Option, bool) = self .transitions .iter() .filter_map(|transition| { @@ -310,12 +311,45 @@ impl DocumentsBatchTransitionMethodsV0 for DocumentsBatchTransitionV0 { .as_transition_purchase() .map(|purchase| purchase.price()) }) - .fold((0, false), |(acc, _), price| (acc + price, true)); + .fold((None, false), |(acc, _), price| { + match acc { + Some(acc_val) => acc_val.checked_add(price).map_or((None, true), |sum| (Some(sum), true)), + None => (Some(price), true), + } + }); - if any_purchases { - Some(total) // Return the sum as Some(Credits) if there were any purchases - } else { - None // Return None if no purchases were found + match (total, any_purchases) { + (Some(total), _) => Ok(Some(total)), + (None, true) => Err(ProtocolError::Overflow("overflow in all purchases amount")), // Overflow occurred + _ => Ok(None), // No purchases were found + } + } + + fn all_conflicting_index_collateral_voting_funds(&self) -> Result, ProtocolError> { + let (total, any_voting_funds): (Option, bool) = self + .transitions + .iter() + .filter_map(|transition| { + transition + .as_transition_create() + .map(|document_create_transition| { + // Safely sum up values to avoid overflow. + document_create_transition.prefunded_voting_balances().values().try_fold(0u64, |acc, &val| { + acc.checked_add(val) + }) + }).flatten() + }) + .fold((None, false), |(acc, _), price| { + match acc { + Some(acc_val) => acc_val.checked_add(price).map_or((None, true), |sum| (Some(sum), true)), + None => (Some(price), true), + } + }); + + match (total, any_voting_funds) { + (Some(total), _) => Ok(Some(total)), + (None, true) => Err(ProtocolError::Overflow("overflow in all voting funds amount")), // Overflow occurred + _ => Ok(None), } } } diff --git a/packages/rs-dpp/src/util/json_schema.rs b/packages/rs-dpp/src/util/json_schema.rs index 0e6459083d..c0d3aa2926 100644 --- a/packages/rs-dpp/src/util/json_schema.rs +++ b/packages/rs-dpp/src/util/json_schema.rs @@ -219,7 +219,7 @@ mod test { ) .unwrap(); - let indices = document_type.indices(); + let indices = document_type.indexes(); assert_eq!(indices.len(), 2); diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/mod.rs b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/mod.rs deleted file mode 100644 index 9db24187d7..0000000000 --- a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/mod.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::data_contract::accessors::v0::DataContractV0Getters; -use crate::data_contract::document_type::accessors::DocumentTypeV0Getters; -use crate::prelude::DataContract; -use crate::ProtocolError; -use crate::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; -use crate::voting::votes::contested_document_resource_vote::methods::v0::ContestedDocumentResourceVoteMethodsV0; -use crate::voting::votes::contested_document_resource_vote::accessors::v0::ContestedDocumentResourceVoteGettersV0; - -mod v0; - -impl ContestedDocumentResourceVoteMethodsV0 for ContestedDocumentResourceVote { - fn index_path(&self, contract: &DataContract) -> Result>, ProtocolError> { - let vote_poll = self.vote_poll(); - let document_type = contract.document_type_for_name(vote_poll.document_type_name.as_str())?; - let index = document_type.indices().get(&vote_poll.index_name).ok_or(ProtocolError::); - } -} \ No newline at end of file diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/v0/mod.rs b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/v0/mod.rs deleted file mode 100644 index 2a329f8256..0000000000 --- a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/methods/v0/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -use crate::prelude::DataContract; -use crate::ProtocolError; - -pub trait ContestedDocumentResourceVoteMethodsV0 { - fn index_path(&self, contract: &DataContract) -> Result>, ProtocolError>; -} \ No newline at end of file diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs index 2942d36f90..47c4ea6976 100644 --- a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs +++ b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs @@ -9,7 +9,6 @@ use crate::ProtocolError; mod v0; mod accessors; -mod methods; #[derive(Debug, Clone, PartialEq, From)] #[cfg_attr( diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs index 2b98dd8b1c..df10dcde93 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs @@ -557,6 +557,9 @@ impl StateTransitionBalanceValidationV0 for StateTransition { | StateTransition::IdentityUpdate(_) => { self.validate_simple_pre_check_minimum_balance(identity, platform_version) } + StateTransition::MasternodeVote(_) => { + // We validate that amount set aside still has funds + } StateTransition::IdentityCreate(_) | StateTransition::IdentityTopUp(_) => { Ok(SimpleConsensusValidationResult::new()) } @@ -572,6 +575,7 @@ impl StateTransitionBalanceValidationV0 for StateTransition { | StateTransition::DataContractUpdate(_) | StateTransition::DocumentsBatch(_) | StateTransition::IdentityUpdate(_) + | StateTransition::MasternodeVote(_) ) } } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_create_transition_action/state_v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_create_transition_action/state_v0/mod.rs index aff96c0337..4793527db9 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_create_transition_action/state_v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_create_transition_action/state_v0/mod.rs @@ -72,7 +72,7 @@ impl DocumentCreateTransitionActionStateValidationV0 for DocumentCreateTransitio // we also need to validate that the new document wouldn't conflict with any other document // this means for example having overlapping unique indexes - if document_type.indices().iter().any(|index| index.unique) { + if document_type.indexes().iter().any(|index| index.unique) { platform .drive .validate_document_create_transition_action_uniqueness( diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_purchase_transition_action/state_v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_purchase_transition_action/state_v0/mod.rs index e4a59552eb..0718289f9c 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_purchase_transition_action/state_v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_purchase_transition_action/state_v0/mod.rs @@ -51,7 +51,7 @@ impl DocumentPurchaseTransitionActionStateValidationV0 for DocumentPurchaseTrans // We need to verify that the resultant document doesn't violate any unique properties - if document_type.indices().iter().any(|index| index.unique) { + if document_type.indexes().iter().any(|index| index.unique) { platform .drive .validate_document_purchase_transition_action_uniqueness( diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_replace_transition_action/state_v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_replace_transition_action/state_v0/mod.rs index ea9e1529e8..a75fed74cd 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_replace_transition_action/state_v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_replace_transition_action/state_v0/mod.rs @@ -49,7 +49,7 @@ impl DocumentReplaceTransitionActionStateValidationV0 for DocumentReplaceTransit // There is no need to verify that the document already existed, since this is done when // transforming into an action - if document_type.indices().iter().any(|index| index.unique) { + if document_type.indexes().iter().any(|index| index.unique) { platform .drive .validate_document_replace_transition_action_uniqueness( diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_transfer_transition_action/state_v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_transfer_transition_action/state_v0/mod.rs index 7e1e64bab4..6bda96cb46 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_transfer_transition_action/state_v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_transfer_transition_action/state_v0/mod.rs @@ -49,7 +49,7 @@ impl DocumentTransferTransitionActionStateValidationV0 for DocumentTransferTrans // There is no need to verify that the document already existed, since this is done when // transforming into an action - if document_type.indices().iter().any(|index| index.unique) { + if document_type.indexes().iter().any(|index| index.unique) { platform .drive .validate_document_transfer_transition_action_uniqueness( diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_update_price_transition_action/state_v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_update_price_transition_action/state_v0/mod.rs index 4f622331b5..e41ccb925d 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_update_price_transition_action/state_v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_update_price_transition_action/state_v0/mod.rs @@ -49,7 +49,7 @@ impl DocumentUpdatePriceTransitionActionStateValidationV0 for DocumentUpdatePric // There is no need to verify that the document already existed, since this is done when // transforming into an action - if document_type.indices().iter().any(|index| index.unique) { + if document_type.indexes().iter().any(|index| index.unique) { platform .drive .validate_document_update_price_transition_action_uniqueness( diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/balance/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/balance/v0/mod.rs index a46b1aad9b..d96915af4e 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/balance/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/balance/v0/mod.rs @@ -1,6 +1,10 @@ +use dpp::consensus::basic::BasicError; +use dpp::consensus::basic::overflow_error::OverflowError; +use dpp::consensus::ConsensusError; use crate::error::Error; use dpp::consensus::state::identity::IdentityInsufficientBalanceError; use dpp::identity::PartialIdentity; +use dpp::ProtocolError; use dpp::state_transition::documents_batch_transition::accessors::DocumentsBatchTransitionAccessorsV0; use dpp::state_transition::documents_batch_transition::methods::v0::DocumentsBatchTransitionMethodsV0; use dpp::state_transition::documents_batch_transition::DocumentsBatchTransition; @@ -32,16 +36,31 @@ impl DocumentsBatchTransitionBalanceValidationV0 for DocumentsBatchTransition { "expected to have a balance on identity for documents batch transition", )))?; - let purchases_amount = self.all_purchases_amount().unwrap_or_default(); - - let base_fees = platform_version.fee_version.state_transition_min_fees.document_batch_sub_transition.checked_mul(self.transitions().len() as u64).ok_or(Error::Execution(ExecutionError::Overflow("overflow when multiplying base fee and amount of sub transitions in documents batch transition")))?; + let purchases_amount = match self.all_purchases_amount() { + Ok(purchase_amount) => purchase_amount.unwrap_or_default(), + Err(ProtocolError::Overflow(e)) => return Ok(SimpleConsensusValidationResult::new_with_error(ConsensusError::BasicError(BasicError::OverflowError(OverflowError::new(e.to_owned()))))), + Err(e) => return Err(e.into()), + }; + + // If we added documents that had a conflicting index we need to put up a collateral that voters can draw on + + let conflicting_indices_collateral_amount = match self.all_conflicting_index_collateral_voting_funds() { + Ok(conflicting_indices_collateral_amount) => conflicting_indices_collateral_amount.unwrap_or_default(), + Err(ProtocolError::Overflow(e)) => return Ok(SimpleConsensusValidationResult::new_with_error(ConsensusError::BasicError(BasicError::OverflowError(OverflowError::new(e.to_owned()))))), + Err(e) => return Err(e.into()), + }; + + let base_fees = match platform_version.fee_version.state_transition_min_fees.document_batch_sub_transition.checked_mul(self.transitions().len() as u64) { + None => return Ok(SimpleConsensusValidationResult::new_with_error(ConsensusError::BasicError(BasicError::OverflowError(OverflowError::new("overflow when multiplying base fee and amount of sub transitions in documents batch transition".to_string()))))), + Some(base_fees) => base_fees + }; // This is just the needed balance to pass this validation step, most likely the actual fees are smaller - let needed_balance = purchases_amount - .checked_add(base_fees) - .ok_or(Error::Execution(ExecutionError::Overflow( - "overflow when adding all purchases amount and base fees in documents batch transition", - )))?; + let needed_balance = match purchases_amount + .checked_add(conflicting_indices_collateral_amount).and_then(|added| added.checked_add(base_fees)) { + None => return Ok(SimpleConsensusValidationResult::new_with_error(ConsensusError::BasicError(BasicError::OverflowError(OverflowError::new("overflow when adding all purchases amount with conflicting_indices_collateral_amounts and base fees in documents batch transition".to_string()))))), + Some(needed_balance) => needed_balance + }; if balance < needed_balance { return Ok(SimpleConsensusValidationResult::new_with_error( diff --git a/packages/rs-drive/src/drive/document/index_uniqueness/internal/validate_uniqueness_of_data/v0/mod.rs b/packages/rs-drive/src/drive/document/index_uniqueness/internal/validate_uniqueness_of_data/v0/mod.rs index 228d1d06d2..0b6b877e94 100644 --- a/packages/rs-drive/src/drive/document/index_uniqueness/internal/validate_uniqueness_of_data/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/index_uniqueness/internal/validate_uniqueness_of_data/v0/mod.rs @@ -60,7 +60,7 @@ impl Drive { } = request; let validation_results = document_type - .indices() + .indexes() .iter() .filter_map(|index| { if !index.unique { diff --git a/packages/rs-drive/src/drive/document/insert/add_document_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_document_for_contract_operations/v0/mod.rs index e82d7b079a..c949041ec1 100644 --- a/packages/rs-drive/src/drive/document/insert/add_document_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_document_for_contract_operations/v0/mod.rs @@ -62,7 +62,7 @@ impl Drive { .document_info .is_document_size(); - // 3. Document is exists in the storage + // 3. Document exists in storage let is_update = could_be_update && self.grove_has_raw( primary_key_path.as_ref().into(), diff --git a/packages/rs-drive/src/drive/document/insert/add_indices_for_top_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_indices_for_top_index_level_for_contract_operations/v0/mod.rs index 854c50f279..94f7cfc6ea 100644 --- a/packages/rs-drive/src/drive/document/insert/add_indices_for_top_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_indices_for_top_index_level_for_contract_operations/v0/mod.rs @@ -54,8 +54,8 @@ impl Drive { // we need to construct the path for documents on the contract // the path is - // * Document andDataContract root tree - // *DataContract ID recovered from document + // * Document and DataContract root tree + // * DataContract ID recovered from document // * 0 to signify Documents and notDataContract let contract_document_type_path = contract_document_type_path_vec( document_and_contract_info.contract.id_ref().as_bytes(), diff --git a/packages/rs-drive/src/drive/document/update/internal/update_document_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/update/internal/update_document_for_contract_operations/v0/mod.rs index d728ffe0c7..420775c9b3 100644 --- a/packages/rs-drive/src/drive/document/update/internal/update_document_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/update/internal/update_document_for_contract_operations/v0/mod.rs @@ -170,7 +170,7 @@ impl Drive { let mut batch_insertion_cache: HashSet>> = HashSet::new(); // fourth we need to store a reference to the document for each index - for index in document_type.indices() { + for index in document_type.indexes() { // at this point the contract path is to the contract documents // for each index the top index component will already have been added // when the contract itself was created diff --git a/packages/rs-drive/src/drive/initialization/v0/mod.rs b/packages/rs-drive/src/drive/initialization/v0/mod.rs index 83165693c5..57c8485fd2 100644 --- a/packages/rs-drive/src/drive/initialization/v0/mod.rs +++ b/packages/rs-drive/src/drive/initialization/v0/mod.rs @@ -1,32 +1,3 @@ -// MIT LICENSE -// -// Copyright (c) 2021 Dash Core Group -// -// Permission is hereby granted, free of charge, to any -// person obtaining a copy of this software and associated -// documentation files (the "Software"), to deal in the -// Software without restriction, including without -// limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software -// is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice -// shall be included in all copies or substantial portions -// of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// - //! Drive Initialization use grovedb_path::SubtreePath; @@ -124,7 +95,7 @@ impl Drive { drive_version, )?; - //Row 3 (5/8 taken) + //Row 3 (6/8 taken) self.grove_insert_empty_tree( SubtreePath::empty(), @@ -144,6 +115,15 @@ impl Drive { drive_version, )?; + self.grove_insert_empty_sum_tree( + SubtreePath::empty(), + &[RootTree::PreFundedSpecializedBalances as u8], + transaction, + None, + &mut drive_operations, + drive_version, + )?; + self.grove_insert_empty_tree( SubtreePath::empty(), &[RootTree::SpentAssetLockTransactions as u8], @@ -194,6 +174,9 @@ impl Drive { // For Versioning via forks Drive::add_initial_fork_update_structure_operations(&mut batch); + + // Pre funded specialized balances tree + Drive::add_initial_pre_funded_specialized_balances_operations(&mut batch); // For the votes tree structure Drive::add_initial_vote_tree_main_structure_operations(&mut batch, platform_version)?; diff --git a/packages/rs-drive/src/drive/mod.rs b/packages/rs-drive/src/drive/mod.rs index 82a83bf87e..1e5564e2de 100644 --- a/packages/rs-drive/src/drive/mod.rs +++ b/packages/rs-drive/src/drive/mod.rs @@ -95,6 +95,7 @@ mod prove; #[cfg(feature = "verify")] pub mod verify; mod votes; +mod pre_funded_specialized_balances; #[cfg(feature = "server")] use crate::drive::cache::DriveCache; @@ -116,13 +117,13 @@ pub struct Drive { // is at the top of the tree in order to reduce proof size // the most import tree is theDataContract Documents tree -// DataContract_Documents 64 -// / \ -// Identities 32 Balances 96 -// / \ / \ -// Token_Balances 16 Pools 48 WithdrawalTransactions 80 Votes 112 -// / \ / / \ -// NUPKH->I 8 UPKH->I 24 SpentAssetLockTransactions 72 Misc 104 Versions 120 +// DataContract_Documents 64 +// / \ +// Identities 32 Balances 96 +// / \ / \ +// Token_Balances 16 Pools 48 WithdrawalTransactions 80 Votes 112 +// / \ / / / \ +// NUPKH->I 8 UPKH->I 24 PreFundedSpecializedBalances 40 SpentAssetLockTransactions 72 Misc 104 Versions 120 /// Keys for the root tree. #[cfg(any(feature = "server", feature = "verify"))] @@ -139,13 +140,16 @@ pub enum RootTree { NonUniquePublicKeyKeyHashesToIdentities = 8, // NUPKH->I /// Pools Pools = 48, + /// PreFundedSpecializedBalances are balances that can fund specific state transitions that match + /// predefined criteria + PreFundedSpecializedBalances = 40, /// Spent Asset Lock Transactions SpentAssetLockTransactions = 72, /// Misc Misc = 104, /// Asset Unlock Transactions WithdrawalTransactions = 80, - /// Balances + /// Balances (For identities) Balances = 96, /// Token Balances TokenBalances = 16, @@ -182,6 +186,7 @@ impl From for &'static [u8; 1] { RootTree::UniquePublicKeyHashesToIdentities => &[24], RootTree::SpentAssetLockTransactions => &[72], RootTree::Pools => &[48], + RootTree::PreFundedSpecializedBalances => &[40], RootTree::Misc => &[104], RootTree::WithdrawalTransactions => &[80], RootTree::Balances => &[96], diff --git a/packages/rs-drive/src/drive/pre_funded_specialized_balances/mod.rs b/packages/rs-drive/src/drive/pre_funded_specialized_balances/mod.rs new file mode 100644 index 0000000000..342a9d83a7 --- /dev/null +++ b/packages/rs-drive/src/drive/pre_funded_specialized_balances/mod.rs @@ -0,0 +1,21 @@ +use crate::drive::batch::GroveDbOpBatch; +use crate::drive::{Drive, RootTree}; +use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; + +pub const PREFUNDED_BALANCES_FOR_VOTING: [u8; 1] = [128]; + +impl Drive { + /// Add operations for creating initial prefunded specialized balances state structure + /// In v1 we will only have the prefunded balances for voting + /// In the future, we could use this for allowing for "free" state transitions as long as the + /// state transition matches specific criteria. + /// For example let's say you make a food delivery app, and you want to pay for when your + /// customers make an order, the restaurant or food delivery app might prepay for all documents + /// that make an order + pub fn add_initial_pre_funded_specialized_balances_operations(batch: &mut GroveDbOpBatch) { + batch.add_insert_empty_sum_tree( + vec![vec![RootTree::PreFundedSpecializedBalances as u8]], + PREFUNDED_BALANCES_FOR_VOTING.to_vec(), + ); + } +} \ No newline at end of file diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs index ddecdfa8d4..5083dfda2f 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs @@ -11,11 +11,8 @@ use dpp::fee::fee_result::FeeResult; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; -use dpp::identifier::Identifier; -use dpp::prelude::IdentityNonce; use dpp::version::PlatformVersion; use dpp::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; -use dpp::voting::ContestedDocumentResourceVote; use grovedb::{EstimatedLayerInformation, TransactionArg}; impl Drive { diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 9c5a0b98a9..4581834973 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -138,14 +138,7 @@ impl TreePath for ContestedDocumentResourceVote { ))); } let document_type = contract.document_type_for_name(&vote_poll.document_type_name)?; - let index = document_type - .indices() - .iter() - .find(|index| &index.name == &vote_poll.index_name) - .ok_or(ProtocolError::VoteError(format!( - "votes index name {} not found", - &vote_poll.index_name - )))?; + let index = document_type.indexes().get(&vote_poll.index_name).ok_or(ProtocolError::UnknownContestedIndexResolution(format!("no index named {} for document type {} on contract with id {}", &vote_poll.index_name, document_type.name(), contract.id())))?; let mut path = contract_document_type_path( &vote_poll.contract_id.as_bytes(), &vote_poll.document_type_name, diff --git a/packages/rs-drive/src/query/test_index.rs b/packages/rs-drive/src/query/test_index.rs index d0b4b12cb6..995f21eb97 100644 --- a/packages/rs-drive/src/query/test_index.rs +++ b/packages/rs-drive/src/query/test_index.rs @@ -117,7 +117,7 @@ mod tests { let index = query .find_best_index(platform_version) .expect("expected to find index"); - assert_eq!(index, document_type.indices().get(2).unwrap()); + assert_eq!(index, document_type.indexes().get(2).unwrap()); let query_value = json!({ "where": [ @@ -136,7 +136,7 @@ mod tests { let index = query .find_best_index(platform_version) .expect("expected to find index"); - assert_eq!(index, document_type.indices().first().unwrap()); + assert_eq!(index, document_type.indexes().first().unwrap()); } #[test] diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/mod.rs index 39e40d8501..e7b3c23d7a 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/mod.rs @@ -6,6 +6,8 @@ use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::prelude::IdentityNonce; use dpp::ProtocolError; use std::sync::Arc; +use dpp::data_contract::document_type::DocumentTypeRef; +use dpp::data_contract::errors::DataContractError; /// transformer module pub mod transformer; @@ -28,12 +30,17 @@ impl DocumentBaseTransitionActionAccessorsV0 for DocumentBaseTransitionAction { DocumentBaseTransitionAction::V0(v0) => v0.id, } } - - fn document_type_field_is_required(&self, field: &str) -> Result { + + fn document_type(&self) -> Result { Ok(self .data_contract_fetch_info() .contract - .document_type_for_name(self.document_type_name())? + .document_type_for_name(self.document_type_name())?) + } + + fn document_type_field_is_required(&self, field: &str) -> Result { + Ok(self + .document_type()? .required_fields() .contains(field)) } diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/v0/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/v0/mod.rs index 89d5c0ac4e..91c500f92e 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/v0/mod.rs @@ -2,6 +2,7 @@ pub mod transformer; use std::sync::Arc; +use dpp::data_contract::document_type::DocumentTypeRef; use dpp::identifier::Identifier; use dpp::prelude::IdentityNonce; @@ -26,6 +27,7 @@ pub struct DocumentBaseTransitionActionV0 { pub trait DocumentBaseTransitionActionAccessorsV0 { /// The document Id fn id(&self) -> Identifier; + fn document_type(&self) -> Result; /// Is a field required on the document type? fn document_type_field_is_required(&self, field: &str) -> Result; diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs index f8f9c0380c..f649cdac16 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs @@ -7,8 +7,10 @@ use derive_more::From; use dpp::block::block_info::BlockInfo; use dpp::platform_value::{Identifier, Value}; use std::collections::BTreeMap; +use dpp::data_contract::document_type::Index; use dpp::document::Document; +use dpp::fee::Credits; use dpp::ProtocolError; @@ -59,6 +61,12 @@ impl DocumentCreateTransitionActionAccessorsV0 for DocumentCreateTransitionActio DocumentCreateTransitionAction::V0(v0) => v0.data, } } + + fn prefunded_voting_balances(&self) -> &BTreeMap { + match self { + DocumentCreateTransitionAction::V0(v0) => &v0.prefunded_voting_balances, + } + } } /// document from create transition diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs index 6a8ff00498..bd4458c3ed 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs @@ -9,12 +9,14 @@ use dpp::ProtocolError; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::data_contract::document_type::Index; use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; use dpp::document::property_names::{ CREATED_AT, CREATED_AT_BLOCK_HEIGHT, CREATED_AT_CORE_BLOCK_HEIGHT, TRANSFERRED_AT, TRANSFERRED_AT_BLOCK_HEIGHT, TRANSFERRED_AT_CORE_BLOCK_HEIGHT, UPDATED_AT, UPDATED_AT_BLOCK_HEIGHT, UPDATED_AT_CORE_BLOCK_HEIGHT, }; +use dpp::fee::Credits; use crate::state_transition_action::document::documents_batch::document_transition::document_base_transition_action::{DocumentBaseTransitionAction, DocumentBaseTransitionActionV0}; @@ -29,6 +31,9 @@ pub struct DocumentCreateTransitionActionV0 { pub block_info: BlockInfo, /// Document properties pub data: BTreeMap, + /// Pre funded balance (for unique index conflict resolution voting - the identity will put money + /// aside that will be used by voters to vote) + pub prefunded_voting_balances: BTreeMap } /// document create transition action accessors v0 @@ -45,6 +50,10 @@ pub trait DocumentCreateTransitionActionAccessorsV0 { fn data_mut(&mut self) -> &mut BTreeMap; /// data owned fn data_owned(self) -> BTreeMap; + + /// pre funded balance (for unique index conflict resolution voting - the identity will put money + /// aside that will be used by voters to vote) + fn prefunded_voting_balances(&self) -> &BTreeMap; } /// documents from create transition v0 @@ -95,6 +104,7 @@ impl DocumentFromCreateTransitionActionV0 for Document { base, block_info, data, + .. } = v0; match base { @@ -207,6 +217,7 @@ impl DocumentFromCreateTransitionActionV0 for Document { base, block_info, data, + .. } = v0; match base { diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs index 5b3286ba22..b26a22f846 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs @@ -1,11 +1,13 @@ use dpp::block::block_info::BlockInfo; use dpp::platform_value::Identifier; use std::sync::Arc; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::ProtocolError; use dpp::state_transition::documents_batch_transition::document_create_transition::v0::DocumentCreateTransitionV0; use crate::drive::contract::DataContractFetchInfo; -use crate::state_transition_action::document::documents_batch::document_transition::document_base_transition_action::DocumentBaseTransitionAction; +use crate::state_transition_action::document::documents_batch::document_transition::document_base_transition_action::{DocumentBaseTransitionAction, DocumentBaseTransitionActionAccessorsV0}; use crate::state_transition_action::document::documents_batch::document_transition::document_create_transition_action::DocumentCreateTransitionActionV0; impl DocumentCreateTransitionActionV0 { @@ -15,16 +17,26 @@ impl DocumentCreateTransitionActionV0 { block_info: &BlockInfo, get_data_contract: impl Fn(Identifier) -> Result, ProtocolError>, ) -> Result { - let DocumentCreateTransitionV0 { base, data, .. } = value; + let DocumentCreateTransitionV0 { base, data, prefunded_voting_balances , .. } = value; let base = DocumentBaseTransitionAction::from_base_transition_with_contract_lookup( base, get_data_contract, )?; + + let document_type = base.document_type()?; + + let document_type_indexes = document_type.indexes(); + + let prefunded_voting_balances_by_index = prefunded_voting_balances.into_iter().map(|(index_name, credits)| { + let index = document_type_indexes.get(&index_name).ok_or(ProtocolError::UnknownContestedIndexResolution(format!("index {} not found on document type {}", index_name, document_type.name())))?; + Ok((index.clone(), credits)) + }).collect(); Ok(DocumentCreateTransitionActionV0 { base, block_info: *block_info, data, + prefunded_voting_balances: prefunded_voting_balances_by_index, }) } @@ -34,18 +46,28 @@ impl DocumentCreateTransitionActionV0 { block_info: &BlockInfo, get_data_contract: impl Fn(Identifier) -> Result, ProtocolError>, ) -> Result { - let DocumentCreateTransitionV0 { base, data, .. } = value; + let DocumentCreateTransitionV0 { base, data, prefunded_voting_balances, .. } = value; let base = DocumentBaseTransitionAction::from_borrowed_base_transition_with_contract_lookup( base, get_data_contract, )?; + let document_type = base.document_type()?; + + let document_type_indexes = document_type.indexes(); + + let prefunded_voting_balances_by_index = prefunded_voting_balances.iter().map(|(index_name, credits)| { + let index = document_type_indexes.get(index_name).ok_or(ProtocolError::UnknownContestedIndexResolution(format!("index {} not found on document type {}", index_name, document_type.name())))?; + Ok((index.clone(), *credits)) + }).collect(); + Ok(DocumentCreateTransitionActionV0 { base, block_info: *block_info, //todo: get rid of clone data: data.clone(), + prefunded_voting_balances: prefunded_voting_balances_by_index, }) } } diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs index 4d1ccce401..f60a2125dc 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs @@ -2,6 +2,7 @@ use dpp::fee::Credits; use crate::state_transition_action::document::documents_batch::document_transition::DocumentTransitionAction; use dpp::identifier::Identifier; use dpp::prelude::UserFeeIncrease; +use dpp::ProtocolError; use crate::state_transition_action::document::documents_batch::document_transition::document_purchase_transition_action::DocumentPurchaseTransitionActionAccessorsV0; /// action v0 @@ -16,20 +17,51 @@ pub struct DocumentsBatchTransitionActionV0 { } impl DocumentsBatchTransitionActionV0 { - pub(super) fn all_purchases_amount(&self) -> Option { - let (total, any_purchases) = self + pub(super) fn all_purchases_amount(&self) -> Result, ProtocolError> { + let (total, any_purchases): (Option, bool) = self .transitions .iter() .filter_map(|transition| match transition { DocumentTransitionAction::PurchaseAction(purchase) => Some(purchase.price()), _ => None, }) - .fold((0, false), |(acc, _), price| (acc + price, true)); + .fold((None, false), |(acc, _), price| { + match acc { + Some(acc_val) => acc_val.checked_add(price).map_or((None, true), |sum| (Some(sum), true)), + None => (Some(price), true), + } + }); - if any_purchases { - Some(total) // Return the sum as Some(Credits) if there were any purchases - } else { - None // Return None if no purchases were found + match (total, any_purchases) { + (Some(total), _) => Ok(Some(total)), + (None, true) => Err(ProtocolError::Overflow("overflow in all purchases amount")), // Overflow occurred + _ => Ok(None), // No purchases were found + } + } + + fn all_conflicting_index_collateral_voting_funds(&self) -> Result, ProtocolError> { + let (total, any_voting_funds): (Option, bool) = self + .transitions + .iter() + .filter_map(|transition| match transition { + DocumentTransitionAction::CreateAction(document_create_transition_action) => { + document_create_transition_action.prefunded_voting_balances().values().try_fold(0u64, |acc, &val| { + acc.checked_add(val) + }) + }, + _ => None, + }) + .fold((None, false), |(acc, _), price| { + match acc { + Some(acc_val) => acc_val.checked_add(price).map_or((None, true), |sum| (Some(sum), true)), + None => (Some(price), true), + } + }); + + match (total, any_voting_funds) { + (Some(total), _) => Ok(Some(total)), + (None, true) => Err(ProtocolError::Overflow("overflow in all voting funds amount")), // Overflow occurred + _ => Ok(None), } } } diff --git a/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_extensions.rs b/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_extensions.rs index d1c4dd2865..1a4d6c459e 100644 --- a/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_extensions.rs +++ b/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_extensions.rs @@ -48,6 +48,14 @@ pub trait BTreeValueRemoveFromMapHelper { fn remove_hash256s(&mut self, key: &str) -> Result, Error>; fn remove_identifiers(&mut self, key: &str) -> Result, Error>; fn remove_optional_identifiers(&mut self, key: &str) -> Result>, Error>; + fn remove_map_as_btree_map(&mut self, key: &str) -> Result, Error> + where + K: TryFrom + Ord, + V: TryFrom; + fn remove_optional_map_as_btree_map(&mut self, key: &str) -> Result>, Error> + where + K: TryFrom + Ord, + V: TryFrom; } impl BTreeValueRemoveFromMapHelper for BTreeMap { @@ -283,6 +291,38 @@ impl BTreeValueRemoveFromMapHelper for BTreeMap { }) .transpose() } + + fn remove_map_as_btree_map(&mut self, key: &str) -> Result, Error> + where + K: TryFrom + Ord, + V: TryFrom { + self.remove_optional_map_as_btree_map(key)?.ok_or_else(|| { + Error::StructureError(format!("unable to remove map property {key}")) + }) + } + + fn remove_optional_map_as_btree_map(&mut self, key: &str) -> Result>, Error> + where + K: TryFrom + Ord, + V: TryFrom, + { + self.remove(key) + .and_then(|v| { + if v.is_null() { + None + } else if let Value::Map(map) = v { + Some( + map + .iter() + .map(|(key, value)| Ok((key.clone().try_into()?, value.clone().try_into()?))) + .collect(), + ) + } else { + None + } + }) + .transpose() + } } impl BTreeValueRemoveFromMapHelper for BTreeMap { @@ -529,4 +569,36 @@ impl BTreeValueRemoveFromMapHelper for BTreeMap { }) .transpose() } + + fn remove_map_as_btree_map(&mut self, key: &str) -> Result, Error> + where + K: TryFrom + Ord, + V: TryFrom { + self.remove_optional_map_as_btree_map(key)?.ok_or_else(|| { + Error::StructureError(format!("unable to remove map property {key}")) + }) + } + + fn remove_optional_map_as_btree_map(&mut self, key: &str) -> Result>, Error> + where + K: TryFrom + Ord, + V: TryFrom, + { + self.remove(key) + .and_then(|v| { + if v.is_null() { + None + } else if let Value::Map(map) = v { + Some( + map + .into_iter() + .map(|(key, value)| Ok((key.try_into()?, value.try_into()?))) + .collect(), + ) + } else { + None + } + }) + .transpose() + } } diff --git a/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_inner_value_extensions.rs b/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_inner_value_extensions.rs index 7af5130201..97d46e35ed 100644 --- a/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_inner_value_extensions.rs +++ b/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_inner_value_extensions.rs @@ -7,6 +7,12 @@ pub trait BTreeValueRemoveInnerValueFromMapHelper { key: &str, ) -> Result, Error>; fn remove_inner_value_array>(&mut self, key: &str) -> Result; + + fn remove_optional_inner_value_map>( + &mut self, + key: &str, + ) -> Result, Error>; + fn remove_inner_value_map>(&mut self, key: &str) -> Result; } impl BTreeValueRemoveInnerValueFromMapHelper for BTreeMap { @@ -21,6 +27,20 @@ impl BTreeValueRemoveInnerValueFromMapHelper for BTreeMap { fn remove_inner_value_array>(&mut self, key: &str) -> Result { self.remove_optional_inner_value_array(key)? - .ok_or_else(|| Error::StructureError(format!("unable to remove float property {key}"))) + .ok_or_else(|| Error::StructureError(format!("unable to remove inner value array property {key}"))) + } + + fn remove_optional_inner_value_map>( + &mut self, + key: &str, + ) -> Result, Error> { + self.remove(key) + .map(|v| v.into_map().map(|vec| vec.into_iter().collect())) + .transpose() + } + + fn remove_inner_value_map>(&mut self, key: &str) -> Result { + self.remove_optional_inner_value_map(key)? + .ok_or_else(|| Error::StructureError(format!("unable to remove inner value map property {key}"))) } } diff --git a/packages/rs-platform-value/src/lib.rs b/packages/rs-platform-value/src/lib.rs index 420504ff43..321107dad4 100644 --- a/packages/rs-platform-value/src/lib.rs +++ b/packages/rs-platform-value/src/lib.rs @@ -1282,11 +1282,11 @@ macro_rules! implfrom { macro_rules! impltryinto { ($($t:ty),+ $(,)?) => { $( - impl TryInto<$t> for Value { + impl TryFrom for $t { type Error = Error; #[inline] - fn try_into(self) -> Result<$t, Self::Error> { - self.to_integer() + fn try_from(value: Value) -> Result { + value.to_integer() } } )+ @@ -1493,19 +1493,18 @@ impl From<&[&str]> for Value { ) } } - -impl TryInto> for Value { +impl TryFrom for Vec { type Error = Error; - fn try_into(self) -> Result, Self::Error> { - self.to_bytes() + fn try_from(value: Value) -> Result { + value.into_bytes() } } -impl TryInto for Value { +impl TryFrom for String { type Error = Error; - fn try_into(self) -> Result { - self.into_text() + fn try_from(value: Value) -> Result { + value.into_text() } -} +} \ No newline at end of file diff --git a/packages/rs-platform-value/src/value_map.rs b/packages/rs-platform-value/src/value_map.rs index fa4d383dab..210c02670a 100644 --- a/packages/rs-platform-value/src/value_map.rs +++ b/packages/rs-platform-value/src/value_map.rs @@ -22,6 +22,7 @@ pub trait ValueMapHelper { fn remove_optional_key_if_null(&mut self, search_key: &str); fn remove_optional_key_if_empty_array(&mut self, search_key: &str); fn remove_optional_key_value(&mut self, search_key_value: &Value) -> Option; + fn from_btree_map + Ord, V: Into>(btree_map: BTreeMap) -> Self; } impl ValueMapHelper for ValueMap { @@ -214,6 +215,9 @@ impl ValueMapHelper for ValueMap { .position(|(key, _)| search_key_value == key) .map(|pos| self.remove(pos).1) } + fn from_btree_map + Ord, V: Into>(btree_map: BTreeMap) -> Self { + btree_map.into_iter().map(|(k, v)| (k.into(), v.into())).collect() + } } impl Value { @@ -349,8 +353,8 @@ impl Value { map: &'a ValueMap, sort_key: &str, ) -> Result, Error> - where - T: TryFrom + where + T: TryFrom + TryFrom + TryFrom + TryFrom @@ -417,4 +421,4 @@ impl Value { }) .collect::>() } -} +} \ No newline at end of file diff --git a/packages/rs-platform-version/src/version/fee/mod.rs b/packages/rs-platform-version/src/version/fee/mod.rs index 0810bc85c8..8da03becbc 100644 --- a/packages/rs-platform-version/src/version/fee/mod.rs +++ b/packages/rs-platform-version/src/version/fee/mod.rs @@ -4,6 +4,7 @@ use crate::version::fee::processing::FeeProcessingVersion; use crate::version::fee::signature::FeeSignatureVersion; use crate::version::fee::state_transition_min_fees::StateTransitionMinFees; use crate::version::fee::storage::FeeStorageVersion; +use crate::version::fee::vote_resolution_fund_fees::VoteResolutionFundFees; mod data_contract; mod hashing; @@ -12,6 +13,7 @@ pub mod signature; pub mod state_transition_min_fees; pub mod storage; pub mod v1; +pub mod vote_resolution_fund_fees; #[derive(Clone, Debug, Default)] pub struct FeeVersion { @@ -21,4 +23,5 @@ pub struct FeeVersion { pub processing: FeeProcessingVersion, pub data_contract: FeeDataContractValidationVersion, pub state_transition_min_fees: StateTransitionMinFees, + pub vote_resolution_fund_fees: VoteResolutionFundFees, } diff --git a/packages/rs-platform-version/src/version/fee/v1.rs b/packages/rs-platform-version/src/version/fee/v1.rs index 2f394bbd05..8598eeb469 100644 --- a/packages/rs-platform-version/src/version/fee/v1.rs +++ b/packages/rs-platform-version/src/version/fee/v1.rs @@ -5,6 +5,7 @@ use crate::version::fee::signature::v1::FEE_SIGNATURE_VERSION1; use crate::version::fee::state_transition_min_fees::v1::STATE_TRANSITION_MIN_FEES_VERSION1; use crate::version::fee::storage::v1::FEE_STORAGE_VERSION1; use crate::version::fee::FeeVersion; +use crate::version::fee::vote_resolution_fund_fees::v1::VOTE_RESOLUTION_FUND_FEES_VERSION1; pub const FEE_VERSION1: FeeVersion = FeeVersion { storage: FEE_STORAGE_VERSION1, @@ -13,4 +14,5 @@ pub const FEE_VERSION1: FeeVersion = FeeVersion { processing: FEE_PROCESSING_VERSION1, data_contract: FEE_DATA_CONTRACT_VALIDATION_VERSION1, state_transition_min_fees: STATE_TRANSITION_MIN_FEES_VERSION1, + vote_resolution_fund_fees: VOTE_RESOLUTION_FUND_FEES_VERSION1, }; diff --git a/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/mod.rs b/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/mod.rs new file mode 100644 index 0000000000..67ec4225a9 --- /dev/null +++ b/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/mod.rs @@ -0,0 +1,6 @@ +pub mod v1; +#[derive(Clone, Debug, Default)] +pub struct VoteResolutionFundFees { + /// This is the amount that will be deducted from an identity and used to pay for voting + pub conflicting_vote_resolution_fund_required_amount: u64, +} diff --git a/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs b/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs new file mode 100644 index 0000000000..02c7e8b3c0 --- /dev/null +++ b/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs @@ -0,0 +1,5 @@ +use crate::version::fee::vote_resolution_fund_fees::VoteResolutionFundFees; + +pub const VOTE_RESOLUTION_FUND_FEES_VERSION1: VoteResolutionFundFees = VoteResolutionFundFees { + conflicting_vote_resolution_fund_required_amount: 20000000000, // 0.2 Dash +}; From e32cabf54dc1177630f5caf59592bd37c6a3e588 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 7 May 2024 02:09:16 +0200 Subject: [PATCH 034/135] more work --- .../data_contract/document_type/index/mod.rs | 132 ++++++++++++------ .../document_type/index/random_index.rs | 11 +- .../document_type/index_level/mod.rs | 14 +- .../document_type/v0/random_document_type.rs | 4 +- .../src/errors/consensus/basic/basic_error.rs | 2 +- .../rs-dpp/src/errors/consensus/basic/mod.rs | 2 +- .../errors/consensus/basic/overflow_error.rs | 6 +- packages/rs-dpp/src/errors/consensus/codes.rs | 2 +- packages/rs-dpp/src/errors/protocol_error.rs | 2 +- .../v0/from_document.rs | 28 ++-- .../document_create_transition/v0/mod.rs | 14 +- .../v0/v0_methods.rs | 2 +- .../document_create_transition/v0_methods.rs | 4 +- .../documents_batch_transition/methods/mod.rs | 4 +- .../methods/v0/mod.rs | 4 +- .../v0/v0_methods.rs | 38 ++--- .../masternode_vote_transition/mod.rs | 4 +- .../state_transition_like.rs | 6 +- .../masternode_vote_transition/v0/mod.rs | 4 +- .../v0/state_transition_like.rs | 4 +- packages/rs-dpp/src/voting/mod.rs | 4 +- .../rs-dpp/src/voting/vote_choices/mod.rs | 4 +- .../mod.rs | 4 +- packages/rs-dpp/src/voting/vote_polls/mod.rs | 2 +- .../accessors/mod.rs | 12 +- .../accessors/v0/mod.rs | 6 +- .../contested_document_resource_vote/mod.rs | 26 ++-- .../v0/mod.rs | 10 +- packages/rs-dpp/src/voting/votes/mod.rs | 2 +- .../documents_batch/balance/v0/mod.rs | 41 ++++-- .../validate_uniqueness_of_data/v0/mod.rs | 4 +- .../v0/mod.rs | 4 +- .../v0/mod.rs | 2 +- .../src/drive/initialization/v0/mod.rs | 2 +- packages/rs-drive/src/drive/mod.rs | 2 +- .../pre_funded_specialized_balances/mod.rs | 4 +- .../v0/mod.rs | 2 +- packages/rs-drive/src/drive/votes/mod.rs | 10 +- .../document_base_transition_action/mod.rs | 10 +- .../document_base_transition_action/v0/mod.rs | 2 +- .../document_create_transition_action/mod.rs | 2 +- .../v0/mod.rs | 6 +- .../v0/transformer.rs | 58 ++++++-- .../document/documents_batch/mod.rs | 13 +- .../document/documents_batch/v0/mod.rs | 38 ++--- .../masternode_vote/v0/transformer.rs | 17 ++- .../btreemap_removal_extensions.rs | 73 +++++----- ...btreemap_removal_inner_value_extensions.rs | 20 ++- packages/rs-platform-value/src/lib.rs | 2 +- packages/rs-platform-value/src/value_map.rs | 11 +- .../rs-platform-version/src/version/fee/v1.rs | 2 +- 51 files changed, 427 insertions(+), 255 deletions(-) diff --git a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs index 2466012fcd..3baeaae5cf 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs @@ -15,15 +15,16 @@ use anyhow::anyhow; use crate::data_contract::document_type::ContestedIndexFieldMatch::Regex; use crate::data_contract::document_type::ContestedIndexResolution::MasternodeVote; +use crate::data_contract::errors::DataContractError::RegexError; use platform_value::{Value, ValueMap}; use rand::distributions::{Alphanumeric, DistString}; +use std::cmp::Ordering; use std::{collections::BTreeMap, convert::TryFrom}; -use crate::data_contract::errors::DataContractError::RegexError; pub mod random_index; #[repr(u8)] -#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd)] pub enum ContestedIndexResolution { MasternodeVote = 0, } @@ -50,36 +51,78 @@ pub enum ContestedIndexFieldMatch { All, } +impl PartialOrd for ContestedIndexFieldMatch { + fn partial_cmp(&self, other: &Self) -> Option { + use ContestedIndexFieldMatch::*; + match (self, other) { + // Comparing two integers + (PositiveIntegerMatch(a), PositiveIntegerMatch(b)) => a.partial_cmp(b), + + // Arbitrarily decide that any Regex is less than any PositiveIntegerMatch + (Regex(_), PositiveIntegerMatch(_)) => Some(Ordering::Less), + (PositiveIntegerMatch(_), Regex(_)) => Some(Ordering::Greater), + + // Comparing Regex with Regex, perhaps based on pattern length + (Regex(a), Regex(b)) => a.as_str().len().partial_cmp(&b.as_str().len()), + + // Handling the `All` variant: + // All is greater than any other variant + (All, All) => Some(Ordering::Equal), + (All, _) => Some(Ordering::Greater), + (_, All) => Some(Ordering::Less), + } + } +} + +impl Ord for ContestedIndexFieldMatch { + fn cmp(&self, other: &Self) -> Ordering { + use ContestedIndexFieldMatch::*; + match (self, other) { + // Directly compare integers + (PositiveIntegerMatch(a), PositiveIntegerMatch(b)) => a.cmp(b), + + // Compare Regex based on pattern string length + (Regex(a), Regex(b)) => a.as_str().len().cmp(&b.as_str().len()), + + // Regex is considered less than a positive integer + (Regex(_), PositiveIntegerMatch(_)) => Ordering::Less, + (PositiveIntegerMatch(_), Regex(_)) => Ordering::Greater, + + // All is always the greatest + (All, All) => Ordering::Equal, + (All, _) => Ordering::Greater, + (_, All) => Ordering::Less, + } + } +} + impl Clone for ContestedIndexFieldMatch { fn clone(&self) -> Self { - match self { Regex(regex) => { - Regex(regex::Regex::new(regex.as_str()).unwrap()) - } + match self { + Regex(regex) => Regex(regex::Regex::new(regex.as_str()).unwrap()), ContestedIndexFieldMatch::All => ContestedIndexFieldMatch::All, - ContestedIndexFieldMatch::PositiveIntegerMatch(int) => ContestedIndexFieldMatch::PositiveIntegerMatch(*int) + ContestedIndexFieldMatch::PositiveIntegerMatch(int) => { + ContestedIndexFieldMatch::PositiveIntegerMatch(*int) + } } } } impl PartialEq for ContestedIndexFieldMatch { fn eq(&self, other: &Self) -> bool { - match self { Regex(regex) => { - match other { Regex(other_regex) => { - regex.as_str() == other_regex.as_str() - } - _ => false - } - } - ContestedIndexFieldMatch::All => { - match other { ContestedIndexFieldMatch::All => true, - _ => false - } - } - ContestedIndexFieldMatch::PositiveIntegerMatch(int) => { - match other { ContestedIndexFieldMatch::PositiveIntegerMatch(other_int) => int == other_int, - _ => false - } - } + match self { + Regex(regex) => match other { + Regex(other_regex) => regex.as_str() == other_regex.as_str(), + _ => false, + }, + ContestedIndexFieldMatch::All => match other { + ContestedIndexFieldMatch::All => true, + _ => false, + }, + ContestedIndexFieldMatch::PositiveIntegerMatch(int) => match other { + ContestedIndexFieldMatch::PositiveIntegerMatch(other_int) => int == other_int, + _ => false, + }, } } } @@ -88,23 +131,24 @@ impl Eq for ContestedIndexFieldMatch {} impl ContestedIndexFieldMatch { pub fn matches(&self, value: &Value) -> bool { - match self { Regex(regex) => { - if let Some(string) = value.as_str() { - regex.is_match(string) - } else { - false + match self { + Regex(regex) => { + if let Some(string) = value.as_str() { + regex.is_match(string) + } else { + false + } } - - } ContestedIndexFieldMatch::All => true, - ContestedIndexFieldMatch::PositiveIntegerMatch(int) => { - value.as_integer::().map(|i| i == *int).unwrap_or(false) - } + ContestedIndexFieldMatch::PositiveIntegerMatch(int) => value + .as_integer::() + .map(|i| i == *int) + .unwrap_or(false), } } } -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq, Ord, PartialOrd)] pub struct ContestedIndexInformation { pub contested_field_temp_replacement_name: String, pub contested_field_name: String, @@ -124,7 +168,7 @@ impl Default for ContestedIndexInformation { } // Indices documentation: https://dashplatform.readme.io/docs/reference-data-contracts#document-indices -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] pub struct Index { pub name: String, pub properties: Vec, @@ -159,7 +203,7 @@ impl Index { } } -#[derive(Clone, Debug, PartialEq, Eq, Hash)] +#[derive(Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd)] pub struct IndexProperty { pub name: String, pub ascending: bool, @@ -325,7 +369,13 @@ impl TryFrom<&[(Value, Value)]> for Index { match contested_key { "regexPattern" => { let regex = contested_value.to_str()?.to_owned(); - contested_index_information.field_match = Regex(regex::Regex::new(®ex).map_err(|e| RegexError(format!("invalid field match regex: {}", e.to_string())))?); + contested_index_information.field_match = + Regex(regex::Regex::new(®ex).map_err(|e| { + RegexError(format!( + "invalid field match regex: {}", + e.to_string() + )) + })?); } "name" => { let field = contested_value.to_str()?.to_owned(); @@ -339,11 +389,15 @@ impl TryFrom<&[(Value, Value)]> for Index { "resolution" => { let resolution_int = contested_value.to_integer::()?; contested_index_information.resolution = - resolution_int.try_into().map_err(|e: ProtocolError| DataContractError::ValueWrongType(e.to_string()))?; + resolution_int.try_into().map_err(|e: ProtocolError| { + DataContractError::ValueWrongType(e.to_string()) + })?; } "description" => {} _ => { - return Err(DataContractError::ValueWrongType("unexpected contested key".to_string())); + return Err(DataContractError::ValueWrongType( + "unexpected contested key".to_string(), + )); } } } diff --git a/packages/rs-dpp/src/data_contract/document_type/index/random_index.rs b/packages/rs-dpp/src/data_contract/document_type/index/random_index.rs index 8780fa0abd..8cabbc60f1 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index/random_index.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index/random_index.rs @@ -1,9 +1,9 @@ -use std::borrow::Borrow; use crate::data_contract::document_type::index::{Index, IndexProperty}; use crate::ProtocolError; use rand::prelude::StdRng; use rand::seq::SliceRandom; use rand::Rng; +use std::borrow::Borrow; impl Index { pub fn random( @@ -11,9 +11,9 @@ impl Index { existing_indices: I, rng: &mut StdRng, ) -> Result - where - I: Clone + IntoIterator, // T is the type of elements in the collection - T: Borrow, // Assuming Index is the type stored in the collection + where + I: Clone + IntoIterator, // T is the type of elements in the collection + T: Borrow, // Assuming Index is the type stored in the collection { let index_name = format!("index_{}", rng.gen::()); @@ -36,7 +36,8 @@ impl Index { }) .collect::>(); - if !existing_indices.clone() + if !existing_indices + .clone() .into_iter() .any(|index| index.borrow().properties == properties) { diff --git a/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs b/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs index b137798148..2ab4ae37c8 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs @@ -1,4 +1,3 @@ -use std::borrow::Borrow; use crate::consensus::basic::data_contract::DuplicateIndexError; use crate::consensus::basic::BasicError; use crate::consensus::ConsensusError; @@ -8,6 +7,7 @@ use crate::data_contract::document_type::index_level::IndexType::{ use crate::data_contract::document_type::Index; use crate::version::PlatformVersion; use crate::ProtocolError; +use std::borrow::Borrow; use std::collections::BTreeMap; #[derive(Debug, PartialEq, Copy, Clone)] @@ -108,9 +108,9 @@ impl IndexLevel { document_type_name: &str, // TODO: We shouldn't pass document type, it's only for errors platform_version: &PlatformVersion, ) -> Result - where - I: IntoIterator, // T is the type of elements in the collection - T: Borrow, // Assuming Index is the type stored in the collection + where + I: IntoIterator, // T is the type of elements in the collection + T: Borrow, // Assuming Index is the type stored in the collection { match platform_version .dpp @@ -132,9 +132,9 @@ impl IndexLevel { indices: I, document_type_name: &str, ) -> Result - where - I: IntoIterator, // T is the type of elements in the collection - T: Borrow, // Assuming Index is the type stored in the collection + where + I: IntoIterator, // T is the type of elements in the collection + T: Borrow, // Assuming Index is the type stored in the collection { let mut index_level = IndexLevel { sub_index_levels: Default::default(), diff --git a/packages/rs-dpp/src/data_contract/document_type/v0/random_document_type.rs b/packages/rs-dpp/src/data_contract/document_type/v0/random_document_type.rs index 329ae89b85..628b3d8bc3 100644 --- a/packages/rs-dpp/src/data_contract/document_type/v0/random_document_type.rs +++ b/packages/rs-dpp/src/data_contract/document_type/v0/random_document_type.rs @@ -240,7 +240,7 @@ impl DocumentTypeV0 { match Index::random(&ten_field_names, indices.values(), rng) { Ok(index) => { indices.insert(index.name.clone(), index); - }, + } Err(_) => break, } } @@ -560,7 +560,7 @@ impl DocumentTypeV0 { match Index::random(&ten_field_names, indices.values(), rng) { Ok(index) => { indices.insert(index.name.clone(), index); - }, + } Err(_) => break, } } diff --git a/packages/rs-dpp/src/errors/consensus/basic/basic_error.rs b/packages/rs-dpp/src/errors/consensus/basic/basic_error.rs index 3c30796f0d..fdf6f939b2 100644 --- a/packages/rs-dpp/src/errors/consensus/basic/basic_error.rs +++ b/packages/rs-dpp/src/errors/consensus/basic/basic_error.rs @@ -60,13 +60,13 @@ use crate::consensus::basic::state_transition::{ use crate::consensus::basic::{IncompatibleProtocolVersionError, UnsupportedProtocolVersionError}; use crate::consensus::ConsensusError; +use crate::consensus::basic::overflow_error::OverflowError; use crate::consensus::basic::unsupported_version_error::UnsupportedVersionError; use crate::consensus::basic::value_error::ValueError; #[cfg(feature = "json-schema-validation")] use crate::consensus::basic::{ json_schema_compilation_error::JsonSchemaCompilationError, json_schema_error::JsonSchemaError, }; -use crate::consensus::basic::overflow_error::OverflowError; use crate::consensus::state::identity::master_public_key_update_error::MasterPublicKeyUpdateError; use crate::data_contract::errors::DataContractError; diff --git a/packages/rs-dpp/src/errors/consensus/basic/mod.rs b/packages/rs-dpp/src/errors/consensus/basic/mod.rs index dd7bba84b2..f0553e49ba 100644 --- a/packages/rs-dpp/src/errors/consensus/basic/mod.rs +++ b/packages/rs-dpp/src/errors/consensus/basic/mod.rs @@ -16,7 +16,7 @@ pub mod invalid_identifier_error; pub mod json_schema_compilation_error; #[cfg(feature = "json-schema-validation")] pub mod json_schema_error; +pub mod overflow_error; pub mod state_transition; pub mod unsupported_version_error; pub mod value_error; -pub mod overflow_error; diff --git a/packages/rs-dpp/src/errors/consensus/basic/overflow_error.rs b/packages/rs-dpp/src/errors/consensus/basic/overflow_error.rs index e80c98d0c7..9d478a9123 100644 --- a/packages/rs-dpp/src/errors/consensus/basic/overflow_error.rs +++ b/packages/rs-dpp/src/errors/consensus/basic/overflow_error.rs @@ -6,7 +6,7 @@ use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use thiserror::Error; #[derive( -Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, + Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, )] #[error("Overflow error")] #[platform_serialize(unversioned)] @@ -21,9 +21,7 @@ pub struct OverflowError { impl OverflowError { pub fn new(message: String) -> Self { - Self { - message - } + Self { message } } pub fn message(&self) -> &str { diff --git a/packages/rs-dpp/src/errors/consensus/codes.rs b/packages/rs-dpp/src/errors/consensus/codes.rs index cd3dfab988..476ec620fb 100644 --- a/packages/rs-dpp/src/errors/consensus/codes.rs +++ b/packages/rs-dpp/src/errors/consensus/codes.rs @@ -152,7 +152,7 @@ impl ErrorWithCode for BasicError { Self::InvalidStateTransitionTypeError { .. } => 10600, Self::MissingStateTransitionTypeError { .. } => 10601, Self::StateTransitionMaxSizeExceededError { .. } => 10602, - + // General Errors 10700-10799 Self::OverflowError(_) => 10700, } diff --git a/packages/rs-dpp/src/errors/protocol_error.rs b/packages/rs-dpp/src/errors/protocol_error.rs index 78b82b9761..0c702402b1 100644 --- a/packages/rs-dpp/src/errors/protocol_error.rs +++ b/packages/rs-dpp/src/errors/protocol_error.rs @@ -108,7 +108,7 @@ pub enum ProtocolError { #[error("Invalid key contract bounds error {0}")] InvalidKeyContractBoundsError(String), - + #[error("unknown storage key requirements {0}")] UnknownStorageKeyRequirements(String), diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/from_document.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/from_document.rs index 55cf317d5b..e7ad6adb44 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/from_document.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/from_document.rs @@ -1,3 +1,4 @@ +use crate::data_contract::document_type::accessors::DocumentTypeV0Getters; use crate::data_contract::document_type::DocumentTypeRef; use crate::document::{Document, DocumentV0Getters}; use crate::prelude::IdentityNonce; @@ -5,7 +6,6 @@ use crate::state_transition::documents_batch_transition::document_base_transitio use crate::state_transition::documents_batch_transition::document_create_transition::DocumentCreateTransitionV0; use crate::ProtocolError; use platform_version::version::{FeatureVersion, PlatformVersion}; -use crate::data_contract::document_type::accessors::DocumentTypeV0Getters; impl DocumentCreateTransitionV0 { pub(crate) fn from_document( @@ -16,16 +16,26 @@ impl DocumentCreateTransitionV0 { platform_version: &PlatformVersion, base_feature_version: Option, ) -> Result { - let prefunded_voting_balances = document_type.indexes().iter().filter_map(|(name, index)| { - if let Some(contested_index_info) = &index.contested_index { - if let Some(value) = document.get(&contested_index_info.contested_field_name) { - if contested_index_info.field_match.matches(value) { - return Some((name.clone(), platform_version.fee_version.vote_resolution_fund_fees.conflicting_vote_resolution_fund_required_amount)); + let prefunded_voting_balances = document_type + .indexes() + .iter() + .filter_map(|(name, index)| { + if let Some(contested_index_info) = &index.contested_index { + if let Some(value) = document.get(&contested_index_info.contested_field_name) { + if contested_index_info.field_match.matches(value) { + return Some(( + name.clone(), + platform_version + .fee_version + .vote_resolution_fund_fees + .conflicting_vote_resolution_fund_required_amount, + )); + } } } - } - None - }).collect(); + None + }) + .collect(); Ok(DocumentCreateTransitionV0 { base: DocumentBaseTransition::from_document( &document, diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs index f97321b8cd..f50b6041ce 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs @@ -23,13 +23,13 @@ use crate::data_contract::document_type::accessors::DocumentTypeV0Getters; use crate::data_contract::document_type::methods::DocumentTypeV0Methods; use crate::data_contract::document_type::DocumentTypeRef; use crate::document::{Document, DocumentV0}; +use crate::fee::Credits; use crate::state_transition::documents_batch_transition::document_base_transition::v0::DocumentBaseTransitionV0; #[cfg(feature = "state-transition-value-conversion")] use crate::state_transition::documents_batch_transition::document_base_transition::v0::DocumentTransitionObjectLike; use crate::state_transition::documents_batch_transition::document_base_transition::DocumentBaseTransition; use derive_more::Display; use platform_version::version::PlatformVersion; -use crate::fee::Credits; #[cfg(feature = "state-transition-value-conversion")] use crate::state_transition::documents_batch_transition; @@ -66,7 +66,10 @@ pub struct DocumentCreateTransitionV0 { #[cfg_attr(feature = "state-transition-serde-conversion", serde(flatten))] pub data: BTreeMap, - #[cfg_attr(feature = "state-transition-serde-conversion", serde(rename = "$prefundedVotingBalances"))] + #[cfg_attr( + feature = "state-transition-serde-conversion", + serde(rename = "$prefundedVotingBalances") + )] /// Pre funded balance (for unique index conflict resolution voting - the identity will put money /// aside that will be used by voters to vote) /// This is a map of index names to the amount we want to prefund them for @@ -92,7 +95,8 @@ impl DocumentCreateTransitionV0 { entropy: map .remove_hash256_bytes(property_names::ENTROPY) .map_err(ProtocolError::ValueError)?, - prefunded_voting_balances: map.remove_map_as_btree_map(property_names::PREFUNDED_VOTING_BALANCES)?, + prefunded_voting_balances: map + .remove_map_as_btree_map(property_names::PREFUNDED_VOTING_BALANCES)?, data: map, }) } @@ -107,7 +111,9 @@ impl DocumentCreateTransitionV0 { transition_base_map.insert( property_names::PREFUNDED_VOTING_BALANCES.to_string(), - Value::Map(ValueMap::from_btree_map(self.prefunded_voting_balances.clone())), + Value::Map(ValueMap::from_btree_map( + self.prefunded_voting_balances.clone(), + )), ); transition_base_map.extend(self.data.clone()); diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/v0_methods.rs index 9d48401fad..045f749cd1 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/v0_methods.rs @@ -3,8 +3,8 @@ use crate::state_transition::documents_batch_transition::document_create_transit use platform_value::Value; -use std::collections::BTreeMap; use crate::fee::Credits; +use std::collections::BTreeMap; pub trait DocumentCreateTransitionV0Methods { /// Returns a reference to the `base` field of the `DocumentCreateTransitionV0`. diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0_methods.rs index 2998fd2d23..33af476a3b 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0_methods.rs @@ -65,12 +65,12 @@ impl DocumentCreateTransitionV0Methods for DocumentCreateTransition { DocumentCreateTransition::V0(v0) => &mut v0.prefunded_voting_balances, } } - + fn add_prefunded_voting_balance(&mut self, index_name: String, amount: Credits) { match self { DocumentCreateTransition::V0(v0) => { v0.prefunded_voting_balances.insert(index_name, amount); - }, + } } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/mod.rs index b1c3dcdd94..a8cf00bca3 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/mod.rs @@ -33,7 +33,9 @@ impl DocumentsBatchTransitionMethodsV0 for DocumentsBatchTransition { } } - fn all_conflicting_index_collateral_voting_funds(&self) -> Result, ProtocolError> { + fn all_conflicting_index_collateral_voting_funds( + &self, + ) -> Result, ProtocolError> { match self { DocumentsBatchTransition::V0(v0) => v0.all_conflicting_index_collateral_voting_funds(), } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/v0/mod.rs index b40bec179f..ceffcaa7ae 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/v0/mod.rs @@ -156,7 +156,9 @@ pub trait DocumentsBatchTransitionMethodsV0: DocumentsBatchTransitionAccessorsV0 fn set_identity_contract_nonce(&mut self, identity_contract_nonce: IdentityNonce); - fn all_conflicting_index_collateral_voting_funds(&self) -> Result, ProtocolError>; + fn all_conflicting_index_collateral_voting_funds( + &self, + ) -> Result, ProtocolError>; fn all_purchases_amount(&self) -> Result, ProtocolError>; } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs index 3d9a643da8..0ff645aefd 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs @@ -311,11 +311,11 @@ impl DocumentsBatchTransitionMethodsV0 for DocumentsBatchTransitionV0 { .as_transition_purchase() .map(|purchase| purchase.price()) }) - .fold((None, false), |(acc, _), price| { - match acc { - Some(acc_val) => acc_val.checked_add(price).map_or((None, true), |sum| (Some(sum), true)), - None => (Some(price), true), - } + .fold((None, false), |(acc, _), price| match acc { + Some(acc_val) => acc_val + .checked_add(price) + .map_or((None, true), |sum| (Some(sum), true)), + None => (Some(price), true), }); match (total, any_purchases) { @@ -325,7 +325,9 @@ impl DocumentsBatchTransitionMethodsV0 for DocumentsBatchTransitionV0 { } } - fn all_conflicting_index_collateral_voting_funds(&self) -> Result, ProtocolError> { + fn all_conflicting_index_collateral_voting_funds( + &self, + ) -> Result, ProtocolError> { let (total, any_voting_funds): (Option, bool) = self .transitions .iter() @@ -334,21 +336,25 @@ impl DocumentsBatchTransitionMethodsV0 for DocumentsBatchTransitionV0 { .as_transition_create() .map(|document_create_transition| { // Safely sum up values to avoid overflow. - document_create_transition.prefunded_voting_balances().values().try_fold(0u64, |acc, &val| { - acc.checked_add(val) - }) - }).flatten() + document_create_transition + .prefunded_voting_balances() + .values() + .try_fold(0u64, |acc, &val| acc.checked_add(val)) + }) + .flatten() }) - .fold((None, false), |(acc, _), price| { - match acc { - Some(acc_val) => acc_val.checked_add(price).map_or((None, true), |sum| (Some(sum), true)), - None => (Some(price), true), - } + .fold((None, false), |(acc, _), price| match acc { + Some(acc_val) => acc_val + .checked_add(price) + .map_or((None, true), |sum| (Some(sum), true)), + None => (Some(price), true), }); match (total, any_voting_funds) { (Some(total), _) => Ok(Some(total)), - (None, true) => Err(ProtocolError::Overflow("overflow in all voting funds amount")), // Overflow occurred + (None, true) => Err(ProtocolError::Overflow( + "overflow in all voting funds amount", + )), // Overflow occurred _ => Ok(None), } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs index 40ebf82e4c..ac6c64a019 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs @@ -10,9 +10,7 @@ pub mod v0; mod value_conversion; mod version; -use crate::state_transition::masternode_vote_transition::fields::property_names::{ - PRO_TX_HASH, -}; +use crate::state_transition::masternode_vote_transition::fields::property_names::PRO_TX_HASH; use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0Signable; use crate::state_transition::StateTransitionFieldTypes; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/state_transition_like.rs index 2e4c23d607..405e6e2a1e 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/state_transition_like.rs @@ -1,8 +1,8 @@ +use crate::prelude::UserFeeIncrease; use crate::state_transition::masternode_vote_transition::MasternodeVoteTransition; use crate::state_transition::{StateTransitionLike, StateTransitionType}; use crate::version::FeatureVersion; use platform_value::{BinaryData, Identifier}; -use crate::prelude::UserFeeIncrease; impl StateTransitionLike for MasternodeVoteTransition { /// Returns ID of the credit_transferred contract @@ -62,7 +62,9 @@ impl StateTransitionLike for MasternodeVoteTransition { fn set_user_fee_increase(&mut self, fee_multiplier: UserFeeIncrease) { match self { - MasternodeVoteTransition::V0(transition) => transition.set_user_fee_increase(fee_multiplier), + MasternodeVoteTransition::V0(transition) => { + transition.set_user_fee_increase(fee_multiplier) + } } } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs index 6542d56c60..7806adfffa 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs @@ -54,12 +54,12 @@ mod test { use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; use crate::voting::resource_vote::ResourceVote; + use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; + use crate::voting::votes::Vote; use crate::voting::ContestedDocumentResourceVote; use platform_value::Identifier; use rand::Rng; use std::fmt::Debug; - use crate::voting::votes::Vote; - use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; fn test_masternode_vote_transition< T: PlatformSerializable + PlatformDeserializable + Debug + PartialEq, diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/state_transition_like.rs index 03b40becc8..03fda4a4f2 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/state_transition_like.rs @@ -1,12 +1,12 @@ -use base64::Engine; use base64::prelude::BASE64_STANDARD; +use base64::Engine; use platform_value::BinaryData; +use crate::prelude::UserFeeIncrease; use crate::{ prelude::Identifier, state_transition::{StateTransitionLike, StateTransitionType}, }; -use crate::prelude::UserFeeIncrease; use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; use crate::state_transition::masternode_vote_transition::MasternodeVoteTransition; diff --git a/packages/rs-dpp/src/voting/mod.rs b/packages/rs-dpp/src/voting/mod.rs index 88058064ae..2bf044eca7 100644 --- a/packages/rs-dpp/src/voting/mod.rs +++ b/packages/rs-dpp/src/voting/mod.rs @@ -1,3 +1,3 @@ -pub mod votes; +pub mod vote_choices; pub mod vote_polls; -pub mod vote_choices; \ No newline at end of file +pub mod votes; diff --git a/packages/rs-dpp/src/voting/vote_choices/mod.rs b/packages/rs-dpp/src/voting/vote_choices/mod.rs index 6b0a91d628..e04ed4ee23 100644 --- a/packages/rs-dpp/src/voting/vote_choices/mod.rs +++ b/packages/rs-dpp/src/voting/vote_choices/mod.rs @@ -1,5 +1,3 @@ - +pub mod resource_vote_choice; /// The various vote choices a vote could have - pub mod yes_no_abstain_vote_choice; -pub mod resource_vote_choice; diff --git a/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs b/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs index 9bce95c731..2c7b0dcb82 100644 --- a/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs +++ b/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs @@ -1,6 +1,6 @@ -use serde::{Deserialize, Serialize}; -use platform_value::{Identifier, Value}; use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; +use platform_value::{Identifier, Value}; +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Encode, Decode, PartialEq)] #[cfg_attr( diff --git a/packages/rs-dpp/src/voting/vote_polls/mod.rs b/packages/rs-dpp/src/voting/vote_polls/mod.rs index 0ef62653cb..c4087488b0 100644 --- a/packages/rs-dpp/src/voting/vote_polls/mod.rs +++ b/packages/rs-dpp/src/voting/vote_polls/mod.rs @@ -1 +1 @@ -pub mod contested_document_resource_vote_poll; \ No newline at end of file +pub mod contested_document_resource_vote_poll; diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/mod.rs b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/mod.rs index 9d9d45377e..bea2126720 100644 --- a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/mod.rs +++ b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/mod.rs @@ -3,24 +3,24 @@ use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedD use crate::voting::votes::contested_document_resource_vote::accessors::v0::ContestedDocumentResourceVoteGettersV0; use crate::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; -pub(crate) mod v0; +pub mod v0; impl ContestedDocumentResourceVoteGettersV0 for ContestedDocumentResourceVote { fn vote_poll(&self) -> &ContestedDocumentResourceVotePoll { - match self { - ContestedDocumentResourceVote::V0(v0) => &v0.vote_poll + match self { + ContestedDocumentResourceVote::V0(v0) => &v0.vote_poll, } } fn vote_poll_owned(self) -> ContestedDocumentResourceVotePoll { match self { - ContestedDocumentResourceVote::V0(v0) => v0.vote_poll + ContestedDocumentResourceVote::V0(v0) => v0.vote_poll, } } fn resource_vote_choice(&self) -> ResourceVoteChoice { match self { - ContestedDocumentResourceVote::V0(v0) => v0.resource_vote_choice + ContestedDocumentResourceVote::V0(v0) => v0.resource_vote_choice, } } -} \ No newline at end of file +} diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/v0/mod.rs b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/v0/mod.rs index b3d98005f3..8ab948be57 100644 --- a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/v0/mod.rs +++ b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/v0/mod.rs @@ -5,10 +5,10 @@ use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedD pub trait ContestedDocumentResourceVoteGettersV0 { /// The vote poll fn vote_poll(&self) -> &ContestedDocumentResourceVotePoll; - + /// The vote poll as owned fn vote_poll_owned(self) -> ContestedDocumentResourceVotePoll; - + /// The choice made in the vote fn resource_vote_choice(&self) -> ResourceVoteChoice; -} \ No newline at end of file +} diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs index 47c4ea6976..d8d7a4d1f1 100644 --- a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs +++ b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs @@ -1,29 +1,29 @@ -use derive_more::From; -#[cfg(feature = "vote-serde-conversion")] -use serde::{Deserialize, Serialize}; -#[cfg(feature = "vote-serialization")] -use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; use crate::voting::votes::contested_document_resource_vote::v0::ContestedDocumentResourceVoteV0; use crate::ProtocolError; +use derive_more::From; +#[cfg(feature = "vote-serialization")] +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +#[cfg(feature = "vote-serde-conversion")] +use serde::{Deserialize, Serialize}; +pub mod accessors; mod v0; -mod accessors; #[derive(Debug, Clone, PartialEq, From)] #[cfg_attr( -feature = "vote-serde-conversion", -derive(Serialize, Deserialize), -serde(tag = "$version"), + feature = "vote-serde-conversion", + derive(Serialize, Deserialize), + serde(tag = "$version") )] #[cfg_attr( -feature = "vote-serialization", -derive(Encode, Decode, PlatformDeserialize, PlatformSerialize), -platform_serialize(limit = 15000, unversioned) + feature = "vote-serialization", + derive(Encode, Decode, PlatformDeserialize, PlatformSerialize), + platform_serialize(limit = 15000, unversioned) )] pub enum ContestedDocumentResourceVote { #[cfg_attr(feature = "vote-serde-conversion", serde(rename = "0"))] - V0(ContestedDocumentResourceVoteV0) + V0(ContestedDocumentResourceVoteV0), } impl Default for ContestedDocumentResourceVote { diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/v0/mod.rs b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/v0/mod.rs index 6769bc458a..74cfb8f083 100644 --- a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/v0/mod.rs +++ b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/v0/mod.rs @@ -1,15 +1,15 @@ +use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use crate::ProtocolError; use bincode::{Decode, Encode}; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use serde::{Deserialize, Serialize}; -use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; #[derive(Debug, Clone, Encode, Decode, PlatformDeserialize, PlatformSerialize, PartialEq)] #[cfg_attr( -feature = "state-transition-serde-conversion", -derive(Serialize, Deserialize), -serde(rename_all = "camelCase") + feature = "state-transition-serde-conversion", + derive(Serialize, Deserialize), + serde(rename_all = "camelCase") )] #[platform_serialize(unversioned)] pub struct ContestedDocumentResourceVoteV0 { diff --git a/packages/rs-dpp/src/voting/votes/mod.rs b/packages/rs-dpp/src/voting/votes/mod.rs index 5a7ede8af5..4eea0be032 100644 --- a/packages/rs-dpp/src/voting/votes/mod.rs +++ b/packages/rs-dpp/src/voting/votes/mod.rs @@ -1,8 +1,8 @@ pub mod contested_document_resource_vote; -use serde::{Deserialize, Serialize}; use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; use crate::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Encode, Decode, PartialEq)] #[cfg_attr( diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/balance/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/balance/v0/mod.rs index d96915af4e..6f2dc0fd99 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/balance/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/balance/v0/mod.rs @@ -1,13 +1,13 @@ -use dpp::consensus::basic::BasicError; -use dpp::consensus::basic::overflow_error::OverflowError; -use dpp::consensus::ConsensusError; use crate::error::Error; +use dpp::consensus::basic::overflow_error::OverflowError; +use dpp::consensus::basic::BasicError; use dpp::consensus::state::identity::IdentityInsufficientBalanceError; +use dpp::consensus::ConsensusError; use dpp::identity::PartialIdentity; -use dpp::ProtocolError; use dpp::state_transition::documents_batch_transition::accessors::DocumentsBatchTransitionAccessorsV0; use dpp::state_transition::documents_batch_transition::methods::v0::DocumentsBatchTransitionMethodsV0; use dpp::state_transition::documents_batch_transition::DocumentsBatchTransition; +use dpp::ProtocolError; use dpp::validation::SimpleConsensusValidationResult; @@ -38,18 +38,33 @@ impl DocumentsBatchTransitionBalanceValidationV0 for DocumentsBatchTransition { let purchases_amount = match self.all_purchases_amount() { Ok(purchase_amount) => purchase_amount.unwrap_or_default(), - Err(ProtocolError::Overflow(e)) => return Ok(SimpleConsensusValidationResult::new_with_error(ConsensusError::BasicError(BasicError::OverflowError(OverflowError::new(e.to_owned()))))), + Err(ProtocolError::Overflow(e)) => { + return Ok(SimpleConsensusValidationResult::new_with_error( + ConsensusError::BasicError(BasicError::OverflowError(OverflowError::new( + e.to_owned(), + ))), + )) + } Err(e) => return Err(e.into()), }; - + // If we added documents that had a conflicting index we need to put up a collateral that voters can draw on - - let conflicting_indices_collateral_amount = match self.all_conflicting_index_collateral_voting_funds() { - Ok(conflicting_indices_collateral_amount) => conflicting_indices_collateral_amount.unwrap_or_default(), - Err(ProtocolError::Overflow(e)) => return Ok(SimpleConsensusValidationResult::new_with_error(ConsensusError::BasicError(BasicError::OverflowError(OverflowError::new(e.to_owned()))))), - Err(e) => return Err(e.into()), - }; - + + let conflicting_indices_collateral_amount = + match self.all_conflicting_index_collateral_voting_funds() { + Ok(conflicting_indices_collateral_amount) => { + conflicting_indices_collateral_amount.unwrap_or_default() + } + Err(ProtocolError::Overflow(e)) => { + return Ok(SimpleConsensusValidationResult::new_with_error( + ConsensusError::BasicError(BasicError::OverflowError(OverflowError::new( + e.to_owned(), + ))), + )) + } + Err(e) => return Err(e.into()), + }; + let base_fees = match platform_version.fee_version.state_transition_min_fees.document_batch_sub_transition.checked_mul(self.transitions().len() as u64) { None => return Ok(SimpleConsensusValidationResult::new_with_error(ConsensusError::BasicError(BasicError::OverflowError(OverflowError::new("overflow when multiplying base fee and amount of sub transitions in documents batch transition".to_string()))))), Some(base_fees) => base_fees diff --git a/packages/rs-drive/src/drive/document/index_uniqueness/internal/validate_uniqueness_of_data/v0/mod.rs b/packages/rs-drive/src/drive/document/index_uniqueness/internal/validate_uniqueness_of_data/v0/mod.rs index 0b6b877e94..c130e04312 100644 --- a/packages/rs-drive/src/drive/document/index_uniqueness/internal/validate_uniqueness_of_data/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/index_uniqueness/internal/validate_uniqueness_of_data/v0/mod.rs @@ -61,10 +61,10 @@ impl Drive { let validation_results = document_type .indexes() - .iter() + .values() .filter_map(|index| { if !index.unique { - // if a index is not unique there is no issue + // if an index is not unique there is no issue None } else { let where_queries = index diff --git a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs index 5317ab6226..8a790370e0 100644 --- a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -9,9 +9,7 @@ use crate::drive::object_size_info::DocumentInfo::{ }; use crate::drive::object_size_info::DriveKeyInfo::{Key, KeyRef}; use crate::drive::object_size_info::KeyElementInfo::{KeyElement, KeyUnknownElementSize}; -use crate::drive::object_size_info::{ - DocumentAndContractInfo, PathInfo, PathKeyElementInfo, PathKeyInfo, -}; +use crate::drive::object_size_info::{DocumentAndContractInfo, PathInfo, PathKeyElementInfo}; use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; diff --git a/packages/rs-drive/src/drive/document/update/internal/update_document_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/update/internal/update_document_for_contract_operations/v0/mod.rs index 420775c9b3..039ccf4dec 100644 --- a/packages/rs-drive/src/drive/document/update/internal/update_document_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/update/internal/update_document_for_contract_operations/v0/mod.rs @@ -170,7 +170,7 @@ impl Drive { let mut batch_insertion_cache: HashSet>> = HashSet::new(); // fourth we need to store a reference to the document for each index - for index in document_type.indexes() { + for index in document_type.indexes().values() { // at this point the contract path is to the contract documents // for each index the top index component will already have been added // when the contract itself was created diff --git a/packages/rs-drive/src/drive/initialization/v0/mod.rs b/packages/rs-drive/src/drive/initialization/v0/mod.rs index 57c8485fd2..4030da96d8 100644 --- a/packages/rs-drive/src/drive/initialization/v0/mod.rs +++ b/packages/rs-drive/src/drive/initialization/v0/mod.rs @@ -174,7 +174,7 @@ impl Drive { // For Versioning via forks Drive::add_initial_fork_update_structure_operations(&mut batch); - + // Pre funded specialized balances tree Drive::add_initial_pre_funded_specialized_balances_operations(&mut batch); diff --git a/packages/rs-drive/src/drive/mod.rs b/packages/rs-drive/src/drive/mod.rs index 1e5564e2de..f58b5261f6 100644 --- a/packages/rs-drive/src/drive/mod.rs +++ b/packages/rs-drive/src/drive/mod.rs @@ -89,13 +89,13 @@ mod open; mod operations; #[cfg(feature = "server")] mod platform_state; +mod pre_funded_specialized_balances; #[cfg(feature = "server")] mod prove; /// Contains a set of useful grovedb proof verification functions #[cfg(feature = "verify")] pub mod verify; mod votes; -mod pre_funded_specialized_balances; #[cfg(feature = "server")] use crate::drive::cache::DriveCache; diff --git a/packages/rs-drive/src/drive/pre_funded_specialized_balances/mod.rs b/packages/rs-drive/src/drive/pre_funded_specialized_balances/mod.rs index 342a9d83a7..88d0cc60ec 100644 --- a/packages/rs-drive/src/drive/pre_funded_specialized_balances/mod.rs +++ b/packages/rs-drive/src/drive/pre_funded_specialized_balances/mod.rs @@ -1,6 +1,6 @@ +use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; use crate::drive::batch::GroveDbOpBatch; use crate::drive::{Drive, RootTree}; -use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; pub const PREFUNDED_BALANCES_FOR_VOTING: [u8; 1] = [128]; @@ -18,4 +18,4 @@ impl Drive { PREFUNDED_BALANCES_FOR_VOTING.to_vec(), ); } -} \ No newline at end of file +} diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index 05a4657cce..56258c1385 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -4,7 +4,7 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; -use dpp::prelude::{Identifier, IdentityNonce}; +use dpp::voting::votes::contested_document_resource_vote::accessors::v0::ContestedDocumentResourceVoteGettersV0; use dpp::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 4581834973..6f6ddae532 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -3,6 +3,7 @@ use crate::drive::RootTree; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::DataContract; +use dpp::voting::votes::contested_document_resource_vote::accessors::v0::ContestedDocumentResourceVoteGettersV0; use dpp::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; use dpp::ProtocolError; @@ -138,7 +139,14 @@ impl TreePath for ContestedDocumentResourceVote { ))); } let document_type = contract.document_type_for_name(&vote_poll.document_type_name)?; - let index = document_type.indexes().get(&vote_poll.index_name).ok_or(ProtocolError::UnknownContestedIndexResolution(format!("no index named {} for document type {} on contract with id {}", &vote_poll.index_name, document_type.name(), contract.id())))?; + let index = document_type.indexes().get(&vote_poll.index_name).ok_or( + ProtocolError::UnknownContestedIndexResolution(format!( + "no index named {} for document type {} on contract with id {}", + &vote_poll.index_name, + document_type.name(), + contract.id() + )), + )?; let mut path = contract_document_type_path( &vote_poll.contract_id.as_bytes(), &vote_poll.document_type_name, diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/mod.rs index e7b3c23d7a..44d763d474 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/mod.rs @@ -3,11 +3,10 @@ use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::platform_value::Identifier; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::data_contract::document_type::DocumentTypeRef; use dpp::prelude::IdentityNonce; use dpp::ProtocolError; use std::sync::Arc; -use dpp::data_contract::document_type::DocumentTypeRef; -use dpp::data_contract::errors::DataContractError; /// transformer module pub mod transformer; @@ -30,7 +29,7 @@ impl DocumentBaseTransitionActionAccessorsV0 for DocumentBaseTransitionAction { DocumentBaseTransitionAction::V0(v0) => v0.id, } } - + fn document_type(&self) -> Result { Ok(self .data_contract_fetch_info() @@ -39,10 +38,7 @@ impl DocumentBaseTransitionActionAccessorsV0 for DocumentBaseTransitionAction { } fn document_type_field_is_required(&self, field: &str) -> Result { - Ok(self - .document_type()? - .required_fields() - .contains(field)) + Ok(self.document_type()?.required_fields().contains(field)) } fn document_type_name(&self) -> &String { diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/v0/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/v0/mod.rs index 91c500f92e..39aa8d0cd5 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/v0/mod.rs @@ -1,8 +1,8 @@ /// transformer pub mod transformer; -use std::sync::Arc; use dpp::data_contract::document_type::DocumentTypeRef; +use std::sync::Arc; use dpp::identifier::Identifier; use dpp::prelude::IdentityNonce; diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs index f649cdac16..4c9a42fd07 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs @@ -5,9 +5,9 @@ mod v0; use derive_more::From; use dpp::block::block_info::BlockInfo; +use dpp::data_contract::document_type::Index; use dpp::platform_value::{Identifier, Value}; use std::collections::BTreeMap; -use dpp::data_contract::document_type::Index; use dpp::document::Document; use dpp::fee::Credits; diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs index bd4458c3ed..24405dd90e 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs @@ -9,8 +9,8 @@ use dpp::ProtocolError; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; -use dpp::data_contract::document_type::Index; use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; +use dpp::data_contract::document_type::Index; use dpp::document::property_names::{ CREATED_AT, CREATED_AT_BLOCK_HEIGHT, CREATED_AT_CORE_BLOCK_HEIGHT, TRANSFERRED_AT, TRANSFERRED_AT_BLOCK_HEIGHT, TRANSFERRED_AT_CORE_BLOCK_HEIGHT, UPDATED_AT, @@ -33,7 +33,7 @@ pub struct DocumentCreateTransitionActionV0 { pub data: BTreeMap, /// Pre funded balance (for unique index conflict resolution voting - the identity will put money /// aside that will be used by voters to vote) - pub prefunded_voting_balances: BTreeMap + pub prefunded_voting_balances: BTreeMap, } /// document create transition action accessors v0 @@ -50,7 +50,7 @@ pub trait DocumentCreateTransitionActionAccessorsV0 { fn data_mut(&mut self) -> &mut BTreeMap; /// data owned fn data_owned(self) -> BTreeMap; - + /// pre funded balance (for unique index conflict resolution voting - the identity will put money /// aside that will be used by voters to vote) fn prefunded_voting_balances(&self) -> &BTreeMap; diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs index b26a22f846..6cfb3b3fc7 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs @@ -1,8 +1,10 @@ use dpp::block::block_info::BlockInfo; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::data_contract::document_type::Index; +use dpp::fee::Credits; use dpp::platform_value::Identifier; +use std::collections::BTreeMap; use std::sync::Arc; -use dpp::data_contract::accessors::v0::DataContractV0Getters; -use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::ProtocolError; use dpp::state_transition::documents_batch_transition::document_create_transition::v0::DocumentCreateTransitionV0; @@ -17,20 +19,34 @@ impl DocumentCreateTransitionActionV0 { block_info: &BlockInfo, get_data_contract: impl Fn(Identifier) -> Result, ProtocolError>, ) -> Result { - let DocumentCreateTransitionV0 { base, data, prefunded_voting_balances , .. } = value; + let DocumentCreateTransitionV0 { + base, + data, + prefunded_voting_balances, + .. + } = value; let base = DocumentBaseTransitionAction::from_base_transition_with_contract_lookup( base, get_data_contract, )?; - + let document_type = base.document_type()?; - + let document_type_indexes = document_type.indexes(); - let prefunded_voting_balances_by_index = prefunded_voting_balances.into_iter().map(|(index_name, credits)| { - let index = document_type_indexes.get(&index_name).ok_or(ProtocolError::UnknownContestedIndexResolution(format!("index {} not found on document type {}", index_name, document_type.name())))?; - Ok((index.clone(), credits)) - }).collect(); + let prefunded_voting_balances_by_index = prefunded_voting_balances + .into_iter() + .map(|(index_name, credits)| { + let index = document_type_indexes.get(&index_name).ok_or( + ProtocolError::UnknownContestedIndexResolution(format!( + "index {} not found on document type {}", + index_name, + document_type.name() + )), + )?; + Ok((index.clone(), credits)) + }) + .collect::, ProtocolError>>()?; Ok(DocumentCreateTransitionActionV0 { base, @@ -46,7 +62,12 @@ impl DocumentCreateTransitionActionV0 { block_info: &BlockInfo, get_data_contract: impl Fn(Identifier) -> Result, ProtocolError>, ) -> Result { - let DocumentCreateTransitionV0 { base, data, prefunded_voting_balances, .. } = value; + let DocumentCreateTransitionV0 { + base, + data, + prefunded_voting_balances, + .. + } = value; let base = DocumentBaseTransitionAction::from_borrowed_base_transition_with_contract_lookup( base, @@ -57,10 +78,19 @@ impl DocumentCreateTransitionActionV0 { let document_type_indexes = document_type.indexes(); - let prefunded_voting_balances_by_index = prefunded_voting_balances.iter().map(|(index_name, credits)| { - let index = document_type_indexes.get(index_name).ok_or(ProtocolError::UnknownContestedIndexResolution(format!("index {} not found on document type {}", index_name, document_type.name())))?; - Ok((index.clone(), *credits)) - }).collect(); + let prefunded_voting_balances_by_index = prefunded_voting_balances + .iter() + .map(|(index_name, credits)| { + let index = document_type_indexes.get(index_name).ok_or( + ProtocolError::UnknownContestedIndexResolution(format!( + "index {} not found on document type {}", + index_name, + document_type.name() + )), + )?; + Ok((index.clone(), *credits)) + }) + .collect::, ProtocolError>>()?; Ok(DocumentCreateTransitionActionV0 { base, diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/mod.rs index fc5de09a35..610f9b6802 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/mod.rs @@ -75,12 +75,23 @@ impl DocumentsBatchTransitionAction { impl DocumentsBatchTransitionAction { /// The sum of all purchases amounts for all purchase transitions in the batch - pub fn all_purchases_amount(&self) -> Option { + pub fn all_purchases_amount(&self) -> Result, ProtocolError> { match self { DocumentsBatchTransitionAction::V0(v0) => v0.all_purchases_amount(), } } + /// The sum of all conflicting index collateral voting funds for all document create transitions in the batch + fn all_conflicting_index_collateral_voting_funds( + &self, + ) -> Result, ProtocolError> { + match self { + DocumentsBatchTransitionAction::V0(v0) => { + v0.all_conflicting_index_collateral_voting_funds() + } + } + } + /// Determines the security level requirements for the batch transition action. /// /// This method performs the following steps: diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs index f60a2125dc..4b4f5f6bd2 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs @@ -3,6 +3,7 @@ use crate::state_transition_action::document::documents_batch::document_transiti use dpp::identifier::Identifier; use dpp::prelude::UserFeeIncrease; use dpp::ProtocolError; +use crate::state_transition_action::document::documents_batch::document_transition::document_create_transition_action::DocumentCreateTransitionActionAccessorsV0; use crate::state_transition_action::document::documents_batch::document_transition::document_purchase_transition_action::DocumentPurchaseTransitionActionAccessorsV0; /// action v0 @@ -25,11 +26,11 @@ impl DocumentsBatchTransitionActionV0 { DocumentTransitionAction::PurchaseAction(purchase) => Some(purchase.price()), _ => None, }) - .fold((None, false), |(acc, _), price| { - match acc { - Some(acc_val) => acc_val.checked_add(price).map_or((None, true), |sum| (Some(sum), true)), - None => (Some(price), true), - } + .fold((None, false), |(acc, _), price| match acc { + Some(acc_val) => acc_val + .checked_add(price) + .map_or((None, true), |sum| (Some(sum), true)), + None => (Some(price), true), }); match (total, any_purchases) { @@ -39,28 +40,33 @@ impl DocumentsBatchTransitionActionV0 { } } - fn all_conflicting_index_collateral_voting_funds(&self) -> Result, ProtocolError> { + pub(super) fn all_conflicting_index_collateral_voting_funds( + &self, + ) -> Result, ProtocolError> { let (total, any_voting_funds): (Option, bool) = self .transitions .iter() .filter_map(|transition| match transition { DocumentTransitionAction::CreateAction(document_create_transition_action) => { - document_create_transition_action.prefunded_voting_balances().values().try_fold(0u64, |acc, &val| { - acc.checked_add(val) - }) - }, + document_create_transition_action + .prefunded_voting_balances() + .values() + .try_fold(0u64, |acc, &val| acc.checked_add(val)) + } _ => None, }) - .fold((None, false), |(acc, _), price| { - match acc { - Some(acc_val) => acc_val.checked_add(price).map_or((None, true), |sum| (Some(sum), true)), - None => (Some(price), true), - } + .fold((None, false), |(acc, _), price| match acc { + Some(acc_val) => acc_val + .checked_add(price) + .map_or((None, true), |sum| (Some(sum), true)), + None => (Some(price), true), }); match (total, any_voting_funds) { (Some(total), _) => Ok(Some(total)), - (None, true) => Err(ProtocolError::Overflow("overflow in all voting funds amount")), // Overflow occurred + (None, true) => Err(ProtocolError::Overflow( + "overflow in all voting funds amount", + )), // Overflow occurred _ => Ok(None), } } diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs index 663b99d8f4..7fc1ca6774 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs @@ -4,20 +4,31 @@ use dpp::state_transition::state_transitions::identity::masternode_vote_transiti impl From for MasternodeVoteTransitionActionV0 { fn from(value: MasternodeVoteTransitionV0) -> Self { let MasternodeVoteTransitionV0 { - pro_tx_hash, vote, .. + pro_tx_hash, + vote, + nonce, + .. } = value; - MasternodeVoteTransitionActionV0 { pro_tx_hash, vote } + MasternodeVoteTransitionActionV0 { + pro_tx_hash, + vote, + nonce, + } } } impl From<&MasternodeVoteTransitionV0> for MasternodeVoteTransitionActionV0 { fn from(value: &MasternodeVoteTransitionV0) -> Self { let MasternodeVoteTransitionV0 { - pro_tx_hash, vote, .. + pro_tx_hash, + vote, + nonce, + .. } = value; MasternodeVoteTransitionActionV0 { pro_tx_hash: *pro_tx_hash, vote: vote.clone(), + nonce: *nonce, } } } diff --git a/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_extensions.rs b/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_extensions.rs index 1a4d6c459e..a65c4b3923 100644 --- a/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_extensions.rs +++ b/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_extensions.rs @@ -49,13 +49,16 @@ pub trait BTreeValueRemoveFromMapHelper { fn remove_identifiers(&mut self, key: &str) -> Result, Error>; fn remove_optional_identifiers(&mut self, key: &str) -> Result>, Error>; fn remove_map_as_btree_map(&mut self, key: &str) -> Result, Error> - where - K: TryFrom + Ord, - V: TryFrom; - fn remove_optional_map_as_btree_map(&mut self, key: &str) -> Result>, Error> - where - K: TryFrom + Ord, - V: TryFrom; + where + K: TryFrom + Ord, + V: TryFrom; + fn remove_optional_map_as_btree_map( + &mut self, + key: &str, + ) -> Result>, Error> + where + K: TryFrom + Ord, + V: TryFrom; } impl BTreeValueRemoveFromMapHelper for BTreeMap { @@ -293,18 +296,21 @@ impl BTreeValueRemoveFromMapHelper for BTreeMap { } fn remove_map_as_btree_map(&mut self, key: &str) -> Result, Error> - where - K: TryFrom + Ord, - V: TryFrom { - self.remove_optional_map_as_btree_map(key)?.ok_or_else(|| { - Error::StructureError(format!("unable to remove map property {key}")) - }) + where + K: TryFrom + Ord, + V: TryFrom, + { + self.remove_optional_map_as_btree_map(key)? + .ok_or_else(|| Error::StructureError(format!("unable to remove map property {key}"))) } - fn remove_optional_map_as_btree_map(&mut self, key: &str) -> Result>, Error> - where - K: TryFrom + Ord, - V: TryFrom, + fn remove_optional_map_as_btree_map( + &mut self, + key: &str, + ) -> Result>, Error> + where + K: TryFrom + Ord, + V: TryFrom, { self.remove(key) .and_then(|v| { @@ -312,9 +318,10 @@ impl BTreeValueRemoveFromMapHelper for BTreeMap { None } else if let Value::Map(map) = v { Some( - map - .iter() - .map(|(key, value)| Ok((key.clone().try_into()?, value.clone().try_into()?))) + map.iter() + .map(|(key, value)| { + Ok((key.clone().try_into()?, value.clone().try_into()?)) + }) .collect(), ) } else { @@ -571,18 +578,21 @@ impl BTreeValueRemoveFromMapHelper for BTreeMap { } fn remove_map_as_btree_map(&mut self, key: &str) -> Result, Error> - where - K: TryFrom + Ord, - V: TryFrom { - self.remove_optional_map_as_btree_map(key)?.ok_or_else(|| { - Error::StructureError(format!("unable to remove map property {key}")) - }) + where + K: TryFrom + Ord, + V: TryFrom, + { + self.remove_optional_map_as_btree_map(key)? + .ok_or_else(|| Error::StructureError(format!("unable to remove map property {key}"))) } - fn remove_optional_map_as_btree_map(&mut self, key: &str) -> Result>, Error> - where - K: TryFrom + Ord, - V: TryFrom, + fn remove_optional_map_as_btree_map( + &mut self, + key: &str, + ) -> Result>, Error> + where + K: TryFrom + Ord, + V: TryFrom, { self.remove(key) .and_then(|v| { @@ -590,8 +600,7 @@ impl BTreeValueRemoveFromMapHelper for BTreeMap { None } else if let Value::Map(map) = v { Some( - map - .into_iter() + map.into_iter() .map(|(key, value)| Ok((key.try_into()?, value.try_into()?))) .collect(), ) diff --git a/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_inner_value_extensions.rs b/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_inner_value_extensions.rs index 97d46e35ed..240f3a60d0 100644 --- a/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_inner_value_extensions.rs +++ b/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_inner_value_extensions.rs @@ -12,7 +12,10 @@ pub trait BTreeValueRemoveInnerValueFromMapHelper { &mut self, key: &str, ) -> Result, Error>; - fn remove_inner_value_map>(&mut self, key: &str) -> Result; + fn remove_inner_value_map>( + &mut self, + key: &str, + ) -> Result; } impl BTreeValueRemoveInnerValueFromMapHelper for BTreeMap { @@ -26,8 +29,9 @@ impl BTreeValueRemoveInnerValueFromMapHelper for BTreeMap { } fn remove_inner_value_array>(&mut self, key: &str) -> Result { - self.remove_optional_inner_value_array(key)? - .ok_or_else(|| Error::StructureError(format!("unable to remove inner value array property {key}"))) + self.remove_optional_inner_value_array(key)?.ok_or_else(|| { + Error::StructureError(format!("unable to remove inner value array property {key}")) + }) } fn remove_optional_inner_value_map>( @@ -39,8 +43,12 @@ impl BTreeValueRemoveInnerValueFromMapHelper for BTreeMap { .transpose() } - fn remove_inner_value_map>(&mut self, key: &str) -> Result { - self.remove_optional_inner_value_map(key)? - .ok_or_else(|| Error::StructureError(format!("unable to remove inner value map property {key}"))) + fn remove_inner_value_map>( + &mut self, + key: &str, + ) -> Result { + self.remove_optional_inner_value_map(key)?.ok_or_else(|| { + Error::StructureError(format!("unable to remove inner value map property {key}")) + }) } } diff --git a/packages/rs-platform-value/src/lib.rs b/packages/rs-platform-value/src/lib.rs index 321107dad4..6d76594be7 100644 --- a/packages/rs-platform-value/src/lib.rs +++ b/packages/rs-platform-value/src/lib.rs @@ -1507,4 +1507,4 @@ impl TryFrom for String { fn try_from(value: Value) -> Result { value.into_text() } -} \ No newline at end of file +} diff --git a/packages/rs-platform-value/src/value_map.rs b/packages/rs-platform-value/src/value_map.rs index 210c02670a..a067b87efb 100644 --- a/packages/rs-platform-value/src/value_map.rs +++ b/packages/rs-platform-value/src/value_map.rs @@ -216,7 +216,10 @@ impl ValueMapHelper for ValueMap { .map(|pos| self.remove(pos).1) } fn from_btree_map + Ord, V: Into>(btree_map: BTreeMap) -> Self { - btree_map.into_iter().map(|(k, v)| (k.into(), v.into())).collect() + btree_map + .into_iter() + .map(|(k, v)| (k.into(), v.into())) + .collect() } } @@ -353,8 +356,8 @@ impl Value { map: &'a ValueMap, sort_key: &str, ) -> Result, Error> - where - T: TryFrom + where + T: TryFrom + TryFrom + TryFrom + TryFrom @@ -421,4 +424,4 @@ impl Value { }) .collect::>() } -} \ No newline at end of file +} diff --git a/packages/rs-platform-version/src/version/fee/v1.rs b/packages/rs-platform-version/src/version/fee/v1.rs index 8598eeb469..36d8ef8ae8 100644 --- a/packages/rs-platform-version/src/version/fee/v1.rs +++ b/packages/rs-platform-version/src/version/fee/v1.rs @@ -4,8 +4,8 @@ use crate::version::fee::processing::v1::FEE_PROCESSING_VERSION1; use crate::version::fee::signature::v1::FEE_SIGNATURE_VERSION1; use crate::version::fee::state_transition_min_fees::v1::STATE_TRANSITION_MIN_FEES_VERSION1; use crate::version::fee::storage::v1::FEE_STORAGE_VERSION1; -use crate::version::fee::FeeVersion; use crate::version::fee::vote_resolution_fund_fees::v1::VOTE_RESOLUTION_FUND_FEES_VERSION1; +use crate::version::fee::FeeVersion; pub const FEE_VERSION1: FeeVersion = FeeVersion { storage: FEE_STORAGE_VERSION1, From 4af5f4eecb08e129f38aa8ea0316c6a03762b360 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 7 May 2024 16:14:00 +0200 Subject: [PATCH 035/135] more work --- .../masternode_vote_transition/v0/mod.rs | 2 +- packages/rs-dpp/src/voting/vote_polls/mod.rs | 21 + .../accessors/mod.rs | 26 -- .../accessors/v0/mod.rs | 14 - packages/rs-dpp/src/voting/votes/mod.rs | 22 +- .../votes/resource_vote/accessors/mod.rs | 27 ++ .../votes/resource_vote/accessors/v0/mod.rs | 14 + .../mod.rs | 10 +- .../v0/mod.rs | 12 +- .../drive/batch/drive_op_batch/document.rs | 54 +++ .../document/document_create_transition.rs | 12 +- packages/rs-drive/src/drive/contract/mod.rs | 2 +- .../rs-drive/src/drive/document/insert/mod.rs | 4 +- .../add_contested_document/mod.rs | 61 +++ .../add_contested_document/v0/mod.rs | 70 +++ .../mod.rs | 60 +++ .../v0/mod.rs | 44 ++ .../mod.rs | 66 +++ .../v0/mod.rs | 67 +++ .../mod.rs | 52 +++ .../v0/mod.rs | 126 +++++ .../mod.rs | 68 +++ .../v0/mod.rs | 431 ++++++++++++++++++ .../mod.rs | 64 +++ .../v0/mod.rs | 189 ++++++++ .../mod.rs | 1 + .../v0/mod.rs | 192 ++++++++ .../mod.rs | 60 +++ .../v0/mod.rs | 388 ++++++++++++++++ .../drive/document/insert_contested/mod.rs | 144 ++++++ packages/rs-drive/src/drive/document/mod.rs | 2 + .../document_and_contract_info.rs | 2 + .../remove_votes_for_identity/v0/mod.rs | 4 +- .../mod.rs | 6 +- .../v0/mod.rs | 8 +- .../add_vote_poll_end_date_query/v0/mod.rs | 2 +- .../insert/register_identity_vote/v0/mod.rs | 4 +- packages/rs-drive/src/drive/votes/mod.rs | 104 +++-- .../src/version/drive_versions.rs | 13 + 39 files changed, 2328 insertions(+), 120 deletions(-) delete mode 100644 packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/mod.rs delete mode 100644 packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/v0/mod.rs create mode 100644 packages/rs-dpp/src/voting/votes/resource_vote/accessors/mod.rs create mode 100644 packages/rs-dpp/src/voting/votes/resource_vote/accessors/v0/mod.rs rename packages/rs-dpp/src/voting/votes/{contested_document_resource_vote => resource_vote}/mod.rs (73%) rename packages/rs-dpp/src/voting/votes/{contested_document_resource_vote => resource_vote}/v0/mod.rs (64%) create mode 100644 packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs create mode 100644 packages/rs-drive/src/drive/document/insert_contested/add_contested_document/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/mod.rs create mode 100644 packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs create mode 100644 packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/mod.rs create mode 100644 packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/mod.rs create mode 100644 packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_index_level_for_contract_operations/mod.rs create mode 100644 packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_index_level_for_contract_operations/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/mod.rs create mode 100644 packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs create mode 100644 packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/document/insert_contested/mod.rs diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs index 7806adfffa..50e5758d92 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs @@ -79,7 +79,7 @@ mod test { let mut rng = rand::thread_rng(); let transition = MasternodeVoteTransitionV0 { pro_tx_hash: Identifier::random(), - vote: Vote::ContestedDocumentResourceVote(ContestedDocumentResourceVote { + vote: Vote::ResourceVote(ContestedDocumentResourceVote { vote_poll: ContestedDocumentResourceVotePoll { contract_id: Default::default(), document_type_name: "hello".to_string(), diff --git a/packages/rs-dpp/src/voting/vote_polls/mod.rs b/packages/rs-dpp/src/voting/vote_polls/mod.rs index c4087488b0..3d2a4c593c 100644 --- a/packages/rs-dpp/src/voting/vote_polls/mod.rs +++ b/packages/rs-dpp/src/voting/vote_polls/mod.rs @@ -1 +1,22 @@ +use derive_more::From; +use serde::{Deserialize, Serialize}; +use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; +use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; + pub mod contested_document_resource_vote_poll; + +#[derive(Debug, Clone, Encode, Decode, PartialEq, From)] +#[cfg_attr( +feature = "state-transition-serde-conversion", +derive(Serialize, Deserialize), +serde(rename_all = "camelCase") +)] +pub enum VotePoll { + ContestedDocumentResourceVotePoll(ContestedDocumentResourceVotePoll) +} + +impl Default for VotePoll { + fn default() -> Self { + ContestedDocumentResourceVotePoll::default().into() + } +} \ No newline at end of file diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/mod.rs b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/mod.rs deleted file mode 100644 index bea2126720..0000000000 --- a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/mod.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; -use crate::voting::votes::contested_document_resource_vote::accessors::v0::ContestedDocumentResourceVoteGettersV0; -use crate::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; - -pub mod v0; - -impl ContestedDocumentResourceVoteGettersV0 for ContestedDocumentResourceVote { - fn vote_poll(&self) -> &ContestedDocumentResourceVotePoll { - match self { - ContestedDocumentResourceVote::V0(v0) => &v0.vote_poll, - } - } - - fn vote_poll_owned(self) -> ContestedDocumentResourceVotePoll { - match self { - ContestedDocumentResourceVote::V0(v0) => v0.vote_poll, - } - } - - fn resource_vote_choice(&self) -> ResourceVoteChoice { - match self { - ContestedDocumentResourceVote::V0(v0) => v0.resource_vote_choice, - } - } -} diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/v0/mod.rs b/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/v0/mod.rs deleted file mode 100644 index 8ab948be57..0000000000 --- a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/accessors/v0/mod.rs +++ /dev/null @@ -1,14 +0,0 @@ -use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; - -/// Trait for getters in Contested Document Resource Vote -pub trait ContestedDocumentResourceVoteGettersV0 { - /// The vote poll - fn vote_poll(&self) -> &ContestedDocumentResourceVotePoll; - - /// The vote poll as owned - fn vote_poll_owned(self) -> ContestedDocumentResourceVotePoll; - - /// The choice made in the vote - fn resource_vote_choice(&self) -> ResourceVoteChoice; -} diff --git a/packages/rs-dpp/src/voting/votes/mod.rs b/packages/rs-dpp/src/voting/votes/mod.rs index 4eea0be032..917e707251 100644 --- a/packages/rs-dpp/src/voting/votes/mod.rs +++ b/packages/rs-dpp/src/voting/votes/mod.rs @@ -1,21 +1,31 @@ -pub mod contested_document_resource_vote; +pub mod resource_vote; -use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; -use crate::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; +use crate::voting::votes::resource_vote::ResourceVote; use serde::{Deserialize, Serialize}; +#[cfg(feature = "vote-serialization")] +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +#[cfg(feature = "vote-serialization")] +use bincode::{Decode, Encode}; +#[cfg(feature = "vote-serialization")] +use crate::ProtocolError; -#[derive(Debug, Clone, Encode, Decode, PartialEq)] +#[derive(Debug, Clone, PartialEq)] #[cfg_attr( feature = "vote-serde-conversion", derive(Serialize, Deserialize), serde(rename_all = "camelCase") )] +#[cfg_attr( +feature = "vote-serialization", +derive(Encode, Decode, PlatformDeserialize, PlatformSerialize), +platform_serialize(limit = 15000, unversioned) +)] pub enum Vote { - ContestedDocumentResourceVote(ContestedDocumentResourceVote), + ResourceVote(ResourceVote), } impl Default for Vote { fn default() -> Self { - Vote::ContestedDocumentResourceVote(ContestedDocumentResourceVote::default()) + Vote::ResourceVote(ResourceVote::default()) } } diff --git a/packages/rs-dpp/src/voting/votes/resource_vote/accessors/mod.rs b/packages/rs-dpp/src/voting/votes/resource_vote/accessors/mod.rs new file mode 100644 index 0000000000..306eec7d48 --- /dev/null +++ b/packages/rs-dpp/src/voting/votes/resource_vote/accessors/mod.rs @@ -0,0 +1,27 @@ +use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use crate::voting::vote_polls::VotePoll; +use crate::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; +use crate::voting::votes::resource_vote::ResourceVote; + +pub mod v0; + +impl ResourceVoteGettersV0 for ResourceVote { + fn vote_poll(&self) -> &VotePoll { + match self { + ResourceVote::V0(v0) => &v0.vote_poll, + } + } + + fn vote_poll_owned(self) -> VotePoll { + match self { + ResourceVote::V0(v0) => v0.vote_poll, + } + } + + fn resource_vote_choice(&self) -> ResourceVoteChoice { + match self { + ResourceVote::V0(v0) => v0.resource_vote_choice, + } + } +} diff --git a/packages/rs-dpp/src/voting/votes/resource_vote/accessors/v0/mod.rs b/packages/rs-dpp/src/voting/votes/resource_vote/accessors/v0/mod.rs new file mode 100644 index 0000000000..f9289475ae --- /dev/null +++ b/packages/rs-dpp/src/voting/votes/resource_vote/accessors/v0/mod.rs @@ -0,0 +1,14 @@ +use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use crate::voting::vote_polls::VotePoll; + +/// Trait for getters in Resource Vote +pub trait ResourceVoteGettersV0 { + /// The vote poll + fn vote_poll(&self) -> &VotePoll; + + /// The vote poll as owned + fn vote_poll_owned(self) -> VotePoll; + + /// The choice made in the vote + fn resource_vote_choice(&self) -> ResourceVoteChoice; +} diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs b/packages/rs-dpp/src/voting/votes/resource_vote/mod.rs similarity index 73% rename from packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs rename to packages/rs-dpp/src/voting/votes/resource_vote/mod.rs index d8d7a4d1f1..ea85d777d0 100644 --- a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/mod.rs +++ b/packages/rs-dpp/src/voting/votes/resource_vote/mod.rs @@ -1,5 +1,5 @@ use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; -use crate::voting::votes::contested_document_resource_vote::v0::ContestedDocumentResourceVoteV0; +use crate::voting::votes::resource_vote::v0::ResourceVoteV0; use crate::ProtocolError; use derive_more::From; #[cfg(feature = "vote-serialization")] @@ -21,13 +21,13 @@ mod v0; derive(Encode, Decode, PlatformDeserialize, PlatformSerialize), platform_serialize(limit = 15000, unversioned) )] -pub enum ContestedDocumentResourceVote { +pub enum ResourceVote { #[cfg_attr(feature = "vote-serde-conversion", serde(rename = "0"))] - V0(ContestedDocumentResourceVoteV0), + V0(ResourceVoteV0), } -impl Default for ContestedDocumentResourceVote { +impl Default for ResourceVote { fn default() -> Self { - Self::V0(ContestedDocumentResourceVoteV0::default()) + Self::V0(ResourceVoteV0::default()) } } diff --git a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/v0/mod.rs b/packages/rs-dpp/src/voting/votes/resource_vote/v0/mod.rs similarity index 64% rename from packages/rs-dpp/src/voting/votes/contested_document_resource_vote/v0/mod.rs rename to packages/rs-dpp/src/voting/votes/resource_vote/v0/mod.rs index 74cfb8f083..4b48107b62 100644 --- a/packages/rs-dpp/src/voting/votes/contested_document_resource_vote/v0/mod.rs +++ b/packages/rs-dpp/src/voting/votes/resource_vote/v0/mod.rs @@ -1,9 +1,9 @@ use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use crate::ProtocolError; use bincode::{Decode, Encode}; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use serde::{Deserialize, Serialize}; +use crate::voting::vote_polls::VotePoll; #[derive(Debug, Clone, Encode, Decode, PlatformDeserialize, PlatformSerialize, PartialEq)] #[cfg_attr( @@ -12,15 +12,15 @@ use serde::{Deserialize, Serialize}; serde(rename_all = "camelCase") )] #[platform_serialize(unversioned)] -pub struct ContestedDocumentResourceVoteV0 { - pub vote_poll: ContestedDocumentResourceVotePoll, +pub struct ResourceVoteV0 { + pub vote_poll: VotePoll, pub resource_vote_choice: ResourceVoteChoice, } -impl Default for ContestedDocumentResourceVoteV0 { +impl Default for ResourceVoteV0 { fn default() -> Self { - ContestedDocumentResourceVoteV0 { - vote_poll: ContestedDocumentResourceVotePoll::default(), + ResourceVoteV0 { + vote_poll: VotePoll::default(), resource_vote_choice: ResourceVoteChoice::Abstain, } } diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/document.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/document.rs index d26327ff8f..9b32d78167 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/document.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/document.rs @@ -77,6 +77,19 @@ pub enum DocumentOperationType<'a> { /// Should we override the document if one already exists? override_document: bool, }, + /// Adds a contested document to a contract matching the desired info. + /// A contested document is a document that is trying to a acquire a + /// unique index that has a conflict resolution mechanism + AddContestedDocument { + /// The document and contract info, also may contain the owner_id + owned_document_info: OwnedDocumentInfo<'a>, + ///DataContract + contract_id: Identifier, + /// Document type + document_type_name: Cow<'a, String>, + /// Should we override the document if one already exists? + override_document: bool, + }, /// Adds a withdrawal document. AddWithdrawalDocument { /// The document and contract info, also may contain the owner_id @@ -249,6 +262,47 @@ impl DriveLowLevelOperationConverter for DocumentOperationType<'_> { drive_operations.append(&mut operations); Ok(drive_operations) } + DocumentOperationType::AddContestedDocument { + owned_document_info, + contract_id, + document_type_name, + override_document, + } => { + let mut drive_operations: Vec = vec![]; + let contract_fetch_info = drive + .get_contract_with_fetch_info_and_add_to_operations( + contract_id.into_buffer(), + Some(&block_info.epoch), + true, + transaction, + &mut drive_operations, + platform_version, + )? + .ok_or(Error::Document(DocumentError::DataContractNotFound))?; + + let contract = &contract_fetch_info.contract; + + let document_type = contract + .document_type_for_name(document_type_name.as_str()) + .map_err(ProtocolError::DataContractError)?; + + let document_and_contract_info = DocumentAndContractInfo { + owned_document_info, + contract, + document_type, + }; + let mut operations = drive.add_contested_document_for_contract_operations( + document_and_contract_info, + override_document, + block_info, + &mut None, + estimated_costs_only_with_layer_info, + transaction, + platform_version, + )?; + drive_operations.append(&mut operations); + Ok(drive_operations) + } DocumentOperationType::AddWithdrawalDocument { owned_document_info, } => { diff --git a/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs b/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs index cca4a7dee6..4daa2ce854 100644 --- a/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs +++ b/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs @@ -3,7 +3,7 @@ use crate::drive::batch::DriveOperation::{DocumentOperation, IdentityOperation}; use crate::drive::batch::{DocumentOperationType, DriveOperation, IdentityOperationType}; use crate::drive::flags::StorageFlags; use crate::drive::object_size_info::DocumentInfo::DocumentOwnedInfo; -use crate::drive::object_size_info::OwnedDocumentInfo; +use crate::drive::object_size_info::{DocumentAndContractInfo, OwnedDocumentInfo}; use crate::error::Error; use dpp::block::epoch::Epoch; @@ -38,7 +38,15 @@ impl DriveHighLevelDocumentOperationConverter for DocumentCreateTransitionAction contract_id: data_contract_id.into_buffer(), nonce: identity_contract_nonce, }), - DocumentOperation(DocumentOperationType::AddDocument { + DocumentOperation(DocumentOperationType::AddDocumentForContract { + document_and_contract_info: DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentOwnedInfo((document, Some(Cow::Owned(storage_flags)))), + owner_id: Some(owner_id.into_buffer()), + }, + contract: &(), + document_type: (), + }, owned_document_info: OwnedDocumentInfo { document_info: DocumentOwnedInfo((document, Some(Cow::Owned(storage_flags)))), owner_id: Some(owner_id.into_buffer()), diff --git a/packages/rs-drive/src/drive/contract/mod.rs b/packages/rs-drive/src/drive/contract/mod.rs index b0f73db3ff..7d67d4d28c 100644 --- a/packages/rs-drive/src/drive/contract/mod.rs +++ b/packages/rs-drive/src/drive/contract/mod.rs @@ -239,7 +239,7 @@ mod tests { // // let random_owner_id = rand::thread_rng().gen::<[u8; 32]>(); // drive - // .add_document_for_contract( + // .add_contested_document_for_contract( // DocumentAndContractInfo { // owned_document_info: OwnedDocumentInfo { // document_info: DocumentInfo::DocumentRefInfo((&document, storage_flags)), diff --git a/packages/rs-drive/src/drive/document/insert/mod.rs b/packages/rs-drive/src/drive/document/insert/mod.rs index 03e8979c84..d53133f5d7 100644 --- a/packages/rs-drive/src/drive/document/insert/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/mod.rs @@ -703,7 +703,7 @@ mod tests { fn test_add_dashpay_many_non_conflicting_documents() { let (drive, dashpay) = setup_dashpay("add_no_conflict", true); - let random_owner_id = rand::thread_rng().gen::<[u8; 32]>(); + let random_owner_id = random::<[u8; 32]>(); let platform_version = PlatformVersion::first(); @@ -807,7 +807,7 @@ mod tests { .document_type_for_name("contactRequest") .expect("expected to get document type"); - let random_owner_id = rand::thread_rng().gen::<[u8; 32]>(); + let random_owner_id = random::<[u8; 32]>(); let platform_version = PlatformVersion::first(); diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs new file mode 100644 index 0000000000..8107322c91 --- /dev/null +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs @@ -0,0 +1,61 @@ +mod v0; + +use crate::drive::object_size_info::OwnedDocumentInfo; +use crate::drive::Drive; + +use crate::error::drive::DriveError; +use crate::error::Error; + +use dpp::block::block_info::BlockInfo; +use dpp::fee::fee_result::FeeResult; +use dpp::identifier::Identifier; + +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +impl Drive { + /// Adds a contested document using bincode serialization + /// + /// # Parameters + /// * `owned_document_info`: The document info to be added. + /// * `data_contract_id`: The identifier for the data contract. + /// * `document_type_name`: The document type name. + /// * `override_document`: Whether to override the document. + /// * `block_info`: The block info. + /// * `apply`: Whether to apply the operation. + /// * `transaction`: The transaction argument. + /// * `platform_version`: The platform version to select the correct function version to run. + /// + /// # Returns + /// * `Ok(FeeResult)` if the operation was successful. + /// * `Err(DriveError::UnknownVersionMismatch)` if the drive version does not match known versions. + pub fn add_contested_document( + &self, + owned_document_info: OwnedDocumentInfo, + data_contract_id: Identifier, + document_type_name: &str, + override_document: bool, + block_info: &BlockInfo, + apply: bool, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + match platform_version.drive.methods.document.insert_contested.add_contested_document { + 0 => self.add_contested_document_v0( + owned_document_info, + data_contract_id, + document_type_name, + override_document, + block_info, + apply, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "add_contested_document".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/v0/mod.rs new file mode 100644 index 0000000000..cd4a7fa0e3 --- /dev/null +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/v0/mod.rs @@ -0,0 +1,70 @@ +use crate::drive::object_size_info::{DocumentAndContractInfo, OwnedDocumentInfo}; +use crate::drive::Drive; +use crate::error::document::DocumentError; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use dpp::block::block_info::BlockInfo; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::fee::fee_result::FeeResult; +use dpp::identifier::Identifier; + +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +impl Drive { + /// Adds a contested document using bincode serialization + #[inline(always)] + pub(super) fn add_contested_document_v0( + &self, + owned_document_info: OwnedDocumentInfo, + data_contract_id: Identifier, + document_type_name: &str, + override_document: bool, + block_info: &BlockInfo, + apply: bool, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + let mut drive_operations: Vec = vec![]; + + let contract_fetch_info = self + .get_contract_with_fetch_info_and_add_to_operations( + data_contract_id.into_buffer(), + Some(&block_info.epoch), + true, + transaction, + &mut drive_operations, + platform_version, + )? + .ok_or(Error::Document(DocumentError::DataContractNotFound))?; + + let contract = &contract_fetch_info.contract; + + let document_type = contract.document_type_for_name(document_type_name)?; + + let document_and_contract_info = DocumentAndContractInfo { + owned_document_info, + contract, + document_type, + }; + let mut drive_operations: Vec = vec![]; + self.add_contested_document_for_contract_apply_and_add_to_operations( + document_and_contract_info, + override_document, + block_info, + true, + apply, + transaction, + &mut drive_operations, + platform_version, + )?; + let fees = Drive::calculate_fee( + None, + Some(drive_operations), + &block_info.epoch, + self.config.epochs_per_era, + platform_version, + )?; + Ok(fees) + } +} diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/mod.rs new file mode 100644 index 0000000000..3f16f3c8b1 --- /dev/null +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/mod.rs @@ -0,0 +1,60 @@ +mod v0; + +use crate::drive::object_size_info::DocumentAndContractInfo; +use crate::drive::Drive; + +use crate::error::drive::DriveError; +use crate::error::Error; + +use dpp::block::block_info::BlockInfo; +use dpp::fee::fee_result::FeeResult; + +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +impl Drive { + /// Adds a contested document to a contract. + /// + /// # Parameters + /// * `document_and_contract_info`: Information about the document and contract. + /// * `override_document`: Whether to override the document. + /// * `block_info`: The block info. + /// * `apply`: Whether to apply the operation. + /// * `transaction`: The transaction argument. + /// * `drive_version`: The drive version to select the correct function version to run. + /// + /// # Returns + /// * `Ok(FeeResult)` if the operation was successful. + /// * `Err(DriveError::UnknownVersionMismatch)` if the drive version does not match known versions. + pub fn add_contested_document_for_contract( + &self, + document_and_contract_info: DocumentAndContractInfo, + override_document: bool, + block_info: BlockInfo, + apply: bool, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + match platform_version + .drive + .methods + .document + .insert_contested + .add_contested_document_for_contract + { + 0 => self.add_contested_document_for_contract_v0( + document_and_contract_info, + override_document, + block_info, + apply, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "add_contested_document_for_contract".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/v0/mod.rs new file mode 100644 index 0000000000..8877bc89af --- /dev/null +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/v0/mod.rs @@ -0,0 +1,44 @@ +use crate::drive::object_size_info::DocumentAndContractInfo; +use crate::drive::Drive; + +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use dpp::block::block_info::BlockInfo; +use dpp::fee::fee_result::FeeResult; + +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +impl Drive { + /// Adds a contested document to a contract. + #[inline(always)] + pub(super) fn add_contested_document_for_contract_v0( + &self, + document_and_contract_info: DocumentAndContractInfo, + override_document: bool, + block_info: BlockInfo, + apply: bool, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + let mut drive_operations: Vec = vec![]; + self.add_contested_document_for_contract_apply_and_add_to_operations( + document_and_contract_info, + override_document, + &block_info, + true, + apply, + transaction, + &mut drive_operations, + platform_version, + )?; + let fees = Drive::calculate_fee( + None, + Some(drive_operations), + &block_info.epoch, + self.config.epochs_per_era, + platform_version, + )?; + Ok(fees) + } +} diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs new file mode 100644 index 0000000000..e4255c46da --- /dev/null +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs @@ -0,0 +1,66 @@ +mod v0; + +use crate::drive::object_size_info::DocumentAndContractInfo; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use dpp::block::block_info::BlockInfo; + +use dpp::version::PlatformVersion; + +use grovedb::TransactionArg; + +impl Drive { + /// Performs the operations to add a contested document to a contract. + /// + /// # Parameters + /// * `document_and_contract_info`: The document and contract info. + /// * `params`: In v0 the params should be: + /// * `override_document`: Whether to override the document. + /// * `block_info`: The block info. + /// * `document_is_unique_for_document_type_in_batch`: Whether the document is unique for the document type in batch. + /// * `stateful`: Whether the operation is stateful. + /// * `transaction`: The transaction argument. + /// * `drive_operations`: The drive operations. + /// * `drive_version`: The drive version to select the correct function version to run. + /// + /// # Returns + /// * `Ok(())` if the operation was successful. + /// * `Err(DriveError::UnknownVersionMismatch)` if the drive version does not match known versions. + pub(crate) fn add_contested_document_for_contract_apply_and_add_to_operations( + &self, + document_and_contract_info: DocumentAndContractInfo, + override_document: bool, + block_info: &BlockInfo, + document_is_unique_for_document_type_in_batch: bool, + stateful: bool, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive + .methods + .document + .insert_contested + .add_contested_document_for_contract_apply_and_add_to_operations + { + 0 => self.add_contested_document_for_contract_apply_and_add_to_operations_v0( + document_and_contract_info, + override_document, + block_info, + document_is_unique_for_document_type_in_batch, + stateful, + transaction, + drive_operations, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "add_contested_document_for_contract_apply_and_add_to_operations".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/v0/mod.rs new file mode 100644 index 0000000000..75364b4376 --- /dev/null +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/v0/mod.rs @@ -0,0 +1,67 @@ +use crate::drive::object_size_info::DocumentAndContractInfo; +use crate::drive::Drive; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use dpp::block::block_info::BlockInfo; + +use dpp::version::PlatformVersion; +use grovedb::batch::KeyInfoPath; +use grovedb::{EstimatedLayerInformation, TransactionArg}; +use std::collections::HashMap; + +impl Drive { + /// Performs the operations to add a document to a contract. + #[inline(always)] + pub(super) fn add_contested_document_for_contract_apply_and_add_to_operations_v0( + &self, + document_and_contract_info: DocumentAndContractInfo, + override_document: bool, + block_info: &BlockInfo, + document_is_unique_for_document_type_in_batch: bool, + stateful: bool, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + let mut estimated_costs_only_with_layer_info = if stateful { + None::> + } else { + Some(HashMap::new()) + }; + if document_is_unique_for_document_type_in_batch { + let batch_operations = self.add_contested_document_for_contract_operations( + document_and_contract_info, + override_document, + block_info, + &mut None, + &mut estimated_costs_only_with_layer_info, + transaction, + platform_version, + )?; + self.apply_batch_low_level_drive_operations( + estimated_costs_only_with_layer_info, + transaction, + batch_operations, + drive_operations, + &platform_version.drive, + ) + } else { + let batch_operations = self.add_contested_document_for_contract_operations( + document_and_contract_info, + override_document, + block_info, + &mut Some(drive_operations), + &mut estimated_costs_only_with_layer_info, + transaction, + platform_version, + )?; + self.apply_batch_low_level_drive_operations( + estimated_costs_only_with_layer_info, + transaction, + batch_operations, + drive_operations, + &platform_version.drive, + ) + } + } +} diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/mod.rs new file mode 100644 index 0000000000..39255402e6 --- /dev/null +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/mod.rs @@ -0,0 +1,52 @@ +mod v0; + +use crate::drive::object_size_info::DocumentAndContractInfo; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use dpp::block::block_info::BlockInfo; + +use dpp::version::PlatformVersion; +use grovedb::batch::KeyInfoPath; +use grovedb::{EstimatedLayerInformation, TransactionArg}; +use std::collections::HashMap; + +impl Drive { + /// Gathers the operations to add a contested document to a contract. + pub(crate) fn add_contested_document_for_contract_operations( + &self, + document_and_contract_info: DocumentAndContractInfo, + override_document: bool, + block_info: &BlockInfo, + previous_batch_operations: &mut 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 + .insert_contested + .add_contested_document_for_contract_operations + { + 0 => self.add_contested_document_for_contract_operations_v0( + document_and_contract_info, + override_document, + block_info, + previous_batch_operations, + estimated_costs_only_with_layer_info, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "add_contested_document_for_contract_operations".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs new file mode 100644 index 0000000000..993202499c --- /dev/null +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs @@ -0,0 +1,126 @@ +use crate::drive::document::contract_documents_primary_key_path; +use crate::drive::grove_operations::DirectQueryType::{StatefulDirectQuery, StatelessDirectQuery}; +use crate::drive::grove_operations::QueryTarget::QueryTargetValue; +use crate::drive::object_size_info::{DocumentAndContractInfo, DocumentInfoV0Methods}; +use crate::drive::Drive; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use dpp::block::block_info::BlockInfo; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; + +use dpp::version::PlatformVersion; +use grovedb::batch::KeyInfoPath; +use grovedb::{EstimatedLayerInformation, TransactionArg}; +use std::collections::HashMap; + +impl Drive { + /// Gathers the operations to add a contested document to a contract. + #[inline(always)] + pub(super) fn add_contested_document_for_contract_operations_v0( + &self, + document_and_contract_info: DocumentAndContractInfo, + override_document: bool, + block_info: &BlockInfo, + previous_batch_operations: &mut 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![]; + let primary_key_path = contract_documents_primary_key_path( + document_and_contract_info.contract.id_ref().as_bytes(), + document_and_contract_info.document_type.name().as_str(), + ); + + // Apply means stateful query + let query_type = if estimated_costs_only_with_layer_info.is_none() { + StatefulDirectQuery + } else { + StatelessDirectQuery { + in_tree_using_sums: false, + query_target: QueryTargetValue( + document_and_contract_info + .document_type + .estimated_size(platform_version)? as u32, + ), + } + }; + + // To update but not create: + + // 1. Override should be allowed + let could_be_update = override_document; + + // 2. Is not a dry run + let could_be_update = could_be_update + && !document_and_contract_info + .owned_document_info + .document_info + .is_document_size(); + + // 3. Document exists in storage + let is_update = could_be_update + && self.grove_has_raw( + primary_key_path.as_ref().into(), + document_and_contract_info + .owned_document_info + .document_info + .id_key_value_info() + .as_key_ref_request()?, + query_type, + transaction, + &mut batch_operations, + &platform_version.drive, + )?; + + if is_update { + let update_operations = self.update_document_for_contract_operations( + document_and_contract_info, + block_info, + previous_batch_operations, + estimated_costs_only_with_layer_info, + transaction, + platform_version, + )?; + + batch_operations.extend(update_operations); + + return Ok(batch_operations); + } + + // if we are trying to get estimated costs we need to add the upper levels + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { + Self::add_estimation_costs_for_levels_up_to_contract_document_type_excluded( + document_and_contract_info.contract, + estimated_costs_only_with_layer_info, + &platform_version.drive, + )?; + } + + // if we have override_document set that means we already checked if it exists + self.add_contested_document_to_primary_storage( + &document_and_contract_info, + block_info, + override_document, + estimated_costs_only_with_layer_info, + transaction, + &mut batch_operations, + platform_version, + )?; + + self.add_contested_indices_for_top_index_level_for_contract_operations( + &document_and_contract_info, + previous_batch_operations, + estimated_costs_only_with_layer_info, + transaction, + &mut batch_operations, + platform_version, + )?; + + Ok(batch_operations) + } +} diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/mod.rs new file mode 100644 index 0000000000..18757b493d --- /dev/null +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/mod.rs @@ -0,0 +1,68 @@ +mod v0; + +use dpp::block::block_info::BlockInfo; + +use grovedb::batch::KeyInfoPath; + +use grovedb::{EstimatedLayerInformation, TransactionArg}; + +use std::collections::HashMap; + +use crate::drive::object_size_info::DocumentAndContractInfo; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; + +use dpp::version::PlatformVersion; + +impl Drive { + /// Adds a contested document to primary storage. + /// + /// # Parameters + /// * `document_and_contract_info`: Information about the document and contract. + /// * `block_info`: The block info. + /// * `insert_without_check`: Whether to insert the document without check. + /// * `estimated_costs_only_with_layer_info`: Information about the estimated costs only with layer. + /// * `transaction`: The transaction argument. + /// * `drive_version`: The drive version to select the correct function version to run. + /// + /// # Returns + /// * `Ok(())` if the operation was successful. + /// * `Err(DriveError::UnknownVersionMismatch)` if the drive version does not match known versions. + pub(crate) fn add_contested_document_to_primary_storage( + &self, + document_and_contract_info: &DocumentAndContractInfo, + block_info: &BlockInfo, + insert_without_check: bool, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive + .methods + .document + .insert_contested + .add_contested_document_to_primary_storage + { + 0 => self.add_document_to_primary_storage_0( + document_and_contract_info, + block_info, + insert_without_check, + estimated_costs_only_with_layer_info, + transaction, + drive_operations, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "add_contested_document_to_primary_storage".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/v0/mod.rs new file mode 100644 index 0000000000..9e8b657dc2 --- /dev/null +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/v0/mod.rs @@ -0,0 +1,431 @@ +use dpp::data_contract::document_type::DocumentPropertyType; + +use grovedb::batch::key_info::KeyInfo; +use grovedb::batch::key_info::KeyInfo::KnownKey; +use grovedb::batch::KeyInfoPath; +use grovedb::reference_path::ReferencePathType::SiblingReference; + +use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; + +use std::collections::HashMap; +use std::option::Option::None; + +use crate::drive::defaults::{DEFAULT_HASH_SIZE_U8, STORAGE_FLAGS_SIZE}; +use crate::drive::document::{ + contract_documents_keeping_history_primary_key_path_for_document_id, + contract_documents_keeping_history_primary_key_path_for_unknown_document_id, + contract_documents_keeping_history_storage_time_reference_path_size, + contract_documents_primary_key_path, +}; + +use crate::drive::flags::StorageFlags; +use crate::drive::object_size_info::DocumentInfo::{ + DocumentAndSerialization, DocumentEstimatedAverageSize, DocumentOwnedInfo, + DocumentRefAndSerialization, DocumentRefInfo, +}; + +use crate::drive::object_size_info::PathKeyElementInfo::{ + PathFixedSizeKeyRefElement, PathKeyUnknownElementSize, +}; +use crate::drive::object_size_info::PathKeyInfo::{PathFixedSizeKeyRef, PathKeySize}; +use crate::drive::object_size_info::{DocumentAndContractInfo, DocumentInfoV0Methods}; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; + +use crate::drive::grove_operations::QueryTarget::QueryTargetValue; +use crate::drive::grove_operations::{BatchInsertApplyType, BatchInsertTreeApplyType}; + +use dpp::block::block_info::BlockInfo; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::config::v0::DataContractConfigGettersV0; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; +use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; +use dpp::document::DocumentV0Getters; + +use dpp::version::PlatformVersion; + +impl Drive { + /// Adds a document to primary storage. + /// If a document isn't sent to this function then we are just calling to know the query and + /// insert operations + pub(super) fn add_contested_document_to_primary_storage_0( + &self, + document_and_contract_info: &DocumentAndContractInfo, + block_info: &BlockInfo, + insert_without_check: bool, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + let drive_version = &platform_version.drive; + let contract = document_and_contract_info.contract; + let document_type = document_and_contract_info.document_type; + let primary_key_path = contract_documents_primary_key_path( + contract.id_ref().as_bytes(), + document_type.name().as_str(), + ); + // if we are trying to get estimated costs we should add this level + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { + Self::add_estimation_costs_for_add_document_to_primary_storage( + document_and_contract_info, + primary_key_path, + estimated_costs_only_with_layer_info, + platform_version, + )?; + } + + if document_type.documents_keep_history() { + let (path_key_info, storage_flags) = if document_and_contract_info + .owned_document_info + .document_info + .is_document_size() + { + ( + PathKeySize( + KeyInfoPath::from_known_path(primary_key_path), + KeyInfo::MaxKeySize { + unique_id: document_type.unique_id_for_storage().to_vec(), + max_size: DEFAULT_HASH_SIZE_U8, + }, + ), + StorageFlags::optional_default_as_ref(), + ) + } else { + let inserted_storage_flags = if contract.config().can_be_deleted() { + document_and_contract_info + .owned_document_info + .document_info + .get_storage_flags_ref() + } else { + // there are no need for storage flags if the contract can not be deleted + // as this tree can never be deleted + None + }; + ( + PathFixedSizeKeyRef(( + primary_key_path, + document_and_contract_info + .owned_document_info + .document_info + .get_document_id_as_slice() + .ok_or(Error::Drive(DriveError::CorruptedCodeExecution( + "can not get document id from estimated document", + )))?, + )), + inserted_storage_flags, + ) + }; + let apply_type = if estimated_costs_only_with_layer_info.is_none() { + BatchInsertTreeApplyType::StatefulBatchInsertTree + } else { + BatchInsertTreeApplyType::StatelessBatchInsertTree { + in_tree_using_sums: false, + is_sum_tree: false, + flags_len: storage_flags + .map(|s| s.serialized_size()) + .unwrap_or_default(), + } + }; + // we first insert an empty tree if the document is new + self.batch_insert_empty_tree_if_not_exists( + path_key_info, + false, + storage_flags, + apply_type, + transaction, + &mut None, //not going to have multiple same documents in same batch + drive_operations, + drive_version, + )?; + let encoded_time = DocumentPropertyType::encode_date_timestamp(block_info.time_ms); + let path_key_element_info = match &document_and_contract_info + .owned_document_info + .document_info + { + DocumentRefAndSerialization((document, serialized_document, storage_flags)) => { + let element = Element::Item( + serialized_document.to_vec(), + StorageFlags::map_borrowed_cow_to_some_element_flags(storage_flags), + ); + let document_id_in_primary_path = + contract_documents_keeping_history_primary_key_path_for_document_id( + contract.id_ref().as_bytes(), + document_type.name().as_str(), + document.id_ref().as_slice(), + ); + PathFixedSizeKeyRefElement(( + document_id_in_primary_path, + encoded_time.as_slice(), + element, + )) + } + DocumentAndSerialization((document, serialized_document, storage_flags)) => { + let element = Element::Item( + serialized_document.to_vec(), + StorageFlags::map_borrowed_cow_to_some_element_flags(storage_flags), + ); + let document_id_in_primary_path = + contract_documents_keeping_history_primary_key_path_for_document_id( + contract.id_ref().as_bytes(), + document_type.name().as_str(), + document.id_ref().as_slice(), + ); + PathFixedSizeKeyRefElement(( + document_id_in_primary_path, + encoded_time.as_slice(), + element, + )) + } + DocumentOwnedInfo((document, storage_flags)) => { + let serialized_document = document + .serialize(document_and_contract_info.document_type, platform_version)?; + let element = Element::Item( + serialized_document, + StorageFlags::map_borrowed_cow_to_some_element_flags(storage_flags), + ); + let document_id_in_primary_path = + contract_documents_keeping_history_primary_key_path_for_document_id( + contract.id_ref().as_bytes(), + document_type.name().as_str(), + document.id_ref().as_slice(), + ); + PathFixedSizeKeyRefElement(( + document_id_in_primary_path, + encoded_time.as_slice(), + element, + )) + } + DocumentRefInfo((document, storage_flags)) => { + let serialized_document = document + .serialize(document_and_contract_info.document_type, platform_version)?; + let element = Element::Item( + serialized_document, + StorageFlags::map_borrowed_cow_to_some_element_flags(storage_flags), + ); + let document_id_in_primary_path = + contract_documents_keeping_history_primary_key_path_for_document_id( + contract.id_ref().as_bytes(), + document_type.name().as_str(), + document.id_ref().as_slice(), + ); + PathFixedSizeKeyRefElement(( + document_id_in_primary_path, + encoded_time.as_slice(), + element, + )) + } + DocumentEstimatedAverageSize(max_size) => { + let document_id_in_primary_path = + contract_documents_keeping_history_primary_key_path_for_unknown_document_id( + contract.id_ref().as_bytes(), + document_type, + ); + PathKeyUnknownElementSize(( + document_id_in_primary_path, + KnownKey(encoded_time.clone()), + Element::required_item_space(*max_size, STORAGE_FLAGS_SIZE), + )) + } + }; + self.batch_insert(path_key_element_info, drive_operations, drive_version)?; + let path_key_element_info = if document_and_contract_info + .owned_document_info + .document_info + .is_document_size() + { + let document_id_in_primary_path = + contract_documents_keeping_history_primary_key_path_for_unknown_document_id( + contract.id_ref().as_bytes(), + document_type, + ); + let reference_max_size = + contract_documents_keeping_history_storage_time_reference_path_size( + document_type.name().len() as u32, + ); + PathKeyUnknownElementSize(( + document_id_in_primary_path, + KnownKey(vec![0]), + Element::required_item_space(reference_max_size, STORAGE_FLAGS_SIZE), + )) + } else { + // we should also insert a reference at 0 to the current value + // todo: we could construct this only once + let document_id_in_primary_path = + contract_documents_keeping_history_primary_key_path_for_document_id( + contract.id_ref().as_bytes(), + document_type.name().as_str(), + document_and_contract_info + .owned_document_info + .document_info + .get_document_id_as_slice() + .ok_or(Error::Drive(DriveError::CorruptedCodeExecution( + "can not get document id from estimated document", + )))?, + ); + PathFixedSizeKeyRefElement(( + document_id_in_primary_path, + &[0], + Element::Reference( + SiblingReference(encoded_time), + Some(1), + StorageFlags::map_to_some_element_flags(storage_flags), + ), + )) + }; + + self.batch_insert(path_key_element_info, drive_operations, drive_version)?; + } else if insert_without_check { + let path_key_element_info = match &document_and_contract_info + .owned_document_info + .document_info + { + DocumentRefAndSerialization((document, serialized_document, storage_flags)) => { + let element = Element::Item( + serialized_document.to_vec(), + StorageFlags::map_borrowed_cow_to_some_element_flags(storage_flags), + ); + PathFixedSizeKeyRefElement(( + primary_key_path, + document.id_ref().as_slice(), + element, + )) + } + DocumentAndSerialization((document, serialized_document, storage_flags)) => { + let element = Element::Item( + serialized_document.to_vec(), + StorageFlags::map_borrowed_cow_to_some_element_flags(storage_flags), + ); + PathFixedSizeKeyRefElement(( + primary_key_path, + document.id_ref().as_slice(), + element, + )) + } + DocumentRefInfo((document, storage_flags)) => { + let serialized_document = document + .serialize(document_and_contract_info.document_type, platform_version)?; + let element = Element::Item( + serialized_document, + StorageFlags::map_borrowed_cow_to_some_element_flags(storage_flags), + ); + PathFixedSizeKeyRefElement(( + primary_key_path, + document.id_ref().as_slice(), + element, + )) + } + DocumentEstimatedAverageSize(average_size) => PathKeyUnknownElementSize(( + KeyInfoPath::from_known_path(primary_key_path), + KeyInfo::MaxKeySize { + unique_id: document_type.unique_id_for_storage().to_vec(), + max_size: DEFAULT_HASH_SIZE_U8, + }, + Element::required_item_space(*average_size, STORAGE_FLAGS_SIZE), + )), + DocumentOwnedInfo((document, storage_flags)) => { + let serialized_document = document + .serialize(document_and_contract_info.document_type, platform_version)?; + let element = Element::Item( + serialized_document, + StorageFlags::map_borrowed_cow_to_some_element_flags(storage_flags), + ); + PathFixedSizeKeyRefElement(( + primary_key_path, + document.id_ref().as_slice(), + element, + )) + } + }; + self.batch_insert(path_key_element_info, drive_operations, drive_version)?; + } else { + let path_key_element_info = match &document_and_contract_info + .owned_document_info + .document_info + { + DocumentRefAndSerialization((document, serialized_document, storage_flags)) => { + let element = Element::Item( + serialized_document.to_vec(), + StorageFlags::map_borrowed_cow_to_some_element_flags(storage_flags), + ); + PathFixedSizeKeyRefElement(( + primary_key_path, + document.id_ref().as_slice(), + element, + )) + } + DocumentAndSerialization((document, serialized_document, storage_flags)) => { + let element = Element::Item( + serialized_document.to_vec(), + StorageFlags::map_borrowed_cow_to_some_element_flags(storage_flags), + ); + PathFixedSizeKeyRefElement(( + primary_key_path, + document.id_ref().as_slice(), + element, + )) + } + DocumentOwnedInfo((document, storage_flags)) => { + let serialized_document = document + .serialize(document_and_contract_info.document_type, platform_version)?; + let element = Element::Item( + serialized_document, + StorageFlags::map_borrowed_cow_to_some_element_flags(storage_flags), + ); + PathFixedSizeKeyRefElement(( + primary_key_path, + document.id_ref().as_slice(), + element, + )) + } + DocumentRefInfo((document, storage_flags)) => { + let serialized_document = document + .serialize(document_and_contract_info.document_type, platform_version)?; + let element = Element::Item( + serialized_document, + StorageFlags::map_borrowed_cow_to_some_element_flags(storage_flags), + ); + PathFixedSizeKeyRefElement(( + primary_key_path, + document.id_ref().as_slice(), + element, + )) + } + DocumentEstimatedAverageSize(max_size) => PathKeyUnknownElementSize(( + KeyInfoPath::from_known_path(primary_key_path), + KeyInfo::MaxKeySize { + unique_id: document_type.unique_id_for_storage().to_vec(), + max_size: DEFAULT_HASH_SIZE_U8, + }, + Element::required_item_space(*max_size, STORAGE_FLAGS_SIZE), + )), + }; + let apply_type = if estimated_costs_only_with_layer_info.is_none() { + BatchInsertApplyType::StatefulBatchInsert + } else { + BatchInsertApplyType::StatelessBatchInsert { + in_tree_using_sums: false, + target: QueryTargetValue(document_type.estimated_size(platform_version)? as u32), + } + }; + let inserted = self.batch_insert_if_not_exists( + path_key_element_info, + apply_type, + transaction, + drive_operations, + drive_version, + )?; + if !inserted { + return Err(Error::Drive(DriveError::CorruptedDocumentAlreadyExists( + "item already exists", + ))); + } + } + Ok(()) + } +} diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_index_level_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_index_level_for_contract_operations/mod.rs new file mode 100644 index 0000000000..76584f5582 --- /dev/null +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_index_level_for_contract_operations/mod.rs @@ -0,0 +1,64 @@ +mod v0; + +use crate::drive::flags::StorageFlags; + +use crate::drive::object_size_info::{DocumentAndContractInfo, PathInfo}; +use crate::drive::Drive; +use crate::error::drive::DriveError; + +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use dpp::data_contract::document_type::IndexLevel; + +use dpp::version::PlatformVersion; +use grovedb::batch::KeyInfoPath; + +use grovedb::{EstimatedLayerInformation, TransactionArg}; +use std::collections::HashMap; + +impl Drive { + /// Adds indices for an index level and recurses. + pub(crate) fn add_contested_indices_for_index_level_for_contract_operations( + &self, + document_and_contract_info: &DocumentAndContractInfo, + index_path_info: PathInfo<0>, + index_level: &IndexLevel, + any_fields_null: bool, + previous_batch_operations: &mut Option<&mut Vec>, + storage_flags: &Option<&StorageFlags>, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + event_id: [u8; 32], + transaction: TransactionArg, + batch_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive + .methods + .document + .insert_contested + .add_contested_indices_for_index_level_for_contract_operations + { + 0 => self.add_contested_indices_for_index_level_for_contract_operations_v0( + document_and_contract_info, + index_path_info, + index_level, + any_fields_null, + previous_batch_operations, + storage_flags, + estimated_costs_only_with_layer_info, + event_id, + transaction, + batch_operations, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "add_contested_indices_for_index_level_for_contract_operations".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_index_level_for_contract_operations/v0/mod.rs new file mode 100644 index 0000000000..6d38972a03 --- /dev/null +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_index_level_for_contract_operations/v0/mod.rs @@ -0,0 +1,189 @@ +use crate::drive::defaults::DEFAULT_HASH_SIZE_U8; +use crate::drive::flags::StorageFlags; +use crate::drive::grove_operations::BatchInsertTreeApplyType; +use crate::drive::object_size_info::DriveKeyInfo::KeyRef; +use crate::drive::object_size_info::{DocumentAndContractInfo, DocumentInfoV0Methods, PathInfo}; +use crate::drive::Drive; +use crate::error::fee::FeeError; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use dpp::data_contract::document_type::IndexLevel; + +use dpp::version::PlatformVersion; +use grovedb::batch::KeyInfoPath; +use grovedb::EstimatedLayerCount::{ApproximateElements, PotentiallyAtMaxElements}; +use grovedb::EstimatedLayerSizes::AllSubtrees; +use grovedb::EstimatedSumTrees::NoSumTrees; +use grovedb::{EstimatedLayerInformation, TransactionArg}; +use std::collections::HashMap; + +impl Drive { + /// Adds indices for an index level and recurses. + #[inline] + pub(super) fn add_contested_indices_for_index_level_for_contract_operations_v0( + &self, + document_and_contract_info: &DocumentAndContractInfo, + index_path_info: PathInfo<0>, + index_level: &IndexLevel, + mut any_fields_null: bool, + previous_batch_operations: &mut Option<&mut Vec>, + storage_flags: &Option<&StorageFlags>, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + event_id: [u8; 32], + transaction: TransactionArg, + batch_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + if let Some(index_type) = index_level.has_index_with_type() { + self.add_contested_reference_for_index_level_for_contract_operations( + document_and_contract_info, + index_path_info.clone(), + index_type, + any_fields_null, + previous_batch_operations, + storage_flags, + estimated_costs_only_with_layer_info, + transaction, + batch_operations, + &platform_version.drive, + )?; + } + + let document_type = document_and_contract_info.document_type; + + let sub_level_index_count = index_level.sub_levels().len() as u32; + + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { + // On this level we will have a 0 and all the top index paths + estimated_costs_only_with_layer_info.insert( + index_path_info.clone().convert_to_key_info_path(), + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: ApproximateElements(sub_level_index_count + 1), + estimated_layer_sizes: AllSubtrees( + DEFAULT_HASH_SIZE_U8, + NoSumTrees, + storage_flags.map(|s| s.serialized_size()), + ), + }, + ); + } + + let apply_type = if estimated_costs_only_with_layer_info.is_none() { + BatchInsertTreeApplyType::StatefulBatchInsertTree + } else { + BatchInsertTreeApplyType::StatelessBatchInsertTree { + in_tree_using_sums: false, + is_sum_tree: false, + flags_len: storage_flags + .map(|s| s.serialized_size()) + .unwrap_or_default(), + } + }; + + // fourth we need to store a reference to the document for each index + for (name, sub_level) in index_level.sub_levels() { + let mut sub_level_index_path_info = index_path_info.clone(); + let index_property_key = KeyRef(name.as_bytes()); + + let document_index_field = document_and_contract_info + .owned_document_info + .document_info + .get_raw_for_document_type( + name, + document_type, + document_and_contract_info.owned_document_info.owner_id, + Some((sub_level, event_id)), + platform_version, + )? + .unwrap_or_default(); + + let path_key_info = index_property_key + .clone() + .add_path_info(sub_level_index_path_info.clone()); + + // here we are inserting an empty tree that will have a subtree of all other index properties + self.batch_insert_empty_tree_if_not_exists( + path_key_info.clone(), + false, + *storage_flags, + apply_type, + transaction, + previous_batch_operations, + batch_operations, + &platform_version.drive, + )?; + + sub_level_index_path_info.push(index_property_key)?; + + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info + { + let document_top_field_estimated_size = document_and_contract_info + .owned_document_info + .document_info + .get_estimated_size_for_document_type(name, document_type)?; + + if document_top_field_estimated_size > u8::MAX as u16 { + return Err(Error::Fee(FeeError::Overflow( + "document top field is too big for being an index on delete", + ))); + } + + estimated_costs_only_with_layer_info.insert( + sub_level_index_path_info.clone().convert_to_key_info_path(), + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: PotentiallyAtMaxElements, + estimated_layer_sizes: AllSubtrees( + document_top_field_estimated_size as u8, + NoSumTrees, + storage_flags.map(|s| s.serialized_size()), + ), + }, + ); + } + + // Iteration 1. the index path is now something likeDataContracts/ContractID/Documents(1)/$ownerId//toUserId + // Iteration 2. the index path is now something likeDataContracts/ContractID/Documents(1)/$ownerId//toUserId//accountReference + + let path_key_info = document_index_field + .clone() + .add_path_info(sub_level_index_path_info.clone()); + + // here we are inserting an empty tree that will have a subtree of all other index properties + self.batch_insert_empty_tree_if_not_exists( + path_key_info.clone(), + false, + *storage_flags, + apply_type, + transaction, + previous_batch_operations, + batch_operations, + &platform_version.drive, + )?; + + any_fields_null |= document_index_field.is_empty(); + + // we push the actual value of the index path + sub_level_index_path_info.push(document_index_field)?; + // Iteration 1. the index path is now something likeDataContracts/ContractID/Documents(1)/$ownerId//toUserId// + // Iteration 2. the index path is now something likeDataContracts/ContractID/Documents(1)/$ownerId//toUserId//accountReference/ + self.add_contested_indices_for_index_level_for_contract_operations( + document_and_contract_info, + sub_level_index_path_info, + sub_level, + any_fields_null, + previous_batch_operations, + storage_flags, + estimated_costs_only_with_layer_info, + event_id, + transaction, + batch_operations, + platform_version, + )?; + } + Ok(()) + } +} diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/mod.rs new file mode 100644 index 0000000000..e084dffc38 --- /dev/null +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/mod.rs @@ -0,0 +1 @@ +mod v0; diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs new file mode 100644 index 0000000000..e05c4d0a0e --- /dev/null +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs @@ -0,0 +1,192 @@ +use crate::drive::defaults::DEFAULT_HASH_SIZE_U8; +use crate::drive::document::{contract_document_type_path_vec, unique_event_id}; + +use crate::drive::grove_operations::BatchInsertTreeApplyType; + +use crate::drive::object_size_info::{DocumentAndContractInfo, DocumentInfoV0Methods, PathInfo}; +use crate::drive::Drive; + +use crate::error::fee::FeeError; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::config::v0::DataContractConfigGettersV0; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; + +use dpp::version::PlatformVersion; + +use grovedb::batch::KeyInfoPath; +use grovedb::EstimatedLayerCount::{ApproximateElements, PotentiallyAtMaxElements}; +use grovedb::EstimatedLayerSizes::AllSubtrees; +use grovedb::EstimatedSumTrees::NoSumTrees; +use grovedb::{EstimatedLayerInformation, TransactionArg}; +use std::collections::HashMap; + +impl Drive { + /// Adds indices for the top index level and calls for lower levels. + pub(crate) fn add_contested_indices_for_top_index_level_for_contract_operations( + &self, + document_and_contract_info: &DocumentAndContractInfo, + previous_batch_operations: &mut Option<&mut Vec>, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + transaction: TransactionArg, + batch_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + let drive_version = &platform_version.drive; + let index_level = &document_and_contract_info.document_type.index_structure(); + let contract = document_and_contract_info.contract; + let event_id = unique_event_id(); + let document_type = document_and_contract_info.document_type; + let storage_flags = + if document_type.documents_mutable() || contract.config().can_be_deleted() { + document_and_contract_info + .owned_document_info + .document_info + .get_storage_flags_ref() + } else { + None //there are no need for storage flags if documents are not mutable and contract can not be deleted + }; + + // dbg!(&estimated_costs_only_with_layer_info); + + // we need to construct the path for documents on the contract + // the path is + // * Document and DataContract root tree + // * DataContract ID recovered from document + // * 0 to signify Documents and notDataContract + let contract_document_type_path = contract_document_type_path_vec( + document_and_contract_info.contract.id_ref().as_bytes(), + document_and_contract_info.document_type.name(), + ); + + let sub_level_index_count = index_level.sub_levels().len() as u32; + + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { + // On this level we will have a 0 and all the top index paths + estimated_costs_only_with_layer_info.insert( + KeyInfoPath::from_known_owned_path(contract_document_type_path.clone()), + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: ApproximateElements(sub_level_index_count + 1), + estimated_layer_sizes: AllSubtrees( + DEFAULT_HASH_SIZE_U8, + NoSumTrees, + storage_flags.map(|s| s.serialized_size()), + ), + }, + ); + } + + let apply_type = if estimated_costs_only_with_layer_info.is_none() { + BatchInsertTreeApplyType::StatefulBatchInsertTree + } else { + BatchInsertTreeApplyType::StatelessBatchInsertTree { + in_tree_using_sums: false, + is_sum_tree: false, + flags_len: storage_flags + .map(|s| s.serialized_size()) + .unwrap_or_default(), + } + }; + + // next we need to store a reference to the document for each index + for (name, sub_level) in index_level.sub_levels() { + // at this point the contract path is to the contract documents + // for each index the top index component will already have been added + // when the contract itself was created + let mut index_path: Vec> = contract_document_type_path.clone(); + index_path.push(Vec::from(name.as_bytes())); + + // with the example of the dashpay contract's first index + // the index path is now something likeDataContracts/ContractID/Documents(1)/$ownerId + let document_top_field = document_and_contract_info + .owned_document_info + .document_info + .get_raw_for_document_type( + name, + document_type, + document_and_contract_info.owned_document_info.owner_id, + Some((sub_level, event_id)), + platform_version, + )? + .unwrap_or_default(); + + // The zero will not matter here, because the PathKeyInfo is variable + let path_key_info = document_top_field.clone().add_path::<0>(index_path.clone()); + // here we are inserting an empty tree that will have a subtree of all other index properties + self.batch_insert_empty_tree_if_not_exists( + path_key_info.clone(), + false, + storage_flags, + apply_type, + transaction, + previous_batch_operations, + batch_operations, + drive_version, + )?; + + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info + { + let document_top_field_estimated_size = document_and_contract_info + .owned_document_info + .document_info + .get_estimated_size_for_document_type(name, document_type)?; + + if document_top_field_estimated_size > u8::MAX as u16 { + return Err(Error::Fee(FeeError::Overflow( + "document field is too big for being an index on delete", + ))); + } + + // On this level we will have all the user defined values for the paths + estimated_costs_only_with_layer_info.insert( + KeyInfoPath::from_known_owned_path(index_path.clone()), + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: PotentiallyAtMaxElements, + estimated_layer_sizes: AllSubtrees( + document_top_field_estimated_size as u8, + NoSumTrees, + storage_flags.map(|s| s.serialized_size()), + ), + }, + ); + } + + let any_fields_null = document_top_field.is_empty(); + + let mut index_path_info = if document_and_contract_info + .owned_document_info + .document_info + .is_document_size() + { + // This is a stateless operation + PathInfo::PathWithSizes(KeyInfoPath::from_known_owned_path(index_path)) + } else { + PathInfo::PathIterator::<0>(index_path) + }; + + // we push the actual value of the index path + index_path_info.push(document_top_field)?; + // the index path is now something likeDataContracts/ContractID/Documents(1)/$ownerId/ + + self.add_contested_indices_for_index_level_for_contract_operations( + document_and_contract_info, + index_path_info, + sub_level, + any_fields_null, + previous_batch_operations, + &storage_flags, + estimated_costs_only_with_layer_info, + event_id, + transaction, + batch_operations, + platform_version, + )?; + } + Ok(()) + } +} diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs new file mode 100644 index 0000000000..ef0b746431 --- /dev/null +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs @@ -0,0 +1,60 @@ +mod v0; + +use crate::drive::flags::StorageFlags; + +use crate::drive::object_size_info::{DocumentAndContractInfo, PathInfo}; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use dpp::version::drive_versions::DriveVersion; + +use grovedb::batch::KeyInfoPath; + +use dpp::data_contract::document_type::IndexType; +use grovedb::{EstimatedLayerInformation, TransactionArg}; +use std::collections::HashMap; + +impl Drive { + /// Adds the terminal reference. + pub fn add_contested_reference_for_index_level_for_contract_operations( + &self, + document_and_contract_info: &DocumentAndContractInfo, + index_path_info: PathInfo<0>, + index_type: IndexType, + any_fields_null: bool, + previous_batch_operations: &mut Option<&mut Vec>, + storage_flags: &Option<&StorageFlags>, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + transaction: TransactionArg, + batch_operations: &mut Vec, + drive_version: &DriveVersion, + ) -> Result<(), Error> { + match drive_version + .methods + .document + .insert_contested + .add_contested_reference_for_index_level_for_contract_operations + { + 0 => self.add_contested_reference_for_index_level_for_contract_operations_v0( + document_and_contract_info, + index_path_info, + index_type, + any_fields_null, + previous_batch_operations, + storage_flags, + estimated_costs_only_with_layer_info, + transaction, + batch_operations, + drive_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "add_contested_reference_for_index_level_for_contract_operations".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs new file mode 100644 index 0000000000..8a790370e0 --- /dev/null +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -0,0 +1,388 @@ +use crate::drive::defaults::{DEFAULT_HASH_SIZE_U8, STORAGE_FLAGS_SIZE}; +use crate::drive::document::{document_reference_size, make_document_reference}; +use crate::drive::flags::StorageFlags; +use crate::drive::grove_operations::QueryTarget::QueryTargetValue; +use crate::drive::grove_operations::{BatchInsertApplyType, BatchInsertTreeApplyType}; +use crate::drive::object_size_info::DocumentInfo::{ + DocumentAndSerialization, DocumentEstimatedAverageSize, DocumentOwnedInfo, + DocumentRefAndSerialization, DocumentRefInfo, +}; +use crate::drive::object_size_info::DriveKeyInfo::{Key, KeyRef}; +use crate::drive::object_size_info::KeyElementInfo::{KeyElement, KeyUnknownElementSize}; +use crate::drive::object_size_info::{DocumentAndContractInfo, PathInfo, PathKeyElementInfo}; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; +use dpp::data_contract::document_type::IndexType; +use dpp::data_contract::document_type::IndexType::{ContestedResourceIndex, NonUniqueIndex}; +use dpp::document::DocumentV0Getters; +use dpp::version::drive_versions::DriveVersion; +use grovedb::batch::key_info::KeyInfo; +use grovedb::batch::KeyInfoPath; +use grovedb::EstimatedLayerCount::PotentiallyAtMaxElements; +use grovedb::EstimatedLayerSizes::{AllReference, AllSubtrees}; +use grovedb::EstimatedSumTrees::NoSumTrees; +use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; +use std::collections::HashMap; + +impl Drive { + /// Adds the terminal reference. + #[inline(always)] + pub(super) fn add_reference_for_index_level_for_contract_operations_v0( + &self, + document_and_contract_info: &DocumentAndContractInfo, + mut index_path_info: PathInfo<0>, + index_type: IndexType, + any_fields_null: bool, + previous_batch_operations: &mut Option<&mut Vec>, + storage_flags: &Option<&StorageFlags>, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + transaction: TransactionArg, + batch_operations: &mut Vec, + drive_version: &DriveVersion, + ) -> Result<(), Error> { + // unique indexes will be stored under key "0" + // non unique indices should have a tree at key "0" that has all elements based off of primary key + if index_type == NonUniqueIndex || index_type == ContestedResourceIndex || any_fields_null { + // Tree generation, this happens for both non unique indexes, unique indexes with a null inside + // a member of the path and for contested resource indexes + let key_path_info = KeyRef(&[0]); + + let path_key_info = key_path_info.add_path_info(index_path_info.clone()); + + let apply_type = if estimated_costs_only_with_layer_info.is_none() { + BatchInsertTreeApplyType::StatefulBatchInsertTree + } else { + BatchInsertTreeApplyType::StatelessBatchInsertTree { + in_tree_using_sums: false, + is_sum_tree: false, + flags_len: storage_flags + .map(|s| s.serialized_size()) + .unwrap_or_default(), + } + }; + + // Here we are inserting an empty tree that will have a subtree of all other index properties + // It is basically the 0 + // Underneath we will have all elements if non unique index, or all identity contenders if + // a contested resource index + self.batch_insert_empty_tree_if_not_exists( + path_key_info, + false, + *storage_flags, + apply_type, + transaction, + previous_batch_operations, + batch_operations, + drive_version, + )?; + + index_path_info.push(Key(vec![0]))?; + + if index_type != ContestedResourceIndex { + // This is the simpler situation + // Under each tree we have all the references + + if let Some(estimated_costs_only_with_layer_info) = + estimated_costs_only_with_layer_info + { + // On this level we will have a 0 and all the top index paths + estimated_costs_only_with_layer_info.insert( + index_path_info.clone().convert_to_key_info_path(), + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: PotentiallyAtMaxElements, + estimated_layer_sizes: AllReference( + DEFAULT_HASH_SIZE_U8, + document_reference_size(document_and_contract_info.document_type), + storage_flags.map(|s| s.serialized_size()), + ), + }, + ); + } + + let key_element_info = + match &document_and_contract_info.owned_document_info.document_info { + DocumentRefAndSerialization((document, _, storage_flags)) + | DocumentRefInfo((document, storage_flags)) => { + let document_reference = make_document_reference( + document, + document_and_contract_info.document_type, + storage_flags.as_ref().map(|flags| flags.as_ref()), + ); + KeyElement((document.id_ref().as_slice(), document_reference)) + } + DocumentOwnedInfo((document, storage_flags)) + | DocumentAndSerialization((document, _, storage_flags)) => { + let document_reference = make_document_reference( + document, + document_and_contract_info.document_type, + storage_flags.as_ref().map(|flags| flags.as_ref()), + ); + KeyElement((document.id_ref().as_slice(), document_reference)) + } + DocumentEstimatedAverageSize(max_size) => KeyUnknownElementSize(( + KeyInfo::MaxKeySize { + unique_id: document_and_contract_info + .document_type + .unique_id_for_storage() + .to_vec(), + max_size: DEFAULT_HASH_SIZE_U8, + }, + Element::required_item_space(*max_size, STORAGE_FLAGS_SIZE), + )), + }; + + let path_key_element_info = PathKeyElementInfo::from_path_info_and_key_element( + index_path_info, + key_element_info, + )?; + + // here we should return an error if the element already exists + self.batch_insert(path_key_element_info, batch_operations, drive_version)?; + } else { + // Contested Resource Index + // Under each tree we have all identifiers of identities that want the contested resource + // We get something like + // item name contested (there will be another path with item_name) + // | + // Goblet of Fire + // | + // 0 (for the termination of the index) + // / \ + // Sam's Document Id Ivan's Document Id + // / \ / \ + // 0 (ref) 1 (sum tree) 0 (ref) 1 (sum tree) + // + + // Here we are getting the document id and the reference + let (document_id, ref_key_element_info) = + match &document_and_contract_info.owned_document_info.document_info { + DocumentRefAndSerialization((document, _, storage_flags)) + | DocumentRefInfo((document, storage_flags)) => { + let document_reference = make_document_reference( + document, + document_and_contract_info.document_type, + storage_flags.as_ref().map(|flags| flags.as_ref()), + ); + (document.id(), KeyElement((&[0], document_reference))) + } + DocumentOwnedInfo((document, storage_flags)) + | DocumentAndSerialization((document, _, storage_flags)) => { + let document_reference = make_document_reference( + document, + document_and_contract_info.document_type, + storage_flags.as_ref().map(|flags| flags.as_ref()), + ); + (document.id(), KeyElement((&[0], document_reference))) + } + DocumentEstimatedAverageSize(max_size) => { + let unique_id = document_and_contract_info + .document_type + .unique_id_for_storage(); + let unique_id_vec = unique_id.to_vec(); + ( + unique_id.into(), + KeyUnknownElementSize(( + KeyInfo::MaxKeySize { + unique_id: unique_id_vec, + max_size: DEFAULT_HASH_SIZE_U8, + }, + Element::required_item_space(*max_size, STORAGE_FLAGS_SIZE), + )), + ) + } + }; + + // Let's start by inserting the document id tree + + // here we are the tree that will contain the ref + // We are inserting this at item name contested / Goblet of Fire / 0 with the key of + // document_key_path_info + + let document_id_key_path_info = KeyRef(document_id.as_slice()); + + let path_key_info = + document_id_key_path_info.add_path_info(index_path_info.clone()); + + index_path_info.push(Key(document_id.to_vec()))?; + + // We check to make sure we are not overridding the tree + let inserted = self.batch_insert_empty_tree_if_not_exists( + path_key_info, + false, + *storage_flags, + apply_type, + transaction, + previous_batch_operations, + batch_operations, + drive_version, + )?; + + if !inserted { + return Err(Error::Drive(DriveError::CorruptedContractIndexes( + "contested votes sub tree document already exists", + ))); + } + + let mut document_path_info = index_path_info.clone(); + + document_path_info.push(KeyRef(document_id.as_slice()))?; + + let votes_key_path_info = KeyRef(&[1]); + + let votes_path_key_info = + votes_key_path_info.add_path_info(document_path_info.clone()); + + if let Some(estimated_costs_only_with_layer_info) = + estimated_costs_only_with_layer_info + { + // On this level we will have a 0 and all the top index paths + estimated_costs_only_with_layer_info.insert( + index_path_info.clone().convert_to_key_info_path(), + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: PotentiallyAtMaxElements, + estimated_layer_sizes: AllSubtrees( + DEFAULT_HASH_SIZE_U8, + NoSumTrees, + storage_flags.map(|s| s.serialized_size()), + ), + }, + ); + + // On this level we will have a 0 and all the top index paths + estimated_costs_only_with_layer_info.insert( + votes_path_key_info.clone().convert_to_key_info_path()?, + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: PotentiallyAtMaxElements, + estimated_layer_sizes: AllSubtrees( + DEFAULT_HASH_SIZE_U8, + NoSumTrees, + storage_flags.map(|s| s.serialized_size()), + ), + }, + ); + } + + let reference_path_key_element_info = + PathKeyElementInfo::from_path_info_and_key_element( + document_path_info.clone(), + ref_key_element_info, + )?; + + // here we are inserting the ref + self.batch_insert( + reference_path_key_element_info, + batch_operations, + drive_version, + )?; + + let apply_type = if estimated_costs_only_with_layer_info.is_none() { + BatchInsertTreeApplyType::StatefulBatchInsertTree + } else { + BatchInsertTreeApplyType::StatelessBatchInsertTree { + in_tree_using_sums: false, + is_sum_tree: true, + flags_len: storage_flags + .map(|s| s.serialized_size()) + .unwrap_or_default(), + } + }; + + // here we are the tree that will contain the voting tree + let inserted = self.batch_insert_empty_tree_if_not_exists( + votes_path_key_info, + true, + *storage_flags, + apply_type, + transaction, + &mut None, + batch_operations, + drive_version, + )?; + + if !inserted { + return Err(Error::Drive(DriveError::CorruptedContractIndexes( + "contested votes tree already exists", + ))); + } + + // Now we need to add a reference to this votes, so we can keep track of it more easily + + // self.add_new_masternode_vote_type() + } + } else { + let key_element_info = + match &document_and_contract_info.owned_document_info.document_info { + DocumentRefAndSerialization((document, _, storage_flags)) + | DocumentRefInfo((document, storage_flags)) => { + let document_reference = make_document_reference( + document, + document_and_contract_info.document_type, + storage_flags.as_ref().map(|flags| flags.as_ref()), + ); + KeyElement((&[0], document_reference)) + } + DocumentOwnedInfo((document, storage_flags)) + | DocumentAndSerialization((document, _, storage_flags)) => { + let document_reference = make_document_reference( + document, + document_and_contract_info.document_type, + storage_flags.as_ref().map(|flags| flags.as_ref()), + ); + KeyElement((&[0], document_reference)) + } + DocumentEstimatedAverageSize(estimated_size) => KeyUnknownElementSize(( + KeyInfo::MaxKeySize { + unique_id: document_and_contract_info + .document_type + .unique_id_for_storage() + .to_vec(), + max_size: 1, + }, + Element::required_item_space(*estimated_size, STORAGE_FLAGS_SIZE), + )), + }; + + let path_key_element_info = PathKeyElementInfo::from_path_info_and_key_element( + index_path_info, + key_element_info, + )?; + + let apply_type = if estimated_costs_only_with_layer_info.is_none() { + BatchInsertApplyType::StatefulBatchInsert + } else { + BatchInsertApplyType::StatelessBatchInsert { + in_tree_using_sums: false, + target: QueryTargetValue( + document_reference_size(document_and_contract_info.document_type) + + storage_flags + .map(|s| s.serialized_size()) + .unwrap_or_default(), + ), + } + }; + + // here we should return an error if the element already exists + let inserted = self.batch_insert_if_not_exists( + path_key_element_info, + apply_type, + transaction, + batch_operations, + drive_version, + )?; + if !inserted { + return Err(Error::Drive(DriveError::CorruptedContractIndexes( + "reference already exists", + ))); + } + } + Ok(()) + } +} diff --git a/packages/rs-drive/src/drive/document/insert_contested/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/mod.rs new file mode 100644 index 0000000000..f3cd5e798e --- /dev/null +++ b/packages/rs-drive/src/drive/document/insert_contested/mod.rs @@ -0,0 +1,144 @@ +//! Insert Documents. +//! +//! This module implements functions in Drive relevant to inserting documents. +//! + +// Module: add_contested_document +// This module contains functionality for adding a document +mod add_contested_document; + +// Module: add_contested_document_for_contract +// This module contains functionality for adding a document for a given contract +mod add_contested_document_for_contract; + +// Module: add_contested_document_for_contract_apply_and_add_to_operations +// This module contains functionality for applying and adding operations for a contract document +mod add_contested_document_for_contract_apply_and_add_to_operations; + +// Module: add_contested_document_for_contract_operations +// This module contains functionality for adding a document for contract operations +mod add_contested_document_for_contract_operations; + +// Module: add_contested_document_to_primary_storage +// This module contains functionality for adding a document to primary storage +mod add_contested_document_to_primary_storage; + +// Module: add_contested_indices_for_index_level_for_contract_operations +// This module contains functionality for adding indices for an index level for contract operations +mod add_contested_indices_for_index_level_for_contract_operations; + +// Module: add_contested_indices_for_top_index_level_for_contract_operations +// This module contains functionality for adding indices for the top index level for contract operations +mod add_contested_indices_for_top_index_level_for_contract_operations; + +// Module: add_contested_reference_for_index_level_for_contract_operations +// This module contains functionality for adding a reference for an index level for contract operations +mod add_contested_reference_for_index_level_for_contract_operations; + +#[cfg(all( + feature = "fixtures-and-mocks", + feature = "data-contract-cbor-conversion" +))] +use dpp::data_contract::conversion::cbor::DataContractCborConversionMethodsV0; + +#[cfg(test)] +mod tests { + use std::borrow::Cow; + use std::option::Option::None; + + use dpp::block::block_info::BlockInfo; + use rand::{random, Rng}; + + use crate::common::setup_contract; + use crate::drive::document::tests::setup_dashpay; + use crate::drive::flags::StorageFlags; + use crate::drive::object_size_info::{DocumentAndContractInfo, OwnedDocumentInfo}; + use crate::fee::op::LowLevelDriveOperation; + + use dpp::block::epoch::Epoch; + use dpp::data_contract::accessors::v0::DataContractV0Getters; + use dpp::document::Document; + + use crate::drive::object_size_info::DocumentInfo::DocumentRefInfo; + use crate::tests::helpers::setup::setup_drive_with_initial_state_structure; + use dpp::document::serialization_traits::DocumentCborMethodsV0; + use dpp::fee::default_costs::EpochCosts; + use dpp::fee::default_costs::KnownCostItem::StorageDiskUsageCreditPerByte; + use dpp::fee::fee_result::FeeResult; + use dpp::tests::fixtures::get_dpns_data_contract_fixture; + use dpp::tests::json_document::json_document_to_document; + use dpp::version::PlatformVersion; + + #[test] + fn test_add_dashpay_conflicting_unique_index_documents() { + let (drive, dashpay) = setup_dashpay("add_conflict", true); + + let document_type = dashpay + .document_type_for_name("contactRequest") + .expect("expected to get document type"); + + let random_owner_id = random::<[u8; 32]>(); + + let platform_version = PlatformVersion::first(); + + let dashpay_cr_document_0 = json_document_to_document( + "tests/supporting_files/contract/dashpay/contact-request0.json", + Some(random_owner_id.into()), + document_type, + platform_version, + ) + .expect("expected to get cbor document"); + + let dashpay_cr_document_0_dup = json_document_to_document( + "tests/supporting_files/contract/dashpay/contact-request0-dup-unique-index.json", + Some(random_owner_id.into()), + document_type, + platform_version, + ) + .expect("expected to get cbor document"); + + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentRefInfo(( + &dashpay_cr_document_0, + StorageFlags::optional_default_as_cow(), + )), + owner_id: None, + }, + contract: &dashpay, + document_type, + }, + false, + BlockInfo::default(), + true, + None, + platform_version, + ) + .expect("expected to insert a document successfully"); + + drive + .add_document_for_contract( + DocumentAndContractInfo { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentRefInfo(( + &dashpay_cr_document_0_dup, + StorageFlags::optional_default_as_cow(), + )), + owner_id: None, + }, + contract: &dashpay, + document_type, + }, + false, + BlockInfo::default(), + true, + None, + platform_version, + ) + .expect_err( + "expected not to be able to insert document with already existing unique index", + ); + } +} diff --git a/packages/rs-drive/src/drive/document/mod.rs b/packages/rs-drive/src/drive/document/mod.rs index 3ec1f37714..d378a61260 100644 --- a/packages/rs-drive/src/drive/document/mod.rs +++ b/packages/rs-drive/src/drive/document/mod.rs @@ -64,6 +64,8 @@ mod index_uniqueness; #[cfg(any(feature = "server", feature = "fixtures-and-mocks"))] mod insert; #[cfg(any(feature = "server", feature = "fixtures-and-mocks"))] +mod insert_contested; +#[cfg(any(feature = "server", feature = "fixtures-and-mocks"))] pub mod query; #[cfg(any(feature = "server", feature = "fixtures-and-mocks"))] mod update; diff --git a/packages/rs-drive/src/drive/object_size_info/document_and_contract_info.rs b/packages/rs-drive/src/drive/object_size_info/document_and_contract_info.rs index cee140732b..531e32a22c 100644 --- a/packages/rs-drive/src/drive/object_size_info/document_and_contract_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/document_and_contract_info.rs @@ -1,6 +1,8 @@ +use std::sync::Arc; use crate::drive::object_size_info::OwnedDocumentInfo; use dpp::data_contract::document_type::DocumentTypeRef; use dpp::data_contract::DataContract; +use crate::drive::contract::DataContractFetchInfo; /// Document and contract info #[derive(Clone, Debug)] diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs index 188fd74707..073fbba093 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs @@ -11,10 +11,10 @@ use crate::query::QueryItem; use dpp::prelude::Identifier; use dpp::serialization::PlatformDeserializable; use dpp::version::PlatformVersion; -use dpp::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; use grovedb::query_result_type::QueryResultType::QueryElementResultType; use grovedb::{Element, PathQuery, Query, SizedQuery, TransactionArg}; use grovedb_path::SubtreePath; +use dpp::voting::votes::Vote; impl Drive { /// We remove vote_choices for an identity when that identity is somehow disabled. Currently there is @@ -63,7 +63,7 @@ impl Drive { )))); }; - let vote = ContestedDocumentResourceVote::deserialize_from_bytes(vote.as_slice())?; + let vote = Vote::deserialize_from_bytes(vote.as_slice())?; // we then need to add to the batch the deletion diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs index 5083dfda2f..a1497e7965 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs @@ -12,14 +12,14 @@ use dpp::fee::fee_result::FeeResult; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; -use dpp::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; +use dpp::voting::votes::resource_vote::ResourceVote; use grovedb::{EstimatedLayerInformation, TransactionArg}; impl Drive { pub fn register_contested_resource_identity_vote( &self, voter_pro_tx_hash: [u8; 32], - vote: ContestedDocumentResourceVote, + vote: ResourceVote, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, @@ -51,7 +51,7 @@ impl Drive { pub fn register_contested_resource_identity_vote_operations( &self, voter_pro_tx_hash: [u8; 32], - vote: ContestedDocumentResourceVote, + vote: ResourceVote, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< HashMap, diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index 56258c1385..5a4ccce77f 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -4,8 +4,8 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; -use dpp::voting::votes::contested_document_resource_vote::accessors::v0::ContestedDocumentResourceVoteGettersV0; -use dpp::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; +use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; +use dpp::voting::votes::resource_vote::ResourceVote; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use platform_version::version::PlatformVersion; @@ -15,7 +15,7 @@ impl Drive { pub fn register_contested_resource_identity_vote_v0( &self, voter_pro_tx_hash: [u8; 32], - vote: ContestedDocumentResourceVote, + vote: ResourceVote, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, @@ -40,7 +40,7 @@ impl Drive { pub fn register_contested_resource_identity_vote_operations_v0( &self, voter_pro_tx_hash: [u8; 32], - vote: ContestedDocumentResourceVote, + vote: ResourceVote, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< HashMap, diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs index 47752fdb6a..90758df3bf 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs @@ -9,7 +9,7 @@ use platform_version::version::PlatformVersion; impl Drive { /// We add votes poll references by end date in order to be able to check on every new block if - /// any votes poll should be closed. + /// any vote polls should be closed. pub(super) fn add_vote_poll_end_date_query_v0( &self, contract_id: Vote, diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs index ae77c6aef8..4222b95a3c 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs @@ -20,7 +20,7 @@ impl Drive { platform_version: &PlatformVersion, ) -> Result { match vote { - Vote::ContestedDocumentResourceVote(contested_document_resource_vote_type) => self + Vote::ResourceVote(contested_document_resource_vote_type) => self .register_contested_resource_identity_vote( voter_pro_tx_hash, contested_document_resource_vote_type, @@ -44,7 +44,7 @@ impl Drive { platform_version: &PlatformVersion, ) -> Result, Error> { match vote { - Vote::ContestedDocumentResourceVote(contested_document_resource_vote_type) => self + Vote::ResourceVote(contested_document_resource_vote_type) => self .register_contested_resource_identity_vote_operations( voter_pro_tx_hash, contested_document_resource_vote_type, diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 6f6ddae532..f88778f1f3 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -3,15 +3,17 @@ use crate::drive::RootTree; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::DataContract; -use dpp::voting::votes::contested_document_resource_vote::accessors::v0::ContestedDocumentResourceVoteGettersV0; -use dpp::voting::votes::contested_document_resource_vote::ContestedDocumentResourceVote; +use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; +use dpp::voting::votes::resource_vote::ResourceVote; use dpp::ProtocolError; +use dpp::voting::vote_polls::VotePoll; +use dpp::voting::votes::Vote; mod cleanup; mod insert; mod setup; -/// The votes tree structure looks likes this +/// The votes tree structure looks like this /// /// Votes /// @@ -128,51 +130,63 @@ pub trait TreePath { fn tree_path(&self, contract: &DataContract) -> Result, ProtocolError>; } -impl TreePath for ContestedDocumentResourceVote { +impl TreePath for Vote { + fn tree_path(&self, contract: &DataContract) -> Result, ProtocolError> { + match self { Vote::ResourceVote(resource_vote) => { + resource_vote.tree_path(contract) + } } + } +} + +impl TreePath for ResourceVote { fn tree_path(&self, contract: &DataContract) -> Result, ProtocolError> { let vote_poll = self.vote_poll(); - if contract.id() != vote_poll.contract_id { - return Err(ProtocolError::VoteError(format!( - "contract id of votes {} does not match supplied contract {}", - self.vote_poll().contract_id, - contract.id() - ))); - } - let document_type = contract.document_type_for_name(&vote_poll.document_type_name)?; - let index = document_type.indexes().get(&vote_poll.index_name).ok_or( - ProtocolError::UnknownContestedIndexResolution(format!( - "no index named {} for document type {} on contract with id {}", - &vote_poll.index_name, - document_type.name(), - contract.id() - )), - )?; - let mut path = contract_document_type_path( - &vote_poll.contract_id.as_bytes(), - &vote_poll.document_type_name, - ) - .to_vec(); - - // at this point the path only contains the parts before the index - - let Some(contested_index) = &index.contested_index else { - return Err(ProtocolError::VoteError( - "we expect the index in a contested document resource votes type to be contested" - .to_string(), - )); - }; - - let mut properties_iter = index.properties.iter(); - - while let Some(index_part) = properties_iter.next() { - let level_name = if contested_index.contested_field_name == index_part.name { - &contested_index.contested_field_temp_replacement_name - } else { - &index_part.name + + match vote_poll { VotePoll::ContestedDocumentResourceVotePoll(contested_document_vote_poll) => { + if contract.id() != contested_document_vote_poll.contract_id { + return Err(ProtocolError::VoteError(format!( + "contract id of votes {} does not match supplied contract {}", + contested_document_vote_poll.contract_id, + contract.id() + ))); + } + let document_type = contract.document_type_for_name(&contested_document_vote_poll.document_type_name)?; + let index = document_type.indexes().get(&contested_document_vote_poll.index_name).ok_or( + ProtocolError::UnknownContestedIndexResolution(format!( + "no index named {} for document type {} on contract with id {}", + &contested_document_vote_poll.index_name, + document_type.name(), + contract.id() + )), + )?; + let mut path = contract_document_type_path( + &contested_document_vote_poll.contract_id.as_bytes(), + &contested_document_vote_poll.document_type_name, + ) + .to_vec(); + + // at this point the path only contains the parts before the index + + let Some(contested_index) = &index.contested_index else { + return Err(ProtocolError::VoteError( + "we expect the index in a contested document resource votes type to be contested" + .to_string(), + )); }; - path.push(level_name.as_bytes()); - } - Ok(path) + let mut properties_iter = index.properties.iter(); + + while let Some(index_part) = properties_iter.next() { + let level_name = if contested_index.contested_field_name == index_part.name { + &contested_index.contested_field_temp_replacement_name + } else { + &index_part.name + }; + + path.push(level_name.as_bytes()); + } + Ok(path) + } } + } } diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index ed2717b5a9..2e2190d4ae 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -273,6 +273,7 @@ pub struct DriveDocumentMethodVersions { pub query: DriveDocumentQueryMethodVersions, pub delete: DriveDocumentDeleteMethodVersions, pub insert: DriveDocumentInsertMethodVersions, + pub insert_contested: DriveDocumentInsertContestedMethodVersions, pub update: DriveDocumentUpdateMethodVersions, pub estimation_costs: DriveDocumentEstimationCostsMethodVersions, pub index_uniqueness: DriveDocumentIndexUniquenessMethodVersions, @@ -301,6 +302,18 @@ pub struct DriveDocumentInsertMethodVersions { pub add_reference_for_index_level_for_contract_operations: FeatureVersion, } +#[derive(Clone, Debug, Default)] +pub struct DriveDocumentInsertContestedMethodVersions { + pub add_contested_document: FeatureVersion, + pub add_contested_document_for_contract: FeatureVersion, + pub add_contested_document_for_contract_apply_and_add_to_operations: FeatureVersion, + pub add_contested_document_for_contract_operations: FeatureVersion, + pub add_contested_document_to_primary_storage: FeatureVersion, + pub add_contested_indices_for_index_level_for_contract_operations: FeatureVersion, + pub add_contested_indices_for_top_index_level_for_contract_operations: FeatureVersion, + pub add_contested_reference_for_index_level_for_contract_operations: FeatureVersion, +} + #[derive(Clone, Debug, Default)] pub struct DriveDocumentUpdateMethodVersions { pub add_update_multiple_documents_operations: FeatureVersion, From d9c413a05bea61d974f2c712f89f85fd1a2f9134 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 8 May 2024 00:37:40 +0200 Subject: [PATCH 036/135] a lot more work --- .../src/drive/batch/drive_op_batch/mod.rs | 13 ++++ .../prefunded_specialized_balance.rs | 57 +++++++++++++++++ .../document/document_create_transition.rs | 35 +++++++++-- .../src/drive/initialization/v0/mod.rs | 2 +- packages/rs-drive/src/drive/mod.rs | 2 +- .../add_prefunded_specialized_balance/mod.rs | 48 ++++++++++++++ .../v0/mod.rs | 51 +++++++++++++++ .../mod.rs | 54 ++++++++++++++++ .../v0/mod.rs | 63 +++++++++++++++++++ .../mod.rs | 46 ++++++++++++++ .../v0/mod.rs | 0 .../mod.rs | 1 + .../v0/mod.rs | 0 .../mod.rs | 7 ++- .../src/version/drive_versions.rs | 9 +++ 15 files changed, 379 insertions(+), 9 deletions(-) create mode 100644 packages/rs-drive/src/drive/batch/drive_op_batch/prefunded_specialized_balance.rs create mode 100644 packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance/mod.rs create mode 100644 packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/mod.rs create mode 100644 packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/mod.rs create mode 100644 packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/mod.rs create mode 100644 packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/v0/mod.rs rename packages/rs-drive/src/drive/{pre_funded_specialized_balances => prefunded_specialized_balances}/mod.rs (76%) diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/mod.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/mod.rs index a7095f2b6f..fe91c7c488 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/mod.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/mod.rs @@ -5,6 +5,7 @@ mod finalize_task; mod identity; mod system; mod withdrawals; +mod prefunded_specialized_balance; use crate::drive::batch::GroveDbOpBatch; @@ -34,6 +35,7 @@ use crate::drive::batch::drive_op_batch::finalize_task::{ }; use crate::error::drive::DriveError; use std::collections::{BTreeMap, HashMap}; +use crate::drive::batch::drive_op_batch::prefunded_specialized_balance::PrefundedSpecializedBalanceOperationType; /// A converter that will get Drive Operations from High Level Operations pub trait DriveLowLevelOperationConverter { @@ -70,6 +72,8 @@ pub enum DriveOperation<'a> { WithdrawalOperation(WithdrawalOperationType), /// An identity operation IdentityOperation(IdentityOperationType), + /// An operation on prefunded balances + PrefundedSpecializedBalanceOperationType(PrefundedSpecializedBalanceOperationType), /// A system operation SystemOperation(SystemOperationType), /// A single low level groveDB operation @@ -124,6 +128,14 @@ impl DriveLowLevelOperationConverter for DriveOperation<'_> { transaction, platform_version, ), + DriveOperation::PrefundedSpecializedBalanceOperationType(prefunded_balance_operation_type) => prefunded_balance_operation_type + .into_low_level_drive_operations( + drive, + estimated_costs_only_with_layer_info, + block_info, + transaction, + platform_version, + ), DriveOperation::SystemOperation(system_operation_type) => system_operation_type .into_low_level_drive_operations( drive, @@ -138,6 +150,7 @@ impl DriveLowLevelOperationConverter for DriveOperation<'_> { .into_iter() .map(GroveOperation) .collect()), + } } } diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/prefunded_specialized_balance.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/prefunded_specialized_balance.rs new file mode 100644 index 0000000000..c0209f7f34 --- /dev/null +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/prefunded_specialized_balance.rs @@ -0,0 +1,57 @@ +use std::collections::HashMap; +use grovedb::batch::KeyInfoPath; +use grovedb::{EstimatedLayerInformation, TransactionArg}; +use dpp::block::block_info::BlockInfo; +use dpp::identifier::Identifier; +use platform_version::version::PlatformVersion; +use crate::drive::batch::drive_op_batch::DriveLowLevelOperationConverter; +use crate::drive::Drive; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; + +/// Operations on Prefunded balances +#[derive(Clone, Debug)] +pub enum PrefundedSpecializedBalanceOperationType { + /// Adds balance to an identity + CreateNewPrefundedBalance { + /// The id of the prefunded balance + prefunded_balance_id: Identifier, + /// The added balance + added_balance: u64, + }, + /// Adds balance to an identity + DeductFromPrefundedBalance { + /// The identity id of the identity + prefunded_balance_id: Identifier, + /// The removed balance + removed_balance: u64, + }, +} + +impl DriveLowLevelOperationConverter for PrefundedSpecializedBalanceOperationType { + fn into_low_level_drive_operations( + self, + drive: &Drive, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + block_info: &BlockInfo, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + match self { + PrefundedSpecializedBalanceOperationType::CreateNewPrefundedBalance { + prefunded_balance_id, added_balance + } => drive.add_new_identity_operations( + identity, + is_masternode_identity, + block_info, + &mut None, + estimated_costs_only_with_layer_info, + transaction, + platform_version, + ), + PrefundedSpecializedBalanceOperationType::DeductFromPrefundedBalance { prefunded_balance_id, removed_balance } => {} + } + } +} \ No newline at end of file diff --git a/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs b/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs index 56d3db6c7e..93d0f55122 100644 --- a/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs +++ b/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs @@ -29,19 +29,40 @@ impl DriveHighLevelDocumentOperationConverter for DocumentCreateTransitionAction let document_type_name = self.base().document_type_name().clone(); let identity_contract_nonce = self.base().identity_contract_nonce(); + + let prefunded_voting_balances = self.prefunded_voting_balances(); let document = Document::try_from_owned_create_transition_action(self, owner_id, platform_version)?; let storage_flags = StorageFlags::new_single_epoch(epoch.index, Some(owner_id.to_buffer())); - - Ok(vec![ + + let mut ops = vec![ IdentityOperation(IdentityOperationType::UpdateIdentityContractNonce { identity_id: owner_id.into_buffer(), contract_id: data_contract_id.into_buffer(), nonce: identity_contract_nonce, - }), - DocumentOperation(DocumentOperationType::AddDocument { + })]; + + if prefunded_voting_balances.is_empty() { + // Just add the document + ops.push(DocumentOperation(DocumentOperationType::AddDocument { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentOwnedInfo((document, Some(Cow::Owned(storage_flags)))), + owner_id: Some(owner_id.into_buffer()), + }, + contract_info: DataContractFetchInfo(contract_fetch_info), + document_type_info: DocumentTypeInfo::DocumentTypeName(document_type_name), + override_document: false, + })); + } else { + // We are in the situation of a contested document + // We prefund the voting balances first + ops.push(); + // We add the contested document + // The contested document resides in a special location in grovedb until a time where the + // resolution expires, at that point it either will be moved to + ops.push(DocumentOperation(DocumentOperationType::AddContestedDocument { owned_document_info: OwnedDocumentInfo { document_info: DocumentOwnedInfo((document, Some(Cow::Owned(storage_flags)))), owner_id: Some(owner_id.into_buffer()), @@ -49,7 +70,9 @@ impl DriveHighLevelDocumentOperationConverter for DocumentCreateTransitionAction contract_info: DataContractFetchInfo(contract_fetch_info), document_type_info: DocumentTypeInfo::DocumentTypeName(document_type_name), override_document: false, - }), - ]) + })); + } + + Ok(ops) } } diff --git a/packages/rs-drive/src/drive/initialization/v0/mod.rs b/packages/rs-drive/src/drive/initialization/v0/mod.rs index 4030da96d8..7060a3e17f 100644 --- a/packages/rs-drive/src/drive/initialization/v0/mod.rs +++ b/packages/rs-drive/src/drive/initialization/v0/mod.rs @@ -176,7 +176,7 @@ impl Drive { Drive::add_initial_fork_update_structure_operations(&mut batch); // Pre funded specialized balances tree - Drive::add_initial_pre_funded_specialized_balances_operations(&mut batch); + Drive::add_initial_prefunded_specialized_balances_operations(&mut batch); // For the votes tree structure Drive::add_initial_vote_tree_main_structure_operations(&mut batch, platform_version)?; diff --git a/packages/rs-drive/src/drive/mod.rs b/packages/rs-drive/src/drive/mod.rs index f58b5261f6..42d9954ccb 100644 --- a/packages/rs-drive/src/drive/mod.rs +++ b/packages/rs-drive/src/drive/mod.rs @@ -89,7 +89,7 @@ mod open; mod operations; #[cfg(feature = "server")] mod platform_state; -mod pre_funded_specialized_balances; +mod prefunded_specialized_balances; #[cfg(feature = "server")] mod prove; /// Contains a set of useful grovedb proof verification functions diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance/mod.rs new file mode 100644 index 0000000000..afcb6be380 --- /dev/null +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance/mod.rs @@ -0,0 +1,48 @@ +mod v0; + +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; + +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; +use dpp::identifier::Identifier; + +impl Drive { + /// Adds a new prefunded specialized balance + /// + /// # Arguments + /// + /// * `amount` - The amount of credits to be added to the prefunded balance. + /// * `transaction` - A `TransactionArg` object representing the transaction to be used for adding to the system credits. + /// * `platform_version` - A `PlatformVersion` object specifying the version of Platform. + /// + /// # Returns + /// + /// * `Result<(), Error>` - If successful, returns `Ok(())`. If an error occurs during the operation, returns an `Error`. + /// + /// # Errors + /// + /// This function will return an error if the version of Platform is unknown. + pub fn add_prefunded_specialized_balance( + &self, + specialized_balance_id: Identifier, + amount: u64, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive + .methods + .prefunded_specialized_balances + .add_prefunded_specialized_balance + { + 0 => self.add_prefunded_specialized_balance_v0(specialized_balance_id, amount, transaction, platform_version), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "add_prefunded_specialized_balance".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance/v0/mod.rs new file mode 100644 index 0000000000..5e68ec2d8a --- /dev/null +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance/v0/mod.rs @@ -0,0 +1,51 @@ +use crate::drive::Drive; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; + +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; +use dpp::identifier::Identifier; + +impl Drive { + /// Adds a new prefunded specialized balance + /// + /// # Arguments + /// + /// * `amount` - The amount of credits to be added to the prefunded balance. + /// * `transaction` - A `TransactionArg` object representing the transaction to be used for adding to the system credits. + /// * `platform_version` - A `PlatformVersion` object specifying the version of Platform. + /// + /// # Returns + /// + /// * `Result<(), Error>` - If successful, returns `Ok(())`. If an error occurs during the operation, returns an `Error`. + /// + /// # Errors + /// + /// This function will return an error if the version of Platform is unknown. + #[inline(always)] + pub(super) fn add_prefunded_specialized_balance_v0( + &self, + specialized_balance_id: Identifier, + amount: u64, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + let mut drive_operations = vec![]; + let batch_operations = self.add_prefunded_specialized_balance_operations( + specialized_balance_id, + amount, + &mut None, + transaction, + platform_version, + )?; + let grove_db_operations = + LowLevelDriveOperation::grovedb_operations_batch(&batch_operations); + self.grove_apply_batch_with_add_costs( + grove_db_operations, + false, + transaction, + &mut drive_operations, + &platform_version.drive, + ) + } +} diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/mod.rs new file mode 100644 index 0000000000..9100524b3f --- /dev/null +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/mod.rs @@ -0,0 +1,54 @@ +mod v0; + +use std::collections::HashMap; +use grovedb::batch::KeyInfoPath; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; + +use dpp::version::PlatformVersion; +use grovedb::{EstimatedLayerInformation, TransactionArg}; +use dpp::identifier::Identifier; +use crate::fee::op::LowLevelDriveOperation; + +impl Drive { + /// Adds a new prefunded specialized balance + /// + /// # Arguments + /// + /// * `amount` - The amount of credits to be added to the prefunded balance. + /// * `transaction` - A `TransactionArg` object representing the transaction to be used for adding to the system credits. + /// * `platform_version` - A `PlatformVersion` object specifying the version of Platform. + /// + /// # Returns + /// + /// * `Result<(), Error>` - If successful, returns `Ok(())`. If an error occurs during the operation, returns an `Error`. + /// + /// # Errors + /// + /// This function will return an error if the version of Platform is unknown. + pub fn add_prefunded_specialized_balance_operations( + &self, + specialized_balance_id: Identifier, + amount: u64, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + match platform_version + .drive + .methods + .prefunded_specialized_balances + .add_prefunded_specialized_balance_operations + { + 0 => self.add_prefunded_specialized_balance_operations_v0(specialized_balance_id, amount, estimated_costs_only_with_layer_info, transaction, platform_version), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "add_prefunded_specialized_balance_operations".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/v0/mod.rs new file mode 100644 index 0000000000..3666849e9a --- /dev/null +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/v0/mod.rs @@ -0,0 +1,63 @@ +use crate::drive::grove_operations::DirectQueryType; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use crate::fee::op::LowLevelDriveOperation::GroveOperation; + +use dpp::version::PlatformVersion; +use grovedb::batch::{GroveDbOp, KeyInfoPath}; +use grovedb::Element::Item; +use grovedb::{EstimatedLayerInformation, TransactionArg}; +use integer_encoding::VarInt; +use std::collections::HashMap; +use dpp::identifier::Identifier; + +impl Drive { + /// The operations to add to the specialized balance + #[inline(always)] + pub(super) fn add_prefunded_specialized_balance_operations_v0( + &self, + specialized_balance_id: Identifier, + amount: u64, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let mut drive_operations = vec![]; + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { + Self::add_estimation_costs_for_total_system_credits_update( + estimated_costs_only_with_layer_info, + &platform_version.drive, + )?; + } + let path_holding_specialized_balances = misc_path(); + let total_credits_in_platform = self + .grove_get_raw_value_u64_from_encoded_var_vec( + (&path_holding_total_credits).into(), + TOTAL_SYSTEM_CREDITS_STORAGE_KEY, + DirectQueryType::StatefulDirectQuery, + transaction, + &mut drive_operations, + &platform_version.drive, + )? + .ok_or(Error::Drive(DriveError::CriticalCorruptedState( + "Credits not found in Platform", + )))?; + let new_total = total_credits_in_platform + .checked_add(amount) + .ok_or(Error::Drive(DriveError::CriticalCorruptedState( + "trying to add an amount that would overflow credits", + )))?; + let path_holding_total_credits_vec = misc_path_vec(); + let replace_op = GroveDbOp::replace_op( + path_holding_total_credits_vec, + TOTAL_SYSTEM_CREDITS_STORAGE_KEY.to_vec(), + Item(new_total.encode_var_vec(), None), + ); + drive_operations.push(GroveOperation(replace_op)); + Ok(drive_operations) + } +} diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/mod.rs new file mode 100644 index 0000000000..7d6bea6d2e --- /dev/null +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/mod.rs @@ -0,0 +1,46 @@ +mod v0; + +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; + +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +impl Drive { + /// Deducts from a prefunded specialized balance + /// + /// # Arguments + /// + /// * `amount` - The amount of credits to be removed from the prefunded balance. + /// * `transaction` - A `TransactionArg` object representing the transaction to be used for adding to the system credits. + /// * `platform_version` - A `PlatformVersion` object specifying the version of Platform. + /// + /// # Returns + /// + /// * `Result<(), Error>` - If successful, returns `Ok(())`. If an error occurs during the operation, returns an `Error`. + /// + /// # Errors + /// + /// This function will return an error if the version of Platform is unknown. + pub fn deduct_from_prefunded_specialized_balance( + &self, + amount: u64, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive + .methods + .prefunded_specialized_balances + .deduct_from_prefunded_specialized_balance + { + 0 => self.deduct_from_prefunded_specialized_balance_v0(amount, transaction, platform_version), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "deduct_from_prefunded_specialized_balance".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/v0/mod.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/mod.rs new file mode 100644 index 0000000000..7affabc980 --- /dev/null +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/mod.rs @@ -0,0 +1 @@ +mod v0; \ No newline at end of file diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/v0/mod.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/rs-drive/src/drive/pre_funded_specialized_balances/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs similarity index 76% rename from packages/rs-drive/src/drive/pre_funded_specialized_balances/mod.rs rename to packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs index 88d0cc60ec..81c41fbd0b 100644 --- a/packages/rs-drive/src/drive/pre_funded_specialized_balances/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs @@ -1,3 +1,8 @@ +mod add_prefunded_specialized_balance; +mod deduct_from_prefunded_specialized_balance; +mod add_prefunded_specialized_balance_operations; +mod deduct_from_prefunded_specialized_balance_operations; + use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; use crate::drive::batch::GroveDbOpBatch; use crate::drive::{Drive, RootTree}; @@ -12,7 +17,7 @@ impl Drive { /// For example let's say you make a food delivery app, and you want to pay for when your /// customers make an order, the restaurant or food delivery app might prepay for all documents /// that make an order - pub fn add_initial_pre_funded_specialized_balances_operations(batch: &mut GroveDbOpBatch) { + pub fn add_initial_prefunded_specialized_balances_operations(batch: &mut GroveDbOpBatch) { batch.add_insert_empty_sum_tree( vec![vec![RootTree::PreFundedSpecializedBalances as u8]], PREFUNDED_BALANCES_FOR_VOTING.to_vec(), diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 2e2190d4ae..cd23f5618c 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -18,6 +18,7 @@ pub struct DriveMethodVersions { pub initialization: DriveInitializationMethodVersions, pub credit_pools: DriveCreditPoolMethodVersions, pub protocol_upgrade: DriveProtocolUpgradeVersions, + pub prefunded_specialized_balances: DrivePrefundedSpecializedMethodVersions, pub balances: DriveBalancesMethodVersions, pub document: DriveDocumentMethodVersions, pub vote: DriveVoteMethodVersions, @@ -134,6 +135,14 @@ pub struct DriveGroveMethodVersions { pub costs: DriveGroveCostMethodVersions, } +#[derive(Clone, Debug, Default)] +pub struct DrivePrefundedSpecializedMethodVersions { + pub add_prefunded_specialized_balance: FeatureVersion, + pub add_prefunded_specialized_balance_operations: FeatureVersion, + pub deduct_from_prefunded_specialized_balance: FeatureVersion, + pub deduct_from_prefunded_specialized_balance_operations: FeatureVersion, +} + #[derive(Clone, Debug, Default)] pub struct DriveBalancesMethodVersions { pub add_to_system_credits: FeatureVersion, From b5a8ff33a8011c652d9fd6bcea3d209bad1814ac Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 8 May 2024 09:56:30 +0200 Subject: [PATCH 037/135] more work --- .../v0/mod.rs | 39 ++++++++------ .../mod.rs | 4 +- .../v0/mod.rs | 51 +++++++++++++++++++ .../prefunded_specialized_balances/mod.rs | 14 +++++ 4 files changed, 91 insertions(+), 17 deletions(-) diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/v0/mod.rs index 3666849e9a..ca8156c95c 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/v0/mod.rs @@ -12,6 +12,7 @@ use grovedb::{EstimatedLayerInformation, TransactionArg}; use integer_encoding::VarInt; use std::collections::HashMap; use dpp::identifier::Identifier; +use crate::drive::prefunded_specialized_balances::{prefunded_specialized_balances_for_voting_path, prefunded_specialized_balances_for_voting_path_vec}; impl Drive { /// The operations to add to the specialized balance @@ -33,31 +34,37 @@ impl Drive { &platform_version.drive, )?; } - let path_holding_specialized_balances = misc_path(); - let total_credits_in_platform = self + let path_holding_specialized_balances = prefunded_specialized_balances_for_voting_path(); + let previous_credits_in_specialized_balance = self .grove_get_raw_value_u64_from_encoded_var_vec( - (&path_holding_total_credits).into(), - TOTAL_SYSTEM_CREDITS_STORAGE_KEY, + (&path_holding_specialized_balances).into(), + specialized_balance_id.as_slice(), DirectQueryType::StatefulDirectQuery, transaction, &mut drive_operations, &platform_version.drive, - )? - .ok_or(Error::Drive(DriveError::CriticalCorruptedState( - "Credits not found in Platform", - )))?; - let new_total = total_credits_in_platform + )?; + let had_previous_balance = previous_credits_in_specialized_balance.is_some(); + let new_total = previous_credits_in_specialized_balance.unwrap_or_default() .checked_add(amount) .ok_or(Error::Drive(DriveError::CriticalCorruptedState( "trying to add an amount that would overflow credits", )))?; - let path_holding_total_credits_vec = misc_path_vec(); - let replace_op = GroveDbOp::replace_op( - path_holding_total_credits_vec, - TOTAL_SYSTEM_CREDITS_STORAGE_KEY.to_vec(), - Item(new_total.encode_var_vec(), None), - ); - drive_operations.push(GroveOperation(replace_op)); + let path_holding_total_credits_vec = prefunded_specialized_balances_for_voting_path_vec(); + let op = if had_previous_balance { + GroveDbOp::replace_op( + path_holding_total_credits_vec, + specialized_balance_id.to_vec(), + Item(new_total.encode_var_vec(), None), + ) + } else { + GroveDbOp::insert_op( + path_holding_total_credits_vec, + specialized_balance_id.to_vec(), + Item(new_total.encode_var_vec(), None), + ) + }; + drive_operations.push(GroveOperation(op)); Ok(drive_operations) } } diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/mod.rs index 7d6bea6d2e..913bfb0e09 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/mod.rs @@ -6,6 +6,7 @@ use crate::error::Error; use dpp::version::PlatformVersion; use grovedb::TransactionArg; +use dpp::identifier::Identifier; impl Drive { /// Deducts from a prefunded specialized balance @@ -25,6 +26,7 @@ impl Drive { /// This function will return an error if the version of Platform is unknown. pub fn deduct_from_prefunded_specialized_balance( &self, + specialized_balance_id: Identifier, amount: u64, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -35,7 +37,7 @@ impl Drive { .prefunded_specialized_balances .deduct_from_prefunded_specialized_balance { - 0 => self.deduct_from_prefunded_specialized_balance_v0(amount, transaction, platform_version), + 0 => self.deduct_from_prefunded_specialized_balance_v0(specialized_balance_id, amount, transaction, platform_version), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "deduct_from_prefunded_specialized_balance".to_string(), known_versions: vec![0], diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/v0/mod.rs index e69de29bb2..dcb2ac83aa 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/v0/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/v0/mod.rs @@ -0,0 +1,51 @@ +use crate::drive::Drive; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; + +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; +use dpp::identifier::Identifier; + +impl Drive { + /// Adds a new prefunded specialized balance + /// + /// # Arguments + /// + /// * `amount` - The amount of credits to be added to the prefunded balance. + /// * `transaction` - A `TransactionArg` object representing the transaction to be used for adding to the system credits. + /// * `platform_version` - A `PlatformVersion` object specifying the version of Platform. + /// + /// # Returns + /// + /// * `Result<(), Error>` - If successful, returns `Ok(())`. If an error occurs during the operation, returns an `Error`. + /// + /// # Errors + /// + /// This function will return an error if the version of Platform is unknown. + #[inline(always)] + pub(super) fn deduct_from_prefunded_specialized_balance_v0( + &self, + specialized_balance_id: Identifier, + amount: u64, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + let mut drive_operations = vec![]; + let batch_operations = self.deduct_from_prefunded_specialized_balance_operations( + specialized_balance_id, + amount, + &mut None, + transaction, + platform_version, + )?; + let grove_db_operations = + LowLevelDriveOperation::grovedb_operations_batch(&batch_operations); + self.grove_apply_batch_with_add_costs( + grove_db_operations, + false, + transaction, + &mut drive_operations, + &platform_version.drive, + ) + } +} diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs index 81c41fbd0b..cc406f442d 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs @@ -9,6 +9,20 @@ use crate::drive::{Drive, RootTree}; pub const PREFUNDED_BALANCES_FOR_VOTING: [u8; 1] = [128]; +/// prefunded specialized balances for voting +pub(crate) fn prefunded_specialized_balances_for_voting_path() -> [&[u8]; 2] { + [ + Into::<&[u8; 1]>::into(RootTree::PreFundedSpecializedBalances), + &PREFUNDED_BALANCES_FOR_VOTING + ] +} + +/// prefunded specialized balances for voting vector +pub(crate) fn prefunded_specialized_balances_for_voting_path_vec() -> Vec> { + vec![Into::<&[u8; 1]>::into(RootTree::PreFundedSpecializedBalances).to_vec(), PREFUNDED_BALANCES_FOR_VOTING.to_vec()] +} + + impl Drive { /// Add operations for creating initial prefunded specialized balances state structure /// In v1 we will only have the prefunded balances for voting From cb5a8e69745cd66ab3e6d73e941cd36e38225462 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 8 May 2024 11:24:54 +0200 Subject: [PATCH 038/135] another function --- .../v0/mod.rs | 63 +++++++++++++++++++ packages/rs-drive/src/error/drive.rs | 9 +++ 2 files changed, 72 insertions(+) diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/v0/mod.rs index e69de29bb2..cc7e8ae8cf 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/v0/mod.rs @@ -0,0 +1,63 @@ +use crate::drive::grove_operations::DirectQueryType; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use crate::fee::op::LowLevelDriveOperation::GroveOperation; + +use dpp::version::PlatformVersion; +use grovedb::batch::{GroveDbOp, KeyInfoPath}; +use grovedb::Element::Item; +use grovedb::{EstimatedLayerInformation, TransactionArg}; +use integer_encoding::VarInt; +use std::collections::HashMap; +use dpp::identifier::Identifier; +use crate::drive::prefunded_specialized_balances::{prefunded_specialized_balances_for_voting_path, prefunded_specialized_balances_for_voting_path_vec}; + +impl Drive { + /// The operations to add to the specialized balance + #[inline(always)] + pub(super) fn deduct_from_prefunded_specialized_balance_operations_v0( + &self, + specialized_balance_id: Identifier, + amount: u64, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let mut drive_operations = vec![]; + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { + Self::add_estimation_costs_for_total_system_credits_update( + estimated_costs_only_with_layer_info, + &platform_version.drive, + )?; + } + let path_holding_specialized_balances = prefunded_specialized_balances_for_voting_path(); + let previous_credits_in_specialized_balance = self + .grove_get_raw_value_u64_from_encoded_var_vec( + (&path_holding_specialized_balances).into(), + specialized_balance_id.as_slice(), + DirectQueryType::StatefulDirectQuery, + transaction, + &mut drive_operations, + &platform_version.drive, + )?.ok_or(Error::Drive(DriveError::PrefundedSpecializedBalanceDoesNotExist( + format!("trying to deduct from a prefunded specialized balance {} that does not exist", specialized_balance_id), + )))?; + let new_total = previous_credits_in_specialized_balance + .checked_sub(amount) + .ok_or(Error::Drive(DriveError::PrefundedSpecializedBalanceNotEnough( + previous_credits_in_specialized_balance, amount + )))?; + let path_holding_total_credits_vec = prefunded_specialized_balances_for_voting_path_vec(); + let replace_op = GroveDbOp::replace_op( + path_holding_total_credits_vec, + specialized_balance_id.to_vec(), + Item(new_total.encode_var_vec(), None), + ); + drive_operations.push(GroveOperation(replace_op)); + Ok(drive_operations) + } +} diff --git a/packages/rs-drive/src/error/drive.rs b/packages/rs-drive/src/error/drive.rs index 8af1de9209..43cfccab5e 100644 --- a/packages/rs-drive/src/error/drive.rs +++ b/packages/rs-drive/src/error/drive.rs @@ -1,3 +1,4 @@ +use dpp::fee::Credits; use crate::drive::contract::MAX_CONTRACT_HISTORY_FETCH_LIMIT; use dpp::version::FeatureVersion; @@ -163,4 +164,12 @@ pub enum DriveError { /// Error #[error("invalid contract history fetch limit: {0}. The limit must be between 1 and {MAX_CONTRACT_HISTORY_FETCH_LIMIT}")] InvalidContractHistoryFetchLimit(u16), + + /// Error + #[error("prefunded specialized balance does not exist: {0}")] + PrefundedSpecializedBalanceDoesNotExist(String), + + /// Error + #[error("prefunded specialized balance does not have enough credits: we have {0}, we want to deduct {1}")] + PrefundedSpecializedBalanceNotEnough(Credits, Credits), } From 9cf2d75334c8014455463734194cda6e1ecb14bf Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 8 May 2024 15:41:11 +0200 Subject: [PATCH 039/135] more work on prefunded balances --- .../v0/mod.rs | 2 +- .../mod.rs | 55 ++++++++++++++++++- .../v0/mod.rs | 2 +- .../mod.rs | 48 ++++++++++++++++ .../v0/mod.rs | 52 ++++++++++++++++++ .../estimation_costs/mod.rs | 1 + .../prefunded_specialized_balances/mod.rs | 1 + .../src/version/drive_versions.rs | 1 + 8 files changed, 159 insertions(+), 3 deletions(-) create mode 100644 packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/mod.rs create mode 100644 packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/mod.rs diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/v0/mod.rs index ca8156c95c..ae3e800f02 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/v0/mod.rs @@ -29,7 +29,7 @@ impl Drive { ) -> Result, Error> { let mut drive_operations = vec![]; if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { - Self::add_estimation_costs_for_total_system_credits_update( + Self::add_estimation_costs_for_prefunded_specialized_balance_update( estimated_costs_only_with_layer_info, &platform_version.drive, )?; diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/mod.rs index 7affabc980..d3690d8ad7 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/mod.rs @@ -1 +1,54 @@ -mod v0; \ No newline at end of file +mod v0; + +use std::collections::HashMap; +use grovedb::batch::KeyInfoPath; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; + +use dpp::version::PlatformVersion; +use grovedb::{EstimatedLayerInformation, TransactionArg}; +use dpp::identifier::Identifier; +use crate::fee::op::LowLevelDriveOperation; + +impl Drive { + /// The operation Deducts from a prefunded specialized balance + /// + /// # Arguments + /// + /// * `amount` - The amount of credits to be removed from the prefunded balance. + /// * `transaction` - A `TransactionArg` object representing the transaction to be used for adding to the system credits. + /// * `platform_version` - A `PlatformVersion` object specifying the version of Platform. + /// + /// # Returns + /// + /// * `Result<(), Error>` - If successful, returns `Ok(())`. If an error occurs during the operation, returns an `Error`. + /// + /// # Errors + /// + /// This function will return an error if the version of Platform is unknown. + pub fn deduct_from_prefunded_specialized_balance_operations( + &self, + specialized_balance_id: Identifier, + amount: u64, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + match platform_version + .drive + .methods + .prefunded_specialized_balances + .deduct_from_prefunded_specialized_balance + { + 0 => self.deduct_from_prefunded_specialized_balance_operations_v0(specialized_balance_id, amount, estimated_costs_only_with_layer_info, transaction, platform_version), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "deduct_from_prefunded_specialized_balance_operations".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/v0/mod.rs index cc7e8ae8cf..86540d39c8 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/v0/mod.rs @@ -29,7 +29,7 @@ impl Drive { ) -> Result, Error> { let mut drive_operations = vec![]; if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { - Self::add_estimation_costs_for_total_system_credits_update( + Self::add_estimation_costs_for_prefunded_specialized_balance_update( estimated_costs_only_with_layer_info, &platform_version.drive, )?; diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/mod.rs new file mode 100644 index 0000000000..31eeebb675 --- /dev/null +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/mod.rs @@ -0,0 +1,48 @@ +mod v0; + +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use dpp::version::drive_versions::DriveVersion; +use grovedb::batch::KeyInfoPath; +use grovedb::EstimatedLayerInformation; +use std::collections::HashMap; + +impl Drive { + /// Adds estimation costs for prefunded specialized balance update. + /// + /// This method operates on the provided HashMap, `estimated_costs_only_with_layer_info`, and adds + /// new entries to it, giving layer info on the prefunded specialized balance trees. + /// + /// # Parameters + /// - `estimated_costs_only_with_layer_info`: A mutable reference to a HashMap storing the `KeyInfoPath` and `EstimatedLayerInformation`. + /// + /// # Returns + /// - `Ok(())` if successful. + /// - `Err(DriveError::UnknownVersionMismatch)` if the method version doesn't match any known versions. + /// + /// # Errors + /// This function will return an error if the method version doesn't match any known versions. + pub(crate) fn add_estimation_costs_for_prefunded_specialized_balance_update( + estimated_costs_only_with_layer_info: &mut HashMap, + drive_version: &DriveVersion, + ) -> Result<(), Error> { + match drive_version + .methods + .prefunded_specialized_balances + .estimated_cost_for_prefunded_specialized_balance_update + { + 0 => { + Self::add_estimation_costs_for_prefunded_specialized_balance_update_v0( + estimated_costs_only_with_layer_info, + ); + Ok(()) + } + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "add_estimation_costs_for_prefunded_specialized_balance_update".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs new file mode 100644 index 0000000000..6ff470cef9 --- /dev/null +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs @@ -0,0 +1,52 @@ +use crate::drive::Drive; + +use grovedb::batch::KeyInfoPath; +use grovedb::EstimatedLayerCount::{ApproximateElements, EstimatedLevel}; +use grovedb::EstimatedLayerInformation; +use grovedb::EstimatedLayerSizes::{AllItems, AllSubtrees}; + +use grovedb::EstimatedSumTrees::SomeSumTrees; +use std::collections::HashMap; +use crate::drive::prefunded_specialized_balances::prefunded_specialized_balances_for_voting_path; + +impl Drive { + /// Adds estimation costs for total system credits update. + /// + /// This method operates on the provided HashMap, `estimated_costs_only_with_layer_info`, and adds + /// new entries to it, representing the estimated costs for the total system credits update. + #[inline(always)] + pub(super) fn add_estimation_costs_for_prefunded_specialized_balance_update_v0( + estimated_costs_only_with_layer_info: &mut HashMap, + ) { + //todo: verify (this is wrong) + // we have constructed the top layer so contract/documents tree are at the top + // since balance will be on layer 2, updating will mean we will update 1 sum tree + // and 1 normal tree, hence we should give an equal weight to both + estimated_costs_only_with_layer_info.insert( + KeyInfoPath::from_known_path([]), + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: EstimatedLevel(1, false), + estimated_layer_sizes: AllSubtrees( + 1, + SomeSumTrees { + sum_trees_weight: 1, + non_sum_trees_weight: 1, + }, + None, + ), + }, + ); + + //todo : verify this + // we then need to insert the contract layer + estimated_costs_only_with_layer_info.insert( + KeyInfoPath::from_known_owned_path(prefunded_specialized_balances_for_voting_path()), + EstimatedLayerInformation { + is_sum_tree: true, + estimated_layer_count: ApproximateElements(0), + estimated_layer_sizes: AllItems(1, 8, None), + }, + ); + } +} diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/mod.rs new file mode 100644 index 0000000000..012258ecd9 --- /dev/null +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/mod.rs @@ -0,0 +1 @@ +mod for_prefunded_specialized_balance_update; diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs index cc406f442d..a5130e229e 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs @@ -2,6 +2,7 @@ mod add_prefunded_specialized_balance; mod deduct_from_prefunded_specialized_balance; mod add_prefunded_specialized_balance_operations; mod deduct_from_prefunded_specialized_balance_operations; +mod estimation_costs; use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; use crate::drive::batch::GroveDbOpBatch; diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index cd23f5618c..55867130e7 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -141,6 +141,7 @@ pub struct DrivePrefundedSpecializedMethodVersions { pub add_prefunded_specialized_balance_operations: FeatureVersion, pub deduct_from_prefunded_specialized_balance: FeatureVersion, pub deduct_from_prefunded_specialized_balance_operations: FeatureVersion, + pub estimated_cost_for_prefunded_specialized_balance_update: FeatureVersion, } #[derive(Clone, Debug, Default)] From ad4240926b36063cd3e3b1f0413121e01cb41aef Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 8 May 2024 20:44:01 +0200 Subject: [PATCH 040/135] more work --- .../mod.rs | 20 ++++- packages/rs-dpp/src/voting/vote_polls/mod.rs | 29 +++++-- packages/rs-dpp/src/voting/votes/mod.rs | 23 +++-- .../votes/resource_vote/accessors/mod.rs | 1 - .../src/voting/votes/resource_vote/v0/mod.rs | 2 +- .../src/drive/batch/drive_op_batch/mod.rs | 24 ++--- .../prefunded_specialized_balance.rs | 50 ++++++----- .../document/document_create_transition.rs | 38 ++++---- .../identity/masternode_vote_transition.rs | 16 +++- .../add_contested_document/mod.rs | 8 +- .../mod.rs | 3 +- .../mod.rs | 3 +- .../v0/mod.rs | 2 +- .../document_and_contract_info.rs | 2 - .../add_prefunded_specialized_balance/mod.rs | 9 +- .../v0/mod.rs | 2 +- .../mod.rs | 16 ++-- .../v0/mod.rs | 10 ++- .../mod.rs | 9 +- .../v0/mod.rs | 2 +- .../mod.rs | 16 ++-- .../v0/mod.rs | 26 ++++-- .../v0/mod.rs | 2 +- .../prefunded_specialized_balances/mod.rs | 12 +-- .../remove_votes_for_identity/v0/mod.rs | 2 +- .../add_vote_poll_end_date_query/v0/mod.rs | 1 - packages/rs-drive/src/drive/votes/mod.rs | 87 ++++++++++--------- packages/rs-drive/src/error/drive.rs | 4 +- .../src/version/mocks/v2_test.rs | 46 +++++++--- .../src/version/mocks/v3_test.rs | 46 +++++++--- .../rs-platform-version/src/version/v1.rs | 46 +++++++--- 31 files changed, 363 insertions(+), 194 deletions(-) diff --git a/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs b/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs index 2c7b0dcb82..c91df81b6e 100644 --- a/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs +++ b/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs @@ -1,13 +1,20 @@ use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; +use crate::serialization::{PlatformSerializable, PlatformSerializableWithPlatformVersion}; +use crate::util::hash::hash_double; +use crate::ProtocolError; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use platform_value::{Identifier, Value}; +use platform_version::version::PlatformVersion; use serde::{Deserialize, Serialize}; -#[derive(Debug, Clone, Encode, Decode, PartialEq)] +#[derive(Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize, PartialEq)] #[cfg_attr( feature = "state-transition-serde-conversion", derive(Serialize, Deserialize), serde(rename_all = "camelCase") )] +#[platform_serialize(unversioned)] //versioned directly, no need to use platform_version +#[platform_serialize(limit = 100000)] pub struct ContestedDocumentResourceVotePoll { pub contract_id: Identifier, pub document_type_name: String, @@ -25,3 +32,14 @@ impl Default for ContestedDocumentResourceVotePoll { } } } + +impl ContestedDocumentResourceVotePoll { + pub fn sha256_2_hash(&self) -> Result<[u8; 32], ProtocolError> { + let encoded = self.serialize_to_bytes()?; + Ok(hash_double(encoded)) + } + + pub fn specialized_balance_id(&self) -> Result { + self.sha256_2_hash().map(|id| Identifier::new(id)) + } +} diff --git a/packages/rs-dpp/src/voting/vote_polls/mod.rs b/packages/rs-dpp/src/voting/vote_polls/mod.rs index 3d2a4c593c..3d9381b4f4 100644 --- a/packages/rs-dpp/src/voting/vote_polls/mod.rs +++ b/packages/rs-dpp/src/voting/vote_polls/mod.rs @@ -1,22 +1,37 @@ -use derive_more::From; -use serde::{Deserialize, Serialize}; use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use crate::ProtocolError; +use derive_more::From; +use platform_value::Identifier; +use platform_version::version::PlatformVersion; +use serde::{Deserialize, Serialize}; pub mod contested_document_resource_vote_poll; #[derive(Debug, Clone, Encode, Decode, PartialEq, From)] #[cfg_attr( -feature = "state-transition-serde-conversion", -derive(Serialize, Deserialize), -serde(rename_all = "camelCase") + feature = "state-transition-serde-conversion", + derive(Serialize, Deserialize), + serde(rename_all = "camelCase") )] pub enum VotePoll { - ContestedDocumentResourceVotePoll(ContestedDocumentResourceVotePoll) + ContestedDocumentResourceVotePoll(ContestedDocumentResourceVotePoll), } impl Default for VotePoll { fn default() -> Self { ContestedDocumentResourceVotePoll::default().into() } -} \ No newline at end of file +} + +impl VotePoll { + pub fn specialized_balance_id(&self) -> Result, ProtocolError> { + match self { + VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll) => { + Ok(Some( + contested_document_resource_vote_poll.specialized_balance_id()?, + )) + } + } + } +} diff --git a/packages/rs-dpp/src/voting/votes/mod.rs b/packages/rs-dpp/src/voting/votes/mod.rs index 917e707251..9e0b28c584 100644 --- a/packages/rs-dpp/src/voting/votes/mod.rs +++ b/packages/rs-dpp/src/voting/votes/mod.rs @@ -1,13 +1,16 @@ pub mod resource_vote; +use crate::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; use crate::voting::votes::resource_vote::ResourceVote; -use serde::{Deserialize, Serialize}; #[cfg(feature = "vote-serialization")] -use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +use crate::ProtocolError; #[cfg(feature = "vote-serialization")] use bincode::{Decode, Encode}; #[cfg(feature = "vote-serialization")] -use crate::ProtocolError; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +use platform_value::Identifier; +use platform_version::version::PlatformVersion; +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, PartialEq)] #[cfg_attr( @@ -16,9 +19,9 @@ use crate::ProtocolError; serde(rename_all = "camelCase") )] #[cfg_attr( -feature = "vote-serialization", -derive(Encode, Decode, PlatformDeserialize, PlatformSerialize), -platform_serialize(limit = 15000, unversioned) + feature = "vote-serialization", + derive(Encode, Decode, PlatformDeserialize, PlatformSerialize), + platform_serialize(limit = 15000, unversioned) )] pub enum Vote { ResourceVote(ResourceVote), @@ -29,3 +32,11 @@ impl Default for Vote { Vote::ResourceVote(ResourceVote::default()) } } + +impl Vote { + pub fn specialized_balance_id(&self) -> Result, ProtocolError> { + match self { + Vote::ResourceVote(resource_vote) => resource_vote.vote_poll().specialized_balance_id(), + } + } +} diff --git a/packages/rs-dpp/src/voting/votes/resource_vote/accessors/mod.rs b/packages/rs-dpp/src/voting/votes/resource_vote/accessors/mod.rs index 306eec7d48..eb6f42ef6e 100644 --- a/packages/rs-dpp/src/voting/votes/resource_vote/accessors/mod.rs +++ b/packages/rs-dpp/src/voting/votes/resource_vote/accessors/mod.rs @@ -1,5 +1,4 @@ use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use crate::voting::vote_polls::VotePoll; use crate::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; use crate::voting::votes::resource_vote::ResourceVote; diff --git a/packages/rs-dpp/src/voting/votes/resource_vote/v0/mod.rs b/packages/rs-dpp/src/voting/votes/resource_vote/v0/mod.rs index 4b48107b62..446e80e0c4 100644 --- a/packages/rs-dpp/src/voting/votes/resource_vote/v0/mod.rs +++ b/packages/rs-dpp/src/voting/votes/resource_vote/v0/mod.rs @@ -1,9 +1,9 @@ use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use crate::voting::vote_polls::VotePoll; use crate::ProtocolError; use bincode::{Decode, Encode}; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use serde::{Deserialize, Serialize}; -use crate::voting::vote_polls::VotePoll; #[derive(Debug, Clone, Encode, Decode, PlatformDeserialize, PlatformSerialize, PartialEq)] #[cfg_attr( diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/mod.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/mod.rs index fe91c7c488..cb8754ddec 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/mod.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/mod.rs @@ -3,9 +3,9 @@ mod document; mod drive_methods; mod finalize_task; mod identity; +mod prefunded_specialized_balance; mod system; mod withdrawals; -mod prefunded_specialized_balance; use crate::drive::batch::GroveDbOpBatch; @@ -20,6 +20,7 @@ pub use document::DocumentOperationType; pub use document::DocumentOperationsForContractDocumentType; pub use document::UpdateOperationInfo; pub use identity::IdentityOperationType; +pub use prefunded_specialized_balance::PrefundedSpecializedBalanceOperationType; pub use system::SystemOperationType; pub use withdrawals::WithdrawalOperationType; @@ -35,7 +36,6 @@ use crate::drive::batch::drive_op_batch::finalize_task::{ }; use crate::error::drive::DriveError; use std::collections::{BTreeMap, HashMap}; -use crate::drive::batch::drive_op_batch::prefunded_specialized_balance::PrefundedSpecializedBalanceOperationType; /// A converter that will get Drive Operations from High Level Operations pub trait DriveLowLevelOperationConverter { @@ -73,7 +73,7 @@ pub enum DriveOperation<'a> { /// An identity operation IdentityOperation(IdentityOperationType), /// An operation on prefunded balances - PrefundedSpecializedBalanceOperationType(PrefundedSpecializedBalanceOperationType), + PrefundedSpecializedBalanceOperation(PrefundedSpecializedBalanceOperationType), /// A system operation SystemOperation(SystemOperationType), /// A single low level groveDB operation @@ -128,14 +128,15 @@ impl DriveLowLevelOperationConverter for DriveOperation<'_> { transaction, platform_version, ), - DriveOperation::PrefundedSpecializedBalanceOperationType(prefunded_balance_operation_type) => prefunded_balance_operation_type - .into_low_level_drive_operations( - drive, - estimated_costs_only_with_layer_info, - block_info, - transaction, - platform_version, - ), + DriveOperation::PrefundedSpecializedBalanceOperation( + prefunded_balance_operation_type, + ) => prefunded_balance_operation_type.into_low_level_drive_operations( + drive, + estimated_costs_only_with_layer_info, + block_info, + transaction, + platform_version, + ), DriveOperation::SystemOperation(system_operation_type) => system_operation_type .into_low_level_drive_operations( drive, @@ -150,7 +151,6 @@ impl DriveLowLevelOperationConverter for DriveOperation<'_> { .into_iter() .map(GroveOperation) .collect()), - } } } diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/prefunded_specialized_balance.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/prefunded_specialized_balance.rs index c0209f7f34..3047aa27c5 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/prefunded_specialized_balance.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/prefunded_specialized_balance.rs @@ -1,30 +1,30 @@ -use std::collections::HashMap; -use grovedb::batch::KeyInfoPath; -use grovedb::{EstimatedLayerInformation, TransactionArg}; -use dpp::block::block_info::BlockInfo; -use dpp::identifier::Identifier; -use platform_version::version::PlatformVersion; use crate::drive::batch::drive_op_batch::DriveLowLevelOperationConverter; use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; +use dpp::block::block_info::BlockInfo; +use dpp::identifier::Identifier; +use grovedb::batch::KeyInfoPath; +use grovedb::{EstimatedLayerInformation, TransactionArg}; +use platform_version::version::PlatformVersion; +use std::collections::HashMap; /// Operations on Prefunded balances #[derive(Clone, Debug)] pub enum PrefundedSpecializedBalanceOperationType { - /// Adds balance to an identity + /// Creates a new prefunded balance CreateNewPrefundedBalance { /// The id of the prefunded balance - prefunded_balance_id: Identifier, + prefunded_specialized_balance_id: Identifier, /// The added balance - added_balance: u64, + add_balance: u64, }, - /// Adds balance to an identity + /// Deducts from a prefunded balance DeductFromPrefundedBalance { /// The identity id of the identity - prefunded_balance_id: Identifier, + prefunded_specialized_balance_id: Identifier, /// The removed balance - removed_balance: u64, + remove_balance: u64, }, } @@ -35,23 +35,31 @@ impl DriveLowLevelOperationConverter for PrefundedSpecializedBalanceOperationTyp estimated_costs_only_with_layer_info: &mut Option< HashMap, >, - block_info: &BlockInfo, + _block_info: &BlockInfo, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { match self { PrefundedSpecializedBalanceOperationType::CreateNewPrefundedBalance { - prefunded_balance_id, added_balance - } => drive.add_new_identity_operations( - identity, - is_masternode_identity, - block_info, - &mut None, + prefunded_specialized_balance_id: specialized_balance_id, + add_balance: added_balance, + } => drive.add_prefunded_specialized_balance_operations( + specialized_balance_id, + added_balance, + estimated_costs_only_with_layer_info, + transaction, + platform_version, + ), + PrefundedSpecializedBalanceOperationType::DeductFromPrefundedBalance { + prefunded_specialized_balance_id: specialized_balance_id, + remove_balance: removed_balance, + } => drive.deduct_from_prefunded_specialized_balance_operations( + specialized_balance_id, + removed_balance, estimated_costs_only_with_layer_info, transaction, platform_version, ), - PrefundedSpecializedBalanceOperationType::DeductFromPrefundedBalance { prefunded_balance_id, removed_balance } => {} } } -} \ No newline at end of file +} diff --git a/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs b/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs index 93d0f55122..0ac6e057c9 100644 --- a/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs +++ b/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs @@ -29,21 +29,22 @@ impl DriveHighLevelDocumentOperationConverter for DocumentCreateTransitionAction let document_type_name = self.base().document_type_name().clone(); let identity_contract_nonce = self.base().identity_contract_nonce(); - + let prefunded_voting_balances = self.prefunded_voting_balances(); let document = Document::try_from_owned_create_transition_action(self, owner_id, platform_version)?; let storage_flags = StorageFlags::new_single_epoch(epoch.index, Some(owner_id.to_buffer())); - - let mut ops = vec![ - IdentityOperation(IdentityOperationType::UpdateIdentityContractNonce { + + let mut ops = vec![IdentityOperation( + IdentityOperationType::UpdateIdentityContractNonce { identity_id: owner_id.into_buffer(), contract_id: data_contract_id.into_buffer(), nonce: identity_contract_nonce, - })]; - + }, + )]; + if prefunded_voting_balances.is_empty() { // Just add the document ops.push(DocumentOperation(DocumentOperationType::AddDocument { @@ -61,18 +62,23 @@ impl DriveHighLevelDocumentOperationConverter for DocumentCreateTransitionAction ops.push(); // We add the contested document // The contested document resides in a special location in grovedb until a time where the - // resolution expires, at that point it either will be moved to - ops.push(DocumentOperation(DocumentOperationType::AddContestedDocument { - owned_document_info: OwnedDocumentInfo { - document_info: DocumentOwnedInfo((document, Some(Cow::Owned(storage_flags)))), - owner_id: Some(owner_id.into_buffer()), + // resolution expires, at that point it either will be moved to + ops.push(DocumentOperation( + DocumentOperationType::AddContestedDocument { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentOwnedInfo(( + document, + Some(Cow::Owned(storage_flags)), + )), + owner_id: Some(owner_id.into_buffer()), + }, + contract_info: DataContractFetchInfo(contract_fetch_info), + document_type_info: DocumentTypeInfo::DocumentTypeName(document_type_name), + override_document: false, }, - contract_info: DataContractFetchInfo(contract_fetch_info), - document_type_info: DocumentTypeInfo::DocumentTypeName(document_type_name), - override_document: false, - })); + )); } - + Ok(ops) } } diff --git a/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs b/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs index c8f6dff36b..e6b04521ff 100644 --- a/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs +++ b/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs @@ -1,21 +1,26 @@ use crate::drive::batch::transitions::DriveHighLevelOperationConverter; -use crate::drive::batch::DriveOperation::IdentityOperation; +use crate::drive::batch::DriveOperation::{ + IdentityOperation, PrefundedSpecializedBalanceOperation, +}; use crate::drive::batch::{DriveOperation, IdentityOperationType}; +use crate::drive::batch::drive_op_batch::PrefundedSpecializedBalanceOperationType; use crate::error::Error; use crate::state_transition_action::identity::masternode_vote::MasternodeVoteTransitionAction; use dpp::block::epoch::Epoch; use dpp::version::PlatformVersion; +use dpp::ProtocolError; impl DriveHighLevelOperationConverter for MasternodeVoteTransitionAction { fn into_high_level_drive_operations<'a>( self, _epoch: &Epoch, - _platform_version: &PlatformVersion, + platform_version: &PlatformVersion, ) -> Result>, Error> { let pro_tx_hash = self.pro_tx_hash(); let nonce = self.nonce(); let vote = self.vote_owned(); + let prefunded_specialized_balance_id = vote.specialized_balance_id(platform_version)?.ok_or(Error::Protocol(ProtocolError::VoteError("vote does not have a specialized balance from where it can use to pay for processing (this should have been caught during validation)".to_string())))?; let drive_operations = vec![ IdentityOperation(IdentityOperationType::UpdateIdentityNonce { @@ -26,6 +31,13 @@ impl DriveHighLevelOperationConverter for MasternodeVoteTransitionAction { voter_pro_tx_hash: pro_tx_hash.to_buffer(), vote, }), + // Casting a vote has a fixed cost + PrefundedSpecializedBalanceOperation( + PrefundedSpecializedBalanceOperationType::DeductFromPrefundedBalance { + prefunded_specialized_balance_id, + remove_balance: 0, + }, + ), ]; Ok(drive_operations) } diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs index 8107322c91..a606a96e25 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs @@ -40,7 +40,13 @@ impl Drive { transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { - match platform_version.drive.methods.document.insert_contested.add_contested_document { + match platform_version + .drive + .methods + .document + .insert_contested + .add_contested_document + { 0 => self.add_contested_document_v0( owned_document_info, data_contract_id, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs index e4255c46da..3fa4e292a6 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs @@ -57,7 +57,8 @@ impl Drive { platform_version, ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "add_contested_document_for_contract_apply_and_add_to_operations".to_string(), + method: "add_contested_document_for_contract_apply_and_add_to_operations" + .to_string(), known_versions: vec![0], received: version, })), diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs index ef0b746431..3207e356a2 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs @@ -51,7 +51,8 @@ impl Drive { drive_version, ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "add_contested_reference_for_index_level_for_contract_operations".to_string(), + method: "add_contested_reference_for_index_level_for_contract_operations" + .to_string(), known_versions: vec![0], received: version, })), diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs index 8a790370e0..f634ee2136 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -30,7 +30,7 @@ use std::collections::HashMap; impl Drive { /// Adds the terminal reference. #[inline(always)] - pub(super) fn add_reference_for_index_level_for_contract_operations_v0( + pub(super) fn add_contested_reference_for_index_level_for_contract_operations_v0( &self, document_and_contract_info: &DocumentAndContractInfo, mut index_path_info: PathInfo<0>, diff --git a/packages/rs-drive/src/drive/object_size_info/document_and_contract_info.rs b/packages/rs-drive/src/drive/object_size_info/document_and_contract_info.rs index 531e32a22c..cee140732b 100644 --- a/packages/rs-drive/src/drive/object_size_info/document_and_contract_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/document_and_contract_info.rs @@ -1,8 +1,6 @@ -use std::sync::Arc; use crate::drive::object_size_info::OwnedDocumentInfo; use dpp::data_contract::document_type::DocumentTypeRef; use dpp::data_contract::DataContract; -use crate::drive::contract::DataContractFetchInfo; /// Document and contract info #[derive(Clone, Debug)] diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance/mod.rs index afcb6be380..5caa730926 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance/mod.rs @@ -4,9 +4,9 @@ use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; +use dpp::identifier::Identifier; use dpp::version::PlatformVersion; use grovedb::TransactionArg; -use dpp::identifier::Identifier; impl Drive { /// Adds a new prefunded specialized balance @@ -37,7 +37,12 @@ impl Drive { .prefunded_specialized_balances .add_prefunded_specialized_balance { - 0 => self.add_prefunded_specialized_balance_v0(specialized_balance_id, amount, transaction, platform_version), + 0 => self.add_prefunded_specialized_balance_v0( + specialized_balance_id, + amount, + transaction, + platform_version, + ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "add_prefunded_specialized_balance".to_string(), known_versions: vec![0], diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance/v0/mod.rs index 5e68ec2d8a..adb8b0ac54 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance/v0/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance/v0/mod.rs @@ -2,9 +2,9 @@ use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; +use dpp::identifier::Identifier; use dpp::version::PlatformVersion; use grovedb::TransactionArg; -use dpp::identifier::Identifier; impl Drive { /// Adds a new prefunded specialized balance diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/mod.rs index 9100524b3f..4d20097f48 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/mod.rs @@ -1,15 +1,15 @@ mod v0; -use std::collections::HashMap; -use grovedb::batch::KeyInfoPath; use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; +use grovedb::batch::KeyInfoPath; +use std::collections::HashMap; +use crate::fee::op::LowLevelDriveOperation; +use dpp::identifier::Identifier; use dpp::version::PlatformVersion; use grovedb::{EstimatedLayerInformation, TransactionArg}; -use dpp::identifier::Identifier; -use crate::fee::op::LowLevelDriveOperation; impl Drive { /// Adds a new prefunded specialized balance @@ -43,7 +43,13 @@ impl Drive { .prefunded_specialized_balances .add_prefunded_specialized_balance_operations { - 0 => self.add_prefunded_specialized_balance_operations_v0(specialized_balance_id, amount, estimated_costs_only_with_layer_info, transaction, platform_version), + 0 => self.add_prefunded_specialized_balance_operations_v0( + specialized_balance_id, + amount, + estimated_costs_only_with_layer_info, + transaction, + platform_version, + ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "add_prefunded_specialized_balance_operations".to_string(), known_versions: vec![0], diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/v0/mod.rs index ae3e800f02..2feb5fd286 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/v0/mod.rs @@ -5,14 +5,17 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use crate::fee::op::LowLevelDriveOperation::GroveOperation; +use crate::drive::prefunded_specialized_balances::{ + prefunded_specialized_balances_for_voting_path, + prefunded_specialized_balances_for_voting_path_vec, +}; +use dpp::identifier::Identifier; use dpp::version::PlatformVersion; use grovedb::batch::{GroveDbOp, KeyInfoPath}; use grovedb::Element::Item; use grovedb::{EstimatedLayerInformation, TransactionArg}; use integer_encoding::VarInt; use std::collections::HashMap; -use dpp::identifier::Identifier; -use crate::drive::prefunded_specialized_balances::{prefunded_specialized_balances_for_voting_path, prefunded_specialized_balances_for_voting_path_vec}; impl Drive { /// The operations to add to the specialized balance @@ -45,7 +48,8 @@ impl Drive { &platform_version.drive, )?; let had_previous_balance = previous_credits_in_specialized_balance.is_some(); - let new_total = previous_credits_in_specialized_balance.unwrap_or_default() + let new_total = previous_credits_in_specialized_balance + .unwrap_or_default() .checked_add(amount) .ok_or(Error::Drive(DriveError::CriticalCorruptedState( "trying to add an amount that would overflow credits", diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/mod.rs index 913bfb0e09..755c5a510c 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/mod.rs @@ -4,9 +4,9 @@ use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; +use dpp::identifier::Identifier; use dpp::version::PlatformVersion; use grovedb::TransactionArg; -use dpp::identifier::Identifier; impl Drive { /// Deducts from a prefunded specialized balance @@ -37,7 +37,12 @@ impl Drive { .prefunded_specialized_balances .deduct_from_prefunded_specialized_balance { - 0 => self.deduct_from_prefunded_specialized_balance_v0(specialized_balance_id, amount, transaction, platform_version), + 0 => self.deduct_from_prefunded_specialized_balance_v0( + specialized_balance_id, + amount, + transaction, + platform_version, + ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "deduct_from_prefunded_specialized_balance".to_string(), known_versions: vec![0], diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/v0/mod.rs index dcb2ac83aa..23d89de1a1 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/v0/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/v0/mod.rs @@ -2,9 +2,9 @@ use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; +use dpp::identifier::Identifier; use dpp::version::PlatformVersion; use grovedb::TransactionArg; -use dpp::identifier::Identifier; impl Drive { /// Adds a new prefunded specialized balance diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/mod.rs index d3690d8ad7..77ee056718 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/mod.rs @@ -1,15 +1,15 @@ mod v0; -use std::collections::HashMap; -use grovedb::batch::KeyInfoPath; use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; +use grovedb::batch::KeyInfoPath; +use std::collections::HashMap; +use crate::fee::op::LowLevelDriveOperation; +use dpp::identifier::Identifier; use dpp::version::PlatformVersion; use grovedb::{EstimatedLayerInformation, TransactionArg}; -use dpp::identifier::Identifier; -use crate::fee::op::LowLevelDriveOperation; impl Drive { /// The operation Deducts from a prefunded specialized balance @@ -43,7 +43,13 @@ impl Drive { .prefunded_specialized_balances .deduct_from_prefunded_specialized_balance { - 0 => self.deduct_from_prefunded_specialized_balance_operations_v0(specialized_balance_id, amount, estimated_costs_only_with_layer_info, transaction, platform_version), + 0 => self.deduct_from_prefunded_specialized_balance_operations_v0( + specialized_balance_id, + amount, + estimated_costs_only_with_layer_info, + transaction, + platform_version, + ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "deduct_from_prefunded_specialized_balance_operations".to_string(), known_versions: vec![0], diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/v0/mod.rs index 86540d39c8..9fb4489608 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/v0/mod.rs @@ -5,14 +5,17 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use crate::fee::op::LowLevelDriveOperation::GroveOperation; +use crate::drive::prefunded_specialized_balances::{ + prefunded_specialized_balances_for_voting_path, + prefunded_specialized_balances_for_voting_path_vec, +}; +use dpp::identifier::Identifier; use dpp::version::PlatformVersion; use grovedb::batch::{GroveDbOp, KeyInfoPath}; use grovedb::Element::Item; use grovedb::{EstimatedLayerInformation, TransactionArg}; use integer_encoding::VarInt; use std::collections::HashMap; -use dpp::identifier::Identifier; -use crate::drive::prefunded_specialized_balances::{prefunded_specialized_balances_for_voting_path, prefunded_specialized_balances_for_voting_path_vec}; impl Drive { /// The operations to add to the specialized balance @@ -43,14 +46,21 @@ impl Drive { transaction, &mut drive_operations, &platform_version.drive, - )?.ok_or(Error::Drive(DriveError::PrefundedSpecializedBalanceDoesNotExist( - format!("trying to deduct from a prefunded specialized balance {} that does not exist", specialized_balance_id), - )))?; + )? + .ok_or(Error::Drive( + DriveError::PrefundedSpecializedBalanceDoesNotExist(format!( + "trying to deduct from a prefunded specialized balance {} that does not exist", + specialized_balance_id + )), + ))?; let new_total = previous_credits_in_specialized_balance .checked_sub(amount) - .ok_or(Error::Drive(DriveError::PrefundedSpecializedBalanceNotEnough( - previous_credits_in_specialized_balance, amount - )))?; + .ok_or(Error::Drive( + DriveError::PrefundedSpecializedBalanceNotEnough( + previous_credits_in_specialized_balance, + amount, + ), + ))?; let path_holding_total_credits_vec = prefunded_specialized_balances_for_voting_path_vec(); let replace_op = GroveDbOp::replace_op( path_holding_total_credits_vec, diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs index 6ff470cef9..57a645d64f 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs @@ -5,9 +5,9 @@ use grovedb::EstimatedLayerCount::{ApproximateElements, EstimatedLevel}; use grovedb::EstimatedLayerInformation; use grovedb::EstimatedLayerSizes::{AllItems, AllSubtrees}; +use crate::drive::prefunded_specialized_balances::prefunded_specialized_balances_for_voting_path; use grovedb::EstimatedSumTrees::SomeSumTrees; use std::collections::HashMap; -use crate::drive::prefunded_specialized_balances::prefunded_specialized_balances_for_voting_path; impl Drive { /// Adds estimation costs for total system credits update. diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs index a5130e229e..6a62b5732a 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs @@ -1,6 +1,6 @@ mod add_prefunded_specialized_balance; -mod deduct_from_prefunded_specialized_balance; mod add_prefunded_specialized_balance_operations; +mod deduct_from_prefunded_specialized_balance; mod deduct_from_prefunded_specialized_balance_operations; mod estimation_costs; @@ -11,19 +11,21 @@ use crate::drive::{Drive, RootTree}; pub const PREFUNDED_BALANCES_FOR_VOTING: [u8; 1] = [128]; /// prefunded specialized balances for voting -pub(crate) fn prefunded_specialized_balances_for_voting_path() -> [&[u8]; 2] { +pub(crate) fn prefunded_specialized_balances_for_voting_path() -> [&'static [u8]; 2] { [ Into::<&[u8; 1]>::into(RootTree::PreFundedSpecializedBalances), - &PREFUNDED_BALANCES_FOR_VOTING + &PREFUNDED_BALANCES_FOR_VOTING, ] } /// prefunded specialized balances for voting vector pub(crate) fn prefunded_specialized_balances_for_voting_path_vec() -> Vec> { - vec![Into::<&[u8; 1]>::into(RootTree::PreFundedSpecializedBalances).to_vec(), PREFUNDED_BALANCES_FOR_VOTING.to_vec()] + vec![ + Into::<&[u8; 1]>::into(RootTree::PreFundedSpecializedBalances).to_vec(), + PREFUNDED_BALANCES_FOR_VOTING.to_vec(), + ] } - impl Drive { /// Add operations for creating initial prefunded specialized balances state structure /// In v1 we will only have the prefunded balances for voting diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs index 073fbba093..5affb3d2b8 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs @@ -11,10 +11,10 @@ use crate::query::QueryItem; use dpp::prelude::Identifier; use dpp::serialization::PlatformDeserializable; use dpp::version::PlatformVersion; +use dpp::voting::votes::Vote; use grovedb::query_result_type::QueryResultType::QueryElementResultType; use grovedb::{Element, PathQuery, Query, SizedQuery, TransactionArg}; use grovedb_path::SubtreePath; -use dpp::voting::votes::Vote; impl Drive { /// We remove vote_choices for an identity when that identity is somehow disabled. Currently there is diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs index 90758df3bf..889ff3d79f 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs @@ -1,7 +1,6 @@ use crate::drive::Drive; use crate::error::Error; use dpp::fee::fee_result::FeeResult; -use dpp::identifier::Identifier; use dpp::identity::TimestampMillis; use dpp::voting::votes::Vote; use grovedb::TransactionArg; diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index f88778f1f3..5364ae9e5e 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -3,11 +3,11 @@ use crate::drive::RootTree; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::DataContract; +use dpp::voting::vote_polls::VotePoll; use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; use dpp::voting::votes::resource_vote::ResourceVote; -use dpp::ProtocolError; -use dpp::voting::vote_polls::VotePoll; use dpp::voting::votes::Vote; +use dpp::ProtocolError; mod cleanup; mod insert; @@ -132,61 +132,64 @@ pub trait TreePath { impl TreePath for Vote { fn tree_path(&self, contract: &DataContract) -> Result, ProtocolError> { - match self { Vote::ResourceVote(resource_vote) => { - resource_vote.tree_path(contract) - } } + match self { + Vote::ResourceVote(resource_vote) => resource_vote.tree_path(contract), + } } } impl TreePath for ResourceVote { fn tree_path(&self, contract: &DataContract) -> Result, ProtocolError> { let vote_poll = self.vote_poll(); - - match vote_poll { VotePoll::ContestedDocumentResourceVotePoll(contested_document_vote_poll) => { - if contract.id() != contested_document_vote_poll.contract_id { - return Err(ProtocolError::VoteError(format!( - "contract id of votes {} does not match supplied contract {}", - contested_document_vote_poll.contract_id, - contract.id() - ))); - } - let document_type = contract.document_type_for_name(&contested_document_vote_poll.document_type_name)?; - let index = document_type.indexes().get(&contested_document_vote_poll.index_name).ok_or( - ProtocolError::UnknownContestedIndexResolution(format!( - "no index named {} for document type {} on contract with id {}", - &contested_document_vote_poll.index_name, - document_type.name(), - contract.id() - )), - )?; - let mut path = contract_document_type_path( - &contested_document_vote_poll.contract_id.as_bytes(), - &contested_document_vote_poll.document_type_name, - ) + + match vote_poll { + VotePoll::ContestedDocumentResourceVotePoll(contested_document_vote_poll) => { + if contract.id() != contested_document_vote_poll.contract_id { + return Err(ProtocolError::VoteError(format!( + "contract id of votes {} does not match supplied contract {}", + contested_document_vote_poll.contract_id, + contract.id() + ))); + } + let document_type = contract + .document_type_for_name(&contested_document_vote_poll.document_type_name)?; + let index = document_type + .indexes() + .get(&contested_document_vote_poll.index_name) + .ok_or(ProtocolError::UnknownContestedIndexResolution(format!( + "no index named {} for document type {} on contract with id {}", + &contested_document_vote_poll.index_name, + document_type.name(), + contract.id() + )))?; + let mut path = contract_document_type_path( + &contested_document_vote_poll.contract_id.as_bytes(), + &contested_document_vote_poll.document_type_name, + ) .to_vec(); - // at this point the path only contains the parts before the index + // at this point the path only contains the parts before the index - let Some(contested_index) = &index.contested_index else { - return Err(ProtocolError::VoteError( + let Some(contested_index) = &index.contested_index else { + return Err(ProtocolError::VoteError( "we expect the index in a contested document resource votes type to be contested" .to_string(), )); - }; + }; - let mut properties_iter = index.properties.iter(); + let mut properties_iter = index.properties.iter(); - while let Some(index_part) = properties_iter.next() { - let level_name = if contested_index.contested_field_name == index_part.name { - &contested_index.contested_field_temp_replacement_name - } else { - &index_part.name - }; + while let Some(index_part) = properties_iter.next() { + let level_name = if contested_index.contested_field_name == index_part.name { + &contested_index.contested_field_temp_replacement_name + } else { + &index_part.name + }; - path.push(level_name.as_bytes()); + path.push(level_name.as_bytes()); + } + Ok(path) } - Ok(path) - } } - + } } } diff --git a/packages/rs-drive/src/error/drive.rs b/packages/rs-drive/src/error/drive.rs index 43cfccab5e..741dacd9bf 100644 --- a/packages/rs-drive/src/error/drive.rs +++ b/packages/rs-drive/src/error/drive.rs @@ -1,5 +1,5 @@ -use dpp::fee::Credits; use crate::drive::contract::MAX_CONTRACT_HISTORY_FETCH_LIMIT; +use dpp::fee::Credits; use dpp::version::FeatureVersion; /// Drive errors @@ -164,7 +164,7 @@ pub enum DriveError { /// Error #[error("invalid contract history fetch limit: {0}. The limit must be between 1 and {MAX_CONTRACT_HISTORY_FETCH_LIMIT}")] InvalidContractHistoryFetchLimit(u16), - + /// Error #[error("prefunded specialized balance does not exist: {0}")] PrefundedSpecializedBalanceDoesNotExist(String), diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index a70c6d09c8..82df01de09 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -40,11 +40,12 @@ use crate::version::drive_versions::{ DriveCreditPoolStorageFeeDistributionPoolMethodVersions, DriveCreditPoolUnpaidEpochMethodVersions, DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, - DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertMethodVersions, - DriveDocumentMethodVersions, DriveDocumentQueryMethodVersions, - DriveDocumentUpdateMethodVersions, DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, - DriveFetchMethodVersions, DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, - DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, DriveGroveMethodVersions, + DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertContestedMethodVersions, + DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, + DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, + DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveFetchMethodVersions, + DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, + DriveGroveCostMethodVersions, DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, @@ -58,15 +59,15 @@ use crate::version::drive_versions::{ DriveIdentityWithdrawalTransactionMethodVersions, DriveIdentityWithdrawalTransactionQueueMethodVersions, DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformStateMethodVersions, - DrivePlatformSystemMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, - DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, - DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, - DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, - DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, - DriveVerifySingleDocumentMethodVersions, DriveVerifyStateTransitionMethodVersions, - DriveVerifySystemMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, - DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, - DriveVoteMethodVersions, DriveVoteSetupMethodVersions, + DrivePlatformSystemMethodVersions, DrivePrefundedSpecializedMethodVersions, + DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, + DriveStateTransitionOperationMethodVersions, DriveStructureVersion, + DriveSystemEstimationCostsMethodVersions, DriveVerifyContractMethodVersions, + DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, + DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, + DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVersion, + DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, + DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions, }; use crate::version::fee::v1::FEE_VERSION1; use crate::version::mocks::TEST_PROTOCOL_VERSION_SHIFT_BYTES; @@ -186,6 +187,16 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { add_indices_for_top_index_level_for_contract_operations: 0, add_reference_for_index_level_for_contract_operations: 0, }, + insert_contested: DriveDocumentInsertContestedMethodVersions { + add_contested_document: 0, + add_contested_document_for_contract: 0, + add_contested_document_for_contract_apply_and_add_to_operations: 0, + add_contested_document_for_contract_operations: 0, + add_contested_document_to_primary_storage: 0, + add_contested_indices_for_index_level_for_contract_operations: 0, + add_contested_indices_for_top_index_level_for_contract_operations: 0, + add_contested_reference_for_index_level_for_contract_operations: 0, + }, update: DriveDocumentUpdateMethodVersions { add_update_multiple_documents_operations: 0, update_document_for_contract: 0, @@ -457,6 +468,13 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { store_platform_state_bytes: 0, }, fetch: DriveFetchMethodVersions { fetch_elements: 0 }, + prefunded_specialized_balances: DrivePrefundedSpecializedMethodVersions { + add_prefunded_specialized_balance: 0, + add_prefunded_specialized_balance_operations: 0, + deduct_from_prefunded_specialized_balance: 0, + deduct_from_prefunded_specialized_balance_operations: 0, + estimated_cost_for_prefunded_specialized_balance_update: 0, + }, }, grove_methods: DriveGroveMethodVersions { basic: DriveGroveBasicMethodVersions { diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 4c7207c653..f758719680 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -40,11 +40,12 @@ use crate::version::drive_versions::{ DriveCreditPoolStorageFeeDistributionPoolMethodVersions, DriveCreditPoolUnpaidEpochMethodVersions, DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, - DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertMethodVersions, - DriveDocumentMethodVersions, DriveDocumentQueryMethodVersions, - DriveDocumentUpdateMethodVersions, DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, - DriveFetchMethodVersions, DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, - DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, DriveGroveMethodVersions, + DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertContestedMethodVersions, + DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, + DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, + DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveFetchMethodVersions, + DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, + DriveGroveCostMethodVersions, DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, @@ -58,15 +59,15 @@ use crate::version::drive_versions::{ DriveIdentityWithdrawalTransactionMethodVersions, DriveIdentityWithdrawalTransactionQueueMethodVersions, DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformStateMethodVersions, - DrivePlatformSystemMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, - DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, - DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, - DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, - DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, - DriveVerifySingleDocumentMethodVersions, DriveVerifyStateTransitionMethodVersions, - DriveVerifySystemMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, - DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, - DriveVoteMethodVersions, DriveVoteSetupMethodVersions, + DrivePlatformSystemMethodVersions, DrivePrefundedSpecializedMethodVersions, + DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, + DriveStateTransitionOperationMethodVersions, DriveStructureVersion, + DriveSystemEstimationCostsMethodVersions, DriveVerifyContractMethodVersions, + DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, + DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, + DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVersion, + DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, + DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions, }; use crate::version::fee::v1::FEE_VERSION1; use crate::version::mocks::TEST_PROTOCOL_VERSION_SHIFT_BYTES; @@ -194,6 +195,16 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { add_indices_for_top_index_level_for_contract_operations: 0, add_reference_for_index_level_for_contract_operations: 0, }, + insert_contested: DriveDocumentInsertContestedMethodVersions { + add_contested_document: 0, + add_contested_document_for_contract: 0, + add_contested_document_for_contract_apply_and_add_to_operations: 0, + add_contested_document_for_contract_operations: 0, + add_contested_document_to_primary_storage: 0, + add_contested_indices_for_index_level_for_contract_operations: 0, + add_contested_indices_for_top_index_level_for_contract_operations: 0, + add_contested_reference_for_index_level_for_contract_operations: 0, + }, update: DriveDocumentUpdateMethodVersions { add_update_multiple_documents_operations: 0, update_document_for_contract: 0, @@ -457,6 +468,13 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { store_platform_state_bytes: 0, }, fetch: DriveFetchMethodVersions { fetch_elements: 0 }, + prefunded_specialized_balances: DrivePrefundedSpecializedMethodVersions { + add_prefunded_specialized_balance: 0, + add_prefunded_specialized_balance_operations: 0, + deduct_from_prefunded_specialized_balance: 0, + deduct_from_prefunded_specialized_balance_operations: 0, + estimated_cost_for_prefunded_specialized_balance_update: 0, + }, }, grove_methods: DriveGroveMethodVersions { basic: DriveGroveBasicMethodVersions { diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 9f41147ebd..62b327e8ce 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -40,11 +40,12 @@ use crate::version::drive_versions::{ DriveCreditPoolStorageFeeDistributionPoolMethodVersions, DriveCreditPoolUnpaidEpochMethodVersions, DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, - DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertMethodVersions, - DriveDocumentMethodVersions, DriveDocumentQueryMethodVersions, - DriveDocumentUpdateMethodVersions, DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, - DriveFetchMethodVersions, DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, - DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, DriveGroveMethodVersions, + DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertContestedMethodVersions, + DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, + DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, + DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveFetchMethodVersions, + DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, + DriveGroveCostMethodVersions, DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, @@ -58,15 +59,15 @@ use crate::version::drive_versions::{ DriveIdentityWithdrawalTransactionMethodVersions, DriveIdentityWithdrawalTransactionQueueMethodVersions, DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformStateMethodVersions, - DrivePlatformSystemMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, - DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, - DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, - DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, - DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, - DriveVerifySingleDocumentMethodVersions, DriveVerifyStateTransitionMethodVersions, - DriveVerifySystemMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, - DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, - DriveVoteMethodVersions, DriveVoteSetupMethodVersions, + DrivePlatformSystemMethodVersions, DrivePrefundedSpecializedMethodVersions, + DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, + DriveStateTransitionOperationMethodVersions, DriveStructureVersion, + DriveSystemEstimationCostsMethodVersions, DriveVerifyContractMethodVersions, + DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, + DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, + DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVersion, + DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, + DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions, }; use crate::version::fee::v1::FEE_VERSION1; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; @@ -185,6 +186,16 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { add_indices_for_top_index_level_for_contract_operations: 0, add_reference_for_index_level_for_contract_operations: 0, }, + insert_contested: DriveDocumentInsertContestedMethodVersions { + add_contested_document: 0, + add_contested_document_for_contract: 0, + add_contested_document_for_contract_apply_and_add_to_operations: 0, + add_contested_document_for_contract_operations: 0, + add_contested_document_to_primary_storage: 0, + add_contested_indices_for_index_level_for_contract_operations: 0, + add_contested_indices_for_top_index_level_for_contract_operations: 0, + add_contested_reference_for_index_level_for_contract_operations: 0, + }, update: DriveDocumentUpdateMethodVersions { add_update_multiple_documents_operations: 0, update_document_for_contract: 0, @@ -456,6 +467,13 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { store_platform_state_bytes: 0, }, fetch: DriveFetchMethodVersions { fetch_elements: 0 }, + prefunded_specialized_balances: DrivePrefundedSpecializedMethodVersions { + add_prefunded_specialized_balance: 0, + add_prefunded_specialized_balance_operations: 0, + deduct_from_prefunded_specialized_balance: 0, + deduct_from_prefunded_specialized_balance_operations: 0, + estimated_cost_for_prefunded_specialized_balance_update: 0, + }, }, grove_methods: DriveGroveMethodVersions { basic: DriveGroveBasicMethodVersions { From 3fadcea34df1ff6daf319a4b4cc4f080040143c1 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Thu, 9 May 2024 02:12:17 +0200 Subject: [PATCH 041/135] more work on masternode voting --- .../data_contract/document_type/index/mod.rs | 8 ++++ .../document/document_create_transition.rs | 21 +++++++-- .../identity/masternode_vote_transition.rs | 4 +- .../mod.rs | 2 +- .../v0/mod.rs | 7 ++- .../document_create_transition_action/mod.rs | 3 +- .../v0/mod.rs | 5 ++- .../v0/transformer.rs | 45 ++++++++++++++----- 8 files changed, 71 insertions(+), 24 deletions(-) diff --git a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs index 3baeaae5cf..5569860d0a 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs @@ -201,6 +201,14 @@ impl Index { .map(|property| property.name.clone()) .collect() } + + /// Get values + pub fn extract_values(&self, data: &BTreeMap) -> Vec { + self.properties + .iter() + .map(|property| data.get(&property.name).cloned().unwrap_or(Value::Null)) + .collect() + } } #[derive(Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd)] diff --git a/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs b/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs index 0ac6e057c9..c9d0e27970 100644 --- a/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs +++ b/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs @@ -1,5 +1,7 @@ use crate::drive::batch::transitions::document::DriveHighLevelDocumentOperationConverter; -use crate::drive::batch::DriveOperation::{DocumentOperation, IdentityOperation}; +use crate::drive::batch::DriveOperation::{ + DocumentOperation, IdentityOperation, PrefundedSpecializedBalanceOperation, +}; use crate::drive::batch::{DocumentOperationType, DriveOperation, IdentityOperationType}; use crate::drive::flags::StorageFlags; use crate::drive::object_size_info::DocumentInfo::DocumentOwnedInfo; @@ -13,6 +15,7 @@ use std::borrow::Cow; use crate::state_transition_action::document::documents_batch::document_transition::document_base_transition_action::DocumentBaseTransitionActionAccessorsV0; use crate::state_transition_action::document::documents_batch::document_transition::document_create_transition_action::{DocumentCreateTransitionAction, DocumentCreateTransitionActionAccessorsV0, DocumentFromCreateTransitionAction}; use dpp::version::PlatformVersion; +use crate::drive::batch::drive_op_batch::PrefundedSpecializedBalanceOperationType; use crate::drive::object_size_info::DataContractInfo::DataContractFetchInfo; impl DriveHighLevelDocumentOperationConverter for DocumentCreateTransitionAction { @@ -57,9 +60,19 @@ impl DriveHighLevelDocumentOperationConverter for DocumentCreateTransitionAction override_document: false, })); } else { - // We are in the situation of a contested document - // We prefund the voting balances first - ops.push(); + for (contested_document_resource_vote_poll, credits) in prefunded_voting_balances { + let prefunded_specialized_balance_id = + contested_document_resource_vote_poll.specialized_balance_id()?; + // We are in the situation of a contested document + // We prefund the voting balances first + ops.push(PrefundedSpecializedBalanceOperation( + PrefundedSpecializedBalanceOperationType::CreateNewPrefundedBalance { + prefunded_specialized_balance_id, + add_balance: *credits, + }, + )); + } + // We add the contested document // The contested document resides in a special location in grovedb until a time where the // resolution expires, at that point it either will be moved to diff --git a/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs b/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs index e6b04521ff..a935ebce7a 100644 --- a/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs +++ b/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs @@ -15,12 +15,12 @@ impl DriveHighLevelOperationConverter for MasternodeVoteTransitionAction { fn into_high_level_drive_operations<'a>( self, _epoch: &Epoch, - platform_version: &PlatformVersion, + _platform_version: &PlatformVersion, ) -> Result>, Error> { let pro_tx_hash = self.pro_tx_hash(); let nonce = self.nonce(); let vote = self.vote_owned(); - let prefunded_specialized_balance_id = vote.specialized_balance_id(platform_version)?.ok_or(Error::Protocol(ProtocolError::VoteError("vote does not have a specialized balance from where it can use to pay for processing (this should have been caught during validation)".to_string())))?; + let prefunded_specialized_balance_id = vote.specialized_balance_id()?.ok_or(Error::Protocol(ProtocolError::VoteError("vote does not have a specialized balance from where it can use to pay for processing (this should have been caught during validation)".to_string())))?; let drive_operations = vec![ IdentityOperation(IdentityOperationType::UpdateIdentityNonce { diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/mod.rs index 18757b493d..76c2f0d3fd 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/mod.rs @@ -49,7 +49,7 @@ impl Drive { .insert_contested .add_contested_document_to_primary_storage { - 0 => self.add_document_to_primary_storage_0( + 0 => self.add_contested_document_to_primary_storage_0( document_and_contract_info, block_info, insert_without_check, diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs index 57a645d64f..550aa43903 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs @@ -5,7 +5,10 @@ use grovedb::EstimatedLayerCount::{ApproximateElements, EstimatedLevel}; use grovedb::EstimatedLayerInformation; use grovedb::EstimatedLayerSizes::{AllItems, AllSubtrees}; -use crate::drive::prefunded_specialized_balances::prefunded_specialized_balances_for_voting_path; +use crate::drive::prefunded_specialized_balances::{ + prefunded_specialized_balances_for_voting_path, + prefunded_specialized_balances_for_voting_path_vec, +}; use grovedb::EstimatedSumTrees::SomeSumTrees; use std::collections::HashMap; @@ -41,7 +44,7 @@ impl Drive { //todo : verify this // we then need to insert the contract layer estimated_costs_only_with_layer_info.insert( - KeyInfoPath::from_known_owned_path(prefunded_specialized_balances_for_voting_path()), + KeyInfoPath::from_known_owned_path(prefunded_specialized_balances_for_voting_path_vec()), EstimatedLayerInformation { is_sum_tree: true, estimated_layer_count: ApproximateElements(0), diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs index 4c9a42fd07..51d02dafb7 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs @@ -17,6 +17,7 @@ use dpp::ProtocolError; pub use v0::*; use crate::state_transition_action::document::documents_batch::document_transition::document_base_transition_action::{DocumentBaseTransitionAction}; use dpp::version::PlatformVersion; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; /// document create transition action #[derive(Debug, Clone, From)] @@ -62,7 +63,7 @@ impl DocumentCreateTransitionActionAccessorsV0 for DocumentCreateTransitionActio } } - fn prefunded_voting_balances(&self) -> &BTreeMap { + fn prefunded_voting_balances(&self) -> &Vec<(ContestedDocumentResourceVotePoll, Credits)> { match self { DocumentCreateTransitionAction::V0(v0) => &v0.prefunded_voting_balances, } diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs index 24405dd90e..b34c0b4679 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs @@ -21,6 +21,7 @@ use dpp::fee::Credits; use crate::state_transition_action::document::documents_batch::document_transition::document_base_transition_action::{DocumentBaseTransitionAction, DocumentBaseTransitionActionV0}; use dpp::version::PlatformVersion; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; /// document create transition action v0 #[derive(Debug, Clone)] @@ -33,7 +34,7 @@ pub struct DocumentCreateTransitionActionV0 { pub data: BTreeMap, /// Pre funded balance (for unique index conflict resolution voting - the identity will put money /// aside that will be used by voters to vote) - pub prefunded_voting_balances: BTreeMap, + pub prefunded_voting_balances: Vec<(ContestedDocumentResourceVotePoll, Credits)>, } /// document create transition action accessors v0 @@ -53,7 +54,7 @@ pub trait DocumentCreateTransitionActionAccessorsV0 { /// pre funded balance (for unique index conflict resolution voting - the identity will put money /// aside that will be used by voters to vote) - fn prefunded_voting_balances(&self) -> &BTreeMap; + fn prefunded_voting_balances(&self) -> &Vec<(ContestedDocumentResourceVotePoll, Credits)>; } /// documents from create transition v0 diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs index 6cfb3b3fc7..f1f90652b0 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs @@ -8,6 +8,7 @@ use std::sync::Arc; use dpp::ProtocolError; use dpp::state_transition::documents_batch_transition::document_create_transition::v0::DocumentCreateTransitionV0; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use crate::drive::contract::DataContractFetchInfo; use crate::state_transition_action::document::documents_batch::document_transition::document_base_transition_action::{DocumentBaseTransitionAction, DocumentBaseTransitionActionAccessorsV0}; use crate::state_transition_action::document::documents_batch::document_transition::document_create_transition_action::DocumentCreateTransitionActionV0; @@ -34,25 +35,35 @@ impl DocumentCreateTransitionActionV0 { let document_type_indexes = document_type.indexes(); - let prefunded_voting_balances_by_index = prefunded_voting_balances + let prefunded_voting_balances_by_vote_poll = prefunded_voting_balances .into_iter() .map(|(index_name, credits)| { let index = document_type_indexes.get(&index_name).ok_or( ProtocolError::UnknownContestedIndexResolution(format!( "index {} not found on document type {}", - index_name, + index_name.clone(), document_type.name() )), )?; - Ok((index.clone(), credits)) + let index_values = index.extract_values(&data); + + let vote_poll = ContestedDocumentResourceVotePoll { + contract_id: base.data_contract_id(), + document_type_name: base.document_type_name().clone(), + index_name, + index_values, + }; + + Ok((vote_poll, credits)) }) - .collect::, ProtocolError>>()?; + .collect::, ProtocolError>>( + )?; Ok(DocumentCreateTransitionActionV0 { base, block_info: *block_info, data, - prefunded_voting_balances: prefunded_voting_balances_by_index, + prefunded_voting_balances: prefunded_voting_balances_by_vote_poll, }) } @@ -78,26 +89,36 @@ impl DocumentCreateTransitionActionV0 { let document_type_indexes = document_type.indexes(); - let prefunded_voting_balances_by_index = prefunded_voting_balances - .iter() + let prefunded_voting_balances_by_vote_poll = prefunded_voting_balances + .into_iter() .map(|(index_name, credits)| { - let index = document_type_indexes.get(index_name).ok_or( + let index = document_type_indexes.get(&index_name).ok_or( ProtocolError::UnknownContestedIndexResolution(format!( "index {} not found on document type {}", - index_name, + index_name.clone(), document_type.name() )), )?; - Ok((index.clone(), *credits)) + let index_values = index.extract_values(&data); + + let vote_poll = ContestedDocumentResourceVotePoll { + contract_id: base.data_contract_id(), + document_type_name: base.document_type_name().clone(), + index_name: index_name.clone(), + index_values, + }; + + Ok((vote_poll, credits)) }) - .collect::, ProtocolError>>()?; + .collect::, ProtocolError>>( + )?; Ok(DocumentCreateTransitionActionV0 { base, block_info: *block_info, //todo: get rid of clone data: data.clone(), - prefunded_voting_balances: prefunded_voting_balances_by_index, + prefunded_voting_balances: prefunded_voting_balances_by_vote_poll, }) } } From 0ce04ff447b7fda7ba0f190ee5ec44346e705248 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Thu, 9 May 2024 13:20:53 +0200 Subject: [PATCH 042/135] more work --- .../mod.rs | 3 +- packages/rs-dpp/src/voting/vote_polls/mod.rs | 1 - packages/rs-dpp/src/voting/votes/mod.rs | 1 - .../v0/mod.rs | 2 +- .../v0/mod.rs | 2 +- .../v0/mod.rs | 2 +- .../mod.rs | 2 + .../v0/mod.rs | 73 ++++++++--- .../v0/mod.rs | 7 ++ .../v0/mod.rs | 1 + .../drive/object_size_info/drive_key_info.rs | 14 +-- .../src/drive/object_size_info/path_info.rs | 22 ++-- .../object_size_info/path_key_element_info.rs | 6 +- .../v0/mod.rs | 1 - .../remove_votes_for_identity/v0/mod.rs | 2 +- .../votes/insert/contested_resource/mod.rs | 1 - .../add_vote_poll_end_date_query/mod.rs | 38 ------ .../add_vote_poll_end_date_query/v0/mod.rs | 20 --- .../contested_resource/vote_poll/mod.rs | 1 - .../rs-drive/src/drive/votes/insert/mod.rs | 1 + .../mod.rs | 48 ++++++++ .../v0/mod.rs | 94 ++++++++++++++ .../src/drive/votes/insert/vote_poll/mod.rs | 1 + packages/rs-drive/src/drive/votes/mod.rs | 115 +----------------- packages/rs-drive/src/drive/votes/paths.rs | 114 +++++++++++++++++ .../v0/mod.rs | 5 +- .../document_create_transition_action/mod.rs | 1 - .../v0/mod.rs | 1 - .../v0/transformer.rs | 6 +- .../document/documents_batch/v0/mod.rs | 3 +- 30 files changed, 352 insertions(+), 236 deletions(-) delete mode 100644 packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/mod.rs delete mode 100644 packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs delete mode 100644 packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/insert/vote_poll/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/paths.rs diff --git a/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs b/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs index c91df81b6e..d38abea58a 100644 --- a/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs +++ b/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs @@ -1,10 +1,9 @@ use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; -use crate::serialization::{PlatformSerializable, PlatformSerializableWithPlatformVersion}; +use crate::serialization::PlatformSerializable; use crate::util::hash::hash_double; use crate::ProtocolError; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use platform_value::{Identifier, Value}; -use platform_version::version::PlatformVersion; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize, PartialEq)] diff --git a/packages/rs-dpp/src/voting/vote_polls/mod.rs b/packages/rs-dpp/src/voting/vote_polls/mod.rs index 3d9381b4f4..6dbb3f27c5 100644 --- a/packages/rs-dpp/src/voting/vote_polls/mod.rs +++ b/packages/rs-dpp/src/voting/vote_polls/mod.rs @@ -3,7 +3,6 @@ use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedD use crate::ProtocolError; use derive_more::From; use platform_value::Identifier; -use platform_version::version::PlatformVersion; use serde::{Deserialize, Serialize}; pub mod contested_document_resource_vote_poll; diff --git a/packages/rs-dpp/src/voting/votes/mod.rs b/packages/rs-dpp/src/voting/votes/mod.rs index 9e0b28c584..488d97b360 100644 --- a/packages/rs-dpp/src/voting/votes/mod.rs +++ b/packages/rs-dpp/src/voting/votes/mod.rs @@ -9,7 +9,6 @@ use bincode::{Decode, Encode}; #[cfg(feature = "vote-serialization")] use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use platform_value::Identifier; -use platform_version::version::PlatformVersion; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, PartialEq)] diff --git a/packages/rs-drive/src/drive/document/delete/remove_indices_for_top_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/delete/remove_indices_for_top_index_level_for_contract_operations/v0/mod.rs index 7e502ca517..19ad064164 100644 --- a/packages/rs-drive/src/drive/document/delete/remove_indices_for_top_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/remove_indices_for_top_index_level_for_contract_operations/v0/mod.rs @@ -139,7 +139,7 @@ impl Drive { // This is a stateless operation PathInfo::PathWithSizes(KeyInfoPath::from_known_owned_path(index_path)) } else { - PathInfo::PathIterator::<0>(index_path) + PathInfo::PathAsVec::<0>(index_path) }; // we push the actual value of the index path diff --git a/packages/rs-drive/src/drive/document/insert/add_indices_for_top_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_indices_for_top_index_level_for_contract_operations/v0/mod.rs index 94f7cfc6ea..24a69d40be 100644 --- a/packages/rs-drive/src/drive/document/insert/add_indices_for_top_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_indices_for_top_index_level_for_contract_operations/v0/mod.rs @@ -166,7 +166,7 @@ impl Drive { // This is a stateless operation PathInfo::PathWithSizes(KeyInfoPath::from_known_owned_path(index_path)) } else { - PathInfo::PathIterator::<0>(index_path) + PathInfo::PathAsVec::<0>(index_path) }; // we push the actual value of the index path diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs index e05c4d0a0e..c0acd51bfa 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs @@ -166,7 +166,7 @@ impl Drive { // This is a stateless operation PathInfo::PathWithSizes(KeyInfoPath::from_known_owned_path(index_path)) } else { - PathInfo::PathIterator::<0>(index_path) + PathInfo::PathAsVec::<0>(index_path) }; // we push the actual value of the index path diff --git a/packages/rs-drive/src/drive/grove_operations/batch_insert_empty_tree_if_not_exists_check_existing_operations/mod.rs b/packages/rs-drive/src/drive/grove_operations/batch_insert_empty_tree_if_not_exists_check_existing_operations/mod.rs index 3ae1d40a46..62c32de2ee 100644 --- a/packages/rs-drive/src/drive/grove_operations/batch_insert_empty_tree_if_not_exists_check_existing_operations/mod.rs +++ b/packages/rs-drive/src/drive/grove_operations/batch_insert_empty_tree_if_not_exists_check_existing_operations/mod.rs @@ -31,6 +31,7 @@ impl Drive { pub fn batch_insert_empty_tree_if_not_exists_check_existing_operations( &self, path_key_info: PathKeyInfo, + use_sum_tree: bool, storage_flags: Option<&StorageFlags>, apply_type: BatchInsertTreeApplyType, transaction: TransactionArg, @@ -44,6 +45,7 @@ impl Drive { { 0 => self.batch_insert_empty_tree_if_not_exists_check_existing_operations_v0( path_key_info, + use_sum_tree, storage_flags, apply_type, transaction, diff --git a/packages/rs-drive/src/drive/grove_operations/batch_insert_empty_tree_if_not_exists_check_existing_operations/v0/mod.rs b/packages/rs-drive/src/drive/grove_operations/batch_insert_empty_tree_if_not_exists_check_existing_operations/v0/mod.rs index 7851e4a941..36c1cf0033 100644 --- a/packages/rs-drive/src/drive/grove_operations/batch_insert_empty_tree_if_not_exists_check_existing_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/grove_operations/batch_insert_empty_tree_if_not_exists_check_existing_operations/v0/mod.rs @@ -20,6 +20,7 @@ impl Drive { >( &self, path_key_info: PathKeyInfo, + use_sum_tree: bool, storage_flags: Option<&StorageFlags>, apply_type: BatchInsertTreeApplyType, transaction: TransactionArg, @@ -28,11 +29,19 @@ impl Drive { ) -> Result { match path_key_info { PathKeyRef((path, key)) => { - let drive_operation = LowLevelDriveOperation::for_known_path_key_empty_tree( - path.clone(), - key.to_vec(), - storage_flags, - ); + let drive_operation = if use_sum_tree { + LowLevelDriveOperation::for_known_path_key_empty_sum_tree( + path.clone(), + key.to_vec(), + storage_flags, + ) + } else { + LowLevelDriveOperation::for_known_path_key_empty_tree( + path.clone(), + key.to_vec(), + storage_flags, + ) + }; // we only add the operation if it doesn't already exist in the current batch if !drive_operations.contains(&drive_operation) { let has_raw = self.grove_has_raw( @@ -55,11 +64,19 @@ impl Drive { DriveError::NotSupportedPrivate("document sizes in batch operations not supported"), )), PathKey((path, key)) => { - let drive_operation = LowLevelDriveOperation::for_known_path_key_empty_tree( - path.clone(), - key.clone(), - storage_flags, - ); + let drive_operation = if use_sum_tree { + LowLevelDriveOperation::for_known_path_key_empty_sum_tree( + path.clone(), + key.to_vec(), + storage_flags, + ) + } else { + LowLevelDriveOperation::for_known_path_key_empty_tree( + path.clone(), + key.to_vec(), + storage_flags, + ) + }; // we only add the operation if it doesn't already exist in the current batch if !drive_operations.contains(&drive_operation) { let has_raw = self.grove_has_raw( @@ -80,11 +97,19 @@ impl Drive { } PathFixedSizeKey((path, key)) => { let path_items: Vec> = path.into_iter().map(Vec::from).collect(); - let drive_operation = LowLevelDriveOperation::for_known_path_key_empty_tree( - path_items, - key.to_vec(), - storage_flags, - ); + let drive_operation = if use_sum_tree { + LowLevelDriveOperation::for_known_path_key_empty_sum_tree( + path_items, + key.to_vec(), + storage_flags, + ) + } else { + LowLevelDriveOperation::for_known_path_key_empty_tree( + path_items, + key.to_vec(), + storage_flags, + ) + }; // we only add the operation if it doesn't already exist in the current batch if !drive_operations.contains(&drive_operation) { let has_raw = self.grove_has_raw( @@ -105,11 +130,19 @@ impl Drive { } PathFixedSizeKeyRef((path, key)) => { let path_items: Vec> = path.into_iter().map(Vec::from).collect(); - let drive_operation = LowLevelDriveOperation::for_known_path_key_empty_tree( - path_items, - key.to_vec(), - storage_flags, - ); + let drive_operation = if use_sum_tree { + LowLevelDriveOperation::for_known_path_key_empty_sum_tree( + path_items, + key.to_vec(), + storage_flags, + ) + } else { + LowLevelDriveOperation::for_known_path_key_empty_tree( + path_items, + key.to_vec(), + storage_flags, + ) + }; // we only add the operation if it doesn't already exist in the current batch if !drive_operations.contains(&drive_operation) { let has_raw = self.grove_has_raw( diff --git a/packages/rs-drive/src/drive/identity/contract_info/keys/add_potential_contract_info_for_contract_bounded_key/v0/mod.rs b/packages/rs-drive/src/drive/identity/contract_info/keys/add_potential_contract_info_for_contract_bounded_key/v0/mod.rs index b43ee22d05..0279570bd2 100644 --- a/packages/rs-drive/src/drive/identity/contract_info/keys/add_potential_contract_info_for_contract_bounded_key/v0/mod.rs +++ b/packages/rs-drive/src/drive/identity/contract_info/keys/add_potential_contract_info_for_contract_bounded_key/v0/mod.rs @@ -104,6 +104,7 @@ impl Drive { // we insert the contract root tree if it doesn't exist already self.batch_insert_empty_tree_if_not_exists_check_existing_operations( PathKeyInfo::<0>::PathKey((identity_path, vec![IdentityContractInfo as u8])), + false, None, apply_type, transaction, @@ -171,6 +172,7 @@ impl Drive { identity_contract_info_root_path_vec(&identity_id), root_id.to_vec(), )), + false, None, apply_type, transaction, @@ -184,6 +186,7 @@ impl Drive { identity_contract_info_group_path_vec(&identity_id, &root_id), vec![ContractInfoKeysKey as u8], )), + false, None, apply_type, transaction, @@ -211,6 +214,7 @@ impl Drive { identity_contract_info_group_keys_path_vec(&identity_id, &root_id), vec![purpose as u8], )), + false, None, apply_type, transaction, @@ -350,6 +354,7 @@ impl Drive { identity_contract_info_root_path_vec(&identity_id), contract_id_bytes_with_document_type_name.to_vec(), )), + false, None, apply_type, transaction, @@ -365,6 +370,7 @@ impl Drive { ), vec![ContractInfoKeysKey as u8], )), + false, None, apply_type, transaction, @@ -394,6 +400,7 @@ impl Drive { ), vec![purpose as u8], )), + false, None, apply_type, transaction, diff --git a/packages/rs-drive/src/drive/identity/key/insert/insert_key_searchable_references/v0/mod.rs b/packages/rs-drive/src/drive/identity/key/insert/insert_key_searchable_references/v0/mod.rs index 588d686cbe..ba3ca72a86 100644 --- a/packages/rs-drive/src/drive/identity/key/insert/insert_key_searchable_references/v0/mod.rs +++ b/packages/rs-drive/src/drive/identity/key/insert/insert_key_searchable_references/v0/mod.rs @@ -87,6 +87,7 @@ impl Drive { // We need to insert the security level if it doesn't yet exist self.batch_insert_empty_tree_if_not_exists_check_existing_operations( PathFixedSizeKey((purpose_path, vec![security_level as u8])), + false, None, apply_type, transaction, diff --git a/packages/rs-drive/src/drive/object_size_info/drive_key_info.rs b/packages/rs-drive/src/drive/object_size_info/drive_key_info.rs index 82fa24f7f7..a690cbeb2e 100644 --- a/packages/rs-drive/src/drive/object_size_info/drive_key_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/drive_key_info.rs @@ -4,7 +4,7 @@ use crate::drive::object_size_info::path_key_info::PathKeyInfo::{ }; use crate::drive::object_size_info::PathInfo; use crate::drive::object_size_info::PathInfo::{ - PathFixedSizeIterator, PathIterator, PathWithSizes, + PathFixedSizeArray, PathAsVec, PathWithSizes, }; use grovedb::batch::key_info::KeyInfo; use grovedb::batch::key_info::KeyInfo::KnownKey; @@ -52,22 +52,22 @@ impl<'a> DriveKeyInfo<'a> { pub fn add_path_info(self, path_info: PathInfo<'a, N>) -> PathKeyInfo<'a, N> { match self { Key(key) => match path_info { - PathFixedSizeIterator(iter) => PathFixedSizeKey((iter, key)), - PathIterator(iter) => PathKey((iter, key)), + PathFixedSizeArray(iter) => PathFixedSizeKey((iter, key)), + PathAsVec(iter) => PathKey((iter, key)), PathWithSizes(key_info_path) => PathKeySize(key_info_path, KnownKey(key)), }, KeyRef(key_ref) => match path_info { - PathFixedSizeIterator(iter) => PathFixedSizeKeyRef((iter, key_ref)), - PathIterator(iter) => PathKeyRef((iter, key_ref)), + PathFixedSizeArray(iter) => PathFixedSizeKeyRef((iter, key_ref)), + PathAsVec(iter) => PathKeyRef((iter, key_ref)), PathWithSizes(key_info_path) => { PathKeySize(key_info_path, KnownKey(key_ref.to_vec())) } }, KeySize(key_info) => match path_info { - PathFixedSizeIterator(iter) => { + PathFixedSizeArray(iter) => { PathKeySize(KeyInfoPath::from_known_path(iter), key_info) } - PathIterator(iter) => { + PathAsVec(iter) => { PathKeySize(KeyInfoPath::from_known_owned_path(iter), key_info) } PathWithSizes(key_info_path) => PathKeySize(key_info_path, key_info), diff --git a/packages/rs-drive/src/drive/object_size_info/path_info.rs b/packages/rs-drive/src/drive/object_size_info/path_info.rs index b2264ba2fb..70a3844cbf 100644 --- a/packages/rs-drive/src/drive/object_size_info/path_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/path_info.rs @@ -4,7 +4,7 @@ use grovedb::batch::KeyInfoPath; use grovedb_storage::worst_case_costs::WorstKeyLength; use DriveKeyInfo::{Key, KeyRef, KeySize}; -use PathInfo::{PathFixedSizeIterator, PathIterator, PathWithSizes}; +use PathInfo::{PathFixedSizeArray, PathAsVec, PathWithSizes}; use crate::drive::object_size_info::drive_key_info::DriveKeyInfo; use crate::error::drive::DriveError; @@ -14,10 +14,10 @@ use crate::error::Error; #[derive(Clone)] pub enum PathInfo<'a, const N: usize> { /// An into iter Path - PathFixedSizeIterator([&'a [u8]; N]), + PathFixedSizeArray([&'a [u8]; N]), /// An into iter Path - PathIterator(Vec>), + PathAsVec(Vec>), /// A path size PathWithSizes(KeyInfoPath), @@ -27,10 +27,10 @@ impl<'a, const N: usize> PathInfo<'a, N> { /// Returns the length of the path as a usize. pub fn len(&self) -> u32 { match self { - PathFixedSizeIterator(path_iterator) => { + PathFixedSizeArray(path_iterator) => { (*path_iterator).into_iter().map(|a| a.len() as u32).sum() } - PathIterator(path_iterator) => path_iterator.iter().map(|a| a.len() as u32).sum(), + PathAsVec(path_iterator) => path_iterator.iter().map(|a| a.len() as u32).sum(), PathWithSizes(path_size) => path_size.iterator().map(|a| a.max_length() as u32).sum(), } } @@ -38,8 +38,8 @@ impl<'a, const N: usize> PathInfo<'a, N> { /// Returns true if the path is empty. pub fn is_empty(&self) -> bool { match self { - PathFixedSizeIterator(path_iterator) => (*path_iterator).is_empty(), - PathIterator(path_iterator) => path_iterator.is_empty(), + PathFixedSizeArray(path_iterator) => (*path_iterator).is_empty(), + PathAsVec(path_iterator) => path_iterator.is_empty(), PathWithSizes(path_size) => path_size.is_empty(), } } @@ -47,12 +47,12 @@ impl<'a, const N: usize> PathInfo<'a, N> { /// Pushes the given key into the path. pub fn push(&mut self, key_info: DriveKeyInfo<'a>) -> Result<(), Error> { match self { - PathFixedSizeIterator(_) => { + PathFixedSizeArray(_) => { return Err(Error::Drive(DriveError::CorruptedCodeExecution( "can not add a key to a fixed size path iterator", ))) } - PathIterator(path_iterator) => match key_info { + PathAsVec(path_iterator) => match key_info { Key(key) => path_iterator.push(key), KeyRef(key_ref) => path_iterator.push(key_ref.to_vec()), KeySize(..) => { @@ -73,8 +73,8 @@ impl<'a, const N: usize> PathInfo<'a, N> { /// Get the KeyInfoPath for grovedb estimated costs pub(crate) fn convert_to_key_info_path(self) -> KeyInfoPath { match self { - PathFixedSizeIterator(path) => KeyInfoPath::from_known_path(path), - PathIterator(path) => KeyInfoPath::from_known_owned_path(path), + PathFixedSizeArray(path) => KeyInfoPath::from_known_path(path), + PathAsVec(path) => KeyInfoPath::from_known_owned_path(path), PathWithSizes(key_info_path) => key_info_path, } } diff --git a/packages/rs-drive/src/drive/object_size_info/path_key_element_info.rs b/packages/rs-drive/src/drive/object_size_info/path_key_element_info.rs index a59e8137c4..32a7d0b7f5 100644 --- a/packages/rs-drive/src/drive/object_size_info/path_key_element_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/path_key_element_info.rs @@ -2,7 +2,7 @@ use crate::drive::object_size_info::path_key_element_info::PathKeyElementInfo::{ PathFixedSizeKeyRefElement, PathKeyElementSize, PathKeyRefElement, PathKeyUnknownElementSize, }; use crate::drive::object_size_info::PathInfo::{ - PathFixedSizeIterator, PathIterator, PathWithSizes, + PathFixedSizeArray, PathAsVec, PathWithSizes, }; use crate::drive::object_size_info::{KeyElementInfo, PathInfo}; use crate::error::drive::DriveError; @@ -33,7 +33,7 @@ impl<'a, const N: usize> PathKeyElementInfo<'a, N> { key_element: KeyElementInfo<'a>, ) -> Result { match path_info { - PathIterator(path) => match key_element { + PathAsVec(path) => match key_element { KeyElementInfo::KeyElement((key, element)) => { Ok(PathKeyRefElement((path, key, element))) } @@ -59,7 +59,7 @@ impl<'a, const N: usize> PathKeyElementInfo<'a, N> { PathKeyUnknownElementSize((path_size, key_len, element_size)), ), }, - PathFixedSizeIterator(path) => match key_element { + PathFixedSizeArray(path) => match key_element { KeyElementInfo::KeyElement((key, element)) => { Ok(PathFixedSizeKeyRefElement((path, key, element))) } diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs index 550aa43903..39e63d1eba 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs @@ -6,7 +6,6 @@ use grovedb::EstimatedLayerInformation; use grovedb::EstimatedLayerSizes::{AllItems, AllSubtrees}; use crate::drive::prefunded_specialized_balances::{ - prefunded_specialized_balances_for_voting_path, prefunded_specialized_balances_for_voting_path_vec, }; use grovedb::EstimatedSumTrees::SomeSumTrees; diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs index 5affb3d2b8..7c0d934077 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs @@ -5,7 +5,7 @@ use crate::error::drive::DriveError; use crate::error::Error; use crate::drive::grove_operations::BatchDeleteApplyType; -use crate::drive::votes::vote_contested_resource_identity_votes_tree_path_for_identity_vec; +use crate::drive::votes::paths::vote_contested_resource_identity_votes_tree_path_for_identity_vec; use crate::drive::votes::TreePath; use crate::query::QueryItem; use dpp::prelude::Identifier; diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/mod.rs index cd377f2ee7..d0a511690d 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/mod.rs @@ -1,3 +1,2 @@ mod individual_vote; -mod vote_poll; diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/mod.rs deleted file mode 100644 index 56971ec259..0000000000 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/mod.rs +++ /dev/null @@ -1,38 +0,0 @@ -mod v0; - -use crate::drive::Drive; - -use crate::error::drive::DriveError; -use crate::error::Error; - -use dpp::fee::fee_result::FeeResult; - -use dpp::prelude::Identifier; -use dpp::version::PlatformVersion; -use grovedb::TransactionArg; - -impl Drive { - /// We add votes poll references by end date in order to be able to check on every new block if - /// any votes poll should be closed. - pub fn add_vote_poll_end_date_query( - &self, - identity_id: Identifier, - transaction: TransactionArg, - platform_version: &PlatformVersion, - ) -> Result { - match platform_version - .drive - .methods - .vote - .contested_resource_insert - .add_vote_poll_end_date_query - { - 0 => self.add_vote_poll_end_date_query_v0(identity_id, transaction, platform_version), - version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "add_vote_poll_end_date_query".to_string(), - known_versions: vec![0], - received: version, - })), - } - } -} diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs deleted file mode 100644 index 889ff3d79f..0000000000 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/add_vote_poll_end_date_query/v0/mod.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::drive::Drive; -use crate::error::Error; -use dpp::fee::fee_result::FeeResult; -use dpp::identity::TimestampMillis; -use dpp::voting::votes::Vote; -use grovedb::TransactionArg; -use platform_version::version::PlatformVersion; - -impl Drive { - /// We add votes poll references by end date in order to be able to check on every new block if - /// any vote polls should be closed. - pub(super) fn add_vote_poll_end_date_query_v0( - &self, - contract_id: Vote, - end_date: TimestampMillis, - transaction: TransactionArg, - platform_version: &PlatformVersion, - ) -> Result { - } -} diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/mod.rs deleted file mode 100644 index 601f917296..0000000000 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/vote_poll/mod.rs +++ /dev/null @@ -1 +0,0 @@ -mod add_vote_poll_end_date_query; diff --git a/packages/rs-drive/src/drive/votes/insert/mod.rs b/packages/rs-drive/src/drive/votes/insert/mod.rs index 32924701ca..d044cd2ad2 100644 --- a/packages/rs-drive/src/drive/votes/insert/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/mod.rs @@ -1,3 +1,4 @@ mod add_new_masternode_vote_type; mod contested_resource; mod register_identity_vote; +mod vote_poll; diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs new file mode 100644 index 0000000000..d50d3ce457 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs @@ -0,0 +1,48 @@ +mod v0; + +use std::collections::HashMap; +use grovedb::batch::KeyInfoPath; +use crate::drive::Drive; + +use crate::error::drive::DriveError; +use crate::error::Error; + +use dpp::fee::fee_result::FeeResult; + +use dpp::prelude::{Identifier, TimestampMillis}; +use dpp::version::PlatformVersion; +use grovedb::{EstimatedLayerInformation, TransactionArg}; +use dpp::voting::vote_polls::VotePoll; +use crate::fee::op::LowLevelDriveOperation; + +impl Drive { + /// We add votes poll references by end date in order to be able to check on every new block if + /// any votes poll should be closed. + pub fn add_vote_poll_end_date_query_operations( + &self, + vote_poll: VotePoll, + end_date: TimestampMillis, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + previous_batch_operations: &mut Option<&mut Vec>, + batch_operations: &mut Vec, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + match platform_version + .drive + .methods + .vote + .contested_resource_insert + .add_vote_poll_end_date_query + { + 0 => self.add_vote_poll_end_date_query_operations_v0(vote_poll, end_date, estimated_costs_only_with_layer_info, previous_batch_operations, batch_operations, transaction, platform_version), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "add_vote_poll_end_date_query_operations".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs new file mode 100644 index 0000000000..5d622f2a2b --- /dev/null +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs @@ -0,0 +1,94 @@ +use std::collections::HashMap; +use grovedb::batch::KeyInfoPath; +use crate::drive::Drive; +use crate::error::Error; +use dpp::fee::fee_result::FeeResult; +use dpp::identity::TimestampMillis; +use grovedb::{EstimatedLayerInformation, TransactionArg}; +use dpp::block::block_info::BlockInfo; +use dpp::identifier::Identifier; +use dpp::voting::vote_polls::VotePoll; +use platform_version::version::PlatformVersion; +use crate::drive::flags::StorageFlags; +use crate::drive::grove_operations::BatchInsertTreeApplyType; +use crate::drive::object_size_info::{DriveKeyInfo, PathInfo}; +use crate::drive::votes::paths::vote_contested_resource_end_date_queries_tree_path_vec; +use crate::fee::op::LowLevelDriveOperation; + +impl Drive { + /// We add votes poll references by end date in order to be able to check on every new block if + /// any vote polls should be closed. + pub(in crate::drive::votes::insert) fn add_vote_poll_end_date_query_operations_v0( + &self, + creator_identity_id: Option, + vote_poll: VotePoll, + end_date: TimestampMillis, + block_info: &BlockInfo, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + previous_batch_operations: &mut Option<&mut Vec>, + batch_operations: &mut Vec, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + + let storage_flags = creator_identity_id.map(|creator_identity_id| { + StorageFlags::new_single_epoch( + block_info.epoch.index, + Some(creator_identity_id.to_buffer()), + ) + }); + + // This is a GroveDB Tree (Not Sub Tree Merk representation) + // End Date queries + // / \ + // 15/08/2025 5PM 15/08/2025 6PM + // / \ | + // VotePoll Info 1 VotePoll Info 2 VotePoll Info 3 + + + // Let's start by inserting a tree for the end date + + let end_date_query_path = vote_contested_resource_end_date_queries_tree_path_vec(); + + let drive_key = DriveKeyInfo::Key(end_date.to_be_bytes().to_vec()); + + let path_key_info = drive_key.add_path_info::<0>(PathInfo::PathAsVec(end_date_query_path)); + + let apply_type = if estimated_costs_only_with_layer_info.is_none() { + BatchInsertTreeApplyType::StatefulBatchInsertTree + } else { + BatchInsertTreeApplyType::StatelessBatchInsertTree { + in_tree_using_sums: false, + is_sum_tree: false, + flags_len: storage_flags + .map(|s| s.serialized_size()) + .unwrap_or_default(), + } + }; + + // We check existing operations just because it is possible that we have already inserted the same + // end data in the documents batch transition + self.batch_insert_empty_tree_if_not_exists_check_existing_operations( + path_key_info.clone(), + false, + storage_flags.as_ref(), + apply_type, + transaction, + previous_batch_operations, + batch_operations, + &platform_version.drive, + )?; + + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info + { + Self::add_estimation_costs_for_levels_up_to_contract_document_type_excluded( + contract, + estimated_costs_only_with_layer_info, + drive_version, + )?; + } + + } +} diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/mod.rs new file mode 100644 index 0000000000..26d37fb179 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/mod.rs @@ -0,0 +1 @@ +mod add_vote_poll_end_date_query_operations; diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 5364ae9e5e..8aa96aaf2b 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -1,5 +1,4 @@ use crate::drive::document::contract_document_type_path; -use crate::drive::RootTree; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::DataContract; @@ -12,119 +11,7 @@ use dpp::ProtocolError; mod cleanup; mod insert; mod setup; - -/// The votes tree structure looks like this -/// -/// Votes -/// -/// |- Decisions [key: "d"] -/// |- Contested Resource [key: "c"] -/// |- End date Queries [key: "e"] -/// |- Identifier Votes Query [key: "i"] -/// -/// - -pub const VOTE_DECISIONS_TREE_KEY: char = 'd'; - -pub const CONTESTED_RESOURCE_TREE_KEY: char = 'c'; - -pub const END_DATE_QUERIES_TREE_KEY: char = 'e'; - -pub const IDENTITY_VOTES_TREE_KEY: char = 'i'; - -pub(in crate::drive::votes) fn vote_root_path<'a>() -> [&'a [u8]; 1] { - [Into::<&[u8; 1]>::into(RootTree::Votes)] -} - -pub(in crate::drive::votes) fn vote_root_path_vec() -> Vec> { - vec![vec![RootTree::Votes as u8]] -} - -pub(in crate::drive::votes) fn vote_decisions_tree_path<'a>() -> [&'a [u8]; 2] { - [ - Into::<&[u8; 1]>::into(RootTree::Votes), - &[VOTE_DECISIONS_TREE_KEY as u8], - ] -} - -pub(in crate::drive::votes) fn vote_decisions_tree_path_vec() -> Vec> { - vec![ - vec![RootTree::Votes as u8], - vec![VOTE_DECISIONS_TREE_KEY as u8], - ] -} - -pub(in crate::drive::votes) fn vote_contested_resource_tree_path<'a>() -> [&'a [u8]; 2] { - [ - Into::<&[u8; 1]>::into(RootTree::Votes), - &[CONTESTED_RESOURCE_TREE_KEY as u8], - ] -} - -pub(in crate::drive::votes) fn vote_contested_resource_tree_path_vec() -> Vec> { - vec![ - vec![RootTree::Votes as u8], - vec![CONTESTED_RESOURCE_TREE_KEY as u8], - ] -} - -pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_tree_path<'a>( -) -> [&'a [u8]; 3] { - [ - Into::<&[u8; 1]>::into(RootTree::Votes), - &[CONTESTED_RESOURCE_TREE_KEY as u8], - &[END_DATE_QUERIES_TREE_KEY as u8], - ] -} - -pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_tree_path_vec( -) -> Vec> { - vec![ - vec![RootTree::Votes as u8], - vec![CONTESTED_RESOURCE_TREE_KEY as u8], - vec![END_DATE_QUERIES_TREE_KEY as u8], - ] -} - -pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path<'a>( -) -> [&'a [u8]; 3] { - [ - Into::<&[u8; 1]>::into(RootTree::Votes), - &[CONTESTED_RESOURCE_TREE_KEY as u8], - &[IDENTITY_VOTES_TREE_KEY as u8], - ] -} - -pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_vec() -> Vec> -{ - vec![ - vec![RootTree::Votes as u8], - vec![CONTESTED_RESOURCE_TREE_KEY as u8], - vec![IDENTITY_VOTES_TREE_KEY as u8], - ] -} - -pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_for_identity<'a>( - identity_id: &[u8; 32], -) -> [&'a [u8]; 4] { - [ - Into::<&[u8; 1]>::into(RootTree::Votes), - &[CONTESTED_RESOURCE_TREE_KEY as u8], - &[IDENTITY_VOTES_TREE_KEY as u8], - identity_id, - ] -} - -pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_for_identity_vec( - identity_id: &[u8; 32], -) -> Vec> { - vec![ - vec![RootTree::Votes as u8], - vec![CONTESTED_RESOURCE_TREE_KEY as u8], - vec![IDENTITY_VOTES_TREE_KEY as u8], - identity_id.to_vec(), - ] -} +mod paths; pub trait TreePath { fn tree_path(&self, contract: &DataContract) -> Result, ProtocolError>; diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs new file mode 100644 index 0000000000..ebb316839d --- /dev/null +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -0,0 +1,114 @@ +use crate::drive::RootTree; + +/// The votes tree structure looks like this +/// +/// Votes +/// +/// |- Decisions [key: "d"] +/// |- Contested Resource [key: "c"] +/// |- End date Queries [key: "e"] +/// |- Identifier Votes Query [key: "i"] +/// +/// + +pub const VOTE_DECISIONS_TREE_KEY: char = 'd'; + +pub const CONTESTED_RESOURCE_TREE_KEY: char = 'c'; + +pub const END_DATE_QUERIES_TREE_KEY: char = 'e'; + +pub const IDENTITY_VOTES_TREE_KEY: char = 'i'; + +pub(in crate::drive::votes) fn vote_root_path<'a>() -> [&'a [u8]; 1] { + [Into::<&[u8; 1]>::into(RootTree::Votes)] +} + +pub(in crate::drive::votes) fn vote_root_path_vec() -> Vec> { + vec![vec![RootTree::Votes as u8]] +} + +pub(in crate::drive::votes) fn vote_decisions_tree_path<'a>() -> [&'a [u8]; 2] { + [ + Into::<&[u8; 1]>::into(RootTree::Votes), + &[VOTE_DECISIONS_TREE_KEY as u8], + ] +} + +pub(in crate::drive::votes) fn vote_decisions_tree_path_vec() -> Vec> { + vec![ + vec![RootTree::Votes as u8], + vec![VOTE_DECISIONS_TREE_KEY as u8], + ] +} + +pub(in crate::drive::votes) fn vote_contested_resource_tree_path<'a>() -> [&'a [u8]; 2] { + [ + Into::<&[u8; 1]>::into(RootTree::Votes), + &[CONTESTED_RESOURCE_TREE_KEY as u8], + ] +} + +pub(in crate::drive::votes) fn vote_contested_resource_tree_path_vec() -> Vec> { + vec![ + vec![RootTree::Votes as u8], + vec![CONTESTED_RESOURCE_TREE_KEY as u8], + ] +} + +pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_tree_path<'a>( +) -> [&'a [u8]; 3] { + [ + Into::<&[u8; 1]>::into(RootTree::Votes), + &[CONTESTED_RESOURCE_TREE_KEY as u8], + &[END_DATE_QUERIES_TREE_KEY as u8], + ] +} + +pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_tree_path_vec( +) -> Vec> { + vec![ + vec![RootTree::Votes as u8], + vec![CONTESTED_RESOURCE_TREE_KEY as u8], + vec![END_DATE_QUERIES_TREE_KEY as u8], + ] +} + +pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path<'a>( +) -> [&'a [u8]; 3] { + [ + Into::<&[u8; 1]>::into(RootTree::Votes), + &[CONTESTED_RESOURCE_TREE_KEY as u8], + &[IDENTITY_VOTES_TREE_KEY as u8], + ] +} + +pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_vec() -> Vec> +{ + vec![ + vec![RootTree::Votes as u8], + vec![CONTESTED_RESOURCE_TREE_KEY as u8], + vec![IDENTITY_VOTES_TREE_KEY as u8], + ] +} + +pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_for_identity<'a>( + identity_id: &[u8; 32], +) -> [&'a [u8]; 4] { + [ + Into::<&[u8; 1]>::into(RootTree::Votes), + &[CONTESTED_RESOURCE_TREE_KEY as u8], + &[IDENTITY_VOTES_TREE_KEY as u8], + identity_id, + ] +} + +pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_for_identity_vec( + identity_id: &[u8; 32], +) -> Vec> { + vec![ + vec![RootTree::Votes as u8], + vec![CONTESTED_RESOURCE_TREE_KEY as u8], + vec![IDENTITY_VOTES_TREE_KEY as u8], + identity_id.to_vec(), + ] +} diff --git a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs index 4d7f5f0c46..c9c34f0091 100644 --- a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs @@ -1,10 +1,7 @@ use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; use crate::drive::batch::GroveDbOpBatch; -use crate::drive::votes::{ - vote_contested_resource_tree_path_vec, vote_root_path_vec, CONTESTED_RESOURCE_TREE_KEY, - END_DATE_QUERIES_TREE_KEY, IDENTITY_VOTES_TREE_KEY, VOTE_DECISIONS_TREE_KEY, -}; use crate::drive::Drive; +use crate::drive::votes::paths::{CONTESTED_RESOURCE_TREE_KEY, END_DATE_QUERIES_TREE_KEY, IDENTITY_VOTES_TREE_KEY, vote_contested_resource_tree_path_vec, VOTE_DECISIONS_TREE_KEY, vote_root_path_vec}; use crate::error::Error; impl Drive { diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs index 51d02dafb7..e14dd4105f 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs @@ -5,7 +5,6 @@ mod v0; use derive_more::From; use dpp::block::block_info::BlockInfo; -use dpp::data_contract::document_type::Index; use dpp::platform_value::{Identifier, Value}; use std::collections::BTreeMap; diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs index b34c0b4679..deed4bab93 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs @@ -10,7 +10,6 @@ use dpp::ProtocolError; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; -use dpp::data_contract::document_type::Index; use dpp::document::property_names::{ CREATED_AT, CREATED_AT_BLOCK_HEIGHT, CREATED_AT_CORE_BLOCK_HEIGHT, TRANSFERRED_AT, TRANSFERRED_AT_BLOCK_HEIGHT, TRANSFERRED_AT_CORE_BLOCK_HEIGHT, UPDATED_AT, diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs index f1f90652b0..3c9368f770 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs @@ -1,9 +1,7 @@ use dpp::block::block_info::BlockInfo; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; -use dpp::data_contract::document_type::Index; use dpp::fee::Credits; use dpp::platform_value::Identifier; -use std::collections::BTreeMap; use std::sync::Arc; use dpp::ProtocolError; @@ -92,7 +90,7 @@ impl DocumentCreateTransitionActionV0 { let prefunded_voting_balances_by_vote_poll = prefunded_voting_balances .into_iter() .map(|(index_name, credits)| { - let index = document_type_indexes.get(&index_name).ok_or( + let index = document_type_indexes.get(index_name).ok_or( ProtocolError::UnknownContestedIndexResolution(format!( "index {} not found on document type {}", index_name.clone(), @@ -108,7 +106,7 @@ impl DocumentCreateTransitionActionV0 { index_values, }; - Ok((vote_poll, credits)) + Ok((vote_poll, *credits)) }) .collect::, ProtocolError>>( )?; diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs index 4b4f5f6bd2..300d296888 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs @@ -50,8 +50,7 @@ impl DocumentsBatchTransitionActionV0 { DocumentTransitionAction::CreateAction(document_create_transition_action) => { document_create_transition_action .prefunded_voting_balances() - .values() - .try_fold(0u64, |acc, &val| acc.checked_add(val)) + .iter().try_fold(0u64, |acc, &(_, val)| acc.checked_add(val)) } _ => None, }) From 4b3bed3bd7e13050bc45f14ee55b38319821a432 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 10 May 2024 00:49:26 +0200 Subject: [PATCH 043/135] a lot more work --- .../rs-dpp/src/data_contract/accessors/mod.rs | 6 ++ .../src/data_contract/accessors/v0/mod.rs | 3 +- .../src/data_contract/v0/accessors/mod.rs | 8 ++ .../src/state_transition/proof_result.rs | 2 + .../v0/identity_signed.rs | 10 ++- .../mod.rs | 2 +- packages/rs-dpp/src/voting/vote_polls/mod.rs | 5 +- .../types/execution_operation/mod.rs | 16 ++++ .../mod.rs | 3 + .../v0/mod.rs | 51 ++++++++---- .../state_transition/processor/v0/mod.rs | 29 ++++++- .../state_transitions/masternode_vote/mod.rs | 38 +++------ .../src/drive/batch/drive_op_batch/mod.rs | 1 + .../src/drive/batch/drive_op_batch/voting.rs | 18 ++++ .../document/document_create_transition.rs | 6 +- .../fetch_identity_keys/mod.rs | 57 +++++++++++++ .../fetch_identity_keys/v0/mod.rs | 56 +++++++++++++ .../fetch_identity_revision_with_keys/mod.rs | 57 +++++++++++++ .../v0/mod.rs | 66 +++++++++++++++ .../identity/fetch/partial_identity/mod.rs | 2 + packages/rs-drive/src/drive/verify/mod.rs | 1 + .../v0/mod.rs | 17 +++- .../rs-drive/src/drive/verify/voting/mod.rs | 1 + .../voting/verify_masternode_vote/mod.rs | 67 +++++++++++++++ .../voting/verify_masternode_vote/v0/mod.rs | 83 +++++++++++++++++++ .../remove_votes_for_identity/v0/mod.rs | 34 +++++--- .../add_new_masternode_vote_type/v0/mod.rs | 1 + .../mod.rs | 68 +++++++++++++-- .../v0/mod.rs | 39 +++++---- .../insert/register_identity_vote/mod.rs | 48 +++++++++++ .../insert/register_identity_vote/v0/mod.rs | 54 ++++++++---- .../mod.rs | 12 +-- .../v0/mod.rs | 55 ++++++++---- packages/rs-drive/src/drive/votes/mod.rs | 8 +- packages/rs-drive/src/drive/votes/paths.rs | 15 +++- .../mod.rs | 23 +++++ .../document_base_transition_action/mod.rs | 7 +- .../document_base_transition_action/v0/mod.rs | 6 ++ .../document_create_transition_action/mod.rs | 7 ++ .../v0/mod.rs | 4 + .../src/version/drive_versions.rs | 8 ++ .../src/version/mocks/v2_test.rs | 45 ++-------- .../src/version/mocks/v3_test.rs | 45 ++-------- .../rs-platform-version/src/version/v1.rs | 45 ++-------- packages/strategy-tests/src/lib.rs | 2 + 45 files changed, 880 insertions(+), 251 deletions(-) create mode 100644 packages/rs-drive/src/drive/batch/drive_op_batch/voting.rs create mode 100644 packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_keys/mod.rs create mode 100644 packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_keys/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_revision_with_keys/mod.rs create mode 100644 packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_revision_with_keys/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/verify/voting/mod.rs create mode 100644 packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/mod.rs create mode 100644 packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs diff --git a/packages/rs-dpp/src/data_contract/accessors/mod.rs b/packages/rs-dpp/src/data_contract/accessors/mod.rs index b595839588..f813699869 100644 --- a/packages/rs-dpp/src/data_contract/accessors/mod.rs +++ b/packages/rs-dpp/src/data_contract/accessors/mod.rs @@ -43,6 +43,12 @@ impl DataContractV0Getters for DataContract { } } + fn document_type_borrowed_for_name(&self, name: &str) -> Result<&DocumentType, DataContractError> { + match self { + DataContract::V0(v0) => v0.document_type_borrowed_for_name(name), + } + } + fn document_type_for_name(&self, name: &str) -> Result { match self { DataContract::V0(v0) => v0.document_type_for_name(name), diff --git a/packages/rs-dpp/src/data_contract/accessors/v0/mod.rs b/packages/rs-dpp/src/data_contract/accessors/v0/mod.rs index aa03cf94f2..68cc86b29c 100644 --- a/packages/rs-dpp/src/data_contract/accessors/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/accessors/v0/mod.rs @@ -1,7 +1,7 @@ use crate::data_contract::config::DataContractConfig; use crate::data_contract::document_type::{DocumentType, DocumentTypeRef}; use crate::data_contract::errors::DataContractError; -use crate::data_contract::DocumentName; +use crate::data_contract::{DataContract, DocumentName}; use crate::metadata::Metadata; use platform_value::Identifier; @@ -19,6 +19,7 @@ pub trait DataContractV0Getters { /// Returns the identifier of the contract owner. fn owner_id(&self) -> Identifier; fn document_type_cloned_for_name(&self, name: &str) -> Result; + fn document_type_borrowed_for_name(&self, name: &str) -> Result<&DocumentType, DataContractError>; /// Returns the document type for the given document name. fn document_type_for_name(&self, name: &str) -> Result; diff --git a/packages/rs-dpp/src/data_contract/v0/accessors/mod.rs b/packages/rs-dpp/src/data_contract/v0/accessors/mod.rs index a3d617dc62..034eb5fcbc 100644 --- a/packages/rs-dpp/src/data_contract/v0/accessors/mod.rs +++ b/packages/rs-dpp/src/data_contract/v0/accessors/mod.rs @@ -36,6 +36,14 @@ impl DataContractV0Getters for DataContractV0 { }) } + fn document_type_borrowed_for_name(&self, name: &str) -> Result<&DocumentType, DataContractError> { + self.document_types.get(name).ok_or_else(|| { + DataContractError::DocumentTypeNotFound( + "can not get document type from contract".to_string(), + ) + }) + } + fn document_type_for_name(&self, name: &str) -> Result { self.document_type_optional_for_name(name).ok_or_else(|| { DataContractError::DocumentTypeNotFound( diff --git a/packages/rs-dpp/src/state_transition/proof_result.rs b/packages/rs-dpp/src/state_transition/proof_result.rs index 6db974dc78..3ffb6fdedc 100644 --- a/packages/rs-dpp/src/state_transition/proof_result.rs +++ b/packages/rs-dpp/src/state_transition/proof_result.rs @@ -3,6 +3,7 @@ use crate::document::Document; use crate::identity::{Identity, PartialIdentity}; use platform_value::Identifier; use std::collections::BTreeMap; +use crate::voting::votes::Vote; #[derive(Debug)] pub enum StateTransitionProofResult { @@ -11,4 +12,5 @@ pub enum StateTransitionProofResult { VerifiedPartialIdentity(PartialIdentity), VerifiedBalanceTransfer(PartialIdentity, PartialIdentity), //from/to VerifiedDocuments(BTreeMap>), + VerifiedMasternodeVote(Vote), } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/identity_signed.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/identity_signed.rs index ec71943fb8..47531db013 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/identity_signed.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/identity_signed.rs @@ -1,5 +1,5 @@ -use crate::identity::SecurityLevel::{CRITICAL, HIGH}; -use crate::identity::{KeyID, SecurityLevel}; +use crate::identity::SecurityLevel::{CRITICAL, HIGH, MEDIUM}; +use crate::identity::{KeyID, Purpose, SecurityLevel}; use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; use crate::state_transition::StateTransitionIdentitySigned; @@ -13,6 +13,10 @@ impl StateTransitionIdentitySigned for MasternodeVoteTransitionV0 { } fn security_level_requirement(&self) -> Vec { - vec![CRITICAL, HIGH] + vec![CRITICAL, HIGH, MEDIUM] + } + + fn purpose_requirement(&self) -> Purpose { + Purpose::VOTING } } diff --git a/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs b/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs index d38abea58a..5024c6eb77 100644 --- a/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs +++ b/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize, PartialEq)] #[cfg_attr( - feature = "state-transition-serde-conversion", + feature = "vote-serde-conversion", derive(Serialize, Deserialize), serde(rename_all = "camelCase") )] diff --git a/packages/rs-dpp/src/voting/vote_polls/mod.rs b/packages/rs-dpp/src/voting/vote_polls/mod.rs index 6dbb3f27c5..8fc06a3790 100644 --- a/packages/rs-dpp/src/voting/vote_polls/mod.rs +++ b/packages/rs-dpp/src/voting/vote_polls/mod.rs @@ -4,15 +4,18 @@ use crate::ProtocolError; use derive_more::From; use platform_value::Identifier; use serde::{Deserialize, Serialize}; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; pub mod contested_document_resource_vote_poll; -#[derive(Debug, Clone, Encode, Decode, PartialEq, From)] +#[derive(Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize, PartialEq, From)] #[cfg_attr( feature = "state-transition-serde-conversion", derive(Serialize, Deserialize), serde(rename_all = "camelCase") )] +#[platform_serialize(unversioned)] +#[platform_serialize(limit = 100000)] pub enum VotePoll { ContestedDocumentResourceVotePoll(ContestedDocumentResourceVotePoll), } diff --git a/packages/rs-drive-abci/src/execution/types/execution_operation/mod.rs b/packages/rs-drive-abci/src/execution/types/execution_operation/mod.rs index a3c116c04c..ea00122ce6 100644 --- a/packages/rs-drive-abci/src/execution/types/execution_operation/mod.rs +++ b/packages/rs-drive-abci/src/execution/types/execution_operation/mod.rs @@ -25,6 +25,14 @@ impl RetrieveIdentityInfo { } } + pub fn one_key() -> Self { + RetrieveIdentityInfo { + query_by_key_id_key_count: 1, + request_balance: false, + request_revision: false, + } + } + pub fn one_key_and_balance_and_revision() -> Self { RetrieveIdentityInfo { query_by_key_id_key_count: 1, @@ -40,6 +48,14 @@ impl RetrieveIdentityInfo { request_revision: false, } } + + pub fn one_key_and_revision() -> Self { + RetrieveIdentityInfo { + query_by_key_id_key_count: 1, + request_balance: false, + request_revision: true, + } + } } pub type HashBlockCount = u16; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_state_transition_identity_signed/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_state_transition_identity_signed/mod.rs index 2d83765796..6e35b4361d 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_state_transition_identity_signed/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_state_transition_identity_signed/mod.rs @@ -15,6 +15,7 @@ pub trait ValidateStateTransitionIdentitySignature { fn validate_state_transition_identity_signed( &self, drive: &Drive, + request_balance: bool, request_revision: bool, transaction: TransactionArg, execution_context: &mut StateTransitionExecutionContext, @@ -26,6 +27,7 @@ impl ValidateStateTransitionIdentitySignature for StateTransition { fn validate_state_transition_identity_signed( &self, drive: &Drive, + request_balance: bool, request_revision: bool, transaction: TransactionArg, execution_context: &mut StateTransitionExecutionContext, @@ -40,6 +42,7 @@ impl ValidateStateTransitionIdentitySignature for StateTransition { { 0 => self.validate_state_transition_identity_signed_v0( drive, + request_balance, request_revision, transaction, execution_context, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_state_transition_identity_signed/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_state_transition_identity_signed/v0/mod.rs index 00bc6ef682..aa8e5c22ce 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_state_transition_identity_signed/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_state_transition_identity_signed/v0/mod.rs @@ -46,7 +46,8 @@ pub(super) trait ValidateStateTransitionIdentitySignatureV0<'a> { fn validate_state_transition_identity_signed_v0( &self, drive: &Drive, - request_revision: bool, + request_identity_balance: bool, + request_identity_revision: bool, transaction: TransactionArg, execution_context: &mut StateTransitionExecutionContext, platform_version: &PlatformVersion, @@ -57,6 +58,7 @@ impl<'a> ValidateStateTransitionIdentitySignatureV0<'a> for StateTransition { fn validate_state_transition_identity_signed_v0( &self, drive: &Drive, + request_identity_balance: bool, request_identity_revision: bool, transaction: TransactionArg, execution_context: &mut StateTransitionExecutionContext, @@ -86,20 +88,39 @@ impl<'a> ValidateStateTransitionIdentitySignatureV0<'a> for StateTransition { let key_request = IdentityKeysRequest::new_specific_key_query(owner_id.as_bytes(), key_id); - let maybe_partial_identity = if request_identity_revision { - execution_context.add_operation(ValidationOperation::RetrieveIdentity( - RetrieveIdentityInfo::one_key_and_balance_and_revision(), - )); - drive.fetch_identity_balance_with_keys_and_revision( - key_request, - transaction, - platform_version, - )? - } else { - execution_context.add_operation(ValidationOperation::RetrieveIdentity( - RetrieveIdentityInfo::one_key_and_balance(), - )); - drive.fetch_identity_balance_with_keys(key_request, transaction, platform_version)? + let maybe_partial_identity = match (request_identity_balance,request_identity_revision) { + (true, true) => { + // This is for identity update + execution_context.add_operation(ValidationOperation::RetrieveIdentity( + RetrieveIdentityInfo::one_key_and_balance_and_revision(), + )); + drive.fetch_identity_balance_with_keys_and_revision( + key_request, + transaction, + platform_version, + )? + }, + (true, false) => { + // This is for most state transitions + execution_context.add_operation(ValidationOperation::RetrieveIdentity( + RetrieveIdentityInfo::one_key_and_balance(), + )); + drive.fetch_identity_balance_with_keys(key_request, transaction, platform_version)? + }, + (false, true) => { + // This currently is not used + execution_context.add_operation(ValidationOperation::RetrieveIdentity( + RetrieveIdentityInfo::one_key_and_revision(), + )); + drive.fetch_identity_revision_with_keys(key_request, transaction, platform_version)? + }, + (false, false) => { + // This is for masternode vote transition + execution_context.add_operation(ValidationOperation::RetrieveIdentity( + RetrieveIdentityInfo::one_key(), + )); + drive.fetch_identity_keys_as_partial_identity(key_request, transaction, platform_version)? + }, }; let partial_identity = match maybe_partial_identity { diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs index df10dcde93..849a787ed0 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs @@ -443,7 +443,7 @@ impl StateTransitionBasicStructureValidationV0 for StateTransition { platform_version: &PlatformVersion, ) -> Result { match self { - StateTransition::DataContractCreate(_) | StateTransition::DataContractUpdate(_) => { + StateTransition::DataContractCreate(_) | StateTransition::DataContractUpdate(_) | StateTransition::MasternodeVote(_) => { // no basic structure validation Ok(SimpleConsensusValidationResult::new()) } @@ -462,7 +462,7 @@ impl StateTransitionBasicStructureValidationV0 for StateTransition { fn has_basic_structure_validation(&self) -> bool { !matches!( self, - StateTransition::DataContractCreate(_) | StateTransition::DataContractUpdate(_) + StateTransition::DataContractCreate(_) | StateTransition::DataContractUpdate(_) | StateTransition::MasternodeVote(_) ) } } @@ -700,6 +700,7 @@ impl StateTransitionIdentityBasedSignatureValidationV0 for StateTransition { //Basic signature verification Ok(self.validate_state_transition_identity_signed( drive, + true, false, tx, execution_context, @@ -711,6 +712,22 @@ impl StateTransitionIdentityBasedSignatureValidationV0 for StateTransition { Ok(self.validate_state_transition_identity_signed( drive, true, + true, + tx, + execution_context, + platform_version, + )?) + } + StateTransition::MasternodeVote(_) => { + //Basic signature verification + + // We do not request the balance because masternodes do not pay for their voting + // themselves + + Ok(self.validate_state_transition_identity_signed( + drive, + false, + false, tx, execution_context, platform_version, @@ -847,6 +864,14 @@ impl StateTransitionStateValidationV0 for StateTransition { execution_context, tx, ), + StateTransition::MasternodeVote(st) => st.validate_state( + action, + platform, + validation_mode, + epoch, + execution_context, + tx, + ) } } } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 6c6d188f9a..2a46cb9567 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -1,6 +1,8 @@ mod state; mod structure; +use dpp::block::block_info::BlockInfo; +use dpp::block::epoch::Epoch; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; use dpp::validation::{ConsensusValidationResult, SimpleConsensusValidationResult}; use dpp::version::PlatformVersion; @@ -10,22 +12,26 @@ use drive::grovedb::TransactionArg; use crate::error::execution::ExecutionError; use crate::error::Error; +use crate::execution::types::state_transition_execution_context::StateTransitionExecutionContext; use crate::platform_types::platform::{PlatformRef, PlatformStateRef}; use crate::rpc::core::CoreRPCLike; use crate::execution::validation::state_transition::masternode_vote::state::v0::MasternodeVoteStateTransitionStateValidationV0; use crate::execution::validation::state_transition::masternode_vote::structure::v0::MasternodeVoteStateTransitionStructureValidationV0; use crate::execution::validation::state_transition::processor::v0::{ - StateTransitionStateValidationV0, StateTransitionStructureValidationV0, + StateTransitionStateValidationV0, }; use crate::execution::validation::state_transition::transformer::StateTransitionActionTransformerV0; +use crate::execution::validation::state_transition::ValidationMode; use crate::platform_types::platform_state::v0::PlatformStateV0Methods; impl StateTransitionActionTransformerV0 for MasternodeVoteTransition { fn transform_into_action( &self, platform: &PlatformRef, - _validate: bool, + _block_info: &BlockInfo, + _validation_mode: ValidationMode, + _execution_context: &mut StateTransitionExecutionContext, _tx: TransactionArg, ) -> Result, Error> { let platform_version = @@ -47,36 +53,14 @@ impl StateTransitionActionTransformerV0 for MasternodeVoteTransition { } } -impl StateTransitionStructureValidationV0 for MasternodeVoteTransition { - fn validate_structure( - &self, - _platform: &PlatformStateRef, - _action: Option<&StateTransitionAction>, - protocol_version: u32, - ) -> Result { - let platform_version = PlatformVersion::get(protocol_version)?; - match platform_version - .drive_abci - .validation_and_processing - .state_transitions - .masternode_vote_state_transition - .structure - { - 0 => self.validate_base_structure_v0(), - version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { - method: "masternode votes state transition: validate_structure".to_string(), - known_versions: vec![0], - received: version, - })), - } - } -} - impl StateTransitionStateValidationV0 for MasternodeVoteTransition { fn validate_state( &self, _action: Option, platform: &PlatformRef, + _validation_mode: ValidationMode, + _epoch: &Epoch, + _execution_context: &mut StateTransitionExecutionContext, tx: TransactionArg, ) -> Result, Error> { let platform_version = diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/mod.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/mod.rs index cb8754ddec..86f38062ac 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/mod.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/mod.rs @@ -6,6 +6,7 @@ mod identity; mod prefunded_specialized_balance; mod system; mod withdrawals; +mod voting; use crate::drive::batch::GroveDbOpBatch; diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/voting.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/voting.rs new file mode 100644 index 0000000000..2ca557d169 --- /dev/null +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/voting.rs @@ -0,0 +1,18 @@ +use dpp::identifier::Identifier; +use dpp::identity::TimestampMillis; + +use dpp::voting::vote_polls::VotePoll; + +/// Voting based Operations +#[derive(Clone, Debug)] +pub enum VotingOperationType { + /// Adds a vote poll to the state. + AddVotePoll { + /// The creator of the vote poll + creator_identity_id: Option, + /// The vote poll + vote_poll: VotePoll, + /// The end date of the vote poll + end_date: TimestampMillis, + }, +} \ No newline at end of file diff --git a/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs b/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs index c9d0e27970..4b90a79ffe 100644 --- a/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs +++ b/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs @@ -20,7 +20,7 @@ use crate::drive::object_size_info::DataContractInfo::DataContractFetchInfo; impl DriveHighLevelDocumentOperationConverter for DocumentCreateTransitionAction { fn into_high_level_document_drive_operations<'b>( - self, + mut self, epoch: &Epoch, owner_id: Identifier, platform_version: &PlatformVersion, @@ -33,7 +33,7 @@ impl DriveHighLevelDocumentOperationConverter for DocumentCreateTransitionAction let identity_contract_nonce = self.base().identity_contract_nonce(); - let prefunded_voting_balances = self.prefunded_voting_balances(); + let prefunded_voting_balances = self.take_prefunded_voting_balances(); let document = Document::try_from_owned_create_transition_action(self, owner_id, platform_version)?; @@ -68,7 +68,7 @@ impl DriveHighLevelDocumentOperationConverter for DocumentCreateTransitionAction ops.push(PrefundedSpecializedBalanceOperation( PrefundedSpecializedBalanceOperationType::CreateNewPrefundedBalance { prefunded_specialized_balance_id, - add_balance: *credits, + add_balance: credits, }, )); } diff --git a/packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_keys/mod.rs b/packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_keys/mod.rs new file mode 100644 index 0000000000..b5ed2e56f2 --- /dev/null +++ b/packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_keys/mod.rs @@ -0,0 +1,57 @@ +mod v0; + +use crate::drive::identity::key::fetch::IdentityKeysRequest; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use dpp::identity::PartialIdentity; +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +impl Drive { + /// Fetches the Identity's keys as `PartialIdentityInfo` from the backing store. + /// + /// This method selects the appropriate version of the function to call based on the + /// provided platform version. + /// + /// # Parameters + /// + /// - `identity_key_request`: A request containing information about the identity whose balance and keys need to be fetched. + /// - `transaction`: A transaction argument for the database. + /// - `platform_version`: The platform version being used. + /// + /// # Returns + /// + /// Returns a `Result` containing an `Option`. + /// + /// # Errors + /// + /// Returns an error if the platform version is not recognized or if there's a failure + /// during the operation. + pub fn fetch_identity_keys_as_partial_identity( + &self, + identity_key_request: IdentityKeysRequest, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + match platform_version + .drive + .methods + .identity + .fetch + .partial_identity + .fetch_identity_keys + { + 0 => self.fetch_identity_keys_as_partial_identity_v0( + identity_key_request, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "fetch_identity_keys_as_partial_identity".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_keys/v0/mod.rs b/packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_keys/v0/mod.rs new file mode 100644 index 0000000000..c3c6cc11b1 --- /dev/null +++ b/packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_keys/v0/mod.rs @@ -0,0 +1,56 @@ +use crate::drive::identity::key::fetch::{ + IdentityKeysRequest, KeyIDOptionalIdentityPublicKeyPairBTreeMap, +}; +use crate::drive::Drive; +use crate::error::Error; + +use dpp::identifier::Identifier; +use dpp::identity::PartialIdentity; +use grovedb::TransactionArg; + +use dpp::version::PlatformVersion; +use std::collections::{BTreeMap, BTreeSet}; + +impl Drive { + /// Fetches the Identity's keys as PartialIdentityInfo from the backing store + /// Passing apply as false get the estimated cost instead + pub(super) fn fetch_identity_keys_as_partial_identity_v0( + &self, + identity_key_request: IdentityKeysRequest, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let id = Identifier::new(identity_key_request.identity_id); + + let public_keys_with_optionals = self + .fetch_identity_keys::( + identity_key_request, + transaction, + platform_version, + )?; + + let mut loaded_public_keys = BTreeMap::new(); + let mut not_found_public_keys = BTreeSet::new(); + + public_keys_with_optionals + .into_iter() + .for_each(|(key, value)| { + match value { + None => { + not_found_public_keys.insert(key); + } + Some(value) => { + loaded_public_keys.insert(key, value); + } + }; + }); + Ok(Some(PartialIdentity { + id, + loaded_public_keys, + balance: None, + revision: None, + + not_found_public_keys, + })) + } +} diff --git a/packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_revision_with_keys/mod.rs b/packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_revision_with_keys/mod.rs new file mode 100644 index 0000000000..06114ebe09 --- /dev/null +++ b/packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_revision_with_keys/mod.rs @@ -0,0 +1,57 @@ +mod v0; + +use crate::drive::identity::key::fetch::IdentityKeysRequest; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use dpp::identity::PartialIdentity; +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +impl Drive { + /// Fetches the Identity's revision along with its keys as `PartialIdentityInfo` from the backing store. + /// + /// This method selects the appropriate version of the function to call based on the + /// provided platform version. + /// + /// # Parameters + /// + /// - `identity_key_request`: A request containing information about the identity whose balance and keys need to be fetched. + /// - `transaction`: A transaction argument for the database. + /// - `platform_version`: The platform version being used. + /// + /// # Returns + /// + /// Returns a `Result` containing an `Option`. + /// + /// # Errors + /// + /// Returns an error if the platform version is not recognized or if there's a failure + /// during the operation. + pub fn fetch_identity_revision_with_keys( + &self, + identity_key_request: IdentityKeysRequest, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + match platform_version + .drive + .methods + .identity + .fetch + .partial_identity + .fetch_identity_balance_with_keys_and_revision + { + 0 => self.fetch_identity_revision_with_keys_v0( + identity_key_request, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "fetch_identity_revision_with_keys".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_revision_with_keys/v0/mod.rs b/packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_revision_with_keys/v0/mod.rs new file mode 100644 index 0000000000..e613e0ff86 --- /dev/null +++ b/packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_revision_with_keys/v0/mod.rs @@ -0,0 +1,66 @@ +use crate::drive::identity::key::fetch::{ + IdentityKeysRequest, KeyIDOptionalIdentityPublicKeyPairBTreeMap, +}; +use crate::drive::Drive; +use crate::error::Error; + +use dpp::identifier::Identifier; +use dpp::identity::PartialIdentity; +use grovedb::TransactionArg; + +use dpp::version::PlatformVersion; +use std::collections::{BTreeMap, BTreeSet}; + +impl Drive { + /// Fetches the Identity's revision with keys as PartialIdentityInfo from the backing store + /// Passing apply as false get the estimated cost instead + pub(super) fn fetch_identity_revision_with_keys_v0( + &self, + identity_key_request: IdentityKeysRequest, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let id = Identifier::new(identity_key_request.identity_id); + + let revision = self.fetch_identity_revision( + identity_key_request.identity_id, + true, + transaction, + platform_version, + )?; + let Some(revision) = revision else { + return Ok(None); + }; + + let public_keys_with_optionals = self + .fetch_identity_keys::( + identity_key_request, + transaction, + platform_version, + )?; + + let mut loaded_public_keys = BTreeMap::new(); + let mut not_found_public_keys = BTreeSet::new(); + + public_keys_with_optionals + .into_iter() + .for_each(|(key, value)| { + match value { + None => { + not_found_public_keys.insert(key); + } + Some(value) => { + loaded_public_keys.insert(key, value); + } + }; + }); + Ok(Some(PartialIdentity { + id, + loaded_public_keys, + balance: None, + revision: Some(revision), + + not_found_public_keys, + })) + } +} diff --git a/packages/rs-drive/src/drive/identity/fetch/partial_identity/mod.rs b/packages/rs-drive/src/drive/identity/fetch/partial_identity/mod.rs index 60fab3a419..373a60e345 100644 --- a/packages/rs-drive/src/drive/identity/fetch/partial_identity/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/partial_identity/mod.rs @@ -1,3 +1,5 @@ mod fetch_identity_balance_with_keys; mod fetch_identity_balance_with_keys_and_revision; mod fetch_identity_with_balance; +mod fetch_identity_revision_with_keys; +mod fetch_identity_keys; diff --git a/packages/rs-drive/src/drive/verify/mod.rs b/packages/rs-drive/src/drive/verify/mod.rs index 01264d6837..605cdb9fa6 100644 --- a/packages/rs-drive/src/drive/verify/mod.rs +++ b/packages/rs-drive/src/drive/verify/mod.rs @@ -12,6 +12,7 @@ pub mod system; /// Verifies that a state transition contents exist in the proof pub mod state_transition; +mod voting; /// Represents the root hash of the grovedb tree pub type RootHash = [u8; 32]; diff --git a/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs b/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs index 1a703b6b4b..4f679200ee 100644 --- a/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs @@ -30,8 +30,9 @@ use dpp::state_transition::documents_batch_transition::document_replace_transiti use dpp::state_transition::documents_batch_transition::document_transition::document_purchase_transition::v0::v0_methods::DocumentPurchaseTransitionV0Methods; use dpp::state_transition::documents_batch_transition::document_transition::document_transfer_transition::v0::v0_methods::DocumentTransferTransitionV0Methods; use dpp::state_transition::documents_batch_transition::document_transition::document_update_price_transition::v0::v0_methods::DocumentUpdatePriceTransitionV0Methods; +use dpp::state_transition::masternode_vote_transition::accessors::MasternodeVoteTransitionAccessorsV0; use dpp::state_transition::proof_result::StateTransitionProofResult; -use dpp::state_transition::proof_result::StateTransitionProofResult::{VerifiedBalanceTransfer, VerifiedDataContract, VerifiedDocuments, VerifiedIdentity, VerifiedPartialIdentity}; +use dpp::state_transition::proof_result::StateTransitionProofResult::{VerifiedBalanceTransfer, VerifiedDataContract, VerifiedDocuments, VerifiedIdentity, VerifiedMasternodeVote, VerifiedPartialIdentity}; use platform_version::TryIntoPlatformVersioned; use platform_version::version::PlatformVersion; use crate::drive::Drive; @@ -352,6 +353,20 @@ impl Drive { ), )) } + StateTransition::MasternodeVote(masternode_vote) => { + let pro_tx_hash = masternode_vote.pro_tx_hash(); + let vote = masternode_vote.vote(); + // we expect to get an identity that matches the state transition + let (root_hash, vote) = Drive::verify_masternode_vote( + proof, + pro_tx_hash.to_buffer(), + vote, + true, + platform_version, + )?; + let vote = vote.ok_or(Error::Proof(ProofError::IncorrectProof(format!("proof did not contain actual vote for masternode {} expected to exist because of state transition (masternode vote)", masternode_vote.pro_tx_hash()))))?; + Ok((root_hash, VerifiedMasternodeVote(vote))) + } } } } diff --git a/packages/rs-drive/src/drive/verify/voting/mod.rs b/packages/rs-drive/src/drive/verify/voting/mod.rs new file mode 100644 index 0000000000..38af2da7e5 --- /dev/null +++ b/packages/rs-drive/src/drive/verify/voting/mod.rs @@ -0,0 +1 @@ +mod verify_masternode_vote; \ No newline at end of file diff --git a/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/mod.rs new file mode 100644 index 0000000000..4746a13073 --- /dev/null +++ b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/mod.rs @@ -0,0 +1,67 @@ +mod v0; + +use crate::drive::Drive; + +use crate::error::drive::DriveError; + +use crate::error::Error; + +use crate::drive::verify::RootHash; + +use dpp::version::PlatformVersion; +use dpp::voting::votes::Vote; + +impl Drive { + /// Verifies the authenticity of a masternode vote using the provided proof. + /// + /// # Parameters + /// + /// - `proof`: A byte slice representing the grovedb proof of authenticity for the vote. + /// - `masternode_pro_tx_hash`: A 32-byte array representing the masternode identifier. + /// - `vote`: A reference to the vote being verified. + /// - `verify_subset_of_proof`: A boolean indicating whether a subset of a larger proof is being verified. + /// - `platform_version`: A reference to the platform version against which to verify the vote. + /// + /// # Returns + /// + /// Returns a `Result` with a tuple containing `RootHash` and an `Option`. The `RootHash` represents + /// the root hash of GroveDB, and the `Option` contains the vote if the proved vote differs from the + /// one provided; otherwise, it returns `None`. + /// + /// # Errors + /// + /// Returns an `Error` if: + /// + /// - The proof is invalid or does not authenticate the vote. + /// - The `masternode_pro_tx_hash` does not correspond to a valid masternode. + /// - The vote details are incorrect or manipulated. + /// - An unknown or unsupported platform version is provided. + /// + pub fn verify_masternode_vote( + proof: &[u8], + masternode_pro_tx_hash: [u8;32], + vote: &Vote, + verify_subset_of_proof: bool, + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Option), Error> { + match platform_version + .drive + .methods + .verify + .voting + .verify_masternode_vote + { + 0 => Self::verify_masternode_vote_v0( + proof, + masternode_pro_tx_hash, + vote, + verify_subset_of_proof, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "verify_masternode_vote".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs new file mode 100644 index 0000000000..790821208d --- /dev/null +++ b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs @@ -0,0 +1,83 @@ +use crate::drive::Drive; + +use crate::error::Error; + +use crate::drive::verify::RootHash; + +use dpp::voting::votes::Vote; + +impl Drive { + /// Verifies the balance of an identity by their identity ID. + /// + /// `verify_subset_of_proof` is used to indicate if we want to verify a subset of a bigger proof. + /// For example, if the proof can prove the balance and the revision, but here we are only interested + /// in verifying the balance. + /// + /// # Parameters + /// + /// - `proof`: A byte slice representing the proof of authentication from the user. + /// - `identity_id`: A 32-byte array representing the identity ID of the user. + /// - `verify_subset_of_proof`: A boolean indicating whether we are verifying a subset of a larger proof. + /// + /// # Returns + /// + /// If the verification is successful, it returns a `Result` with a tuple of `RootHash` and + /// an `Option`. The `RootHash` represents the root hash of GroveDB, and the + /// `Option` represents the balance of the user's identity if it exists. + /// + /// # Errors + /// + /// Returns an `Error` if: + /// + /// - The proof of authentication is not valid. + /// - The identity ID does not correspond to a valid balance. + /// - The proved key value is not for the correct path or key in balances. + /// - More than one balance is found. + /// + pub(crate) fn verify_masternode_vote_v0( + proof: &[u8], + masternode_pro_tx_hash: [u8;32], + vote: &Vote, + verify_subset_of_proof: bool, + ) -> Result<(RootHash, Option), Error> { + todo!() + // let mut path_query = Self::identity_balance_query(&identity_id); + // path_query.query.limit = Some(1); + // let (root_hash, mut proved_key_values) = if verify_subset_of_proof { + // GroveDb::verify_subset_query_with_absence_proof(proof, &path_query)? + // } else { + // GroveDb::verify_query_with_absence_proof(proof, &path_query)? + // }; + // if proved_key_values.len() == 1 { + // let (path, key, maybe_element) = &proved_key_values.remove(0); + // if path != &balance_path() { + // return Err(Error::Proof(ProofError::CorruptedProof( + // "we did not get back an element for the correct path in balances".to_string(), + // ))); + // } + // if key != &identity_id { + // return Err(Error::Proof(ProofError::CorruptedProof( + // "we did not get back an element for the correct key in balances".to_string(), + // ))); + // } + // + // let signed_balance = maybe_element + // .as_ref() + // .map(|element| { + // element + // .as_sum_item_value() + // .map_err(Error::GroveDB)? + // .try_into() + // .map_err(|_| { + // Error::Proof(ProofError::IncorrectValueSize("value size is incorrect")) + // }) + // }) + // .transpose()?; + // Ok((root_hash, signed_balance)) + // } else { + // Err(Error::Proof(ProofError::TooManyElements( + // "expected one identity balance", + // ))) + // } + } +} diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs index 7c0d934077..e993830679 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs @@ -5,16 +5,13 @@ use crate::error::drive::DriveError; use crate::error::Error; use crate::drive::grove_operations::BatchDeleteApplyType; -use crate::drive::votes::paths::vote_contested_resource_identity_votes_tree_path_for_identity_vec; -use crate::drive::votes::TreePath; +use crate::drive::votes::paths::{vote_contested_resource_identity_votes_tree_path_for_identity, vote_contested_resource_identity_votes_tree_path_for_identity_vec}; use crate::query::QueryItem; use dpp::prelude::Identifier; -use dpp::serialization::PlatformDeserializable; use dpp::version::PlatformVersion; -use dpp::voting::votes::Vote; use grovedb::query_result_type::QueryResultType::QueryElementResultType; use grovedb::{Element, PathQuery, Query, SizedQuery, TransactionArg}; -use grovedb_path::SubtreePath; +use grovedb::reference_path::path_from_reference_path_type; impl Drive { /// We remove vote_choices for an identity when that identity is somehow disabled. Currently there is @@ -35,13 +32,13 @@ impl Drive { vote_path, SizedQuery::new( Query::new_single_query_item(QueryItem::RangeFull(RangeFull)), - Some(512), + None, // Todo: there might be an issue if too many votes are removed at the same time None, ), ); let votes_to_remove_elements = self - .grove_get_path_query( + .grove_get_raw_path_query( &path_query, transaction, QueryElementResultType, @@ -55,21 +52,32 @@ impl Drive { let mut deletion_batch = vec![]; + let vote_path_ref = vote_contested_resource_identity_votes_tree_path_for_identity( + identity_id.as_bytes(), + ); + for vote_to_remove in votes_to_remove_elements { - let Element::Item(vote, ..) = vote_to_remove else { + let Element::Reference(vote_reference, ..) = vote_to_remove else { return Err(Error::Drive(DriveError::CorruptedDriveState(format!( - "votes {:?} for identity {} is not an item", + "votes {:?} for identity {} are not a reference", vote_to_remove, identity_id )))); }; - let vote = Vote::deserialize_from_bytes(vote.as_slice())?; + let mut absolute_path = path_from_reference_path_type(vote_reference, vote_path_ref.as_ref(), None)?; + + if absolute_path.is_empty() { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!("reference to vote for identity {} is empty", identity_id)))); + } + let key = absolute_path.remove(absolute_path.len() - 1); // we then need to add to the batch the deletion + + let absolute_path_ref: Vec<_> = absolute_path.iter().map(|a| a.as_slice()).collect(); self.batch_delete( - SubtreePath::from(vote.tree_path()), - vote.tree_key(), + absolute_path_ref.as_slice().into(), + key.as_slice(), BatchDeleteApplyType::StatefulBatchDelete { is_known_to_be_subtree_with_sum: Some((false, false)), }, @@ -79,6 +87,6 @@ impl Drive { )?; } - self.Ok(()) + Ok(()) } } diff --git a/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs index 29c53a5461..0ebdb2d9f1 100644 --- a/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs @@ -19,5 +19,6 @@ impl Drive { transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { + todo!() } } diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs index a1497e7965..3ddfaab98b 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs @@ -12,14 +12,43 @@ use dpp::fee::fee_result::FeeResult; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; -use dpp::voting::votes::resource_vote::ResourceVote; use grovedb::{EstimatedLayerInformation, TransactionArg}; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; impl Drive { + + /// Registers a vote for a contested resource based on the voter's identifier, + /// vote poll, and the specific vote choice. + /// + /// # Parameters + /// + /// - `voter_pro_tx_hash`: A 32-byte array representing the ProRegTx hash of the voter. + /// - `vote_poll`: The specific contested document resource vote poll context. + /// - `vote_choice`: The choice made by the voter on the contested resource. + /// - `block_info`: Reference to the block information at the time of the vote. + /// - `apply`: Boolean flag indicating whether to apply the vote to the database immediately. + /// - `transaction`: Transaction arguments providing context for this operation. + /// - `platform_version`: Reference to the platform version against which the operation is executed. + /// + /// # Returns + /// + /// Returns a `Result` that, on success, includes the `FeeResult` detailing any fees applied as a result of the vote. + /// On failure, it returns an `Error`. + /// + /// # Errors + /// + /// Returns an `Error` if: + /// + /// - The platform version is unknown or unsupported. + /// - There is an issue processing the transaction or applying it to the database. + /// + pub fn register_contested_resource_identity_vote( &self, voter_pro_tx_hash: [u8; 32], - vote: ResourceVote, + vote_poll: ContestedDocumentResourceVotePoll, + vote_choice: ResourceVoteChoice, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, @@ -34,7 +63,8 @@ impl Drive { { 0 => self.register_contested_resource_identity_vote_v0( voter_pro_tx_hash, - vote, + vote_poll, + vote_choice, block_info, apply, transaction, @@ -48,10 +78,37 @@ impl Drive { } } + /// Gathers and returns low-level drive operations needed to register a vote for a contested resource, + /// considering the voter's identifier, vote poll, and vote choice, optionally estimating costs. + /// + /// # Parameters + /// + /// - `voter_pro_tx_hash`: A 32-byte array representing the ProRegTx hash of the voter. + /// - `vote_poll`: The specific contested document resource vote poll context. + /// - `vote_choice`: The choice made by the voter on the contested resource. + /// - `block_info`: Reference to the block information at the time of the vote. + /// - `estimated_costs_only_with_layer_info`: A mutable reference to an optional HashMap that, if provided, + /// will be filled with estimated costs and layer information necessary for processing the vote. + /// - `transaction`: Transaction arguments providing context for this operation. + /// - `platform_version`: Reference to the platform version against which the operation is executed. + /// + /// # Returns + /// + /// Returns a `Result` containing a vector of `LowLevelDriveOperation` detailing the necessary operations + /// to execute the vote registration, or an `Error` if the operation cannot be completed. + /// + /// # Errors + /// + /// Returns an `Error` if: + /// + /// - The platform version is unknown or unsupported. + /// - Any low-level drive operation fails due to transaction or database inconsistencies. + /// pub fn register_contested_resource_identity_vote_operations( &self, voter_pro_tx_hash: [u8; 32], - vote: ResourceVote, + vote_poll: ContestedDocumentResourceVotePoll, + vote_choice: ResourceVoteChoice, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< HashMap, @@ -68,7 +125,8 @@ impl Drive { { 0 => self.register_contested_resource_identity_vote_operations_v0( voter_pro_tx_hash, - vote, + vote_poll, + vote_choice, block_info, estimated_costs_only_with_layer_info, transaction, diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index 5a4ccce77f..fd72383a73 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -1,46 +1,49 @@ use crate::drive::Drive; -use crate::error::document::DocumentError; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; -use dpp::voting::votes::resource_vote::ResourceVote; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use platform_version::version::PlatformVersion; use std::collections::HashMap; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; impl Drive { - pub fn register_contested_resource_identity_vote_v0( + pub(super) fn register_contested_resource_identity_vote_v0( &self, voter_pro_tx_hash: [u8; 32], - vote: ResourceVote, + vote_poll: ContestedDocumentResourceVotePoll, + vote_choice: ResourceVoteChoice, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { - let vote_poll = vote.vote_poll(); // let's start by creating a batch of operations let mut drive_operations: Vec = vec![]; - let contract_fetch_info = self - .get_contract_with_fetch_info_and_add_to_operations( - vote.vote_poll().contract_id.to_buffer(), - Some(&block_info.epoch), - true, - transaction, - &mut drive_operations, - platform_version, - )? - .ok_or(Error::Document(DocumentError::DataContractNotFound))?; + // let contract_fetch_info = self + // .get_contract_with_fetch_info_and_add_to_operations( + // vote.vote_poll().contract_id.to_buffer(), + // Some(&block_info.epoch), + // true, + // transaction, + // &mut drive_operations, + // platform_version, + // )? + // .ok_or(Error::Document(DocumentError::DataContractNotFound))?; + + todo!() } - pub fn register_contested_resource_identity_vote_operations_v0( + pub(super) fn register_contested_resource_identity_vote_operations_v0( &self, voter_pro_tx_hash: [u8; 32], - vote: ResourceVote, + vote_poll: ContestedDocumentResourceVotePoll, + vote_choice: ResourceVoteChoice, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< HashMap, @@ -52,5 +55,7 @@ impl Drive { let mut drive_operations: Vec = vec![]; // The vote at this point will have been verified as valid by rs-drive-abci + + todo!() } } diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs index 6d478f8a91..d63dcfa76b 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs @@ -16,6 +16,29 @@ use dpp::voting::votes::Vote; use grovedb::{EstimatedLayerInformation, TransactionArg}; impl Drive { + /// Registers a vote associated with a specific identity using the given voter's ProRegTx hash. + /// This function applies the vote to the blockchain state if specified, within the context of the given block. + /// + /// # Parameters + /// + /// - `voter_pro_tx_hash`: A 32-byte array representing the ProRegTx hash of the voter. + /// - `vote`: The vote to be registered, encapsulating the decision made by the voter. + /// - `block_info`: Reference to the block information at the time of the vote. + /// - `apply`: A boolean flag indicating whether the vote should be immediately applied to the state. + /// - `transaction`: Contextual transaction arguments that may affect the processing of the vote. + /// - `platform_version`: Reference to the platform version to ensure compatibility of the vote registration method. + /// + /// # Returns + /// + /// Returns a `Result`, where `FeeResult` includes any fees applied as a result of registering the vote, + /// and `Error` captures any issues encountered during the process. + /// + /// # Errors + /// + /// Returns an `Error` if: + /// - The platform version is unknown or unsupported, resulting in a version mismatch error. + /// - There is a failure in processing the vote due to transaction or blockchain state issues. + /// pub fn register_identity_vote( &self, voter_pro_tx_hash: [u8; 32], @@ -48,6 +71,31 @@ impl Drive { } } + /// Prepares and returns a list of low-level drive operations necessary for registering a vote, + /// based on the voter's ProRegTx hash and current block information. This method can also estimate costs + /// if required, which helps in preparing for the actual application of the vote. + /// + /// # Parameters + /// + /// - `voter_pro_tx_hash`: A 32-byte array representing the ProRegTx hash of the voter. + /// - `vote`: The vote to be registered, detailing the decision made. + /// - `block_info`: Reference to current block information. + /// - `estimated_costs_only_with_layer_info`: A mutable reference to an optional HashMap that, if provided, + /// will be filled with estimated cost and layer information required for processing the vote. + /// - `transaction`: Contextual transaction arguments that may influence the generation of operations. + /// - `platform_version`: Reference to the platform version to ensure compatibility of the operation generation method. + /// + /// # Returns + /// + /// Returns a `Result, Error>`, where `Vec` contains the detailed operations needed, + /// and `Error` captures any issues encountered during the operation preparation. + /// + /// # Errors + /// + /// Returns an `Error` if: + /// - The platform version is unknown or unsupported, resulting in a version mismatch error. + /// - There are issues generating the necessary operations due to transaction inconsistencies or blockchain state errors. + /// pub fn register_identity_vote_operations( &self, voter_pro_tx_hash: [u8; 32], diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs index 4222b95a3c..a07885f9d7 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs @@ -8,6 +8,8 @@ use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use platform_version::version::PlatformVersion; use std::collections::HashMap; +use dpp::voting::vote_polls::VotePoll; +use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; impl Drive { pub(super) fn register_identity_vote_v0( @@ -20,15 +22,23 @@ impl Drive { platform_version: &PlatformVersion, ) -> Result { match vote { - Vote::ResourceVote(contested_document_resource_vote_type) => self - .register_contested_resource_identity_vote( - voter_pro_tx_hash, - contested_document_resource_vote_type, - block_info, - apply, - transaction, - platform_version, - ), + Vote::ResourceVote(resource_vote) => { + let vote_choice = resource_vote.resource_vote_choice(); + match resource_vote.vote_poll_owned() { VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll) => { + self + .register_contested_resource_identity_vote( + voter_pro_tx_hash, + contested_document_resource_vote_poll, + vote_choice, + block_info, + apply, + transaction, + platform_version, + ) + } + } + + }, } } @@ -44,15 +54,23 @@ impl Drive { platform_version: &PlatformVersion, ) -> Result, Error> { match vote { - Vote::ResourceVote(contested_document_resource_vote_type) => self - .register_contested_resource_identity_vote_operations( - voter_pro_tx_hash, - contested_document_resource_vote_type, - block_info, - estimated_costs_only_with_layer_info, - transaction, - platform_version, - ), + Vote::ResourceVote(resource_vote) => { + let vote_choice = resource_vote.resource_vote_choice(); + match resource_vote.vote_poll_owned() { VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll) => { + self + .register_contested_resource_identity_vote_operations( + voter_pro_tx_hash, + contested_document_resource_vote_poll, + vote_choice, + block_info, + estimated_costs_only_with_layer_info, + transaction, + platform_version, + ) + } + } + + }, } } } diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs index d50d3ce457..13d1425c38 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs @@ -7,11 +7,11 @@ use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; -use dpp::fee::fee_result::FeeResult; - -use dpp::prelude::{Identifier, TimestampMillis}; +use dpp::prelude::TimestampMillis; use dpp::version::PlatformVersion; use grovedb::{EstimatedLayerInformation, TransactionArg}; +use dpp::block::block_info::BlockInfo; +use dpp::identifier::Identifier; use dpp::voting::vote_polls::VotePoll; use crate::fee::op::LowLevelDriveOperation; @@ -20,8 +20,10 @@ impl Drive { /// any votes poll should be closed. pub fn add_vote_poll_end_date_query_operations( &self, + creator_identity_id: Option, vote_poll: VotePoll, end_date: TimestampMillis, + block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< HashMap, >, @@ -29,7 +31,7 @@ impl Drive { batch_operations: &mut Vec, transaction: TransactionArg, platform_version: &PlatformVersion, - ) -> Result { + ) -> Result<(), Error> { match platform_version .drive .methods @@ -37,7 +39,7 @@ impl Drive { .contested_resource_insert .add_vote_poll_end_date_query { - 0 => self.add_vote_poll_end_date_query_operations_v0(vote_poll, end_date, estimated_costs_only_with_layer_info, previous_batch_operations, batch_operations, transaction, platform_version), + 0 => self.add_vote_poll_end_date_query_operations_v0(creator_identity_id, vote_poll, end_date, block_info, estimated_costs_only_with_layer_info, previous_batch_operations, batch_operations, transaction, platform_version), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "add_vote_poll_end_date_query_operations".to_string(), known_versions: vec![0], diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs index 5d622f2a2b..1e7f9abb14 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs @@ -2,17 +2,19 @@ use std::collections::HashMap; use grovedb::batch::KeyInfoPath; use crate::drive::Drive; use crate::error::Error; -use dpp::fee::fee_result::FeeResult; use dpp::identity::TimestampMillis; -use grovedb::{EstimatedLayerInformation, TransactionArg}; +use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; +use grovedb::batch::key_info::KeyInfo; use dpp::block::block_info::BlockInfo; use dpp::identifier::Identifier; +use dpp::serialization::PlatformSerializable; use dpp::voting::vote_polls::VotePoll; use platform_version::version::PlatformVersion; use crate::drive::flags::StorageFlags; use crate::drive::grove_operations::BatchInsertTreeApplyType; -use crate::drive::object_size_info::{DriveKeyInfo, PathInfo}; -use crate::drive::votes::paths::vote_contested_resource_end_date_queries_tree_path_vec; +use crate::drive::object_size_info::{DriveKeyInfo, PathInfo, PathKeyElementInfo}; +use crate::drive::object_size_info::PathKeyElementInfo::{PathKeyElementSize, PathKeyRefElement}; +use crate::drive::votes::paths::{vote_contested_resource_end_date_queries_at_time_tree_path_vec, vote_contested_resource_end_date_queries_tree_path_vec}; use crate::fee::op::LowLevelDriveOperation; impl Drive { @@ -31,7 +33,7 @@ impl Drive { batch_operations: &mut Vec, transaction: TransactionArg, platform_version: &PlatformVersion, - ) -> Result { + ) -> Result<(), Error> { let storage_flags = creator_identity_id.map(|creator_identity_id| { StorageFlags::new_single_epoch( @@ -62,7 +64,7 @@ impl Drive { BatchInsertTreeApplyType::StatelessBatchInsertTree { in_tree_using_sums: false, is_sum_tree: false, - flags_len: storage_flags + flags_len: storage_flags.as_ref() .map(|s| s.serialized_size()) .unwrap_or_default(), } @@ -70,7 +72,7 @@ impl Drive { // We check existing operations just because it is possible that we have already inserted the same // end data in the documents batch transition - self.batch_insert_empty_tree_if_not_exists_check_existing_operations( + self.batch_insert_empty_tree_if_not_exists( path_key_info.clone(), false, storage_flags.as_ref(), @@ -81,14 +83,37 @@ impl Drive { &platform_version.drive, )?; - if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info - { - Self::add_estimation_costs_for_levels_up_to_contract_document_type_excluded( - contract, - estimated_costs_only_with_layer_info, - drive_version, - )?; - } + let time_path = vote_contested_resource_end_date_queries_at_time_tree_path_vec(end_date); + + let item = Element::Item(vote_poll.serialize_to_bytes()?, StorageFlags::map_to_some_element_flags(storage_flags.as_ref())); + + let path_key_element_info : PathKeyElementInfo<'_, 0> = if estimated_costs_only_with_layer_info.is_none() { + PathKeyRefElement(( + time_path, + &[0], + item, + )) + } else { + PathKeyElementSize(( + KeyInfoPath::from_known_owned_path(time_path), + KeyInfo::KnownKey(vec![0u8]), + item, + )) + }; + + self.batch_insert(path_key_element_info, batch_operations, &platform_version.drive)?; + + Ok(()) + + //todo + // if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info + // { + // Self::add_estimation_costs_for_levels_up_to_contract_document_type_excluded( + // contract, + // estimated_costs_only_with_layer_info, + // drive_version, + // )?; + // } } } diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 8aa96aaf2b..6f5625a307 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -14,11 +14,11 @@ mod setup; mod paths; pub trait TreePath { - fn tree_path(&self, contract: &DataContract) -> Result, ProtocolError>; + fn tree_path<'a>(&'a self, contract: &'a DataContract) -> Result, ProtocolError>; } impl TreePath for Vote { - fn tree_path(&self, contract: &DataContract) -> Result, ProtocolError> { + fn tree_path<'a>(&'a self, contract: &'a DataContract) -> Result, ProtocolError> { match self { Vote::ResourceVote(resource_vote) => resource_vote.tree_path(contract), } @@ -26,7 +26,7 @@ impl TreePath for Vote { } impl TreePath for ResourceVote { - fn tree_path(&self, contract: &DataContract) -> Result, ProtocolError> { + fn tree_path<'a>(&'a self, contract: &'a DataContract) -> Result, ProtocolError> { let vote_poll = self.vote_poll(); match vote_poll { @@ -39,7 +39,7 @@ impl TreePath for ResourceVote { ))); } let document_type = contract - .document_type_for_name(&contested_document_vote_poll.document_type_name)?; + .document_type_borrowed_for_name(&contested_document_vote_poll.document_type_name)?; let index = document_type .indexes() .get(&contested_document_vote_poll.index_name) diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index ebb316839d..b3636f858d 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -1,3 +1,4 @@ +use dpp::identity::TimestampMillis; use crate::drive::RootTree; /// The votes tree structure looks like this @@ -73,6 +74,16 @@ pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_tree_pat ] } +pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_at_time_tree_path_vec(time: TimestampMillis +) -> Vec> { + vec![ + vec![RootTree::Votes as u8], + vec![CONTESTED_RESOURCE_TREE_KEY as u8], + vec![END_DATE_QUERIES_TREE_KEY as u8], + time.to_be_bytes().to_vec(), + ] +} + pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path<'a>( ) -> [&'a [u8]; 3] { [ @@ -91,9 +102,9 @@ pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_ ] } -pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_for_identity<'a>( +pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_for_identity( identity_id: &[u8; 32], -) -> [&'a [u8]; 4] { +) -> [&[u8]; 4] { [ Into::<&[u8; 1]>::into(RootTree::Votes), &[CONTESTED_RESOURCE_TREE_KEY as u8], diff --git a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs index d67ac9f152..d1d26a02ea 100644 --- a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs +++ b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs @@ -9,6 +9,29 @@ use crate::drive::batch::GroveDbOpBatch; use dpp::version::PlatformVersion; impl Drive { + + /// Initializes the main structure of the vote tree within a GroveDB operation batch. + /// This function is version-controlled to ensure compatibility with different versions of the platform. + /// + /// # Parameters + /// + /// - `batch`: A mutable reference to a GroveDbOpBatch, which will accumulate the necessary operations + /// to set up the main vote tree structure. + /// - `platform_version`: A reference to the platform version to ensure the correct setup operations + /// are applied based on the specified version. + /// + /// # Returns + /// + /// Returns a `Result<(), Error>`, indicating successful setup of the initial vote tree structure + /// within the provided batch or an error in case of failure. + /// + /// # Errors + /// + /// Returns an `Error` if: + /// - The platform version is unknown or unsupported, resulting in a version mismatch error. + /// - Specific operations for the given version fail to be added to the batch, potentially due to + /// constraints or issues within the GroveDB operation batch. + /// pub fn add_initial_vote_tree_main_structure_operations( batch: &mut GroveDbOpBatch, platform_version: &PlatformVersion, diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/mod.rs index 44d763d474..c303da0bfb 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/mod.rs @@ -32,7 +32,7 @@ impl DocumentBaseTransitionActionAccessorsV0 for DocumentBaseTransitionAction { fn document_type(&self) -> Result { Ok(self - .data_contract_fetch_info() + .data_contract_fetch_info_ref() .contract .document_type_for_name(self.document_type_name())?) } @@ -59,6 +59,11 @@ impl DocumentBaseTransitionActionAccessorsV0 for DocumentBaseTransitionAction { } } + fn data_contract_fetch_info_ref(&self) -> &Arc { + match self { + DocumentBaseTransitionAction::V0(v0) => &v0.data_contract, + } + } fn data_contract_fetch_info(&self) -> Arc { match self { DocumentBaseTransitionAction::V0(v0) => v0.data_contract.clone(), diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/v0/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/v0/mod.rs index 39aa8d0cd5..73c3735e95 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/v0/mod.rs @@ -9,6 +9,7 @@ use dpp::prelude::IdentityNonce; use dpp::ProtocolError; use crate::drive::contract::DataContractFetchInfo; +use crate::state_transition_action::document::documents_batch::document_transition::document_base_transition_action::DocumentBaseTransitionAction; #[derive(Debug, Clone)] /// document base transition action v0 @@ -27,6 +28,8 @@ pub struct DocumentBaseTransitionActionV0 { pub trait DocumentBaseTransitionActionAccessorsV0 { /// The document Id fn id(&self) -> Identifier; + + /// The document type fn document_type(&self) -> Result; /// Is a field required on the document type? @@ -38,6 +41,9 @@ pub trait DocumentBaseTransitionActionAccessorsV0 { fn document_type_name_owned(self) -> String; /// Data contract ID generated from the data contract's `owner_id` and `entropy` fn data_contract_id(&self) -> Identifier; + + /// A reference to the data contract fetch info that does not clone the Arc + fn data_contract_fetch_info_ref(&self) -> &Arc; /// Data contract fn data_contract_fetch_info(&self) -> Arc; /// Identity contract nonce diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs index e14dd4105f..ba5d12324f 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs @@ -7,6 +7,7 @@ use derive_more::From; use dpp::block::block_info::BlockInfo; use dpp::platform_value::{Identifier, Value}; use std::collections::BTreeMap; +use std::mem; use dpp::document::Document; use dpp::fee::Credits; @@ -62,6 +63,12 @@ impl DocumentCreateTransitionActionAccessorsV0 for DocumentCreateTransitionActio } } + fn take_prefunded_voting_balances(&mut self) -> Vec<(ContestedDocumentResourceVotePoll, Credits)> { + match self { + DocumentCreateTransitionAction::V0(v0) => mem::replace(&mut v0.prefunded_voting_balances, vec![]), + } + } + fn prefunded_voting_balances(&self) -> &Vec<(ContestedDocumentResourceVotePoll, Credits)> { match self { DocumentCreateTransitionAction::V0(v0) => &v0.prefunded_voting_balances, diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs index deed4bab93..c1aa12d0ee 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs @@ -4,6 +4,7 @@ use dpp::block::block_info::BlockInfo; use dpp::document::{Document, DocumentV0}; use dpp::platform_value::{Identifier, Value}; use std::collections::BTreeMap; +use std::vec; use dpp::ProtocolError; @@ -50,6 +51,9 @@ pub trait DocumentCreateTransitionActionAccessorsV0 { fn data_mut(&mut self) -> &mut BTreeMap; /// data owned fn data_owned(self) -> BTreeMap; + + /// Take the prefunded voting balance vec (and replace it with an empty vec). + fn take_prefunded_voting_balances(&mut self) -> Vec<(ContestedDocumentResourceVotePoll, Credits)>; /// pre funded balance (for unique index conflict resolution voting - the identity will put money /// aside that will be used by voters to vote) diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 55867130e7..c675b7e0c7 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -77,6 +77,7 @@ pub struct DriveVerifyMethodVersions { pub identity: DriveVerifyIdentityMethodVersions, pub single_document: DriveVerifySingleDocumentMethodVersions, pub system: DriveVerifySystemMethodVersions, + pub voting: DriveVerifyVoteMethodVersions, pub state_transition: DriveVerifyStateTransitionMethodVersions, } @@ -108,6 +109,11 @@ pub struct DriveVerifyIdentityMethodVersions { pub verify_identities_contract_keys: FeatureVersion, } +#[derive(Clone, Debug, Default)] +pub struct DriveVerifyVoteMethodVersions { + pub verify_masternode_vote: FeatureVersion, +} + #[derive(Clone, Debug, Default)] pub struct DriveVerifySystemMethodVersions { pub verify_epoch_infos: FeatureVersion, @@ -581,9 +587,11 @@ pub struct DriveIdentityFetchFullIdentityMethodVersions { #[derive(Clone, Debug, Default)] pub struct DriveIdentityFetchPartialIdentityMethodVersions { + pub fetch_identity_revision_with_keys: FeatureVersion, pub fetch_identity_balance_with_keys: FeatureVersion, pub fetch_identity_balance_with_keys_and_revision: FeatureVersion, pub fetch_identity_with_balance: FeatureVersion, + pub fetch_identity_keys: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 82df01de09..e090632eb0 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -30,45 +30,7 @@ use crate::version::drive_abci_versions::{ DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts, }; -use crate::version::drive_versions::{ - DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, - DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, - DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, - DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, - DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, - DriveCreditPoolPendingEpochRefundsMethodVersions, - DriveCreditPoolStorageFeeDistributionPoolMethodVersions, - DriveCreditPoolUnpaidEpochMethodVersions, DriveDataContractOperationMethodVersions, - DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, - DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertContestedMethodVersions, - DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, - DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, - DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveFetchMethodVersions, - DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, - DriveGroveCostMethodVersions, DriveGroveMethodVersions, - DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, - DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, - DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, - DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, - DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, - DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, - DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, - DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, - DriveIdentityWithdrawalDocumentMethodVersions, DriveIdentityWithdrawalMethodVersions, - DriveIdentityWithdrawalTransactionIndexMethodVersions, - DriveIdentityWithdrawalTransactionMethodVersions, - DriveIdentityWithdrawalTransactionQueueMethodVersions, DriveInitializationMethodVersions, - DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformStateMethodVersions, - DrivePlatformSystemMethodVersions, DrivePrefundedSpecializedMethodVersions, - DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, - DriveStateTransitionOperationMethodVersions, DriveStructureVersion, - DriveSystemEstimationCostsMethodVersions, DriveVerifyContractMethodVersions, - DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, - DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, - DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVersion, - DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, - DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions, -}; +use crate::version::drive_versions::{DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, DriveCreditPoolPendingEpochRefundsMethodVersions, DriveCreditPoolStorageFeeDistributionPoolMethodVersions, DriveCreditPoolUnpaidEpochMethodVersions, DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertContestedMethodVersions, DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveFetchMethodVersions, DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, DriveIdentityWithdrawalDocumentMethodVersions, DriveIdentityWithdrawalMethodVersions, DriveIdentityWithdrawalTransactionIndexMethodVersions, DriveIdentityWithdrawalTransactionMethodVersions, DriveIdentityWithdrawalTransactionQueueMethodVersions, DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformStateMethodVersions, DrivePlatformSystemMethodVersions, DrivePrefundedSpecializedMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVerifyVoteMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions}; use crate::version::fee::v1::FEE_VERSION1; use crate::version::mocks::TEST_PROTOCOL_VERSION_SHIFT_BYTES; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; @@ -305,6 +267,9 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { verify_upgrade_state: 0, verify_upgrade_vote_status: 0, }, + voting: DriveVerifyVoteMethodVersions { + verify_masternode_vote: 0, + }, state_transition: DriveVerifyStateTransitionMethodVersions { verify_state_transition_was_executed_with_proof: 0, }, @@ -332,9 +297,11 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { negative_balance: 0, }, partial_identity: DriveIdentityFetchPartialIdentityMethodVersions { + fetch_identity_revision_with_keys: 0, fetch_identity_balance_with_keys: 0, fetch_identity_balance_with_keys_and_revision: 0, fetch_identity_with_balance: 0, + fetch_identity_keys: 0, }, full_identity: DriveIdentityFetchFullIdentityMethodVersions { fetch_full_identity: Some(0), diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index f758719680..a05b6a5dd3 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -30,45 +30,7 @@ use crate::version::drive_abci_versions::{ DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts, }; -use crate::version::drive_versions::{ - DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, - DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, - DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, - DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, - DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, - DriveCreditPoolPendingEpochRefundsMethodVersions, - DriveCreditPoolStorageFeeDistributionPoolMethodVersions, - DriveCreditPoolUnpaidEpochMethodVersions, DriveDataContractOperationMethodVersions, - DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, - DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertContestedMethodVersions, - DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, - DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, - DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveFetchMethodVersions, - DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, - DriveGroveCostMethodVersions, DriveGroveMethodVersions, - DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, - DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, - DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, - DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, - DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, - DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, - DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, - DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, - DriveIdentityWithdrawalDocumentMethodVersions, DriveIdentityWithdrawalMethodVersions, - DriveIdentityWithdrawalTransactionIndexMethodVersions, - DriveIdentityWithdrawalTransactionMethodVersions, - DriveIdentityWithdrawalTransactionQueueMethodVersions, DriveInitializationMethodVersions, - DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformStateMethodVersions, - DrivePlatformSystemMethodVersions, DrivePrefundedSpecializedMethodVersions, - DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, - DriveStateTransitionOperationMethodVersions, DriveStructureVersion, - DriveSystemEstimationCostsMethodVersions, DriveVerifyContractMethodVersions, - DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, - DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, - DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVersion, - DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, - DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions, -}; +use crate::version::drive_versions::{DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, DriveCreditPoolPendingEpochRefundsMethodVersions, DriveCreditPoolStorageFeeDistributionPoolMethodVersions, DriveCreditPoolUnpaidEpochMethodVersions, DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertContestedMethodVersions, DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveFetchMethodVersions, DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, DriveIdentityWithdrawalDocumentMethodVersions, DriveIdentityWithdrawalMethodVersions, DriveIdentityWithdrawalTransactionIndexMethodVersions, DriveIdentityWithdrawalTransactionMethodVersions, DriveIdentityWithdrawalTransactionQueueMethodVersions, DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformStateMethodVersions, DrivePlatformSystemMethodVersions, DrivePrefundedSpecializedMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVerifyVoteMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions}; use crate::version::fee::v1::FEE_VERSION1; use crate::version::mocks::TEST_PROTOCOL_VERSION_SHIFT_BYTES; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; @@ -313,6 +275,9 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { verify_upgrade_state: 0, verify_upgrade_vote_status: 0, }, + voting: DriveVerifyVoteMethodVersions { + verify_masternode_vote: 0, + }, state_transition: DriveVerifyStateTransitionMethodVersions { verify_state_transition_was_executed_with_proof: 0, }, @@ -340,9 +305,11 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { negative_balance: 0, }, partial_identity: DriveIdentityFetchPartialIdentityMethodVersions { + fetch_identity_revision_with_keys: 0, fetch_identity_balance_with_keys: 0, fetch_identity_balance_with_keys_and_revision: 0, fetch_identity_with_balance: 0, + fetch_identity_keys: 0, }, full_identity: DriveIdentityFetchFullIdentityMethodVersions { fetch_full_identity: Some(0), diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 62b327e8ce..27fc7123f9 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -30,45 +30,7 @@ use crate::version::drive_abci_versions::{ DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts, }; -use crate::version::drive_versions::{ - DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, - DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, - DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, - DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, - DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, - DriveCreditPoolPendingEpochRefundsMethodVersions, - DriveCreditPoolStorageFeeDistributionPoolMethodVersions, - DriveCreditPoolUnpaidEpochMethodVersions, DriveDataContractOperationMethodVersions, - DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, - DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertContestedMethodVersions, - DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, - DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, - DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveFetchMethodVersions, - DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, - DriveGroveCostMethodVersions, DriveGroveMethodVersions, - DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, - DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, - DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, - DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, - DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, - DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, - DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, - DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, - DriveIdentityWithdrawalDocumentMethodVersions, DriveIdentityWithdrawalMethodVersions, - DriveIdentityWithdrawalTransactionIndexMethodVersions, - DriveIdentityWithdrawalTransactionMethodVersions, - DriveIdentityWithdrawalTransactionQueueMethodVersions, DriveInitializationMethodVersions, - DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformStateMethodVersions, - DrivePlatformSystemMethodVersions, DrivePrefundedSpecializedMethodVersions, - DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, - DriveStateTransitionOperationMethodVersions, DriveStructureVersion, - DriveSystemEstimationCostsMethodVersions, DriveVerifyContractMethodVersions, - DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, - DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, - DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVersion, - DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, - DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions, -}; +use crate::version::drive_versions::{DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, DriveCreditPoolPendingEpochRefundsMethodVersions, DriveCreditPoolStorageFeeDistributionPoolMethodVersions, DriveCreditPoolUnpaidEpochMethodVersions, DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertContestedMethodVersions, DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveFetchMethodVersions, DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, DriveIdentityWithdrawalDocumentMethodVersions, DriveIdentityWithdrawalMethodVersions, DriveIdentityWithdrawalTransactionIndexMethodVersions, DriveIdentityWithdrawalTransactionMethodVersions, DriveIdentityWithdrawalTransactionQueueMethodVersions, DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformStateMethodVersions, DrivePlatformSystemMethodVersions, DrivePrefundedSpecializedMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVerifyVoteMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions}; use crate::version::fee::v1::FEE_VERSION1; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; use crate::version::{AbciStructureVersion, PlatformArchitectureVersion}; @@ -304,6 +266,9 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { verify_upgrade_state: 0, verify_upgrade_vote_status: 0, }, + voting: DriveVerifyVoteMethodVersions { + verify_masternode_vote: 0, + }, state_transition: DriveVerifyStateTransitionMethodVersions { verify_state_transition_was_executed_with_proof: 0, }, @@ -331,9 +296,11 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { negative_balance: 0, }, partial_identity: DriveIdentityFetchPartialIdentityMethodVersions { + fetch_identity_revision_with_keys: 0, fetch_identity_balance_with_keys: 0, fetch_identity_balance_with_keys_and_revision: 0, fetch_identity_with_balance: 0, + fetch_identity_keys: 0, }, full_identity: DriveIdentityFetchFullIdentityMethodVersions { fetch_full_identity: Some(0), diff --git a/packages/strategy-tests/src/lib.rs b/packages/strategy-tests/src/lib.rs index 29ce98f09c..e7259d476b 100644 --- a/packages/strategy-tests/src/lib.rs +++ b/packages/strategy-tests/src/lib.rs @@ -609,6 +609,7 @@ impl Strategy { .into(), entropy: entropy.to_buffer(), data: document.properties_consumed(), + prefunded_voting_balances: Default::default(), } .into(); @@ -719,6 +720,7 @@ impl Strategy { .into(), entropy: entropy.to_buffer(), data: document.properties_consumed(), + prefunded_voting_balances: Default::default(), } .into(); From b8eb46494c1a83b9d7ab69d1ca7506a7dc9735fa Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 10 May 2024 01:43:58 +0200 Subject: [PATCH 044/135] a lot more work --- .../protos/platform/v0/platform.proto | 14 +- .../proto/org.dash.platform.dapi.v0.rs | 68 ++++----- .../state_transition/processor/v0/mod.rs | 7 + .../masternode_vote/balance/mod.rs | 38 +++++ .../masternode_vote/balance/v0/mod.rs | 43 ++++++ .../state_transitions/masternode_vote/mod.rs | 2 + .../masternode_vote/nonce/mod.rs | 48 +++++++ .../masternode_vote/nonce/v0/mod.rs | 71 ++++++++++ .../masternode_vote/state/v0/mod.rs | 35 +---- packages/rs-drive-abci/src/query/mod.rs | 2 + .../balance/mod.rs | 57 ++++++++ .../balance/v0/mod.rs | 129 +++++++++++++++++ .../prefunded_specialized_balances/mod.rs | 1 + packages/rs-drive-abci/src/query/service.rs | 17 +-- .../contested_resource_vote_state/mod.rs | 0 .../contested_resource_vote_status/mod.rs | 0 .../query/voting/contested_resources/mod.rs | 0 .../rs-drive-abci/src/query/voting/mod.rs | 3 + .../fetch/mod.rs | 1 + .../fetch/single_balance/mod.rs | 134 ++++++++++++++++++ .../fetch/single_balance/v0/mod.rs | 114 +++++++++++++++ .../prefunded_specialized_balances/mod.rs | 1 + .../src/version/drive_abci_versions.rs | 6 + .../src/version/drive_versions.rs | 1 + 24 files changed, 701 insertions(+), 91 deletions(-) create mode 100644 packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/v0/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/nonce/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/nonce/v0/mod.rs create mode 100644 packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/mod.rs create mode 100644 packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/v0/mod.rs create mode 100644 packages/rs-drive-abci/src/query/prefunded_specialized_balances/mod.rs create mode 100644 packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/mod.rs create mode 100644 packages/rs-drive-abci/src/query/voting/contested_resource_vote_status/mod.rs create mode 100644 packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs create mode 100644 packages/rs-drive-abci/src/query/voting/mod.rs create mode 100644 packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/mod.rs create mode 100644 packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/single_balance/mod.rs create mode 100644 packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/single_balance/v0/mod.rs diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index 23925a6038..6182204444 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -37,7 +37,7 @@ service Platform { rpc getContestedResources(GetContestedResourcesRequest) returns (GetContestedResourcesResponse); rpc getContestedResourceVoteState(GetContestedResourceVoteStateRequest) returns (GetContestedResourceVoteStateResponse); rpc getContestedResourceVoteStatus(GetContestedResourceVoteStatusRequest) returns (GetContestedResourceVoteStatusResponse); - rpc getPreFundedSpecializedBalances(GetPreFundedSpecializedBalancesRequest) returns (GetPreFundedSpecializedBalancesResponse); + rpc getPrefundedSpecializedBalance(GetPrefundedSpecializedBalanceRequest) returns (GetPrefundedSpecializedBalanceResponse); rpc getPathElements(GetPathElementsRequest) returns (GetPathElementsResponse); } @@ -726,19 +726,19 @@ message GetContestedResourceVoteStatusResponse { } } -message GetPreFundedSpecializedBalancesRequest { +message GetPrefundedSpecializedBalanceRequest { - message GetPreFundedSpecializedBalancesRequestV0 { + message GetPrefundedSpecializedBalanceRequestV0 { bytes id = 1; bool prove = 2; } - oneof version { GetPreFundedSpecializedBalancesRequestV0 v0 = 1; } + oneof version { GetPrefundedSpecializedBalanceRequestV0 v0 = 1; } } -message GetPreFundedSpecializedBalancesResponse { +message GetPrefundedSpecializedBalanceResponse { - message GetPreFundedSpecializedBalancesResponseV0 { + message GetPrefundedSpecializedBalanceResponseV0 { oneof result { uint64 balance = 1; Proof proof = 2; @@ -746,7 +746,7 @@ message GetPreFundedSpecializedBalancesResponse { ResponseMetadata metadata = 3; } - oneof version { GetPreFundedSpecializedBalancesResponseV0 v0 = 1; } + oneof version { GetPrefundedSpecializedBalanceResponseV0 v0 = 1; } } diff --git a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs index c9d31406bf..1b4efe7d80 100644 --- a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs +++ b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs @@ -2368,20 +2368,20 @@ pub mod get_contested_resource_vote_status_response { #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] -pub struct GetPreFundedSpecializedBalancesRequest { - #[prost(oneof = "get_pre_funded_specialized_balances_request::Version", tags = "1")] +pub struct GetPrefundedSpecializedBalanceRequest { + #[prost(oneof = "get_prefunded_specialized_balance_request::Version", tags = "1")] pub version: ::core::option::Option< - get_pre_funded_specialized_balances_request::Version, + get_prefunded_specialized_balance_request::Version, >, } -/// Nested message and enum types in `GetPreFundedSpecializedBalancesRequest`. -pub mod get_pre_funded_specialized_balances_request { +/// Nested message and enum types in `GetPrefundedSpecializedBalanceRequest`. +pub mod get_prefunded_specialized_balance_request { #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] - pub struct GetPreFundedSpecializedBalancesRequestV0 { + pub struct GetPrefundedSpecializedBalanceRequestV0 { #[prost(bytes = "vec", tag = "1")] #[serde(with = "serde_bytes")] pub id: ::prost::alloc::vec::Vec, @@ -2394,7 +2394,7 @@ pub mod get_pre_funded_specialized_balances_request { #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { #[prost(message, tag = "1")] - V0(GetPreFundedSpecializedBalancesRequestV0), + V0(GetPrefundedSpecializedBalanceRequestV0), } } #[derive(::serde::Serialize, ::serde::Deserialize)] @@ -2402,32 +2402,32 @@ pub mod get_pre_funded_specialized_balances_request { #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] -pub struct GetPreFundedSpecializedBalancesResponse { - #[prost(oneof = "get_pre_funded_specialized_balances_response::Version", tags = "1")] +pub struct GetPrefundedSpecializedBalanceResponse { + #[prost(oneof = "get_prefunded_specialized_balance_response::Version", tags = "1")] pub version: ::core::option::Option< - get_pre_funded_specialized_balances_response::Version, + get_prefunded_specialized_balance_response::Version, >, } -/// Nested message and enum types in `GetPreFundedSpecializedBalancesResponse`. -pub mod get_pre_funded_specialized_balances_response { +/// Nested message and enum types in `GetPrefundedSpecializedBalanceResponse`. +pub mod get_prefunded_specialized_balance_response { #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] - pub struct GetPreFundedSpecializedBalancesResponseV0 { + pub struct GetPrefundedSpecializedBalanceResponseV0 { #[prost(message, optional, tag = "3")] pub metadata: ::core::option::Option, #[prost( - oneof = "get_pre_funded_specialized_balances_response_v0::Result", + oneof = "get_prefunded_specialized_balance_response_v0::Result", tags = "1, 2" )] pub result: ::core::option::Option< - get_pre_funded_specialized_balances_response_v0::Result, + get_prefunded_specialized_balance_response_v0::Result, >, } - /// Nested message and enum types in `GetPreFundedSpecializedBalancesResponseV0`. - pub mod get_pre_funded_specialized_balances_response_v0 { + /// Nested message and enum types in `GetPrefundedSpecializedBalanceResponseV0`. + pub mod get_prefunded_specialized_balance_response_v0 { #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] @@ -2445,7 +2445,7 @@ pub mod get_pre_funded_specialized_balances_response { #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { #[prost(message, tag = "1")] - V0(GetPreFundedSpecializedBalancesResponseV0), + V0(GetPrefundedSpecializedBalanceResponseV0), } } #[derive(::serde::Serialize, ::serde::Deserialize)] @@ -3320,13 +3320,13 @@ pub mod platform_client { ); self.inner.unary(req, path, codec).await } - pub async fn get_pre_funded_specialized_balances( + pub async fn get_prefunded_specialized_balance( &mut self, request: impl tonic::IntoRequest< - super::GetPreFundedSpecializedBalancesRequest, + super::GetPrefundedSpecializedBalanceRequest, >, ) -> std::result::Result< - tonic::Response, + tonic::Response, tonic::Status, > { self.inner @@ -3340,14 +3340,14 @@ pub mod platform_client { })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getPreFundedSpecializedBalances", + "/org.dash.platform.dapi.v0.Platform/getPrefundedSpecializedBalance", ); let mut req = request.into_request(); req.extensions_mut() .insert( GrpcMethod::new( "org.dash.platform.dapi.v0.Platform", - "getPreFundedSpecializedBalances", + "getPrefundedSpecializedBalance", ), ); self.inner.unary(req, path, codec).await @@ -3545,11 +3545,11 @@ pub mod platform_server { tonic::Response, tonic::Status, >; - async fn get_pre_funded_specialized_balances( + async fn get_prefunded_specialized_balance( &self, - request: tonic::Request, + request: tonic::Request, ) -> std::result::Result< - tonic::Response, + tonic::Response, tonic::Status, >; async fn get_path_elements( @@ -4681,15 +4681,15 @@ pub mod platform_server { }; Box::pin(fut) } - "/org.dash.platform.dapi.v0.Platform/getPreFundedSpecializedBalances" => { + "/org.dash.platform.dapi.v0.Platform/getPrefundedSpecializedBalance" => { #[allow(non_camel_case_types)] - struct getPreFundedSpecializedBalancesSvc(pub Arc); + struct getPrefundedSpecializedBalanceSvc(pub Arc); impl< T: Platform, > tonic::server::UnaryService< - super::GetPreFundedSpecializedBalancesRequest, - > for getPreFundedSpecializedBalancesSvc { - type Response = super::GetPreFundedSpecializedBalancesResponse; + super::GetPrefundedSpecializedBalanceRequest, + > for getPrefundedSpecializedBalanceSvc { + type Response = super::GetPrefundedSpecializedBalanceResponse; type Future = BoxFuture< tonic::Response, tonic::Status, @@ -4697,12 +4697,12 @@ pub mod platform_server { fn call( &mut self, request: tonic::Request< - super::GetPreFundedSpecializedBalancesRequest, + super::GetPrefundedSpecializedBalanceRequest, >, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - (*inner).get_pre_funded_specialized_balances(request).await + (*inner).get_prefunded_specialized_balance(request).await }; Box::pin(fut) } @@ -4714,7 +4714,7 @@ pub mod platform_server { let inner = self.inner.clone(); let fut = async move { let inner = inner.0; - let method = getPreFundedSpecializedBalancesSvc(inner); + let method = getPrefundedSpecializedBalanceSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) .apply_compression_config( diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs index 849a787ed0..4ad4732ba1 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs @@ -519,6 +519,13 @@ impl StateTransitionNonceValidationV0 for StateTransition { execution_context, platform_version, ), + StateTransition::MasternodeVote(st) => st.validate_nonces( + platform, + block_info, + tx, + execution_context, + platform_version, + ), _ => Ok(SimpleConsensusValidationResult::new()), } } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/mod.rs new file mode 100644 index 0000000000..47577cc378 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/mod.rs @@ -0,0 +1,38 @@ +use crate::error::execution::ExecutionError; +use crate::error::Error; +use crate::execution::validation::state_transition::masternode_vote::balance::v0::IdentityCreditTransferTransitionBalanceValidationV0; +use crate::execution::validation::state_transition::processor::v0::StateTransitionBalanceValidationV0; +use dpp::identity::PartialIdentity; +use dpp::state_transition::identity_credit_transfer_transition::IdentityCreditTransferTransition; +use dpp::validation::SimpleConsensusValidationResult; +use dpp::version::PlatformVersion; + +pub(crate) mod v0; +impl StateTransitionBalanceValidationV0 for IdentityCreditTransferTransition { + fn validate_minimum_balance_pre_check( + &self, + identity: &PartialIdentity, + platform_version: &PlatformVersion, + ) -> Result { + match platform_version + .drive_abci + .validation_and_processing + .state_transitions + .identity_credit_transfer_state_transition + .advanced_minimum_balance_pre_check + { + Some(0) => { + self.validate_advanced_minimum_balance_pre_check_v0(identity, platform_version) + } + Some(version) => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { + method: "identity credit transfer transition: validate_balance".to_string(), + known_versions: vec![0], + received: version, + })), + None => Err(Error::Execution(ExecutionError::VersionNotActive { + method: "identity credit transfer transition: validate_balance".to_string(), + known_versions: vec![0], + })), + } + } +} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/v0/mod.rs new file mode 100644 index 0000000000..47036f8a44 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/v0/mod.rs @@ -0,0 +1,43 @@ +use crate::error::Error; +use dpp::consensus::state::identity::IdentityInsufficientBalanceError; +use dpp::identity::PartialIdentity; +use dpp::state_transition::masternode_vote_transition::accessors::MasternodeVoteTransitionAccessorsV0; +use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; + +use dpp::validation::SimpleConsensusValidationResult; + +use crate::error::execution::ExecutionError; +use dpp::version::PlatformVersion; + +pub(in crate::execution::validation::state_transition::state_transitions) trait MasternodeVoteTransitionBalanceValidationV0 +{ + fn validate_advanced_minimum_balance_pre_check_v0( + &self, + identity: &PartialIdentity, + platform_version: &PlatformVersion, + ) -> Result; +} + +impl MasternodeVoteTransitionBalanceValidationV0 for MasternodeVoteTransition { + fn validate_advanced_minimum_balance_pre_check_v0( + &self, + identity: &PartialIdentity, + platform_version: &PlatformVersion, + ) -> Result { + let balance = + identity + .balance + .ok_or(Error::Execution(ExecutionError::CorruptedCodeExecution( + "expected to have a balance on identity for credit transfer transition", + )))?; + + if balance < self.amount().checked_add(platform_version.fee_version.state_transition_min_fees.credit_transfer).ok_or(Error::Execution(ExecutionError::Overflow("overflow when adding amount and min_leftover_credits_before_processing in identity credit transfer")))? { + return Ok(SimpleConsensusValidationResult::new_with_error( + IdentityInsufficientBalanceError::new(self.identity_id(), balance, self.amount()) + .into(), + )); + } + + Ok(SimpleConsensusValidationResult::new()) + } +} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 2a46cb9567..4325ff11bd 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -1,5 +1,7 @@ mod state; mod structure; +mod balance; +mod nonce; use dpp::block::block_info::BlockInfo; use dpp::block::epoch::Epoch; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/nonce/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/nonce/mod.rs new file mode 100644 index 0000000000..216c68a1ec --- /dev/null +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/nonce/mod.rs @@ -0,0 +1,48 @@ +use crate::error::execution::ExecutionError; +use crate::error::Error; +use crate::execution::types::state_transition_execution_context::StateTransitionExecutionContext; +use crate::execution::validation::state_transition::masternode_vote::nonce::v0::MasternodeVoteTransitionIdentityNonceV0; +use crate::execution::validation::state_transition::processor::v0::StateTransitionNonceValidationV0; +use crate::platform_types::platform::PlatformStateRef; +use dpp::block::block_info::BlockInfo; +use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; +use dpp::validation::SimpleConsensusValidationResult; +use dpp::version::PlatformVersion; +use drive::grovedb::TransactionArg; + +pub(crate) mod v0; +impl StateTransitionNonceValidationV0 for MasternodeVoteTransition { + fn validate_nonces( + &self, + platform: &PlatformStateRef, + block_info: &BlockInfo, + tx: TransactionArg, + execution_context: &mut StateTransitionExecutionContext, + platform_version: &PlatformVersion, + ) -> Result { + match platform_version + .drive_abci + .validation_and_processing + .state_transitions + .masternode_vote_state_transition + .nonce + { + Some(0) => self.validate_nonce_v0( + platform, + block_info, + tx, + execution_context, + platform_version, + ), + Some(version) => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { + method: "masternode vote transition: validate_nonces".to_string(), + known_versions: vec![0], + received: version, + })), + None => Err(Error::Execution(ExecutionError::VersionNotActive { + method: "masternode vote transition: validate_nonces".to_string(), + known_versions: vec![0], + })), + } + } +} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/nonce/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/nonce/v0/mod.rs new file mode 100644 index 0000000000..a09208f94a --- /dev/null +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/nonce/v0/mod.rs @@ -0,0 +1,71 @@ +use crate::error::Error; +use dpp::block::block_info::BlockInfo; +use dpp::consensus::basic::document::NonceOutOfBoundsError; +use dpp::consensus::basic::BasicError; +use dpp::identity::identity_nonce::{ + validate_identity_nonce_update, validate_new_identity_nonce, MISSING_IDENTITY_REVISIONS_FILTER, +}; +use dpp::state_transition::masternode_vote_transition::accessors::MasternodeVoteTransitionAccessorsV0; +use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; + +use dpp::validation::SimpleConsensusValidationResult; + +use crate::execution::types::execution_operation::ValidationOperation; +use crate::execution::types::state_transition_execution_context::{ + StateTransitionExecutionContext, StateTransitionExecutionContextMethodsV0, +}; +use crate::platform_types::platform::PlatformStateRef; +use dpp::version::PlatformVersion; +use drive::grovedb::TransactionArg; + +pub(in crate::execution::validation::state_transition::state_transitions) trait MasternodeVoteTransitionIdentityNonceV0 +{ + fn validate_nonce_v0( + &self, + platform: &PlatformStateRef, + block_info: &BlockInfo, + tx: TransactionArg, + execution_context: &mut StateTransitionExecutionContext, + platform_version: &PlatformVersion, + ) -> Result; +} + +impl MasternodeVoteTransitionIdentityNonceV0 for MasternodeVoteTransition { + fn validate_nonce_v0( + &self, + platform: &PlatformStateRef, + block_info: &BlockInfo, + tx: TransactionArg, + execution_context: &mut StateTransitionExecutionContext, + platform_version: &PlatformVersion, + ) -> Result { + let revision_nonce = self.nonce(); + + if revision_nonce & MISSING_IDENTITY_REVISIONS_FILTER > 0 { + return Ok(SimpleConsensusValidationResult::new_with_error( + BasicError::NonceOutOfBoundsError(NonceOutOfBoundsError::new(revision_nonce)) + .into(), + )); + } + + let identity_id = self.identity_id(); + + let (existing_nonce, fee) = platform.drive.fetch_identity_nonce_with_fees( + identity_id.to_buffer(), + block_info, + true, + tx, + platform_version, + )?; + + execution_context.add_operation(ValidationOperation::PrecalculatedOperation(fee)); + + let result = if let Some(existing_nonce) = existing_nonce { + validate_identity_nonce_update(existing_nonce, revision_nonce, identity_id) + } else { + validate_new_identity_nonce(revision_nonce, identity_id) + }; + + Ok(result) + } +} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs index e999a0ff9c..ebd984256f 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs @@ -36,40 +36,7 @@ impl MasternodeVoteStateTransitionStateValidationV0 for MasternodeVoteTransition tx: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { - let maybe_existing_identity_balance = platform.drive.fetch_identity_balance( - self.pro_tx_hash().to_buffer(), - tx, - platform_version, - )?; - - let Some(existing_identity_balance) = maybe_existing_identity_balance else { - return Ok(ConsensusValidationResult::new_with_error( - IdentityNotFoundError::new(self.identity_id()).into(), - )); - }; - - if existing_identity_balance < self.amount() { - return Ok(ConsensusValidationResult::new_with_error( - IdentityInsufficientBalanceError::new( - self.identity_id(), - existing_identity_balance, - self.amount(), - ) - .into(), - )); - } - - let maybe_existing_recipient = platform.drive.fetch_identity_balance( - self.recipient_id().to_buffer(), - tx, - platform_version, - )?; - - if maybe_existing_recipient.is_none() { - return Ok(ConsensusValidationResult::new_with_error( - IdentityNotFoundError::new(self.recipient_id()).into(), - )); - } + self.transform_into_action_v0() } diff --git a/packages/rs-drive-abci/src/query/mod.rs b/packages/rs-drive-abci/src/query/mod.rs index c27ec51c7d..d38b836b20 100644 --- a/packages/rs-drive-abci/src/query/mod.rs +++ b/packages/rs-drive-abci/src/query/mod.rs @@ -5,6 +5,8 @@ mod proofs; mod response_metadata; mod service; mod system; +mod voting; +mod prefunded_specialized_balances; use crate::error::query::QueryError; diff --git a/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/mod.rs b/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/mod.rs new file mode 100644 index 0000000000..8dee0277c5 --- /dev/null +++ b/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/mod.rs @@ -0,0 +1,57 @@ +use crate::error::query::QueryError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::PlatformState; +use crate::query::QueryValidationResult; +use dapi_grpc::platform::v0::get_prefunded_specialized_balance_request::Version as RequestVersion; +use dapi_grpc::platform::v0::get_prefunded_specialized_balance_response::Version as ResponseVersion; +use dapi_grpc::platform::v0::{GetPrefundedSpecializedBalanceRequest, GetPrefundedSpecializedBalanceResponse}; +use dpp::version::PlatformVersion; + +mod v0; + +impl Platform { + /// Querying the value of a prefunded specialized balance + pub fn query_prefunded_specialized_balance( + &self, + GetPrefundedSpecializedBalanceRequest { version }: GetPrefundedSpecializedBalanceRequest, + platform_state: &PlatformState, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let Some(version) = version else { + return Ok(QueryValidationResult::new_with_error( + QueryError::DecodingError("could not decode prefunded specialized balance query".to_string()), + )); + }; + + let feature_version_bounds = &platform_version + .drive_abci + .query + .prefunded_specialized_balances + .balance; + + let feature_version = match &version { + RequestVersion::V0(_) => 0, + }; + if !feature_version_bounds.check_version(feature_version) { + return Ok(QueryValidationResult::new_with_error( + QueryError::UnsupportedQueryVersion( + "balance".to_string(), + feature_version_bounds.min_version, + feature_version_bounds.max_version, + platform_version.protocol_version, + feature_version, + ), + )); + } + match version { + RequestVersion::V0(request_v0) => { + let result = self.query_prefunded_specialized_balance_v0(request_v0, platform_state, platform_version)?; + + Ok(result.map(|response_v0| GetPrefundedSpecializedBalanceResponse { + version: Some(ResponseVersion::V0(response_v0)), + })) + } + } + } +} diff --git a/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/v0/mod.rs b/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/v0/mod.rs new file mode 100644 index 0000000000..ed95b047bf --- /dev/null +++ b/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/v0/mod.rs @@ -0,0 +1,129 @@ +use crate::error::query::QueryError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::PlatformState; +use crate::query::QueryValidationResult; +use dapi_grpc::platform::v0::get_prefunded_specialized_balance_request::GetPrefundedSpecializedBalanceRequestV0; +use dapi_grpc::platform::v0::get_prefunded_specialized_balance_response::get_prefunded_specialized_balance_response_v0; +use dapi_grpc::platform::v0::get_prefunded_specialized_balance_response::GetPrefundedSpecializedBalanceResponseV0; +use dpp::check_validation_result_with_data; +use dpp::identifier::Identifier; +use dpp::validation::ValidationResult; +use dpp::version::PlatformVersion; + +impl Platform { + pub(super) fn query_prefunded_specialized_balance_v0( + &self, + GetPrefundedSpecializedBalanceRequestV0 { id, prove }: GetPrefundedSpecializedBalanceRequestV0, + platform_state: &PlatformState, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let identity_id: Identifier = + check_validation_result_with_data!(id.try_into().map_err(|_| { + QueryError::InvalidArgument( + "id must be a valid identifier (32 bytes long)".to_string(), + ) + })); + + let response = if prove { + let proof = check_validation_result_with_data!(self.drive.prove_identity_balance( + identity_id.into_buffer(), + None, + &platform_version.drive + )); + + GetIdentityBalanceResponseV0 { + result: Some(get_identity_balance_response_v0::Result::Proof( + self.response_proof_v0(platform_state, proof), + )), + metadata: Some(self.response_metadata_v0(platform_state)), + } + } else { + let maybe_balance = self.drive.fetch_identity_balance( + identity_id.into_buffer(), + None, + platform_version, + )?; + + let Some(balance) = maybe_balance else { + return Ok(ValidationResult::new_with_error(QueryError::NotFound( + "No Identity found".to_string(), + ))); + }; + + GetIdentityBalanceResponseV0 { + result: Some(get_identity_balance_response_v0::Result::Balance(balance)), + metadata: Some(self.response_metadata_v0(platform_state)), + } + }; + + Ok(QueryValidationResult::new_with_data(response)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::query::tests::{assert_invalid_identifier, setup_platform}; + + #[test] + fn test_invalid_identity_id() { + let (platform, state, version) = setup_platform(false); + + let request = GetIdentityBalanceRequestV0 { + id: vec![0; 8], + prove: false, + }; + + let result = platform + .query_balance_v0(request, &state, version) + .expect("should query balance"); + + assert_invalid_identifier(result); + } + + #[test] + fn test_identity_not_found() { + let (platform, state, version) = setup_platform(false); + + let id = vec![0; 32]; + + let request = GetIdentityBalanceRequestV0 { + id: id.clone(), + prove: false, + }; + + let result = platform + .query_balance_v0(request, &state, version) + .expect("expected query to succeed"); + + assert!(matches!( + result.errors.as_slice(), + [QueryError::NotFound(_)] + )); + } + + #[test] + fn test_identity_balance_absence_proof() { + let (platform, state, version) = setup_platform(false); + + let id = vec![0; 32]; + + let request = GetIdentityBalanceRequestV0 { + id: id.clone(), + prove: true, + }; + + let result = platform + .query_balance_v0(request, &state, version) + .expect("should query balance"); + + assert!(matches!( + result.data, + Some(GetIdentityBalanceResponseV0 { + result: Some(get_identity_balance_response_v0::Result::Proof(_)), + metadata: Some(_) + }) + )); + } +} diff --git a/packages/rs-drive-abci/src/query/prefunded_specialized_balances/mod.rs b/packages/rs-drive-abci/src/query/prefunded_specialized_balances/mod.rs new file mode 100644 index 0000000000..3f3d38870c --- /dev/null +++ b/packages/rs-drive-abci/src/query/prefunded_specialized_balances/mod.rs @@ -0,0 +1 @@ +mod balance; \ No newline at end of file diff --git a/packages/rs-drive-abci/src/query/service.rs b/packages/rs-drive-abci/src/query/service.rs index 4a95675645..c6b4b975c0 100644 --- a/packages/rs-drive-abci/src/query/service.rs +++ b/packages/rs-drive-abci/src/query/service.rs @@ -8,22 +8,7 @@ use crate::rpc::core::DefaultCoreRPC; use crate::utils::spawn_blocking_task_with_name_if_supported; use async_trait::async_trait; use dapi_grpc::platform::v0::platform_server::Platform as PlatformService; -use dapi_grpc::platform::v0::{ - BroadcastStateTransitionRequest, BroadcastStateTransitionResponse, GetConsensusParamsRequest, - GetConsensusParamsResponse, GetDataContractHistoryRequest, GetDataContractHistoryResponse, - GetDataContractRequest, GetDataContractResponse, GetDataContractsRequest, - GetDataContractsResponse, GetDocumentsRequest, GetDocumentsResponse, GetEpochsInfoRequest, - GetEpochsInfoResponse, GetIdentitiesContractKeysRequest, GetIdentitiesContractKeysResponse, - GetIdentityBalanceAndRevisionRequest, GetIdentityBalanceAndRevisionResponse, - GetIdentityBalanceRequest, GetIdentityBalanceResponse, GetIdentityByPublicKeyHashRequest, - GetIdentityByPublicKeyHashResponse, GetIdentityContractNonceRequest, - GetIdentityContractNonceResponse, GetIdentityKeysRequest, GetIdentityKeysResponse, - GetIdentityNonceRequest, GetIdentityNonceResponse, GetIdentityRequest, GetIdentityResponse, - GetPathElementsRequest, GetPathElementsResponse, GetProofsRequest, GetProofsResponse, - GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, - GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, - WaitForStateTransitionResultRequest, WaitForStateTransitionResultResponse, -}; +use dapi_grpc::platform::v0::{BroadcastStateTransitionRequest, BroadcastStateTransitionResponse, GetConsensusParamsRequest, GetConsensusParamsResponse, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetDataContractHistoryRequest, GetDataContractHistoryResponse, GetDataContractRequest, GetDataContractResponse, GetDataContractsRequest, GetDataContractsResponse, GetDocumentsRequest, GetDocumentsResponse, GetEpochsInfoRequest, GetEpochsInfoResponse, GetIdentitiesContractKeysRequest, GetIdentitiesContractKeysResponse, GetIdentityBalanceAndRevisionRequest, GetIdentityBalanceAndRevisionResponse, GetIdentityBalanceRequest, GetIdentityBalanceResponse, GetIdentityByPublicKeyHashRequest, GetIdentityByPublicKeyHashResponse, GetIdentityContractNonceRequest, GetIdentityContractNonceResponse, GetIdentityKeysRequest, GetIdentityKeysResponse, GetIdentityNonceRequest, GetIdentityNonceResponse, GetIdentityRequest, GetIdentityResponse, GetPathElementsRequest, GetPathElementsResponse, GetProofsRequest, GetProofsResponse, GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, WaitForStateTransitionResultRequest, WaitForStateTransitionResultResponse}; use dapi_grpc::tonic::{Request, Response, Status}; use dpp::version::PlatformVersion; use std::sync::atomic::Ordering; diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/mod.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_status/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_status/mod.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/rs-drive-abci/src/query/voting/mod.rs b/packages/rs-drive-abci/src/query/voting/mod.rs new file mode 100644 index 0000000000..af02d3b928 --- /dev/null +++ b/packages/rs-drive-abci/src/query/voting/mod.rs @@ -0,0 +1,3 @@ +mod contested_resources; +mod contested_resource_vote_state; +mod contested_resource_vote_status; \ No newline at end of file diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/mod.rs new file mode 100644 index 0000000000..36dd2c5b5d --- /dev/null +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/mod.rs @@ -0,0 +1 @@ +mod single_balance; \ No newline at end of file diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/single_balance/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/single_balance/mod.rs new file mode 100644 index 0000000000..e2106cbc7e --- /dev/null +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/single_balance/mod.rs @@ -0,0 +1,134 @@ +mod v0; + +use crate::drive::Drive; +use crate::error::{drive::DriveError, Error}; +use crate::fee::op::LowLevelDriveOperation; +use dpp::block::block_info::BlockInfo; +use dpp::fee::fee_result::FeeResult; +use dpp::fee::Credits; + +use dpp::version::PlatformVersion; + +use grovedb::TransactionArg; + +impl Drive { + /// Fetches a prefunded specialized balance from the backing store, respecting drive versioning. + /// + /// # Arguments + /// + /// * `identity_id` - The ID of the Identity whose balance is to be fetched. + /// * `transaction` - The current transaction. + /// * `platform_version` - The platform version to use. + /// + /// # Returns + /// + /// * `Result, Error>` - The balance of the Identity if successful, or an error. + pub fn fetch_prefunded_specialized_balance( + &self, + prefunded_specialized_balance_id: [u8; 32], + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + match platform_version + .drive + .methods + .prefunded_specialized_balances + .fetch_single + { + 0 => self.fetch_prefunded_specialized_balance_v0(prefunded_specialized_balance_id, transaction, platform_version), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "fetch_prefunded_specialized_balance".to_string(), + known_versions: vec![0], + received: version, + })), + } + } + + /// Fetches a prefunded specialized balance from the backing store, including the estimated costs + /// of the operation. + /// Respects drive versioning. + /// + /// # Arguments + /// + /// * `identity_id` - The ID of the Identity whose balance is to be fetched. + /// * `block_info` - The information about the current block. + /// * `apply` - Whether to actually run the query or just get the estimated costs that the query + /// would use. + /// * `transaction` - The current transaction. + /// * `platform_version` - The platform version to use. + /// + /// # Returns + /// + /// * `Result<(Option, FeeResult), Error>` - The balance of the Identity and the fee if successful, or an error. + pub fn fetch_prefunded_specialized_balance_with_costs( + &self, + prefunded_specialized_balance_id: [u8; 32], + block_info: &BlockInfo, + apply: bool, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(Option, FeeResult), Error> { + match platform_version + .drive + .methods + .prefunded_specialized_balances + .fetch_single + { + 0 => self.fetch_prefunded_specialized_balance_with_costs_v0( + prefunded_specialized_balance_id, + block_info, + apply, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "fetch_prefunded_specialized_balance_with_costs".to_string(), + known_versions: vec![0], + received: version, + })), + } + } + + /// Creates operations to get a prefunded specialized balance from the backing store. + /// Operations are created based on the 'apply' argument (stateful vs stateless). + /// + /// # Arguments + /// + /// * `identity_id` - The ID of the Identity whose balance is to be fetched. + /// * `apply` - Whether to create stateful or stateless operations. + /// * `transaction` - The current transaction. + /// * `drive_operations` - The drive operations to be updated. + /// * `platform_version` - The platform version to use. + /// + /// # Returns + /// + /// * `Result, Error>` - The balance of the Identity if successful, or an error. + pub(crate) fn fetch_prefunded_specialized_balance_operations( + &self, + prefunded_specialized_balance_id: [u8; 32], + apply: bool, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result, Error> { + match platform_version + .drive + .methods + .prefunded_specialized_balances + .fetch_single + { + 0 => self.fetch_prefunded_specialized_balance_operations_v0( + prefunded_specialized_balance_id, + apply, + transaction, + drive_operations, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "fetch_prefunded_specialized_balance_operations".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/single_balance/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/single_balance/v0/mod.rs new file mode 100644 index 0000000000..e26086ee1d --- /dev/null +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/single_balance/v0/mod.rs @@ -0,0 +1,114 @@ +use crate::drive::grove_operations::DirectQueryType; +use crate::drive::grove_operations::QueryTarget::QueryTargetValue; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use dpp::block::block_info::BlockInfo; +use dpp::fee::fee_result::FeeResult; +use dpp::fee::Credits; + +use dpp::version::PlatformVersion; +use grovedb::Element::SumItem; +use grovedb::TransactionArg; +use crate::drive::prefunded_specialized_balances::prefunded_specialized_balances_for_voting_path; + +impl Drive { + /// Fetches the Prefunded specialized balance from the backing store + /// Passing apply as false get the estimated cost instead + pub(super) fn fetch_prefunded_specialized_balance_v0( + &self, + balance_id: [u8; 32], + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let mut drive_operations: Vec = vec![]; + self.fetch_prefunded_specialized_balance_operations_v0( + balance_id, + true, + transaction, + &mut drive_operations, + platform_version, + ) + } + + /// Fetches the Prefunded specialized balance from the backing store + /// Passing apply as false get the estimated cost instead + pub(super) fn fetch_prefunded_specialized_balance_with_costs_v0( + &self, + balance_id: [u8; 32], + block_info: &BlockInfo, + apply: bool, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(Option, FeeResult), Error> { + let mut drive_operations: Vec = vec![]; + let value = self.fetch_prefunded_specialized_balance_operations_v0( + balance_id, + apply, + transaction, + &mut drive_operations, + platform_version, + )?; + let fees = Drive::calculate_fee( + None, + Some(drive_operations), + &block_info.epoch, + self.config.epochs_per_era, + platform_version, + )?; + Ok((value, fees)) + } + + /// Creates the operations to get Prefunded specialized balance from the backing store + /// This gets operations based on apply flag (stateful vs stateless) + pub(super) fn fetch_prefunded_specialized_balance_operations_v0( + &self, + balance_id: [u8; 32], + apply: bool, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let direct_query_type = if apply { + DirectQueryType::StatefulDirectQuery + } else { + // 8 is the size of a i64 used in sum trees + DirectQueryType::StatelessDirectQuery { + in_tree_using_sums: true, + query_target: QueryTargetValue(8), + } + }; + + let balance_path = prefunded_specialized_balances_for_voting_path(); + + match self.grove_get_raw_optional( + (&balance_path).into(), + balance_id.as_slice(), + direct_query_type, + transaction, + drive_operations, + &platform_version.drive, + ) { + Ok(Some(SumItem(balance, _))) if balance >= 0 => Ok(Some(balance as Credits)), + + Ok(None) | Err(Error::GroveDB(grovedb::Error::PathKeyNotFound(_))) => { + if apply { + Ok(None) + } else { + Ok(Some(0)) + } + } + + Ok(Some(SumItem(..))) => Err(Error::Drive(DriveError::CorruptedElementType( + "specialized balance was present but was negative", + ))), + + Ok(Some(_)) => Err(Error::Drive(DriveError::CorruptedElementType( + "specialized balance was present but was not identified as a sum item", + ))), + + Err(e) => Err(e), + } + } +} diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs index 6a62b5732a..224eb27b95 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs @@ -3,6 +3,7 @@ mod add_prefunded_specialized_balance_operations; mod deduct_from_prefunded_specialized_balance; mod deduct_from_prefunded_specialized_balance_operations; mod estimation_costs; +mod fetch; use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; use crate::drive::batch::GroveDbOpBatch; diff --git a/packages/rs-platform-version/src/version/drive_abci_versions.rs b/packages/rs-platform-version/src/version/drive_abci_versions.rs index 0d42dd0400..fbe2005a67 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions.rs @@ -14,11 +14,17 @@ pub struct DriveAbciQueryVersions { pub response_metadata: FeatureVersion, pub proofs_query: FeatureVersionBounds, pub document_query: FeatureVersionBounds, + pub prefunded_specialized_balances: DriveAbciQueryPrefundedSpecializedBalancesVersions, pub identity_based_queries: DriveAbciQueryIdentityVersions, pub data_contract_based_queries: DriveAbciQueryDataContractVersions, pub system: DriveAbciQuerySystemVersions, } +#[derive(Clone, Debug, Default)] +pub struct DriveAbciQueryPrefundedSpecializedBalancesVersions { + pub balance: FeatureVersionBounds, +} + #[derive(Clone, Debug, Default)] pub struct DriveAbciQueryIdentityVersions { pub identity: FeatureVersionBounds, diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index c675b7e0c7..8320092808 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -143,6 +143,7 @@ pub struct DriveGroveMethodVersions { #[derive(Clone, Debug, Default)] pub struct DrivePrefundedSpecializedMethodVersions { + pub fetch_single: FeatureVersion, pub add_prefunded_specialized_balance: FeatureVersion, pub add_prefunded_specialized_balance_operations: FeatureVersion, pub deduct_from_prefunded_specialized_balance: FeatureVersion, From b8b93d63ba9ee56f80297501f3496571cb0e9aa9 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sat, 11 May 2024 16:54:49 +0200 Subject: [PATCH 045/135] more work --- packages/rs-dpp/src/errors/consensus/codes.rs | 5 ++ .../rs-dpp/src/errors/consensus/state/mod.rs | 1 + .../prefunded_specialized_balances/mod.rs | 2 + ..._specialized_balance_insufficient_error.rs | 52 +++++++++++++ ...ded_specialized_balance_not_found_error.rs | 40 ++++++++++ .../src/errors/consensus/state/state_error.rs | 8 ++ packages/rs-dpp/src/lib.rs | 1 + .../src/prefunded_specialized_balance/mod.rs | 3 + .../types/execution_operation/mod.rs | 1 + .../check_tx_verification/v0/mod.rs | 2 +- .../state_transition/processor/v0/mod.rs | 78 +++++++++++++++++-- .../documents_batch/balance/mod.rs | 4 +- .../identity_credit_transfer/balance/mod.rs | 4 +- .../identity_credit_withdrawal/balance/mod.rs | 4 +- .../masternode_vote/balance/mod.rs | 34 ++++---- .../masternode_vote/balance/v0/mod.rs | 49 ++++++++---- .../balance/v0/mod.rs | 36 ++++----- .../prefunded_specialized_balances/mod.rs | 6 +- .../prove/mod.rs | 1 + .../prove/single_balance/mod.rs | 46 +++++++++++ .../prove/single_balance/v0/mod.rs | 27 +++++++ .../src/version/drive_versions.rs | 1 + .../fee/state_transition_min_fees/mod.rs | 1 + .../fee/state_transition_min_fees/v1.rs | 1 + .../src/version/mocks/v2_test.rs | 29 +++---- .../src/version/mocks/v3_test.rs | 29 +++---- .../rs-platform-version/src/version/v1.rs | 29 +++---- 27 files changed, 375 insertions(+), 119 deletions(-) create mode 100644 packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/mod.rs create mode 100644 packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/prefunded_specialized_balance_insufficient_error.rs create mode 100644 packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/prefunded_specialized_balance_not_found_error.rs create mode 100644 packages/rs-dpp/src/prefunded_specialized_balance/mod.rs create mode 100644 packages/rs-drive/src/drive/prefunded_specialized_balances/prove/mod.rs create mode 100644 packages/rs-drive/src/drive/prefunded_specialized_balances/prove/single_balance/mod.rs create mode 100644 packages/rs-drive/src/drive/prefunded_specialized_balances/prove/single_balance/v0/mod.rs diff --git a/packages/rs-dpp/src/errors/consensus/codes.rs b/packages/rs-dpp/src/errors/consensus/codes.rs index 476ec620fb..39bcc6ec4a 100644 --- a/packages/rs-dpp/src/errors/consensus/codes.rs +++ b/packages/rs-dpp/src/errors/consensus/codes.rs @@ -221,9 +221,14 @@ impl ErrorWithCode for StateError { Self::IdentityPublicKeyAlreadyExistsForUniqueContractBoundsError(_) => 40211, Self::DocumentTypeUpdateError(_) => 40212, + // Prefunded specialized balances Errors: 40400-40499 + Self::PrefundedSpecializedBalanceInsufficientError(_) => 40400, + Self::PrefundedSpecializedBalanceNotFoundError(_) => 40401, + // Data trigger errors: 40500-40799 #[cfg(feature = "state-transition-validation")] Self::DataTriggerError(ref e) => e.code(), + } } } diff --git a/packages/rs-dpp/src/errors/consensus/state/mod.rs b/packages/rs-dpp/src/errors/consensus/state/mod.rs index bd83045b71..2e17a38dec 100644 --- a/packages/rs-dpp/src/errors/consensus/state/mod.rs +++ b/packages/rs-dpp/src/errors/consensus/state/mod.rs @@ -4,3 +4,4 @@ pub mod data_trigger; pub mod document; pub mod identity; pub mod state_error; +pub mod prefunded_specialized_balances; diff --git a/packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/mod.rs b/packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/mod.rs new file mode 100644 index 0000000000..236e3c34d9 --- /dev/null +++ b/packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/mod.rs @@ -0,0 +1,2 @@ +pub mod prefunded_specialized_balance_insufficient_error; +pub mod prefunded_specialized_balance_not_found_error; \ No newline at end of file diff --git a/packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/prefunded_specialized_balance_insufficient_error.rs b/packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/prefunded_specialized_balance_insufficient_error.rs new file mode 100644 index 0000000000..daa2ae3d60 --- /dev/null +++ b/packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/prefunded_specialized_balance_insufficient_error.rs @@ -0,0 +1,52 @@ +use crate::consensus::state::state_error::StateError; +use crate::consensus::ConsensusError; +use crate::errors::ProtocolError; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +use thiserror::Error; + +use crate::prelude::Identifier; + +use bincode::{Decode, Encode}; + +#[derive( + Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] +#[error("Insufficient specialized balance {balance_id} balance {balance} required {required_balance}")] +#[platform_serialize(unversioned)] +pub struct PrefundedSpecializedBalanceInsufficientError { + /* + + DO NOT CHANGE ORDER OF FIELDS WITHOUT INTRODUCING OF NEW VERSION + + */ + pub balance_id: Identifier, + pub balance: u64, + pub required_balance: u64, +} + +impl PrefundedSpecializedBalanceInsufficientError { + pub fn new(balance_id: Identifier, balance: u64, required_balance: u64) -> Self { + Self { + balance_id, + balance, + required_balance, + } + } + + pub fn balance_id(&self) -> &Identifier { + &self.balance_id + } + + pub fn balance(&self) -> u64 { + self.balance + } + + pub fn required_balance(&self) -> u64 { + self.required_balance + } +} +impl From for ConsensusError { + fn from(err: PrefundedSpecializedBalanceInsufficientError) -> Self { + Self::StateError(StateError::PrefundedSpecializedBalanceInsufficientError(err)) + } +} diff --git a/packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/prefunded_specialized_balance_not_found_error.rs b/packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/prefunded_specialized_balance_not_found_error.rs new file mode 100644 index 0000000000..b40a9d3461 --- /dev/null +++ b/packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/prefunded_specialized_balance_not_found_error.rs @@ -0,0 +1,40 @@ +use crate::consensus::state::state_error::StateError; +use crate::consensus::ConsensusError; +use crate::errors::ProtocolError; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +use thiserror::Error; + +use crate::prelude::Identifier; + +use bincode::{Decode, Encode}; + +#[derive( + Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] +#[error("Did not find a specialized balance with id: {balance_id}")] +#[platform_serialize(unversioned)] +pub struct PrefundedSpecializedBalanceNotFoundError { + /* + + DO NOT CHANGE ORDER OF FIELDS WITHOUT INTRODUCING OF NEW VERSION + + */ + pub balance_id: Identifier, +} + +impl PrefundedSpecializedBalanceNotFoundError { + pub fn new(balance_id: Identifier) -> Self { + Self { + balance_id, + } + } + + pub fn balance_id(&self) -> &Identifier { + &self.balance_id + } +} +impl From for ConsensusError { + fn from(err: PrefundedSpecializedBalanceNotFoundError) -> Self { + Self::StateError(StateError::PrefundedSpecializedBalanceNotFoundError(err)) + } +} diff --git a/packages/rs-dpp/src/errors/consensus/state/state_error.rs b/packages/rs-dpp/src/errors/consensus/state/state_error.rs index a71511e45b..5ea98fc21a 100644 --- a/packages/rs-dpp/src/errors/consensus/state/state_error.rs +++ b/packages/rs-dpp/src/errors/consensus/state/state_error.rs @@ -32,6 +32,8 @@ use crate::consensus::state::document::document_incorrect_purchase_price_error:: use crate::consensus::state::document::document_not_for_sale_error::DocumentNotForSaleError; use crate::consensus::state::identity::identity_public_key_already_exists_for_unique_contract_bounds_error::IdentityPublicKeyAlreadyExistsForUniqueContractBoundsError; use crate::consensus::state::identity::invalid_identity_contract_nonce_error::InvalidIdentityNonceError; +use crate::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_insufficient_error::PrefundedSpecializedBalanceInsufficientError; +use crate::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_not_found_error::PrefundedSpecializedBalanceNotFoundError; use super::document::document_timestamps_are_equal_error::DocumentTimestampsAreEqualError; @@ -127,6 +129,12 @@ pub enum StateError { #[error(transparent)] DocumentTypeUpdateError(DocumentTypeUpdateError), + + #[error(transparent)] + PrefundedSpecializedBalanceInsufficientError(PrefundedSpecializedBalanceInsufficientError), + + #[error(transparent)] + PrefundedSpecializedBalanceNotFoundError(PrefundedSpecializedBalanceNotFoundError), } impl From for ConsensusError { diff --git a/packages/rs-dpp/src/lib.rs b/packages/rs-dpp/src/lib.rs index 8f59e52bd4..30700641f1 100644 --- a/packages/rs-dpp/src/lib.rs +++ b/packages/rs-dpp/src/lib.rs @@ -50,6 +50,7 @@ pub mod signing; pub mod system_data_contracts; pub mod voting; pub mod withdrawal; +pub mod prefunded_specialized_balance; pub use async_trait; diff --git a/packages/rs-dpp/src/prefunded_specialized_balance/mod.rs b/packages/rs-dpp/src/prefunded_specialized_balance/mod.rs new file mode 100644 index 0000000000..76a4ddba4e --- /dev/null +++ b/packages/rs-dpp/src/prefunded_specialized_balance/mod.rs @@ -0,0 +1,3 @@ +use platform_value::Identifier; + +pub type PrefundedSpecializedBalanceIdentifier = Identifier; \ No newline at end of file diff --git a/packages/rs-drive-abci/src/execution/types/execution_operation/mod.rs b/packages/rs-drive-abci/src/execution/types/execution_operation/mod.rs index ea00122ce6..7f718137ad 100644 --- a/packages/rs-drive-abci/src/execution/types/execution_operation/mod.rs +++ b/packages/rs-drive-abci/src/execution/types/execution_operation/mod.rs @@ -66,6 +66,7 @@ pub const SHA256_BLOCK_SIZE: u16 = 64; pub enum ValidationOperation { Protocol(ProtocolValidationOperation), RetrieveIdentity(RetrieveIdentityInfo), + RetrievePrefundedSpecializedBalance, DoubleSha256(HashBlockCount), ValidateKeyStructure(KeyCount), // This is extremely cheap SignatureVerification(SignatureVerificationOperation), diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/check_tx_verification/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/check_tx_verification/v0/mod.rs index 3846ebad99..f3ce164f57 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/check_tx_verification/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/check_tx_verification/v0/mod.rs @@ -16,7 +16,7 @@ use crate::error::execution::ExecutionError; use crate::execution::check_tx::CheckTxLevel; use crate::execution::types::state_transition_execution_context::StateTransitionExecutionContext; use crate::execution::validation::state_transition::common::asset_lock::proof::verify_is_not_spent::AssetLockProofVerifyIsNotSpent; -use crate::execution::validation::state_transition::processor::v0::{StateTransitionBalanceValidationV0, StateTransitionBasicStructureValidationV0, StateTransitionNonceValidationV0, StateTransitionIdentityBasedSignatureValidationV0, StateTransitionStructureKnownInStateValidationV0}; +use crate::execution::validation::state_transition::processor::v0::{StateTransitionIdentityBalanceValidationV0, StateTransitionBasicStructureValidationV0, StateTransitionNonceValidationV0, StateTransitionIdentityBasedSignatureValidationV0, StateTransitionStructureKnownInStateValidationV0}; use crate::execution::validation::state_transition::ValidationMode; pub(super) fn state_transition_to_execution_event_for_check_tx_v0<'a, C: CoreRPCLike>( diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs index 4ad4732ba1..dc032b5aa7 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs @@ -1,3 +1,4 @@ +use std::collections::BTreeMap; use crate::error::Error; use crate::execution::types::execution_event::ExecutionEvent; use crate::execution::validation::state_transition::transformer::StateTransitionActionTransformerV0; @@ -6,7 +7,10 @@ use crate::platform_types::platform_state::v0::PlatformStateV0Methods; use crate::rpc::core::CoreRPCLike; use dpp::block::block_info::BlockInfo; use dpp::block::epoch::Epoch; +use dpp::fee::Credits; +use dpp::identifier::Identifier; use dpp::identity::PartialIdentity; +use dpp::prefunded_specialized_balance::PrefundedSpecializedBalanceIdentifier; use dpp::prelude::ConsensusValidationResult; use dpp::ProtocolError; @@ -134,6 +138,12 @@ pub(super) fn process_state_transition_v0<'a, C: CoreRPCLike>( } } + let prefunded_balances = if state_transition.uses_prefunded_specialized_balance_for_payment() { + Some(state_transition.validate_minimum_prefunded_specialized_balance_pre_check()?) + } else { + None + }; + // Only identity update and data contract create have advanced structure validation without state if state_transition.has_advanced_structure_validation_without_state() { // Currently only used for Identity Update @@ -379,7 +389,7 @@ pub(crate) trait StateTransitionStructureKnownInStateValidationV0 { } /// A trait for validating state transitions within a blockchain. -pub(crate) trait StateTransitionBalanceValidationV0 { +pub(crate) trait StateTransitionIdentityBalanceValidationV0 { /// Validates the state transition by analyzing the changes in the platform state after applying the transaction. /// /// # Arguments @@ -404,7 +414,38 @@ pub(crate) trait StateTransitionBalanceValidationV0 { /// This balance validation is not for the operations of the state transition, but more as a /// quick early verification that the user has the balance they want to transfer or withdraw. fn has_balance_pre_check_validation(&self) -> bool { - true + !matches!(self, StateTransition::MasternodeVote(_)) + } +} + +pub(crate) trait StateTransitionPrefundedSpecializedBalanceValidationV0 { + + /// Validates the state transition by analyzing the changes in the platform state after applying the transaction. + /// + /// # Arguments + /// + /// * `platform` - A reference to the platform containing the state data. + /// * `tx` - The transaction argument to be applied. + /// + /// # Type Parameters + /// + /// * `C: CoreRPCLike` - A type constraint indicating that C should implement `CoreRPCLike`. + /// + /// # Returns + /// + /// * `Result, Error>` - A result with either a ConsensusValidationResult containing a StateTransitionAction or an Error. + fn validate_minimum_prefunded_specialized_balance_pre_check( + &self, + drive: &Drive, + tx: TransactionArg, + execution_context: &mut StateTransitionExecutionContext, + platform_version: &PlatformVersion, + ) -> Result>, Error>; + + + /// Do we use a prefunded specialized balance for payment + fn uses_prefunded_specialized_balance_for_payment(&self) -> bool { + matches!(self, StateTransition::MasternodeVote(_)) } } @@ -543,7 +584,7 @@ impl StateTransitionNonceValidationV0 for StateTransition { } } -impl StateTransitionBalanceValidationV0 for StateTransition { +impl StateTransitionIdentityBalanceValidationV0 for StateTransition { fn validate_minimum_balance_pre_check( &self, identity: &PartialIdentity, @@ -564,10 +605,7 @@ impl StateTransitionBalanceValidationV0 for StateTransition { | StateTransition::IdentityUpdate(_) => { self.validate_simple_pre_check_minimum_balance(identity, platform_version) } - StateTransition::MasternodeVote(_) => { - // We validate that amount set aside still has funds - } - StateTransition::IdentityCreate(_) | StateTransition::IdentityTopUp(_) => { + StateTransition::MasternodeVote(_) | StateTransition::IdentityCreate(_) | StateTransition::IdentityTopUp(_) => { Ok(SimpleConsensusValidationResult::new()) } } @@ -582,6 +620,32 @@ impl StateTransitionBalanceValidationV0 for StateTransition { | StateTransition::DataContractUpdate(_) | StateTransition::DocumentsBatch(_) | StateTransition::IdentityUpdate(_) + ) + } +} + + +impl StateTransitionPrefundedSpecializedBalanceValidationV0 for StateTransition { + fn validate_minimum_prefunded_specialized_balance_pre_check( + &self, + drive: &Drive, + tx: TransactionArg, + execution_context: &mut StateTransitionExecutionContext, + platform_version: &PlatformVersion, + ) -> Result>, Error> { + match self { + StateTransition::MasternodeVote(masternode_vote_transition) => { + masternode_vote_transition.validate_minimum_prefunded_specialized_balance_pre_check(drive, tx, execution_context, platform_version) + } + _ => { + Ok(ConsensusValidationResult::new()) + } + } + } + + fn uses_prefunded_specialized_balance_for_payment(&self) -> bool { + matches!( + self, | StateTransition::MasternodeVote(_) ) } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/balance/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/balance/mod.rs index 4ca24ddc1c..b56c2b8ff3 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/balance/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/balance/mod.rs @@ -1,14 +1,14 @@ use crate::error::execution::ExecutionError; use crate::error::Error; use crate::execution::validation::state_transition::documents_batch::balance::v0::DocumentsBatchTransitionBalanceValidationV0; -use crate::execution::validation::state_transition::processor::v0::StateTransitionBalanceValidationV0; +use crate::execution::validation::state_transition::processor::v0::StateTransitionIdentityBalanceValidationV0; use dpp::identity::PartialIdentity; use dpp::state_transition::documents_batch_transition::DocumentsBatchTransition; use dpp::validation::SimpleConsensusValidationResult; use dpp::version::PlatformVersion; pub(crate) mod v0; -impl StateTransitionBalanceValidationV0 for DocumentsBatchTransition { +impl StateTransitionIdentityBalanceValidationV0 for DocumentsBatchTransition { fn validate_minimum_balance_pre_check( &self, identity: &PartialIdentity, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_transfer/balance/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_transfer/balance/mod.rs index da04bb187b..fe390272c1 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_transfer/balance/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_transfer/balance/mod.rs @@ -1,14 +1,14 @@ use crate::error::execution::ExecutionError; use crate::error::Error; use crate::execution::validation::state_transition::identity_credit_transfer::balance::v0::IdentityCreditTransferTransitionBalanceValidationV0; -use crate::execution::validation::state_transition::processor::v0::StateTransitionBalanceValidationV0; +use crate::execution::validation::state_transition::processor::v0::StateTransitionIdentityBalanceValidationV0; use dpp::identity::PartialIdentity; use dpp::state_transition::identity_credit_transfer_transition::IdentityCreditTransferTransition; use dpp::validation::SimpleConsensusValidationResult; use dpp::version::PlatformVersion; pub(crate) mod v0; -impl StateTransitionBalanceValidationV0 for IdentityCreditTransferTransition { +impl StateTransitionIdentityBalanceValidationV0 for IdentityCreditTransferTransition { fn validate_minimum_balance_pre_check( &self, identity: &PartialIdentity, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/balance/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/balance/mod.rs index 60eeb8047b..edbfa3f1a6 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/balance/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/balance/mod.rs @@ -1,14 +1,14 @@ use crate::error::execution::ExecutionError; use crate::error::Error; use crate::execution::validation::state_transition::identity_credit_withdrawal::balance::v0::IdentityCreditTransferTransitionBalanceValidationV0; -use crate::execution::validation::state_transition::processor::v0::StateTransitionBalanceValidationV0; +use crate::execution::validation::state_transition::processor::v0::StateTransitionIdentityBalanceValidationV0; use dpp::identity::PartialIdentity; use dpp::state_transition::identity_credit_withdrawal_transition::IdentityCreditWithdrawalTransition; use dpp::validation::SimpleConsensusValidationResult; use dpp::version::PlatformVersion; pub(crate) mod v0; -impl StateTransitionBalanceValidationV0 for IdentityCreditWithdrawalTransition { +impl StateTransitionIdentityBalanceValidationV0 for IdentityCreditWithdrawalTransition { fn validate_minimum_balance_pre_check( &self, identity: &PartialIdentity, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/mod.rs index 47577cc378..768a08904f 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/mod.rs @@ -1,36 +1,44 @@ +use std::collections::BTreeMap; +use dpp::fee::Credits; use crate::error::execution::ExecutionError; use crate::error::Error; -use crate::execution::validation::state_transition::masternode_vote::balance::v0::IdentityCreditTransferTransitionBalanceValidationV0; -use crate::execution::validation::state_transition::processor::v0::StateTransitionBalanceValidationV0; -use dpp::identity::PartialIdentity; -use dpp::state_transition::identity_credit_transfer_transition::IdentityCreditTransferTransition; -use dpp::validation::SimpleConsensusValidationResult; +use crate::execution::validation::state_transition::processor::v0::{StateTransitionIdentityBalanceValidationV0, StateTransitionPrefundedSpecializedBalanceValidationV0}; +use dpp::prefunded_specialized_balance::PrefundedSpecializedBalanceIdentifier; +use dpp::prelude::ConsensusValidationResult; +use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; use dpp::version::PlatformVersion; +use drive::drive::Drive; +use drive::grovedb::TransactionArg; +use crate::execution::types::state_transition_execution_context::StateTransitionExecutionContext; +use crate::execution::validation::state_transition::masternode_vote::balance::v0::MasternodeVoteTransitionBalanceValidationV0; pub(crate) mod v0; -impl StateTransitionBalanceValidationV0 for IdentityCreditTransferTransition { - fn validate_minimum_balance_pre_check( + +impl StateTransitionPrefundedSpecializedBalanceValidationV0 for MasternodeVoteTransition { + fn validate_minimum_prefunded_specialized_balance_pre_check( &self, - identity: &PartialIdentity, + drive: &Drive, + tx: TransactionArg, + execution_context: &mut StateTransitionExecutionContext, platform_version: &PlatformVersion, - ) -> Result { + ) -> Result>, Error> { match platform_version .drive_abci .validation_and_processing .state_transitions - .identity_credit_transfer_state_transition + .masternode_vote_state_transition .advanced_minimum_balance_pre_check { Some(0) => { - self.validate_advanced_minimum_balance_pre_check_v0(identity, platform_version) + self.validate_advanced_minimum_balance_pre_check_v0(drive, tx, execution_context, platform_version) } Some(version) => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { - method: "identity credit transfer transition: validate_balance".to_string(), + method: "masternode vote transition: validate_balance".to_string(), known_versions: vec![0], received: version, })), None => Err(Error::Execution(ExecutionError::VersionNotActive { - method: "identity credit transfer transition: validate_balance".to_string(), + method: "masternode vote transition: validate_balance".to_string(), known_versions: vec![0], })), } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/v0/mod.rs index 47036f8a44..d54ce1ec5b 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/v0/mod.rs @@ -1,6 +1,10 @@ +use std::collections::BTreeMap; +use dpp::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_insufficient_error::PrefundedSpecializedBalanceInsufficientError; +use dpp::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_not_found_error::PrefundedSpecializedBalanceNotFoundError; use crate::error::Error; -use dpp::consensus::state::identity::IdentityInsufficientBalanceError; -use dpp::identity::PartialIdentity; +use dpp::fee::Credits; +use dpp::prefunded_specialized_balance::PrefundedSpecializedBalanceIdentifier; +use dpp::prelude::ConsensusValidationResult; use dpp::state_transition::masternode_vote_transition::accessors::MasternodeVoteTransitionAccessorsV0; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; @@ -8,12 +12,18 @@ use dpp::validation::SimpleConsensusValidationResult; use crate::error::execution::ExecutionError; use dpp::version::PlatformVersion; +use drive::drive::Drive; +use drive::grovedb::TransactionArg; +use crate::execution::types::execution_operation::ValidationOperation; +use crate::execution::types::state_transition_execution_context::{StateTransitionExecutionContext, StateTransitionExecutionContextMethodsV0}; -pub(in crate::execution::validation::state_transition::state_transitions) trait MasternodeVoteTransitionBalanceValidationV0 +pub(super) trait MasternodeVoteTransitionBalanceValidationV0 { fn validate_advanced_minimum_balance_pre_check_v0( &self, - identity: &PartialIdentity, + drive: &Drive, + tx: TransactionArg, + execution_context: &mut StateTransitionExecutionContext, platform_version: &PlatformVersion, ) -> Result; } @@ -21,23 +31,30 @@ pub(in crate::execution::validation::state_transition::state_transitions) trait impl MasternodeVoteTransitionBalanceValidationV0 for MasternodeVoteTransition { fn validate_advanced_minimum_balance_pre_check_v0( &self, - identity: &PartialIdentity, + drive: &Drive, + tx: TransactionArg, + execution_context: &mut StateTransitionExecutionContext, platform_version: &PlatformVersion, - ) -> Result { - let balance = - identity - .balance - .ok_or(Error::Execution(ExecutionError::CorruptedCodeExecution( - "expected to have a balance on identity for credit transfer transition", - )))?; + ) -> Result>, Error> { - if balance < self.amount().checked_add(platform_version.fee_version.state_transition_min_fees.credit_transfer).ok_or(Error::Execution(ExecutionError::Overflow("overflow when adding amount and min_leftover_credits_before_processing in identity credit transfer")))? { - return Ok(SimpleConsensusValidationResult::new_with_error( - IdentityInsufficientBalanceError::new(self.identity_id(), balance, self.amount()) + execution_context.add_operation(ValidationOperation::RetrievePrefundedSpecializedBalance); + + let vote = self.vote(); + + let balance_id = vote.specialized_balance_id()?.ok_or(Error::Execution(ExecutionError::CorruptedCodeExecution("In this version there should always be a specialized balance id")))?; + let maybe_balance = drive.fetch_prefunded_specialized_balance(balance_id.to_buffer(), tx, platform_version)?; + + let Some(balance) = maybe_balance else { + // If there is no balance we are voting on something that either was never created or has finished + return Ok(ConsensusValidationResult::new_with_error(PrefundedSpecializedBalanceNotFoundError::new(balance_id).into())); + }; + if balance < platform_version.fee_version.state_transition_min_fees.masternode_vote { + return Ok(ConsensusValidationResult::new_with_error( + PrefundedSpecializedBalanceInsufficientError::new(balance_id, balance, platform_version.fee_version.state_transition_min_fees.masternode_vote) .into(), )); } - Ok(SimpleConsensusValidationResult::new()) + Ok(ConsensusValidationResult::new_with_data(BTreeMap::from([(balance_id, balance)]))) } } diff --git a/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/v0/mod.rs b/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/v0/mod.rs index ed95b047bf..e43943c4a4 100644 --- a/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/v0/mod.rs @@ -18,7 +18,7 @@ impl Platform { platform_state: &PlatformState, platform_version: &PlatformVersion, ) -> Result, Error> { - let identity_id: Identifier = + let balance_id: Identifier = check_validation_result_with_data!(id.try_into().map_err(|_| { QueryError::InvalidArgument( "id must be a valid identifier (32 bytes long)".to_string(), @@ -26,21 +26,21 @@ impl Platform { })); let response = if prove { - let proof = check_validation_result_with_data!(self.drive.prove_identity_balance( - identity_id.into_buffer(), + let proof = check_validation_result_with_data!(self.drive.prove_prefunded_specialized_balance( + balance_id.into_buffer(), None, - &platform_version.drive + platform_version, )); - GetIdentityBalanceResponseV0 { - result: Some(get_identity_balance_response_v0::Result::Proof( + GetPrefundedSpecializedBalanceResponseV0 { + result: Some(get_prefunded_specialized_balance_response_v0::Result::Proof( self.response_proof_v0(platform_state, proof), )), metadata: Some(self.response_metadata_v0(platform_state)), } } else { - let maybe_balance = self.drive.fetch_identity_balance( - identity_id.into_buffer(), + let maybe_balance = self.drive.fetch_prefunded_specialized_balance( + balance_id.into_buffer(), None, platform_version, )?; @@ -51,8 +51,8 @@ impl Platform { ))); }; - GetIdentityBalanceResponseV0 { - result: Some(get_identity_balance_response_v0::Result::Balance(balance)), + GetPrefundedSpecializedBalanceResponseV0 { + result: Some(get_prefunded_specialized_balance_response_v0::Result::Balance(balance)), metadata: Some(self.response_metadata_v0(platform_state)), } }; @@ -70,13 +70,13 @@ mod tests { fn test_invalid_identity_id() { let (platform, state, version) = setup_platform(false); - let request = GetIdentityBalanceRequestV0 { + let request = GetPrefundedSpecializedBalanceRequestV0 { id: vec![0; 8], prove: false, }; let result = platform - .query_balance_v0(request, &state, version) + .query_prefunded_specialized_balance_v0(request, &state, version) .expect("should query balance"); assert_invalid_identifier(result); @@ -88,13 +88,13 @@ mod tests { let id = vec![0; 32]; - let request = GetIdentityBalanceRequestV0 { + let request = GetPrefundedSpecializedBalanceRequestV0 { id: id.clone(), prove: false, }; let result = platform - .query_balance_v0(request, &state, version) + .query_prefunded_specialized_balance_v0(request, &state, version) .expect("expected query to succeed"); assert!(matches!( @@ -109,19 +109,19 @@ mod tests { let id = vec![0; 32]; - let request = GetIdentityBalanceRequestV0 { + let request = GetPrefundedSpecializedBalanceRequestV0 { id: id.clone(), prove: true, }; let result = platform - .query_balance_v0(request, &state, version) + .query_prefunded_specialized_balance_v0(request, &state, version) .expect("should query balance"); assert!(matches!( result.data, - Some(GetIdentityBalanceResponseV0 { - result: Some(get_identity_balance_response_v0::Result::Proof(_)), + Some(GetPrefundedSpecializedBalanceResponseV0 { + result: Some(get_prefunded_specialized_balance_response_v0::Result::Proof(_)), metadata: Some(_) }) )); diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs index 224eb27b95..03c2b002ca 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs @@ -4,10 +4,14 @@ mod deduct_from_prefunded_specialized_balance; mod deduct_from_prefunded_specialized_balance_operations; mod estimation_costs; mod fetch; +mod prove; +use grovedb::TransactionArg; +use platform_version::version::drive_versions::DriveVersion; use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; use crate::drive::batch::GroveDbOpBatch; use crate::drive::{Drive, RootTree}; +use crate::error::Error; pub const PREFUNDED_BALANCES_FOR_VOTING: [u8; 1] = [128]; @@ -41,4 +45,4 @@ impl Drive { PREFUNDED_BALANCES_FOR_VOTING.to_vec(), ); } -} +} \ No newline at end of file diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/prove/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/prove/mod.rs new file mode 100644 index 0000000000..36dd2c5b5d --- /dev/null +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/prove/mod.rs @@ -0,0 +1 @@ +mod single_balance; \ No newline at end of file diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/prove/single_balance/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/prove/single_balance/mod.rs new file mode 100644 index 0000000000..c165ee5335 --- /dev/null +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/prove/single_balance/mod.rs @@ -0,0 +1,46 @@ +mod v0; + +use crate::drive::Drive; +use crate::error::{drive::DriveError, Error}; +use crate::fee::op::LowLevelDriveOperation; +use dpp::block::block_info::BlockInfo; +use dpp::fee::fee_result::FeeResult; +use dpp::fee::Credits; + +use dpp::version::PlatformVersion; + +use grovedb::TransactionArg; + +impl Drive { + /// proves a prefunded specialized balance from the backing store, respecting drive versioning. + /// + /// # Arguments + /// + /// * `identity_id` - The ID of the Specialized balance whose amount is to be proved. + /// * `transaction` - The current transaction. + /// * `platform_version` - The platform version to use. + /// + /// # Returns + /// + /// * `Result, Error>` - The proof if successful, or an error. + pub fn prove_prefunded_specialized_balance( + &self, + prefunded_specialized_balance_id: [u8; 32], + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + match platform_version + .drive + .methods + .prefunded_specialized_balances + .prove_single + { + 0 => self.prove_prefunded_specialized_balance_v0(prefunded_specialized_balance_id, transaction, platform_version), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "prove_prefunded_specialized_balance".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/prove/single_balance/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/prove/single_balance/v0/mod.rs new file mode 100644 index 0000000000..e8d80131a3 --- /dev/null +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/prove/single_balance/v0/mod.rs @@ -0,0 +1,27 @@ +use crate::drive::Drive; +use crate::error::Error; + +use dpp::version::PlatformVersion; +use grovedb::{PathQuery, TransactionArg}; +use crate::drive::prefunded_specialized_balances::prefunded_specialized_balances_for_voting_path_vec; + +impl Drive { + /// Proves the prefunded specialized balance from the backing store + /// Passing apply as false get the estimated cost instead + pub(super) fn prove_prefunded_specialized_balance_v0( + &self, + balance_id: [u8; 32], + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let balance_path = prefunded_specialized_balances_for_voting_path_vec(); + let balance_query = PathQuery::new_single_key(balance_path, balance_id.to_vec()); + self.grove_get_proved_path_query( + &balance_query, + false, + transaction, + &mut vec![], + &platform_version.drive, + ) + } +} diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 8320092808..046ac0cae0 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -144,6 +144,7 @@ pub struct DriveGroveMethodVersions { #[derive(Clone, Debug, Default)] pub struct DrivePrefundedSpecializedMethodVersions { pub fetch_single: FeatureVersion, + pub prove_single: FeatureVersion, pub add_prefunded_specialized_balance: FeatureVersion, pub add_prefunded_specialized_balance_operations: FeatureVersion, pub deduct_from_prefunded_specialized_balance: FeatureVersion, diff --git a/packages/rs-platform-version/src/version/fee/state_transition_min_fees/mod.rs b/packages/rs-platform-version/src/version/fee/state_transition_min_fees/mod.rs index 692634e747..b94d61253b 100644 --- a/packages/rs-platform-version/src/version/fee/state_transition_min_fees/mod.rs +++ b/packages/rs-platform-version/src/version/fee/state_transition_min_fees/mod.rs @@ -7,4 +7,5 @@ pub struct StateTransitionMinFees { pub document_batch_sub_transition: u64, pub contract_create: u64, pub contract_update: u64, + pub masternode_vote: u64, } diff --git a/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs b/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs index 9c1a8f27ff..5f759e50fc 100644 --- a/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs +++ b/packages/rs-platform-version/src/version/fee/state_transition_min_fees/v1.rs @@ -7,4 +7,5 @@ pub const STATE_TRANSITION_MIN_FEES_VERSION1: StateTransitionMinFees = StateTran document_batch_sub_transition: 100000, contract_create: 100000, contract_update: 100000, + masternode_vote: 100000, }; diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index e090632eb0..8663db2dd4 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -11,25 +11,7 @@ use crate::version::dpp_versions::{ RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, }; -use crate::version::drive_abci_versions::{ - DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, - DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, - DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, - DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, - DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, - DriveAbciFeePoolInwardsDistributionMethodVersions, - DriveAbciFeePoolOutwardsDistributionMethodVersions, - DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, - DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, - DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, - DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, - DriveAbciQuerySystemVersions, DriveAbciQueryVersions, - DriveAbciStateTransitionCommonValidationVersions, - DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, - DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, - DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, - DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts, -}; +use crate::version::drive_abci_versions::{DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, DriveAbciFeePoolInwardsDistributionMethodVersions, DriveAbciFeePoolOutwardsDistributionMethodVersions, DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, DriveAbciQueryPrefundedSpecializedBalancesVersions, DriveAbciQuerySystemVersions, DriveAbciQueryVersions, DriveAbciStateTransitionCommonValidationVersions, DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts}; use crate::version::drive_versions::{DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, DriveCreditPoolPendingEpochRefundsMethodVersions, DriveCreditPoolStorageFeeDistributionPoolMethodVersions, DriveCreditPoolUnpaidEpochMethodVersions, DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertContestedMethodVersions, DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveFetchMethodVersions, DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, DriveIdentityWithdrawalDocumentMethodVersions, DriveIdentityWithdrawalMethodVersions, DriveIdentityWithdrawalTransactionIndexMethodVersions, DriveIdentityWithdrawalTransactionMethodVersions, DriveIdentityWithdrawalTransactionQueueMethodVersions, DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformStateMethodVersions, DrivePlatformSystemMethodVersions, DrivePrefundedSpecializedMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVerifyVoteMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions}; use crate::version::fee::v1::FEE_VERSION1; use crate::version::mocks::TEST_PROTOCOL_VERSION_SHIFT_BYTES; @@ -436,6 +418,8 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { }, fetch: DriveFetchMethodVersions { fetch_elements: 0 }, prefunded_specialized_balances: DrivePrefundedSpecializedMethodVersions { + fetch_single: 0, + prove_single: 0, add_prefunded_specialized_balance: 0, add_prefunded_specialized_balance_operations: 0, deduct_from_prefunded_specialized_balance: 0, @@ -745,6 +729,13 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { max_version: 0, default_current_version: 0, }, + prefunded_specialized_balances: DriveAbciQueryPrefundedSpecializedBalancesVersions { + balance: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, + }, identity_based_queries: DriveAbciQueryIdentityVersions { identity: FeatureVersionBounds { min_version: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index a05b6a5dd3..a8062b60b7 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -11,25 +11,7 @@ use crate::version::dpp_versions::{ RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, }; -use crate::version::drive_abci_versions::{ - DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, - DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, - DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, - DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, - DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, - DriveAbciFeePoolInwardsDistributionMethodVersions, - DriveAbciFeePoolOutwardsDistributionMethodVersions, - DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, - DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, - DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, - DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, - DriveAbciQuerySystemVersions, DriveAbciQueryVersions, - DriveAbciStateTransitionCommonValidationVersions, - DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, - DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, - DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, - DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts, -}; +use crate::version::drive_abci_versions::{DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, DriveAbciFeePoolInwardsDistributionMethodVersions, DriveAbciFeePoolOutwardsDistributionMethodVersions, DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, DriveAbciQueryPrefundedSpecializedBalancesVersions, DriveAbciQuerySystemVersions, DriveAbciQueryVersions, DriveAbciStateTransitionCommonValidationVersions, DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts}; use crate::version::drive_versions::{DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, DriveCreditPoolPendingEpochRefundsMethodVersions, DriveCreditPoolStorageFeeDistributionPoolMethodVersions, DriveCreditPoolUnpaidEpochMethodVersions, DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertContestedMethodVersions, DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveFetchMethodVersions, DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, DriveIdentityWithdrawalDocumentMethodVersions, DriveIdentityWithdrawalMethodVersions, DriveIdentityWithdrawalTransactionIndexMethodVersions, DriveIdentityWithdrawalTransactionMethodVersions, DriveIdentityWithdrawalTransactionQueueMethodVersions, DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformStateMethodVersions, DrivePlatformSystemMethodVersions, DrivePrefundedSpecializedMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVerifyVoteMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions}; use crate::version::fee::v1::FEE_VERSION1; use crate::version::mocks::TEST_PROTOCOL_VERSION_SHIFT_BYTES; @@ -436,6 +418,8 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { }, fetch: DriveFetchMethodVersions { fetch_elements: 0 }, prefunded_specialized_balances: DrivePrefundedSpecializedMethodVersions { + fetch_single: 0, + prove_single: 0, add_prefunded_specialized_balance: 0, add_prefunded_specialized_balance_operations: 0, deduct_from_prefunded_specialized_balance: 0, @@ -745,6 +729,13 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { max_version: 0, default_current_version: 0, }, + prefunded_specialized_balances: DriveAbciQueryPrefundedSpecializedBalancesVersions { + balance: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, + }, identity_based_queries: DriveAbciQueryIdentityVersions { identity: FeatureVersionBounds { min_version: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 27fc7123f9..1e8e2723aa 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -11,25 +11,7 @@ use crate::version::dpp_versions::{ RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, }; -use crate::version::drive_abci_versions::{ - DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, - DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, - DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, - DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, - DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, - DriveAbciFeePoolInwardsDistributionMethodVersions, - DriveAbciFeePoolOutwardsDistributionMethodVersions, - DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, - DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, - DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, - DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, - DriveAbciQuerySystemVersions, DriveAbciQueryVersions, - DriveAbciStateTransitionCommonValidationVersions, - DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, - DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, - DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, - DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts, -}; +use crate::version::drive_abci_versions::{DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, DriveAbciFeePoolInwardsDistributionMethodVersions, DriveAbciFeePoolOutwardsDistributionMethodVersions, DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, DriveAbciQueryPrefundedSpecializedBalancesVersions, DriveAbciQuerySystemVersions, DriveAbciQueryVersions, DriveAbciStateTransitionCommonValidationVersions, DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts}; use crate::version::drive_versions::{DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, DriveCreditPoolPendingEpochRefundsMethodVersions, DriveCreditPoolStorageFeeDistributionPoolMethodVersions, DriveCreditPoolUnpaidEpochMethodVersions, DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertContestedMethodVersions, DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveFetchMethodVersions, DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, DriveIdentityWithdrawalDocumentMethodVersions, DriveIdentityWithdrawalMethodVersions, DriveIdentityWithdrawalTransactionIndexMethodVersions, DriveIdentityWithdrawalTransactionMethodVersions, DriveIdentityWithdrawalTransactionQueueMethodVersions, DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformStateMethodVersions, DrivePlatformSystemMethodVersions, DrivePrefundedSpecializedMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVerifyVoteMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions}; use crate::version::fee::v1::FEE_VERSION1; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; @@ -435,6 +417,8 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { }, fetch: DriveFetchMethodVersions { fetch_elements: 0 }, prefunded_specialized_balances: DrivePrefundedSpecializedMethodVersions { + fetch_single: 0, + prove_single: 0, add_prefunded_specialized_balance: 0, add_prefunded_specialized_balance_operations: 0, deduct_from_prefunded_specialized_balance: 0, @@ -744,6 +728,13 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { max_version: 0, default_current_version: 0, }, + prefunded_specialized_balances: DriveAbciQueryPrefundedSpecializedBalancesVersions { + balance: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, + }, identity_based_queries: DriveAbciQueryIdentityVersions { identity: FeatureVersionBounds { min_version: 0, From b87a06315f22ac3ee08ab246378ac56700e47d59 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sat, 11 May 2024 23:01:47 +0200 Subject: [PATCH 046/135] more work --- .../rs-dpp/src/data_contract/accessors/mod.rs | 5 +- .../src/data_contract/accessors/v0/mod.rs | 7 +- .../src/data_contract/v0/accessors/mod.rs | 5 +- packages/rs-dpp/src/errors/consensus/codes.rs | 1 - .../rs-dpp/src/errors/consensus/state/mod.rs | 2 +- .../prefunded_specialized_balances/mod.rs | 2 +- ..._specialized_balance_insufficient_error.rs | 8 +- ...ded_specialized_balance_not_found_error.rs | 4 +- packages/rs-dpp/src/lib.rs | 2 +- .../src/prefunded_specialized_balance/mod.rs | 2 +- .../src/state_transition/proof_result.rs | 2 +- .../accessors/mod.rs | 7 ++ .../accessors/v0/mod.rs | 2 + packages/rs-dpp/src/voting/vote_polls/mod.rs | 2 +- .../execution/types/execution_event/mod.rs | 2 +- .../v0/mod.rs | 28 ++++-- .../state_transition/processor/v0/mod.rs | 66 ++++++++------ .../state_v0/mod.rs | 2 +- .../state_v0/mod.rs | 2 +- .../state_v0/mod.rs | 2 +- .../state_v0/mod.rs | 2 +- .../state_v0/mod.rs | 2 +- .../masternode_vote/balance/mod.rs | 28 ++++-- .../masternode_vote/balance/v0/mod.rs | 66 +++++++++----- .../state_transitions/masternode_vote/mod.rs | 13 ++- .../masternode_vote/nonce/v0/mod.rs | 8 +- .../masternode_vote/state/v0/mod.rs | 2 - packages/rs-drive-abci/src/query/mod.rs | 2 +- .../balance/mod.rs | 22 +++-- .../balance/v0/mod.rs | 23 +++-- .../prefunded_specialized_balances/mod.rs | 2 +- packages/rs-drive-abci/src/query/service.rs | 54 +++++++++++- .../contested_resource_vote_state/mod.rs | 1 + .../contested_resource_vote_status/mod.rs | 1 + .../query/voting/contested_resources/mod.rs | 1 + .../rs-drive-abci/src/query/voting/mod.rs | 4 +- .../src/drive/batch/drive_op_batch/mod.rs | 2 +- .../src/drive/batch/drive_op_batch/voting.rs | 2 +- .../fetch_identity_keys/v0/mod.rs | 2 +- .../v0/mod.rs | 2 +- .../identity/fetch/partial_identity/mod.rs | 4 +- .../drive/object_size_info/drive_key_info.rs | 8 +- .../src/drive/object_size_info/path_info.rs | 2 +- .../object_size_info/path_key_element_info.rs | 4 +- .../v0/mod.rs | 4 +- .../fetch/mod.rs | 2 +- .../fetch/single_balance/mod.rs | 6 +- .../fetch/single_balance/v0/mod.rs | 2 +- .../prefunded_specialized_balances/mod.rs | 5 +- .../prove/mod.rs | 2 +- .../prove/single_balance/mod.rs | 10 +-- .../prove/single_balance/v0/mod.rs | 2 +- .../rs-drive/src/drive/verify/voting/mod.rs | 2 +- .../voting/verify_masternode_vote/mod.rs | 2 +- .../voting/verify_masternode_vote/v0/mod.rs | 4 +- .../remove_votes_for_identity/v0/mod.rs | 24 ++++-- .../mod.rs | 3 +- .../v0/mod.rs | 8 +- .../votes/insert/contested_resource/mod.rs | 1 - .../insert/register_identity_vote/v0/mod.rs | 58 ++++++------- .../mod.rs | 24 ++++-- .../v0/mod.rs | 85 ++++++++++--------- packages/rs-drive/src/drive/votes/mod.rs | 7 +- packages/rs-drive/src/drive/votes/paths.rs | 5 +- .../mod.rs | 3 +- .../v0/mod.rs | 5 +- .../document_base_transition_action/v0/mod.rs | 4 +- .../document_create_transition_action/mod.rs | 8 +- .../v0/mod.rs | 6 +- .../document/documents_batch/mod.rs | 7 ++ .../document/documents_batch/v0/mod.rs | 12 ++- .../src/version/mocks/v2_test.rs | 63 +++++++++++++- .../src/version/mocks/v3_test.rs | 61 ++++++++++++- .../rs-platform-version/src/version/v1.rs | 61 ++++++++++++- 74 files changed, 628 insertions(+), 268 deletions(-) diff --git a/packages/rs-dpp/src/data_contract/accessors/mod.rs b/packages/rs-dpp/src/data_contract/accessors/mod.rs index f813699869..25a22800df 100644 --- a/packages/rs-dpp/src/data_contract/accessors/mod.rs +++ b/packages/rs-dpp/src/data_contract/accessors/mod.rs @@ -43,7 +43,10 @@ impl DataContractV0Getters for DataContract { } } - fn document_type_borrowed_for_name(&self, name: &str) -> Result<&DocumentType, DataContractError> { + fn document_type_borrowed_for_name( + &self, + name: &str, + ) -> Result<&DocumentType, DataContractError> { match self { DataContract::V0(v0) => v0.document_type_borrowed_for_name(name), } diff --git a/packages/rs-dpp/src/data_contract/accessors/v0/mod.rs b/packages/rs-dpp/src/data_contract/accessors/v0/mod.rs index 68cc86b29c..9999e9b173 100644 --- a/packages/rs-dpp/src/data_contract/accessors/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/accessors/v0/mod.rs @@ -1,7 +1,7 @@ use crate::data_contract::config::DataContractConfig; use crate::data_contract::document_type::{DocumentType, DocumentTypeRef}; use crate::data_contract::errors::DataContractError; -use crate::data_contract::{DataContract, DocumentName}; +use crate::data_contract::DocumentName; use crate::metadata::Metadata; use platform_value::Identifier; @@ -19,7 +19,10 @@ pub trait DataContractV0Getters { /// Returns the identifier of the contract owner. fn owner_id(&self) -> Identifier; fn document_type_cloned_for_name(&self, name: &str) -> Result; - fn document_type_borrowed_for_name(&self, name: &str) -> Result<&DocumentType, DataContractError>; + fn document_type_borrowed_for_name( + &self, + name: &str, + ) -> Result<&DocumentType, DataContractError>; /// Returns the document type for the given document name. fn document_type_for_name(&self, name: &str) -> Result; diff --git a/packages/rs-dpp/src/data_contract/v0/accessors/mod.rs b/packages/rs-dpp/src/data_contract/v0/accessors/mod.rs index 034eb5fcbc..ed1efb3115 100644 --- a/packages/rs-dpp/src/data_contract/v0/accessors/mod.rs +++ b/packages/rs-dpp/src/data_contract/v0/accessors/mod.rs @@ -36,7 +36,10 @@ impl DataContractV0Getters for DataContractV0 { }) } - fn document_type_borrowed_for_name(&self, name: &str) -> Result<&DocumentType, DataContractError> { + fn document_type_borrowed_for_name( + &self, + name: &str, + ) -> Result<&DocumentType, DataContractError> { self.document_types.get(name).ok_or_else(|| { DataContractError::DocumentTypeNotFound( "can not get document type from contract".to_string(), diff --git a/packages/rs-dpp/src/errors/consensus/codes.rs b/packages/rs-dpp/src/errors/consensus/codes.rs index 39bcc6ec4a..5563d5dcee 100644 --- a/packages/rs-dpp/src/errors/consensus/codes.rs +++ b/packages/rs-dpp/src/errors/consensus/codes.rs @@ -228,7 +228,6 @@ impl ErrorWithCode for StateError { // Data trigger errors: 40500-40799 #[cfg(feature = "state-transition-validation")] Self::DataTriggerError(ref e) => e.code(), - } } } diff --git a/packages/rs-dpp/src/errors/consensus/state/mod.rs b/packages/rs-dpp/src/errors/consensus/state/mod.rs index 2e17a38dec..9beb6b3b24 100644 --- a/packages/rs-dpp/src/errors/consensus/state/mod.rs +++ b/packages/rs-dpp/src/errors/consensus/state/mod.rs @@ -3,5 +3,5 @@ pub mod data_contract; pub mod data_trigger; pub mod document; pub mod identity; -pub mod state_error; pub mod prefunded_specialized_balances; +pub mod state_error; diff --git a/packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/mod.rs b/packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/mod.rs index 236e3c34d9..fd640dd7ac 100644 --- a/packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/mod.rs +++ b/packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/mod.rs @@ -1,2 +1,2 @@ pub mod prefunded_specialized_balance_insufficient_error; -pub mod prefunded_specialized_balance_not_found_error; \ No newline at end of file +pub mod prefunded_specialized_balance_not_found_error; diff --git a/packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/prefunded_specialized_balance_insufficient_error.rs b/packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/prefunded_specialized_balance_insufficient_error.rs index daa2ae3d60..05bbb11324 100644 --- a/packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/prefunded_specialized_balance_insufficient_error.rs +++ b/packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/prefunded_specialized_balance_insufficient_error.rs @@ -11,7 +11,9 @@ use bincode::{Decode, Encode}; #[derive( Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, )] -#[error("Insufficient specialized balance {balance_id} balance {balance} required {required_balance}")] +#[error( + "Insufficient specialized balance {balance_id} balance {balance} required {required_balance}" +)] #[platform_serialize(unversioned)] pub struct PrefundedSpecializedBalanceInsufficientError { /* @@ -47,6 +49,8 @@ impl PrefundedSpecializedBalanceInsufficientError { } impl From for ConsensusError { fn from(err: PrefundedSpecializedBalanceInsufficientError) -> Self { - Self::StateError(StateError::PrefundedSpecializedBalanceInsufficientError(err)) + Self::StateError(StateError::PrefundedSpecializedBalanceInsufficientError( + err, + )) } } diff --git a/packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/prefunded_specialized_balance_not_found_error.rs b/packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/prefunded_specialized_balance_not_found_error.rs index b40a9d3461..bf8f4bc100 100644 --- a/packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/prefunded_specialized_balance_not_found_error.rs +++ b/packages/rs-dpp/src/errors/consensus/state/prefunded_specialized_balances/prefunded_specialized_balance_not_found_error.rs @@ -24,9 +24,7 @@ pub struct PrefundedSpecializedBalanceNotFoundError { impl PrefundedSpecializedBalanceNotFoundError { pub fn new(balance_id: Identifier) -> Self { - Self { - balance_id, - } + Self { balance_id } } pub fn balance_id(&self) -> &Identifier { diff --git a/packages/rs-dpp/src/lib.rs b/packages/rs-dpp/src/lib.rs index 30700641f1..4701daa126 100644 --- a/packages/rs-dpp/src/lib.rs +++ b/packages/rs-dpp/src/lib.rs @@ -40,6 +40,7 @@ pub mod balances; pub mod block; pub mod fee; pub mod nft; +pub mod prefunded_specialized_balance; pub mod serialization; #[cfg(any( feature = "message-signing", @@ -50,7 +51,6 @@ pub mod signing; pub mod system_data_contracts; pub mod voting; pub mod withdrawal; -pub mod prefunded_specialized_balance; pub use async_trait; diff --git a/packages/rs-dpp/src/prefunded_specialized_balance/mod.rs b/packages/rs-dpp/src/prefunded_specialized_balance/mod.rs index 76a4ddba4e..72f0a1e983 100644 --- a/packages/rs-dpp/src/prefunded_specialized_balance/mod.rs +++ b/packages/rs-dpp/src/prefunded_specialized_balance/mod.rs @@ -1,3 +1,3 @@ use platform_value::Identifier; -pub type PrefundedSpecializedBalanceIdentifier = Identifier; \ No newline at end of file +pub type PrefundedSpecializedBalanceIdentifier = Identifier; diff --git a/packages/rs-dpp/src/state_transition/proof_result.rs b/packages/rs-dpp/src/state_transition/proof_result.rs index 3ffb6fdedc..ebff592c8c 100644 --- a/packages/rs-dpp/src/state_transition/proof_result.rs +++ b/packages/rs-dpp/src/state_transition/proof_result.rs @@ -1,9 +1,9 @@ use crate::data_contract::DataContract; use crate::document::Document; use crate::identity::{Identity, PartialIdentity}; +use crate::voting::votes::Vote; use platform_value::Identifier; use std::collections::BTreeMap; -use crate::voting::votes::Vote; #[derive(Debug)] pub enum StateTransitionProofResult { diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/mod.rs index 6bbbebb480..ee47fec29a 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/mod.rs @@ -1,11 +1,18 @@ mod v0; +use crate::prelude::IdentityNonce; use crate::state_transition::masternode_vote_transition::MasternodeVoteTransition; use crate::voting::votes::Vote; use platform_value::Identifier; pub use v0::*; impl MasternodeVoteTransitionAccessorsV0 for MasternodeVoteTransition { + fn nonce(&self) -> IdentityNonce { + match self { + MasternodeVoteTransition::V0(transition) => transition.nonce, + } + } + fn pro_tx_hash(&self) -> Identifier { match self { MasternodeVoteTransition::V0(transition) => transition.pro_tx_hash, diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/v0/mod.rs index baca561024..e12b9c649d 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/accessors/v0/mod.rs @@ -1,3 +1,4 @@ +use crate::prelude::IdentityNonce; use crate::voting::votes::Vote; use platform_value::Identifier; @@ -6,4 +7,5 @@ pub trait MasternodeVoteTransitionAccessorsV0 { fn set_pro_tx_hash(&mut self, pro_tx_hash: Identifier); fn vote(&self) -> &Vote; fn set_vote(&mut self, vote: Vote); + fn nonce(&self) -> IdentityNonce; } diff --git a/packages/rs-dpp/src/voting/vote_polls/mod.rs b/packages/rs-dpp/src/voting/vote_polls/mod.rs index 8fc06a3790..51cc55ab0d 100644 --- a/packages/rs-dpp/src/voting/vote_polls/mod.rs +++ b/packages/rs-dpp/src/voting/vote_polls/mod.rs @@ -2,9 +2,9 @@ use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use crate::ProtocolError; use derive_more::From; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use platform_value::Identifier; use serde::{Deserialize, Serialize}; -use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; pub mod contested_document_resource_vote_poll; diff --git a/packages/rs-drive-abci/src/execution/types/execution_event/mod.rs b/packages/rs-drive-abci/src/execution/types/execution_event/mod.rs index a5b011522b..131bc401d2 100644 --- a/packages/rs-drive-abci/src/execution/types/execution_event/mod.rs +++ b/packages/rs-drive-abci/src/execution/types/execution_event/mod.rs @@ -157,7 +157,7 @@ impl<'a> ExecutionEvent<'a> { } StateTransitionAction::DocumentsBatchAction(document_batch_action) => { let user_fee_increase = action.user_fee_increase(); - let removed_balance = document_batch_action.all_purchases_amount(); + let removed_balance = document_batch_action.all_used_balances()?; let operations = action.into_high_level_drive_operations(epoch, platform_version)?; if let Some(identity) = identity { diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_state_transition_identity_signed/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_state_transition_identity_signed/v0/mod.rs index aa8e5c22ce..09da255515 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_state_transition_identity_signed/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_state_transition_identity_signed/v0/mod.rs @@ -88,7 +88,7 @@ impl<'a> ValidateStateTransitionIdentitySignatureV0<'a> for StateTransition { let key_request = IdentityKeysRequest::new_specific_key_query(owner_id.as_bytes(), key_id); - let maybe_partial_identity = match (request_identity_balance,request_identity_revision) { + let maybe_partial_identity = match (request_identity_balance, request_identity_revision) { (true, true) => { // This is for identity update execution_context.add_operation(ValidationOperation::RetrieveIdentity( @@ -99,28 +99,40 @@ impl<'a> ValidateStateTransitionIdentitySignatureV0<'a> for StateTransition { transaction, platform_version, )? - }, + } (true, false) => { // This is for most state transitions execution_context.add_operation(ValidationOperation::RetrieveIdentity( RetrieveIdentityInfo::one_key_and_balance(), )); - drive.fetch_identity_balance_with_keys(key_request, transaction, platform_version)? - }, + drive.fetch_identity_balance_with_keys( + key_request, + transaction, + platform_version, + )? + } (false, true) => { // This currently is not used execution_context.add_operation(ValidationOperation::RetrieveIdentity( RetrieveIdentityInfo::one_key_and_revision(), )); - drive.fetch_identity_revision_with_keys(key_request, transaction, platform_version)? - }, + drive.fetch_identity_revision_with_keys( + key_request, + transaction, + platform_version, + )? + } (false, false) => { // This is for masternode vote transition execution_context.add_operation(ValidationOperation::RetrieveIdentity( RetrieveIdentityInfo::one_key(), )); - drive.fetch_identity_keys_as_partial_identity(key_request, transaction, platform_version)? - }, + drive.fetch_identity_keys_as_partial_identity( + key_request, + transaction, + platform_version, + )? + } }; let partial_identity = match maybe_partial_identity { diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs index dc032b5aa7..86c5eb7953 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs @@ -1,4 +1,3 @@ -use std::collections::BTreeMap; use crate::error::Error; use crate::execution::types::execution_event::ExecutionEvent; use crate::execution::validation::state_transition::transformer::StateTransitionActionTransformerV0; @@ -8,11 +7,11 @@ use crate::rpc::core::CoreRPCLike; use dpp::block::block_info::BlockInfo; use dpp::block::epoch::Epoch; use dpp::fee::Credits; -use dpp::identifier::Identifier; use dpp::identity::PartialIdentity; use dpp::prefunded_specialized_balance::PrefundedSpecializedBalanceIdentifier; use dpp::prelude::ConsensusValidationResult; use dpp::ProtocolError; +use std::collections::BTreeMap; use crate::error::execution::ExecutionError; use dpp::serialization::Signable; @@ -138,8 +137,17 @@ pub(super) fn process_state_transition_v0<'a, C: CoreRPCLike>( } } - let prefunded_balances = if state_transition.uses_prefunded_specialized_balance_for_payment() { - Some(state_transition.validate_minimum_prefunded_specialized_balance_pre_check()?) + // The prefunded_balances are currently not used as we would only use them for a masternode vote + // however the masternode vote acts as a free operation, as it is paid for + let _prefunded_balances = if state_transition.uses_prefunded_specialized_balance_for_payment() { + Some( + state_transition.validate_minimum_prefunded_specialized_balance_pre_check( + platform.drive, + transaction, + &mut state_transition_execution_context, + platform_version, + )?, + ) } else { None }; @@ -414,12 +422,11 @@ pub(crate) trait StateTransitionIdentityBalanceValidationV0 { /// This balance validation is not for the operations of the state transition, but more as a /// quick early verification that the user has the balance they want to transfer or withdraw. fn has_balance_pre_check_validation(&self) -> bool { - !matches!(self, StateTransition::MasternodeVote(_)) + true } } pub(crate) trait StateTransitionPrefundedSpecializedBalanceValidationV0 { - /// Validates the state transition by analyzing the changes in the platform state after applying the transaction. /// /// # Arguments @@ -440,12 +447,14 @@ pub(crate) trait StateTransitionPrefundedSpecializedBalanceValidationV0 { tx: TransactionArg, execution_context: &mut StateTransitionExecutionContext, platform_version: &PlatformVersion, - ) -> Result>, Error>; - - + ) -> Result< + ConsensusValidationResult>, + Error, + >; + /// Do we use a prefunded specialized balance for payment fn uses_prefunded_specialized_balance_for_payment(&self) -> bool { - matches!(self, StateTransition::MasternodeVote(_)) + false } } @@ -484,7 +493,9 @@ impl StateTransitionBasicStructureValidationV0 for StateTransition { platform_version: &PlatformVersion, ) -> Result { match self { - StateTransition::DataContractCreate(_) | StateTransition::DataContractUpdate(_) | StateTransition::MasternodeVote(_) => { + StateTransition::DataContractCreate(_) + | StateTransition::DataContractUpdate(_) + | StateTransition::MasternodeVote(_) => { // no basic structure validation Ok(SimpleConsensusValidationResult::new()) } @@ -503,7 +514,9 @@ impl StateTransitionBasicStructureValidationV0 for StateTransition { fn has_basic_structure_validation(&self) -> bool { !matches!( self, - StateTransition::DataContractCreate(_) | StateTransition::DataContractUpdate(_) | StateTransition::MasternodeVote(_) + StateTransition::DataContractCreate(_) + | StateTransition::DataContractUpdate(_) + | StateTransition::MasternodeVote(_) ) } } @@ -605,9 +618,9 @@ impl StateTransitionIdentityBalanceValidationV0 for StateTransition { | StateTransition::IdentityUpdate(_) => { self.validate_simple_pre_check_minimum_balance(identity, platform_version) } - StateTransition::MasternodeVote(_) | StateTransition::IdentityCreate(_) | StateTransition::IdentityTopUp(_) => { - Ok(SimpleConsensusValidationResult::new()) - } + StateTransition::MasternodeVote(_) + | StateTransition::IdentityCreate(_) + | StateTransition::IdentityTopUp(_) => Ok(SimpleConsensusValidationResult::new()), } } @@ -624,7 +637,6 @@ impl StateTransitionIdentityBalanceValidationV0 for StateTransition { } } - impl StateTransitionPrefundedSpecializedBalanceValidationV0 for StateTransition { fn validate_minimum_prefunded_specialized_balance_pre_check( &self, @@ -632,14 +644,20 @@ impl StateTransitionPrefundedSpecializedBalanceValidationV0 for StateTransition tx: TransactionArg, execution_context: &mut StateTransitionExecutionContext, platform_version: &PlatformVersion, - ) -> Result>, Error> { + ) -> Result< + ConsensusValidationResult>, + Error, + > { match self { StateTransition::MasternodeVote(masternode_vote_transition) => { - masternode_vote_transition.validate_minimum_prefunded_specialized_balance_pre_check(drive, tx, execution_context, platform_version) - } - _ => { - Ok(ConsensusValidationResult::new()) + masternode_vote_transition.validate_minimum_prefunded_specialized_balance_pre_check( + drive, + tx, + execution_context, + platform_version, + ) } + _ => Ok(ConsensusValidationResult::new()), } } @@ -794,10 +812,10 @@ impl StateTransitionIdentityBasedSignatureValidationV0 for StateTransition { // We do not request the balance because masternodes do not pay for their voting // themselves - + Ok(self.validate_state_transition_identity_signed( drive, - false, + false, false, tx, execution_context, @@ -942,7 +960,7 @@ impl StateTransitionStateValidationV0 for StateTransition { epoch, execution_context, tx, - ) + ), } } } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_create_transition_action/state_v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_create_transition_action/state_v0/mod.rs index 4793527db9..22c71ac140 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_create_transition_action/state_v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_create_transition_action/state_v0/mod.rs @@ -72,7 +72,7 @@ impl DocumentCreateTransitionActionStateValidationV0 for DocumentCreateTransitio // we also need to validate that the new document wouldn't conflict with any other document // this means for example having overlapping unique indexes - if document_type.indexes().iter().any(|index| index.unique) { + if document_type.indexes().values().any(|index| index.unique) { platform .drive .validate_document_create_transition_action_uniqueness( diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_purchase_transition_action/state_v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_purchase_transition_action/state_v0/mod.rs index 0718289f9c..74bc3b36a5 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_purchase_transition_action/state_v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_purchase_transition_action/state_v0/mod.rs @@ -51,7 +51,7 @@ impl DocumentPurchaseTransitionActionStateValidationV0 for DocumentPurchaseTrans // We need to verify that the resultant document doesn't violate any unique properties - if document_type.indexes().iter().any(|index| index.unique) { + if document_type.indexes().values().any(|index| index.unique) { platform .drive .validate_document_purchase_transition_action_uniqueness( diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_replace_transition_action/state_v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_replace_transition_action/state_v0/mod.rs index a75fed74cd..0747945742 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_replace_transition_action/state_v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_replace_transition_action/state_v0/mod.rs @@ -49,7 +49,7 @@ impl DocumentReplaceTransitionActionStateValidationV0 for DocumentReplaceTransit // There is no need to verify that the document already existed, since this is done when // transforming into an action - if document_type.indexes().iter().any(|index| index.unique) { + if document_type.indexes().values().any(|index| index.unique) { platform .drive .validate_document_replace_transition_action_uniqueness( diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_transfer_transition_action/state_v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_transfer_transition_action/state_v0/mod.rs index 6bda96cb46..c6d7eb4b4e 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_transfer_transition_action/state_v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_transfer_transition_action/state_v0/mod.rs @@ -49,7 +49,7 @@ impl DocumentTransferTransitionActionStateValidationV0 for DocumentTransferTrans // There is no need to verify that the document already existed, since this is done when // transforming into an action - if document_type.indexes().iter().any(|index| index.unique) { + if document_type.indexes().values().any(|index| index.unique) { platform .drive .validate_document_transfer_transition_action_uniqueness( diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_update_price_transition_action/state_v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_update_price_transition_action/state_v0/mod.rs index e41ccb925d..33889ed634 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_update_price_transition_action/state_v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_update_price_transition_action/state_v0/mod.rs @@ -49,7 +49,7 @@ impl DocumentUpdatePriceTransitionActionStateValidationV0 for DocumentUpdatePric // There is no need to verify that the document already existed, since this is done when // transforming into an action - if document_type.indexes().iter().any(|index| index.unique) { + if document_type.indexes().values().any(|index| index.unique) { platform .drive .validate_document_update_price_transition_action_uniqueness( diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/mod.rs index 768a08904f..8fd9438e1d 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/mod.rs @@ -1,16 +1,16 @@ -use std::collections::BTreeMap; -use dpp::fee::Credits; use crate::error::execution::ExecutionError; use crate::error::Error; -use crate::execution::validation::state_transition::processor::v0::{StateTransitionIdentityBalanceValidationV0, StateTransitionPrefundedSpecializedBalanceValidationV0}; +use crate::execution::types::state_transition_execution_context::StateTransitionExecutionContext; +use crate::execution::validation::state_transition::masternode_vote::balance::v0::MasternodeVoteTransitionBalanceValidationV0; +use crate::execution::validation::state_transition::processor::v0::StateTransitionPrefundedSpecializedBalanceValidationV0; +use dpp::fee::Credits; use dpp::prefunded_specialized_balance::PrefundedSpecializedBalanceIdentifier; use dpp::prelude::ConsensusValidationResult; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; use dpp::version::PlatformVersion; use drive::drive::Drive; use drive::grovedb::TransactionArg; -use crate::execution::types::state_transition_execution_context::StateTransitionExecutionContext; -use crate::execution::validation::state_transition::masternode_vote::balance::v0::MasternodeVoteTransitionBalanceValidationV0; +use std::collections::BTreeMap; pub(crate) mod v0; @@ -21,7 +21,10 @@ impl StateTransitionPrefundedSpecializedBalanceValidationV0 for MasternodeVoteTr tx: TransactionArg, execution_context: &mut StateTransitionExecutionContext, platform_version: &PlatformVersion, - ) -> Result>, Error> { + ) -> Result< + ConsensusValidationResult>, + Error, + > { match platform_version .drive_abci .validation_and_processing @@ -29,9 +32,12 @@ impl StateTransitionPrefundedSpecializedBalanceValidationV0 for MasternodeVoteTr .masternode_vote_state_transition .advanced_minimum_balance_pre_check { - Some(0) => { - self.validate_advanced_minimum_balance_pre_check_v0(drive, tx, execution_context, platform_version) - } + Some(0) => self.validate_advanced_minimum_balance_pre_check_v0( + drive, + tx, + execution_context, + platform_version, + ), Some(version) => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { method: "masternode vote transition: validate_balance".to_string(), known_versions: vec![0], @@ -43,4 +49,8 @@ impl StateTransitionPrefundedSpecializedBalanceValidationV0 for MasternodeVoteTr })), } } + + fn uses_prefunded_specialized_balance_for_payment(&self) -> bool { + true + } } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/v0/mod.rs index d54ce1ec5b..f5c7a56309 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/v0/mod.rs @@ -8,24 +8,26 @@ use dpp::prelude::ConsensusValidationResult; use dpp::state_transition::masternode_vote_transition::accessors::MasternodeVoteTransitionAccessorsV0; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; -use dpp::validation::SimpleConsensusValidationResult; - use crate::error::execution::ExecutionError; +use crate::execution::types::execution_operation::ValidationOperation; +use crate::execution::types::state_transition_execution_context::{ + StateTransitionExecutionContext, StateTransitionExecutionContextMethodsV0, +}; use dpp::version::PlatformVersion; use drive::drive::Drive; use drive::grovedb::TransactionArg; -use crate::execution::types::execution_operation::ValidationOperation; -use crate::execution::types::state_transition_execution_context::{StateTransitionExecutionContext, StateTransitionExecutionContextMethodsV0}; -pub(super) trait MasternodeVoteTransitionBalanceValidationV0 -{ +pub(super) trait MasternodeVoteTransitionBalanceValidationV0 { fn validate_advanced_minimum_balance_pre_check_v0( &self, drive: &Drive, tx: TransactionArg, execution_context: &mut StateTransitionExecutionContext, platform_version: &PlatformVersion, - ) -> Result; + ) -> Result< + ConsensusValidationResult>, + Error, + >; } impl MasternodeVoteTransitionBalanceValidationV0 for MasternodeVoteTransition { @@ -35,26 +37,52 @@ impl MasternodeVoteTransitionBalanceValidationV0 for MasternodeVoteTransition { tx: TransactionArg, execution_context: &mut StateTransitionExecutionContext, platform_version: &PlatformVersion, - ) -> Result>, Error> { - + ) -> Result< + ConsensusValidationResult>, + Error, + > { execution_context.add_operation(ValidationOperation::RetrievePrefundedSpecializedBalance); - + let vote = self.vote(); - - let balance_id = vote.specialized_balance_id()?.ok_or(Error::Execution(ExecutionError::CorruptedCodeExecution("In this version there should always be a specialized balance id")))?; - let maybe_balance = drive.fetch_prefunded_specialized_balance(balance_id.to_buffer(), tx, platform_version)?; - + + let balance_id = vote.specialized_balance_id()?.ok_or(Error::Execution( + ExecutionError::CorruptedCodeExecution( + "In this version there should always be a specialized balance id", + ), + ))?; + let maybe_balance = drive.fetch_prefunded_specialized_balance( + balance_id.to_buffer(), + tx, + platform_version, + )?; + let Some(balance) = maybe_balance else { // If there is no balance we are voting on something that either was never created or has finished - return Ok(ConsensusValidationResult::new_with_error(PrefundedSpecializedBalanceNotFoundError::new(balance_id).into())); + return Ok(ConsensusValidationResult::new_with_error( + PrefundedSpecializedBalanceNotFoundError::new(balance_id).into(), + )); }; - if balance < platform_version.fee_version.state_transition_min_fees.masternode_vote { + if balance + < platform_version + .fee_version + .state_transition_min_fees + .masternode_vote + { return Ok(ConsensusValidationResult::new_with_error( - PrefundedSpecializedBalanceInsufficientError::new(balance_id, balance, platform_version.fee_version.state_transition_min_fees.masternode_vote) - .into(), + PrefundedSpecializedBalanceInsufficientError::new( + balance_id, + balance, + platform_version + .fee_version + .state_transition_min_fees + .masternode_vote, + ) + .into(), )); } - Ok(ConsensusValidationResult::new_with_data(BTreeMap::from([(balance_id, balance)]))) + Ok(ConsensusValidationResult::new_with_data(BTreeMap::from([ + (balance_id, balance), + ]))) } } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 4325ff11bd..ee1a9d77b7 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -1,12 +1,12 @@ -mod state; -mod structure; mod balance; mod nonce; +mod state; +mod structure; use dpp::block::block_info::BlockInfo; use dpp::block::epoch::Epoch; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; -use dpp::validation::{ConsensusValidationResult, SimpleConsensusValidationResult}; +use dpp::validation::ConsensusValidationResult; use dpp::version::PlatformVersion; use drive::state_transition_action::StateTransitionAction; @@ -15,14 +15,11 @@ use drive::grovedb::TransactionArg; use crate::error::execution::ExecutionError; use crate::error::Error; use crate::execution::types::state_transition_execution_context::StateTransitionExecutionContext; -use crate::platform_types::platform::{PlatformRef, PlatformStateRef}; +use crate::platform_types::platform::PlatformRef; use crate::rpc::core::CoreRPCLike; use crate::execution::validation::state_transition::masternode_vote::state::v0::MasternodeVoteStateTransitionStateValidationV0; -use crate::execution::validation::state_transition::masternode_vote::structure::v0::MasternodeVoteStateTransitionStructureValidationV0; -use crate::execution::validation::state_transition::processor::v0::{ - StateTransitionStateValidationV0, -}; +use crate::execution::validation::state_transition::processor::v0::StateTransitionStateValidationV0; use crate::execution::validation::state_transition::transformer::StateTransitionActionTransformerV0; use crate::execution::validation::state_transition::ValidationMode; use crate::platform_types::platform_state::v0::PlatformStateV0Methods; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/nonce/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/nonce/v0/mod.rs index a09208f94a..bdb92a5a71 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/nonce/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/nonce/v0/mod.rs @@ -48,10 +48,10 @@ impl MasternodeVoteTransitionIdentityNonceV0 for MasternodeVoteTransition { )); } - let identity_id = self.identity_id(); + let pro_tx_hash_identity_id = self.pro_tx_hash(); let (existing_nonce, fee) = platform.drive.fetch_identity_nonce_with_fees( - identity_id.to_buffer(), + pro_tx_hash_identity_id.to_buffer(), block_info, true, tx, @@ -61,9 +61,9 @@ impl MasternodeVoteTransitionIdentityNonceV0 for MasternodeVoteTransition { execution_context.add_operation(ValidationOperation::PrecalculatedOperation(fee)); let result = if let Some(existing_nonce) = existing_nonce { - validate_identity_nonce_update(existing_nonce, revision_nonce, identity_id) + validate_identity_nonce_update(existing_nonce, revision_nonce, pro_tx_hash_identity_id) } else { - validate_new_identity_nonce(revision_nonce, identity_id) + validate_new_identity_nonce(revision_nonce, pro_tx_hash_identity_id) }; Ok(result) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs index ebd984256f..4b7bb4afe7 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs @@ -36,8 +36,6 @@ impl MasternodeVoteStateTransitionStateValidationV0 for MasternodeVoteTransition tx: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { - - self.transform_into_action_v0() } diff --git a/packages/rs-drive-abci/src/query/mod.rs b/packages/rs-drive-abci/src/query/mod.rs index d38b836b20..1e46effafb 100644 --- a/packages/rs-drive-abci/src/query/mod.rs +++ b/packages/rs-drive-abci/src/query/mod.rs @@ -1,12 +1,12 @@ mod data_contract_based_queries; mod document_query; mod identity_based_queries; +mod prefunded_specialized_balances; mod proofs; mod response_metadata; mod service; mod system; mod voting; -mod prefunded_specialized_balances; use crate::error::query::QueryError; diff --git a/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/mod.rs b/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/mod.rs index 8dee0277c5..54a0cd6bf3 100644 --- a/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/mod.rs +++ b/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/mod.rs @@ -5,7 +5,9 @@ use crate::platform_types::platform_state::PlatformState; use crate::query::QueryValidationResult; use dapi_grpc::platform::v0::get_prefunded_specialized_balance_request::Version as RequestVersion; use dapi_grpc::platform::v0::get_prefunded_specialized_balance_response::Version as ResponseVersion; -use dapi_grpc::platform::v0::{GetPrefundedSpecializedBalanceRequest, GetPrefundedSpecializedBalanceResponse}; +use dapi_grpc::platform::v0::{ + GetPrefundedSpecializedBalanceRequest, GetPrefundedSpecializedBalanceResponse, +}; use dpp::version::PlatformVersion; mod v0; @@ -20,7 +22,9 @@ impl Platform { ) -> Result, Error> { let Some(version) = version else { return Ok(QueryValidationResult::new_with_error( - QueryError::DecodingError("could not decode prefunded specialized balance query".to_string()), + QueryError::DecodingError( + "could not decode prefunded specialized balance query".to_string(), + ), )); }; @@ -46,11 +50,17 @@ impl Platform { } match version { RequestVersion::V0(request_v0) => { - let result = self.query_prefunded_specialized_balance_v0(request_v0, platform_state, platform_version)?; + let result = self.query_prefunded_specialized_balance_v0( + request_v0, + platform_state, + platform_version, + )?; - Ok(result.map(|response_v0| GetPrefundedSpecializedBalanceResponse { - version: Some(ResponseVersion::V0(response_v0)), - })) + Ok( + result.map(|response_v0| GetPrefundedSpecializedBalanceResponse { + version: Some(ResponseVersion::V0(response_v0)), + }), + ) } } } diff --git a/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/v0/mod.rs b/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/v0/mod.rs index e43943c4a4..b4a21fd97b 100644 --- a/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/prefunded_specialized_balances/balance/v0/mod.rs @@ -26,16 +26,19 @@ impl Platform { })); let response = if prove { - let proof = check_validation_result_with_data!(self.drive.prove_prefunded_specialized_balance( - balance_id.into_buffer(), - None, - platform_version, - )); + let proof = + check_validation_result_with_data!(self.drive.prove_prefunded_specialized_balance( + balance_id.into_buffer(), + None, + platform_version, + )); GetPrefundedSpecializedBalanceResponseV0 { - result: Some(get_prefunded_specialized_balance_response_v0::Result::Proof( - self.response_proof_v0(platform_state, proof), - )), + result: Some( + get_prefunded_specialized_balance_response_v0::Result::Proof( + self.response_proof_v0(platform_state, proof), + ), + ), metadata: Some(self.response_metadata_v0(platform_state)), } } else { @@ -52,7 +55,9 @@ impl Platform { }; GetPrefundedSpecializedBalanceResponseV0 { - result: Some(get_prefunded_specialized_balance_response_v0::Result::Balance(balance)), + result: Some( + get_prefunded_specialized_balance_response_v0::Result::Balance(balance), + ), metadata: Some(self.response_metadata_v0(platform_state)), } }; diff --git a/packages/rs-drive-abci/src/query/prefunded_specialized_balances/mod.rs b/packages/rs-drive-abci/src/query/prefunded_specialized_balances/mod.rs index 3f3d38870c..b95ce78b5a 100644 --- a/packages/rs-drive-abci/src/query/prefunded_specialized_balances/mod.rs +++ b/packages/rs-drive-abci/src/query/prefunded_specialized_balances/mod.rs @@ -1 +1 @@ -mod balance; \ No newline at end of file +mod balance; diff --git a/packages/rs-drive-abci/src/query/service.rs b/packages/rs-drive-abci/src/query/service.rs index c6b4b975c0..7efaaf15d1 100644 --- a/packages/rs-drive-abci/src/query/service.rs +++ b/packages/rs-drive-abci/src/query/service.rs @@ -8,7 +8,26 @@ use crate::rpc::core::DefaultCoreRPC; use crate::utils::spawn_blocking_task_with_name_if_supported; use async_trait::async_trait; use dapi_grpc::platform::v0::platform_server::Platform as PlatformService; -use dapi_grpc::platform::v0::{BroadcastStateTransitionRequest, BroadcastStateTransitionResponse, GetConsensusParamsRequest, GetConsensusParamsResponse, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetDataContractHistoryRequest, GetDataContractHistoryResponse, GetDataContractRequest, GetDataContractResponse, GetDataContractsRequest, GetDataContractsResponse, GetDocumentsRequest, GetDocumentsResponse, GetEpochsInfoRequest, GetEpochsInfoResponse, GetIdentitiesContractKeysRequest, GetIdentitiesContractKeysResponse, GetIdentityBalanceAndRevisionRequest, GetIdentityBalanceAndRevisionResponse, GetIdentityBalanceRequest, GetIdentityBalanceResponse, GetIdentityByPublicKeyHashRequest, GetIdentityByPublicKeyHashResponse, GetIdentityContractNonceRequest, GetIdentityContractNonceResponse, GetIdentityKeysRequest, GetIdentityKeysResponse, GetIdentityNonceRequest, GetIdentityNonceResponse, GetIdentityRequest, GetIdentityResponse, GetPathElementsRequest, GetPathElementsResponse, GetProofsRequest, GetProofsResponse, GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, WaitForStateTransitionResultRequest, WaitForStateTransitionResultResponse}; +use dapi_grpc::platform::v0::{ + BroadcastStateTransitionRequest, BroadcastStateTransitionResponse, GetConsensusParamsRequest, + GetConsensusParamsResponse, GetContestedResourceVoteStateRequest, + GetContestedResourceVoteStateResponse, GetContestedResourceVoteStatusRequest, + GetContestedResourceVoteStatusResponse, GetContestedResourcesRequest, + GetContestedResourcesResponse, GetDataContractHistoryRequest, GetDataContractHistoryResponse, + GetDataContractRequest, GetDataContractResponse, GetDataContractsRequest, + GetDataContractsResponse, GetDocumentsRequest, GetDocumentsResponse, GetEpochsInfoRequest, + GetEpochsInfoResponse, GetIdentitiesContractKeysRequest, GetIdentitiesContractKeysResponse, + GetIdentityBalanceAndRevisionRequest, GetIdentityBalanceAndRevisionResponse, + GetIdentityBalanceRequest, GetIdentityBalanceResponse, GetIdentityByPublicKeyHashRequest, + GetIdentityByPublicKeyHashResponse, GetIdentityContractNonceRequest, + GetIdentityContractNonceResponse, GetIdentityKeysRequest, GetIdentityKeysResponse, + GetIdentityNonceRequest, GetIdentityNonceResponse, GetIdentityRequest, GetIdentityResponse, + GetPathElementsRequest, GetPathElementsResponse, GetPrefundedSpecializedBalanceRequest, + GetPrefundedSpecializedBalanceResponse, GetProofsRequest, GetProofsResponse, + GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, + GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, + WaitForStateTransitionResultRequest, WaitForStateTransitionResultResponse, +}; use dapi_grpc::tonic::{Request, Response, Status}; use dpp::version::PlatformVersion; use std::sync::atomic::Ordering; @@ -372,6 +391,39 @@ impl PlatformService for QueryService { ) .await } + + async fn get_contested_resources( + &self, + request: Request, + ) -> Result, Status> { + todo!() + } + + async fn get_contested_resource_vote_state( + &self, + request: Request, + ) -> Result, Status> { + todo!() + } + + async fn get_contested_resource_vote_status( + &self, + request: Request, + ) -> Result, Status> { + todo!() + } + + async fn get_prefunded_specialized_balance( + &self, + request: Request, + ) -> Result, Status> { + self.handle_blocking_query( + request, + Platform::::query_prefunded_specialized_balance, + "get_prefunded_specialized_balance", + ) + .await + } } fn query_error_into_status(error: QueryError) -> Status { diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/mod.rs index e69de29bb2..8b13789179 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/mod.rs @@ -0,0 +1 @@ + diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_status/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_status/mod.rs index e69de29bb2..8b13789179 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_status/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_status/mod.rs @@ -0,0 +1 @@ + diff --git a/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs index e69de29bb2..8b13789179 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs @@ -0,0 +1 @@ + diff --git a/packages/rs-drive-abci/src/query/voting/mod.rs b/packages/rs-drive-abci/src/query/voting/mod.rs index af02d3b928..4781aac591 100644 --- a/packages/rs-drive-abci/src/query/voting/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/mod.rs @@ -1,3 +1,3 @@ -mod contested_resources; mod contested_resource_vote_state; -mod contested_resource_vote_status; \ No newline at end of file +mod contested_resource_vote_status; +mod contested_resources; diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/mod.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/mod.rs index 86f38062ac..e8a9b98d3e 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/mod.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/mod.rs @@ -5,8 +5,8 @@ mod finalize_task; mod identity; mod prefunded_specialized_balance; mod system; -mod withdrawals; mod voting; +mod withdrawals; use crate::drive::batch::GroveDbOpBatch; diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/voting.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/voting.rs index 2ca557d169..92f9f53086 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/voting.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/voting.rs @@ -15,4 +15,4 @@ pub enum VotingOperationType { /// The end date of the vote poll end_date: TimestampMillis, }, -} \ No newline at end of file +} diff --git a/packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_keys/v0/mod.rs b/packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_keys/v0/mod.rs index c3c6cc11b1..c837c6746c 100644 --- a/packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_keys/v0/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_keys/v0/mod.rs @@ -21,7 +21,7 @@ impl Drive { platform_version: &PlatformVersion, ) -> Result, Error> { let id = Identifier::new(identity_key_request.identity_id); - + let public_keys_with_optionals = self .fetch_identity_keys::( identity_key_request, diff --git a/packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_revision_with_keys/v0/mod.rs b/packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_revision_with_keys/v0/mod.rs index e613e0ff86..50199051f4 100644 --- a/packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_revision_with_keys/v0/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/partial_identity/fetch_identity_revision_with_keys/v0/mod.rs @@ -21,7 +21,7 @@ impl Drive { platform_version: &PlatformVersion, ) -> Result, Error> { let id = Identifier::new(identity_key_request.identity_id); - + let revision = self.fetch_identity_revision( identity_key_request.identity_id, true, diff --git a/packages/rs-drive/src/drive/identity/fetch/partial_identity/mod.rs b/packages/rs-drive/src/drive/identity/fetch/partial_identity/mod.rs index 373a60e345..00576a7435 100644 --- a/packages/rs-drive/src/drive/identity/fetch/partial_identity/mod.rs +++ b/packages/rs-drive/src/drive/identity/fetch/partial_identity/mod.rs @@ -1,5 +1,5 @@ mod fetch_identity_balance_with_keys; mod fetch_identity_balance_with_keys_and_revision; -mod fetch_identity_with_balance; -mod fetch_identity_revision_with_keys; mod fetch_identity_keys; +mod fetch_identity_revision_with_keys; +mod fetch_identity_with_balance; diff --git a/packages/rs-drive/src/drive/object_size_info/drive_key_info.rs b/packages/rs-drive/src/drive/object_size_info/drive_key_info.rs index a690cbeb2e..c5a58d60a5 100644 --- a/packages/rs-drive/src/drive/object_size_info/drive_key_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/drive_key_info.rs @@ -3,9 +3,7 @@ use crate::drive::object_size_info::path_key_info::PathKeyInfo::{ PathFixedSizeKey, PathFixedSizeKeyRef, PathKey, PathKeyRef, PathKeySize, }; use crate::drive::object_size_info::PathInfo; -use crate::drive::object_size_info::PathInfo::{ - PathFixedSizeArray, PathAsVec, PathWithSizes, -}; +use crate::drive::object_size_info::PathInfo::{PathAsVec, PathFixedSizeArray, PathWithSizes}; use grovedb::batch::key_info::KeyInfo; use grovedb::batch::key_info::KeyInfo::KnownKey; use grovedb::batch::KeyInfoPath; @@ -67,9 +65,7 @@ impl<'a> DriveKeyInfo<'a> { PathFixedSizeArray(iter) => { PathKeySize(KeyInfoPath::from_known_path(iter), key_info) } - PathAsVec(iter) => { - PathKeySize(KeyInfoPath::from_known_owned_path(iter), key_info) - } + PathAsVec(iter) => PathKeySize(KeyInfoPath::from_known_owned_path(iter), key_info), PathWithSizes(key_info_path) => PathKeySize(key_info_path, key_info), }, } diff --git a/packages/rs-drive/src/drive/object_size_info/path_info.rs b/packages/rs-drive/src/drive/object_size_info/path_info.rs index 70a3844cbf..c458ead68f 100644 --- a/packages/rs-drive/src/drive/object_size_info/path_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/path_info.rs @@ -4,7 +4,7 @@ use grovedb::batch::KeyInfoPath; use grovedb_storage::worst_case_costs::WorstKeyLength; use DriveKeyInfo::{Key, KeyRef, KeySize}; -use PathInfo::{PathFixedSizeArray, PathAsVec, PathWithSizes}; +use PathInfo::{PathAsVec, PathFixedSizeArray, PathWithSizes}; use crate::drive::object_size_info::drive_key_info::DriveKeyInfo; use crate::error::drive::DriveError; diff --git a/packages/rs-drive/src/drive/object_size_info/path_key_element_info.rs b/packages/rs-drive/src/drive/object_size_info/path_key_element_info.rs index 32a7d0b7f5..7c2ef3e9c0 100644 --- a/packages/rs-drive/src/drive/object_size_info/path_key_element_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/path_key_element_info.rs @@ -1,9 +1,7 @@ use crate::drive::object_size_info::path_key_element_info::PathKeyElementInfo::{ PathFixedSizeKeyRefElement, PathKeyElementSize, PathKeyRefElement, PathKeyUnknownElementSize, }; -use crate::drive::object_size_info::PathInfo::{ - PathFixedSizeArray, PathAsVec, PathWithSizes, -}; +use crate::drive::object_size_info::PathInfo::{PathAsVec, PathFixedSizeArray, PathWithSizes}; use crate::drive::object_size_info::{KeyElementInfo, PathInfo}; use crate::error::drive::DriveError; use crate::error::Error; diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs index 39e63d1eba..d4b0061427 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs @@ -5,9 +5,7 @@ use grovedb::EstimatedLayerCount::{ApproximateElements, EstimatedLevel}; use grovedb::EstimatedLayerInformation; use grovedb::EstimatedLayerSizes::{AllItems, AllSubtrees}; -use crate::drive::prefunded_specialized_balances::{ - prefunded_specialized_balances_for_voting_path_vec, -}; +use crate::drive::prefunded_specialized_balances::prefunded_specialized_balances_for_voting_path_vec; use grovedb::EstimatedSumTrees::SomeSumTrees; use std::collections::HashMap; diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/mod.rs index 36dd2c5b5d..6a2e296c13 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/mod.rs @@ -1 +1 @@ -mod single_balance; \ No newline at end of file +mod single_balance; diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/single_balance/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/single_balance/mod.rs index e2106cbc7e..e341e7bb2b 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/single_balance/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/single_balance/mod.rs @@ -35,7 +35,11 @@ impl Drive { .prefunded_specialized_balances .fetch_single { - 0 => self.fetch_prefunded_specialized_balance_v0(prefunded_specialized_balance_id, transaction, platform_version), + 0 => self.fetch_prefunded_specialized_balance_v0( + prefunded_specialized_balance_id, + transaction, + platform_version, + ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "fetch_prefunded_specialized_balance".to_string(), known_versions: vec![0], diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/single_balance/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/single_balance/v0/mod.rs index e26086ee1d..9ed5965c45 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/single_balance/v0/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/fetch/single_balance/v0/mod.rs @@ -8,10 +8,10 @@ use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; use dpp::fee::Credits; +use crate::drive::prefunded_specialized_balances::prefunded_specialized_balances_for_voting_path; use dpp::version::PlatformVersion; use grovedb::Element::SumItem; use grovedb::TransactionArg; -use crate::drive::prefunded_specialized_balances::prefunded_specialized_balances_for_voting_path; impl Drive { /// Fetches the Prefunded specialized balance from the backing store diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs index 03c2b002ca..05baa3d8b3 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs @@ -6,12 +6,9 @@ mod estimation_costs; mod fetch; mod prove; -use grovedb::TransactionArg; -use platform_version::version::drive_versions::DriveVersion; use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; use crate::drive::batch::GroveDbOpBatch; use crate::drive::{Drive, RootTree}; -use crate::error::Error; pub const PREFUNDED_BALANCES_FOR_VOTING: [u8; 1] = [128]; @@ -45,4 +42,4 @@ impl Drive { PREFUNDED_BALANCES_FOR_VOTING.to_vec(), ); } -} \ No newline at end of file +} diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/prove/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/prove/mod.rs index 36dd2c5b5d..6a2e296c13 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/prove/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/prove/mod.rs @@ -1 +1 @@ -mod single_balance; \ No newline at end of file +mod single_balance; diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/prove/single_balance/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/prove/single_balance/mod.rs index c165ee5335..1bd707bff5 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/prove/single_balance/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/prove/single_balance/mod.rs @@ -2,10 +2,6 @@ mod v0; use crate::drive::Drive; use crate::error::{drive::DriveError, Error}; -use crate::fee::op::LowLevelDriveOperation; -use dpp::block::block_info::BlockInfo; -use dpp::fee::fee_result::FeeResult; -use dpp::fee::Credits; use dpp::version::PlatformVersion; @@ -35,7 +31,11 @@ impl Drive { .prefunded_specialized_balances .prove_single { - 0 => self.prove_prefunded_specialized_balance_v0(prefunded_specialized_balance_id, transaction, platform_version), + 0 => self.prove_prefunded_specialized_balance_v0( + prefunded_specialized_balance_id, + transaction, + platform_version, + ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "prove_prefunded_specialized_balance".to_string(), known_versions: vec![0], diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/prove/single_balance/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/prove/single_balance/v0/mod.rs index e8d80131a3..1ff25e076a 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/prove/single_balance/v0/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/prove/single_balance/v0/mod.rs @@ -1,9 +1,9 @@ use crate::drive::Drive; use crate::error::Error; +use crate::drive::prefunded_specialized_balances::prefunded_specialized_balances_for_voting_path_vec; use dpp::version::PlatformVersion; use grovedb::{PathQuery, TransactionArg}; -use crate::drive::prefunded_specialized_balances::prefunded_specialized_balances_for_voting_path_vec; impl Drive { /// Proves the prefunded specialized balance from the backing store diff --git a/packages/rs-drive/src/drive/verify/voting/mod.rs b/packages/rs-drive/src/drive/verify/voting/mod.rs index 38af2da7e5..26611b695b 100644 --- a/packages/rs-drive/src/drive/verify/voting/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/mod.rs @@ -1 +1 @@ -mod verify_masternode_vote; \ No newline at end of file +mod verify_masternode_vote; diff --git a/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/mod.rs index 4746a13073..dbbb7b89ad 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/mod.rs @@ -39,7 +39,7 @@ impl Drive { /// pub fn verify_masternode_vote( proof: &[u8], - masternode_pro_tx_hash: [u8;32], + masternode_pro_tx_hash: [u8; 32], vote: &Vote, verify_subset_of_proof: bool, platform_version: &PlatformVersion, diff --git a/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs index 790821208d..fe9d51c9ef 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs @@ -36,7 +36,7 @@ impl Drive { /// pub(crate) fn verify_masternode_vote_v0( proof: &[u8], - masternode_pro_tx_hash: [u8;32], + masternode_pro_tx_hash: [u8; 32], vote: &Vote, verify_subset_of_proof: bool, ) -> Result<(RootHash, Option), Error> { @@ -60,7 +60,7 @@ impl Drive { // "we did not get back an element for the correct key in balances".to_string(), // ))); // } - // + // // let signed_balance = maybe_element // .as_ref() // .map(|element| { diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs index e993830679..c522589c5a 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs @@ -5,13 +5,16 @@ use crate::error::drive::DriveError; use crate::error::Error; use crate::drive::grove_operations::BatchDeleteApplyType; -use crate::drive::votes::paths::{vote_contested_resource_identity_votes_tree_path_for_identity, vote_contested_resource_identity_votes_tree_path_for_identity_vec}; +use crate::drive::votes::paths::{ + vote_contested_resource_identity_votes_tree_path_for_identity, + vote_contested_resource_identity_votes_tree_path_for_identity_vec, +}; use crate::query::QueryItem; use dpp::prelude::Identifier; use dpp::version::PlatformVersion; use grovedb::query_result_type::QueryResultType::QueryElementResultType; -use grovedb::{Element, PathQuery, Query, SizedQuery, TransactionArg}; use grovedb::reference_path::path_from_reference_path_type; +use grovedb::{Element, PathQuery, Query, SizedQuery, TransactionArg}; impl Drive { /// We remove vote_choices for an identity when that identity is somehow disabled. Currently there is @@ -52,9 +55,8 @@ impl Drive { let mut deletion_batch = vec![]; - let vote_path_ref = vote_contested_resource_identity_votes_tree_path_for_identity( - identity_id.as_bytes(), - ); + let vote_path_ref = + vote_contested_resource_identity_votes_tree_path_for_identity(identity_id.as_bytes()); for vote_to_remove in votes_to_remove_elements { let Element::Reference(vote_reference, ..) = vote_to_remove else { @@ -64,15 +66,19 @@ impl Drive { )))); }; - let mut absolute_path = path_from_reference_path_type(vote_reference, vote_path_ref.as_ref(), None)?; - + let mut absolute_path = + path_from_reference_path_type(vote_reference, vote_path_ref.as_ref(), None)?; + if absolute_path.is_empty() { - return Err(Error::Drive(DriveError::CorruptedDriveState(format!("reference to vote for identity {} is empty", identity_id)))); + return Err(Error::Drive(DriveError::CorruptedDriveState(format!( + "reference to vote for identity {} is empty", + identity_id + )))); } let key = absolute_path.remove(absolute_path.len() - 1); // we then need to add to the batch the deletion - + let absolute_path_ref: Vec<_> = absolute_path.iter().map(|a| a.as_slice()).collect(); self.batch_delete( diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs index 3ddfaab98b..c7ebe69030 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs @@ -12,12 +12,11 @@ use dpp::fee::fee_result::FeeResult; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; -use grovedb::{EstimatedLayerInformation, TransactionArg}; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use grovedb::{EstimatedLayerInformation, TransactionArg}; impl Drive { - /// Registers a vote for a contested resource based on the voter's identifier, /// vote poll, and the specific vote choice. /// diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index fd72383a73..9968828f07 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -3,13 +3,13 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use platform_version::version::PlatformVersion; use std::collections::HashMap; -use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; impl Drive { pub(super) fn register_contested_resource_identity_vote_v0( @@ -35,7 +35,7 @@ impl Drive { // platform_version, // )? // .ok_or(Error::Document(DocumentError::DataContractNotFound))?; - + todo!() } @@ -55,7 +55,7 @@ impl Drive { let mut drive_operations: Vec = vec![]; // The vote at this point will have been verified as valid by rs-drive-abci - + todo!() } } diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/mod.rs index d0a511690d..5f7ca5cdce 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/mod.rs @@ -1,2 +1 @@ mod individual_vote; - diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs index a07885f9d7..3b91f994d7 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs @@ -3,13 +3,13 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; +use dpp::voting::vote_polls::VotePoll; +use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; use dpp::voting::votes::Vote; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use platform_version::version::PlatformVersion; use std::collections::HashMap; -use dpp::voting::vote_polls::VotePoll; -use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; impl Drive { pub(super) fn register_identity_vote_v0( @@ -24,21 +24,20 @@ impl Drive { match vote { Vote::ResourceVote(resource_vote) => { let vote_choice = resource_vote.resource_vote_choice(); - match resource_vote.vote_poll_owned() { VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll) => { - self - .register_contested_resource_identity_vote( - voter_pro_tx_hash, - contested_document_resource_vote_poll, - vote_choice, - block_info, - apply, - transaction, - platform_version, - ) - } + match resource_vote.vote_poll_owned() { + VotePoll::ContestedDocumentResourceVotePoll( + contested_document_resource_vote_poll, + ) => self.register_contested_resource_identity_vote( + voter_pro_tx_hash, + contested_document_resource_vote_poll, + vote_choice, + block_info, + apply, + transaction, + platform_version, + ), } - - }, + } } } @@ -56,21 +55,20 @@ impl Drive { match vote { Vote::ResourceVote(resource_vote) => { let vote_choice = resource_vote.resource_vote_choice(); - match resource_vote.vote_poll_owned() { VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll) => { - self - .register_contested_resource_identity_vote_operations( - voter_pro_tx_hash, - contested_document_resource_vote_poll, - vote_choice, - block_info, - estimated_costs_only_with_layer_info, - transaction, - platform_version, - ) - } + match resource_vote.vote_poll_owned() { + VotePoll::ContestedDocumentResourceVotePoll( + contested_document_resource_vote_poll, + ) => self.register_contested_resource_identity_vote_operations( + voter_pro_tx_hash, + contested_document_resource_vote_poll, + vote_choice, + block_info, + estimated_costs_only_with_layer_info, + transaction, + platform_version, + ), } - - }, + } } } } diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs index 13d1425c38..583776e5f6 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs @@ -1,19 +1,19 @@ mod v0; -use std::collections::HashMap; -use grovedb::batch::KeyInfoPath; use crate::drive::Drive; +use grovedb::batch::KeyInfoPath; +use std::collections::HashMap; use crate::error::drive::DriveError; use crate::error::Error; -use dpp::prelude::TimestampMillis; -use dpp::version::PlatformVersion; -use grovedb::{EstimatedLayerInformation, TransactionArg}; +use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::identifier::Identifier; +use dpp::prelude::TimestampMillis; +use dpp::version::PlatformVersion; use dpp::voting::vote_polls::VotePoll; -use crate::fee::op::LowLevelDriveOperation; +use grovedb::{EstimatedLayerInformation, TransactionArg}; impl Drive { /// We add votes poll references by end date in order to be able to check on every new block if @@ -39,7 +39,17 @@ impl Drive { .contested_resource_insert .add_vote_poll_end_date_query { - 0 => self.add_vote_poll_end_date_query_operations_v0(creator_identity_id, vote_poll, end_date, block_info, estimated_costs_only_with_layer_info, previous_batch_operations, batch_operations, transaction, platform_version), + 0 => self.add_vote_poll_end_date_query_operations_v0( + creator_identity_id, + vote_poll, + end_date, + block_info, + estimated_costs_only_with_layer_info, + previous_batch_operations, + batch_operations, + transaction, + platform_version, + ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "add_vote_poll_end_date_query_operations".to_string(), known_versions: vec![0], diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs index 1e7f9abb14..373d235a0f 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs @@ -1,21 +1,24 @@ -use std::collections::HashMap; -use grovedb::batch::KeyInfoPath; +use crate::drive::flags::StorageFlags; +use crate::drive::grove_operations::BatchInsertTreeApplyType; +use crate::drive::object_size_info::PathKeyElementInfo::{PathKeyElementSize, PathKeyRefElement}; +use crate::drive::object_size_info::{DriveKeyInfo, PathInfo, PathKeyElementInfo}; +use crate::drive::votes::paths::{ + vote_contested_resource_end_date_queries_at_time_tree_path_vec, + vote_contested_resource_end_date_queries_tree_path_vec, +}; use crate::drive::Drive; use crate::error::Error; -use dpp::identity::TimestampMillis; -use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; -use grovedb::batch::key_info::KeyInfo; +use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::identifier::Identifier; +use dpp::identity::TimestampMillis; use dpp::serialization::PlatformSerializable; use dpp::voting::vote_polls::VotePoll; +use grovedb::batch::key_info::KeyInfo; +use grovedb::batch::KeyInfoPath; +use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; use platform_version::version::PlatformVersion; -use crate::drive::flags::StorageFlags; -use crate::drive::grove_operations::BatchInsertTreeApplyType; -use crate::drive::object_size_info::{DriveKeyInfo, PathInfo, PathKeyElementInfo}; -use crate::drive::object_size_info::PathKeyElementInfo::{PathKeyElementSize, PathKeyRefElement}; -use crate::drive::votes::paths::{vote_contested_resource_end_date_queries_at_time_tree_path_vec, vote_contested_resource_end_date_queries_tree_path_vec}; -use crate::fee::op::LowLevelDriveOperation; +use std::collections::HashMap; impl Drive { /// We add votes poll references by end date in order to be able to check on every new block if @@ -34,14 +37,13 @@ impl Drive { transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { - let storage_flags = creator_identity_id.map(|creator_identity_id| { StorageFlags::new_single_epoch( block_info.epoch.index, Some(creator_identity_id.to_buffer()), ) }); - + // This is a GroveDB Tree (Not Sub Tree Merk representation) // End Date queries // / \ @@ -49,13 +51,12 @@ impl Drive { // / \ | // VotePoll Info 1 VotePoll Info 2 VotePoll Info 3 - // Let's start by inserting a tree for the end date - + let end_date_query_path = vote_contested_resource_end_date_queries_tree_path_vec(); - + let drive_key = DriveKeyInfo::Key(end_date.to_be_bytes().to_vec()); - + let path_key_info = drive_key.add_path_info::<0>(PathInfo::PathAsVec(end_date_query_path)); let apply_type = if estimated_costs_only_with_layer_info.is_none() { @@ -64,12 +65,13 @@ impl Drive { BatchInsertTreeApplyType::StatelessBatchInsertTree { in_tree_using_sums: false, is_sum_tree: false, - flags_len: storage_flags.as_ref() + flags_len: storage_flags + .as_ref() .map(|s| s.serialized_size()) .unwrap_or_default(), } }; - + // We check existing operations just because it is possible that we have already inserted the same // end data in the documents batch transition self.batch_insert_empty_tree_if_not_exists( @@ -82,29 +84,33 @@ impl Drive { batch_operations, &platform_version.drive, )?; - + let time_path = vote_contested_resource_end_date_queries_at_time_tree_path_vec(end_date); - - let item = Element::Item(vote_poll.serialize_to_bytes()?, StorageFlags::map_to_some_element_flags(storage_flags.as_ref())); - let path_key_element_info : PathKeyElementInfo<'_, 0> = if estimated_costs_only_with_layer_info.is_none() { - PathKeyRefElement(( - time_path, - &[0], - item, - )) - } else { - PathKeyElementSize(( - KeyInfoPath::from_known_owned_path(time_path), - KeyInfo::KnownKey(vec![0u8]), - item, - )) - }; - - self.batch_insert(path_key_element_info, batch_operations, &platform_version.drive)?; - + let item = Element::Item( + vote_poll.serialize_to_bytes()?, + StorageFlags::map_to_some_element_flags(storage_flags.as_ref()), + ); + + let path_key_element_info: PathKeyElementInfo<'_, 0> = + if estimated_costs_only_with_layer_info.is_none() { + PathKeyRefElement((time_path, &[0], item)) + } else { + PathKeyElementSize(( + KeyInfoPath::from_known_owned_path(time_path), + KeyInfo::KnownKey(vec![0u8]), + item, + )) + }; + + self.batch_insert( + path_key_element_info, + batch_operations, + &platform_version.drive, + )?; + Ok(()) - + //todo // if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info // { @@ -114,6 +120,5 @@ impl Drive { // drive_version, // )?; // } - } } diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 6f5625a307..afd3080352 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -10,8 +10,8 @@ use dpp::ProtocolError; mod cleanup; mod insert; -mod setup; mod paths; +mod setup; pub trait TreePath { fn tree_path<'a>(&'a self, contract: &'a DataContract) -> Result, ProtocolError>; @@ -38,8 +38,9 @@ impl TreePath for ResourceVote { contract.id() ))); } - let document_type = contract - .document_type_borrowed_for_name(&contested_document_vote_poll.document_type_name)?; + let document_type = contract.document_type_borrowed_for_name( + &contested_document_vote_poll.document_type_name, + )?; let index = document_type .indexes() .get(&contested_document_vote_poll.index_name) diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index b3636f858d..ca2c49ccc3 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -1,5 +1,5 @@ -use dpp::identity::TimestampMillis; use crate::drive::RootTree; +use dpp::identity::TimestampMillis; /// The votes tree structure looks like this /// @@ -74,7 +74,8 @@ pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_tree_pat ] } -pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_at_time_tree_path_vec(time: TimestampMillis +pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_at_time_tree_path_vec( + time: TimestampMillis, ) -> Vec> { vec![ vec![RootTree::Votes as u8], diff --git a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs index d1d26a02ea..51c2675f2b 100644 --- a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs +++ b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/mod.rs @@ -9,8 +9,7 @@ use crate::drive::batch::GroveDbOpBatch; use dpp::version::PlatformVersion; impl Drive { - - /// Initializes the main structure of the vote tree within a GroveDB operation batch. + /// Initializes the main structure of the vote tree within a GroveDB operation batch. /// This function is version-controlled to ensure compatibility with different versions of the platform. /// /// # Parameters diff --git a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs index c9c34f0091..a8dc952472 100644 --- a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs @@ -1,7 +1,10 @@ use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; use crate::drive::batch::GroveDbOpBatch; +use crate::drive::votes::paths::{ + vote_contested_resource_tree_path_vec, vote_root_path_vec, CONTESTED_RESOURCE_TREE_KEY, + END_DATE_QUERIES_TREE_KEY, IDENTITY_VOTES_TREE_KEY, VOTE_DECISIONS_TREE_KEY, +}; use crate::drive::Drive; -use crate::drive::votes::paths::{CONTESTED_RESOURCE_TREE_KEY, END_DATE_QUERIES_TREE_KEY, IDENTITY_VOTES_TREE_KEY, vote_contested_resource_tree_path_vec, VOTE_DECISIONS_TREE_KEY, vote_root_path_vec}; use crate::error::Error; impl Drive { diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/v0/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/v0/mod.rs index 73c3735e95..39677e22ac 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/v0/mod.rs @@ -28,7 +28,7 @@ pub struct DocumentBaseTransitionActionV0 { pub trait DocumentBaseTransitionActionAccessorsV0 { /// The document Id fn id(&self) -> Identifier; - + /// The document type fn document_type(&self) -> Result; @@ -41,7 +41,7 @@ pub trait DocumentBaseTransitionActionAccessorsV0 { fn document_type_name_owned(self) -> String; /// Data contract ID generated from the data contract's `owner_id` and `entropy` fn data_contract_id(&self) -> Identifier; - + /// A reference to the data contract fetch info that does not clone the Arc fn data_contract_fetch_info_ref(&self) -> &Arc; /// Data contract diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs index ba5d12324f..bb05c2088f 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs @@ -63,9 +63,13 @@ impl DocumentCreateTransitionActionAccessorsV0 for DocumentCreateTransitionActio } } - fn take_prefunded_voting_balances(&mut self) -> Vec<(ContestedDocumentResourceVotePoll, Credits)> { + fn take_prefunded_voting_balances( + &mut self, + ) -> Vec<(ContestedDocumentResourceVotePoll, Credits)> { match self { - DocumentCreateTransitionAction::V0(v0) => mem::replace(&mut v0.prefunded_voting_balances, vec![]), + DocumentCreateTransitionAction::V0(v0) => { + mem::replace(&mut v0.prefunded_voting_balances, vec![]) + } } } diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs index c1aa12d0ee..4a2ea259fd 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs @@ -51,9 +51,11 @@ pub trait DocumentCreateTransitionActionAccessorsV0 { fn data_mut(&mut self) -> &mut BTreeMap; /// data owned fn data_owned(self) -> BTreeMap; - + /// Take the prefunded voting balance vec (and replace it with an empty vec). - fn take_prefunded_voting_balances(&mut self) -> Vec<(ContestedDocumentResourceVotePoll, Credits)>; + fn take_prefunded_voting_balances( + &mut self, + ) -> Vec<(ContestedDocumentResourceVotePoll, Credits)>; /// pre funded balance (for unique index conflict resolution voting - the identity will put money /// aside that will be used by voters to vote) diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/mod.rs index 610f9b6802..1f918e396d 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/mod.rs @@ -74,6 +74,13 @@ impl DocumentsBatchTransitionAction { } impl DocumentsBatchTransitionAction { + /// The sum of all purchases amount and all conflicting index collateral voting funds + pub fn all_used_balances(&self) -> Result, ProtocolError> { + match self { + DocumentsBatchTransitionAction::V0(v0) => v0.all_used_balances(), + } + } + /// The sum of all purchases amounts for all purchase transitions in the batch pub fn all_purchases_amount(&self) -> Result, ProtocolError> { match self { diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs index 300d296888..b93000b15b 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs @@ -5,6 +5,7 @@ use dpp::prelude::UserFeeIncrease; use dpp::ProtocolError; use crate::state_transition_action::document::documents_batch::document_transition::document_create_transition_action::DocumentCreateTransitionActionAccessorsV0; use crate::state_transition_action::document::documents_batch::document_transition::document_purchase_transition_action::DocumentPurchaseTransitionActionAccessorsV0; +use crate::state_transition_action::document::documents_batch::DocumentsBatchTransitionAction; /// action v0 #[derive(Default, Debug, Clone)] @@ -18,6 +19,14 @@ pub struct DocumentsBatchTransitionActionV0 { } impl DocumentsBatchTransitionActionV0 { + pub(super) fn all_used_balances(&self) -> Result, ProtocolError> { + Ok(match (self.all_purchases_amount()?, self.all_conflicting_index_collateral_voting_funds()?) { + (Some(all_purchases_amount), Some(all_conflicting_index_collateral_voting_funds)) => Some(all_purchases_amount.checked_add(all_conflicting_index_collateral_voting_funds).ok_or(ProtocolError::Overflow("overflow between all_purchases_amount and all_conflicting_index_collateral_voting_funds"))?), + (Some(all_purchases_amount), None) => Some(all_purchases_amount), + (None, Some(all_conflicting_index_collateral_voting_funds)) => Some(all_conflicting_index_collateral_voting_funds), + (None, None) => None, + }) + } pub(super) fn all_purchases_amount(&self) -> Result, ProtocolError> { let (total, any_purchases): (Option, bool) = self .transitions @@ -50,7 +59,8 @@ impl DocumentsBatchTransitionActionV0 { DocumentTransitionAction::CreateAction(document_create_transition_action) => { document_create_transition_action .prefunded_voting_balances() - .iter().try_fold(0u64, |acc, &(_, val)| acc.checked_add(val)) + .iter() + .try_fold(0u64, |acc, &(_, val)| acc.checked_add(val)) } _ => None, }) diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 8663db2dd4..a31e023026 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -11,8 +11,65 @@ use crate::version::dpp_versions::{ RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, }; -use crate::version::drive_abci_versions::{DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, DriveAbciFeePoolInwardsDistributionMethodVersions, DriveAbciFeePoolOutwardsDistributionMethodVersions, DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, DriveAbciQueryPrefundedSpecializedBalancesVersions, DriveAbciQuerySystemVersions, DriveAbciQueryVersions, DriveAbciStateTransitionCommonValidationVersions, DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts}; -use crate::version::drive_versions::{DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, DriveCreditPoolPendingEpochRefundsMethodVersions, DriveCreditPoolStorageFeeDistributionPoolMethodVersions, DriveCreditPoolUnpaidEpochMethodVersions, DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertContestedMethodVersions, DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveFetchMethodVersions, DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, DriveIdentityWithdrawalDocumentMethodVersions, DriveIdentityWithdrawalMethodVersions, DriveIdentityWithdrawalTransactionIndexMethodVersions, DriveIdentityWithdrawalTransactionMethodVersions, DriveIdentityWithdrawalTransactionQueueMethodVersions, DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformStateMethodVersions, DrivePlatformSystemMethodVersions, DrivePrefundedSpecializedMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVerifyVoteMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions}; +use crate::version::drive_abci_versions::{ + DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, + DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, + DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, + DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, + DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, + DriveAbciFeePoolInwardsDistributionMethodVersions, + DriveAbciFeePoolOutwardsDistributionMethodVersions, + DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, + DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, + DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, + DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, + DriveAbciQueryPrefundedSpecializedBalancesVersions, DriveAbciQuerySystemVersions, + DriveAbciQueryVersions, DriveAbciStateTransitionCommonValidationVersions, + DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, + DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, + DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, + DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts, +}; +use crate::version::drive_versions::{ + DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, + DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, + DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, + DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, + DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, + DriveCreditPoolPendingEpochRefundsMethodVersions, + DriveCreditPoolStorageFeeDistributionPoolMethodVersions, + DriveCreditPoolUnpaidEpochMethodVersions, DriveDataContractOperationMethodVersions, + DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, + DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertContestedMethodVersions, + DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, + DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, + DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveFetchMethodVersions, + DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, + DriveGroveCostMethodVersions, DriveGroveMethodVersions, + DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, + DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, + DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, + DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, + DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, + DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, + DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, + DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, + DriveIdentityWithdrawalDocumentMethodVersions, DriveIdentityWithdrawalMethodVersions, + DriveIdentityWithdrawalTransactionIndexMethodVersions, + DriveIdentityWithdrawalTransactionMethodVersions, + DriveIdentityWithdrawalTransactionQueueMethodVersions, DriveInitializationMethodVersions, + DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformStateMethodVersions, + DrivePlatformSystemMethodVersions, DrivePrefundedSpecializedMethodVersions, + DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, + DriveStateTransitionOperationMethodVersions, DriveStructureVersion, + DriveSystemEstimationCostsMethodVersions, DriveVerifyContractMethodVersions, + DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, + DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, + DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, + DriveVerifyVoteMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, + DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, + DriveVoteMethodVersions, DriveVoteSetupMethodVersions, +}; use crate::version::fee::v1::FEE_VERSION1; use crate::version::mocks::TEST_PROTOCOL_VERSION_SHIFT_BYTES; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; @@ -729,7 +786,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { max_version: 0, default_current_version: 0, }, - prefunded_specialized_balances: DriveAbciQueryPrefundedSpecializedBalancesVersions { + prefunded_specialized_balances: DriveAbciQueryPrefundedSpecializedBalancesVersions { balance: FeatureVersionBounds { min_version: 0, max_version: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index a8062b60b7..22129bdf0d 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -11,8 +11,65 @@ use crate::version::dpp_versions::{ RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, }; -use crate::version::drive_abci_versions::{DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, DriveAbciFeePoolInwardsDistributionMethodVersions, DriveAbciFeePoolOutwardsDistributionMethodVersions, DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, DriveAbciQueryPrefundedSpecializedBalancesVersions, DriveAbciQuerySystemVersions, DriveAbciQueryVersions, DriveAbciStateTransitionCommonValidationVersions, DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts}; -use crate::version::drive_versions::{DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, DriveCreditPoolPendingEpochRefundsMethodVersions, DriveCreditPoolStorageFeeDistributionPoolMethodVersions, DriveCreditPoolUnpaidEpochMethodVersions, DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertContestedMethodVersions, DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveFetchMethodVersions, DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, DriveIdentityWithdrawalDocumentMethodVersions, DriveIdentityWithdrawalMethodVersions, DriveIdentityWithdrawalTransactionIndexMethodVersions, DriveIdentityWithdrawalTransactionMethodVersions, DriveIdentityWithdrawalTransactionQueueMethodVersions, DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformStateMethodVersions, DrivePlatformSystemMethodVersions, DrivePrefundedSpecializedMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVerifyVoteMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions}; +use crate::version::drive_abci_versions::{ + DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, + DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, + DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, + DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, + DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, + DriveAbciFeePoolInwardsDistributionMethodVersions, + DriveAbciFeePoolOutwardsDistributionMethodVersions, + DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, + DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, + DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, + DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, + DriveAbciQueryPrefundedSpecializedBalancesVersions, DriveAbciQuerySystemVersions, + DriveAbciQueryVersions, DriveAbciStateTransitionCommonValidationVersions, + DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, + DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, + DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, + DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts, +}; +use crate::version::drive_versions::{ + DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, + DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, + DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, + DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, + DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, + DriveCreditPoolPendingEpochRefundsMethodVersions, + DriveCreditPoolStorageFeeDistributionPoolMethodVersions, + DriveCreditPoolUnpaidEpochMethodVersions, DriveDataContractOperationMethodVersions, + DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, + DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertContestedMethodVersions, + DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, + DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, + DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveFetchMethodVersions, + DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, + DriveGroveCostMethodVersions, DriveGroveMethodVersions, + DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, + DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, + DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, + DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, + DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, + DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, + DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, + DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, + DriveIdentityWithdrawalDocumentMethodVersions, DriveIdentityWithdrawalMethodVersions, + DriveIdentityWithdrawalTransactionIndexMethodVersions, + DriveIdentityWithdrawalTransactionMethodVersions, + DriveIdentityWithdrawalTransactionQueueMethodVersions, DriveInitializationMethodVersions, + DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformStateMethodVersions, + DrivePlatformSystemMethodVersions, DrivePrefundedSpecializedMethodVersions, + DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, + DriveStateTransitionOperationMethodVersions, DriveStructureVersion, + DriveSystemEstimationCostsMethodVersions, DriveVerifyContractMethodVersions, + DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, + DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, + DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, + DriveVerifyVoteMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, + DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, + DriveVoteMethodVersions, DriveVoteSetupMethodVersions, +}; use crate::version::fee::v1::FEE_VERSION1; use crate::version::mocks::TEST_PROTOCOL_VERSION_SHIFT_BYTES; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 1e8e2723aa..909155db00 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -11,8 +11,65 @@ use crate::version::dpp_versions::{ RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, }; -use crate::version::drive_abci_versions::{DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, DriveAbciFeePoolInwardsDistributionMethodVersions, DriveAbciFeePoolOutwardsDistributionMethodVersions, DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, DriveAbciQueryPrefundedSpecializedBalancesVersions, DriveAbciQuerySystemVersions, DriveAbciQueryVersions, DriveAbciStateTransitionCommonValidationVersions, DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts}; -use crate::version::drive_versions::{DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, DriveCreditPoolPendingEpochRefundsMethodVersions, DriveCreditPoolStorageFeeDistributionPoolMethodVersions, DriveCreditPoolUnpaidEpochMethodVersions, DriveDataContractOperationMethodVersions, DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertContestedMethodVersions, DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveFetchMethodVersions, DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, DriveGroveCostMethodVersions, DriveGroveMethodVersions, DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, DriveIdentityWithdrawalDocumentMethodVersions, DriveIdentityWithdrawalMethodVersions, DriveIdentityWithdrawalTransactionIndexMethodVersions, DriveIdentityWithdrawalTransactionMethodVersions, DriveIdentityWithdrawalTransactionQueueMethodVersions, DriveInitializationMethodVersions, DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformStateMethodVersions, DrivePlatformSystemMethodVersions, DrivePrefundedSpecializedMethodVersions, DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, DriveStateTransitionOperationMethodVersions, DriveStructureVersion, DriveSystemEstimationCostsMethodVersions, DriveVerifyContractMethodVersions, DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVerifyVoteMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions}; +use crate::version::drive_abci_versions::{ + DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, + DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, + DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, + DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, + DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, + DriveAbciFeePoolInwardsDistributionMethodVersions, + DriveAbciFeePoolOutwardsDistributionMethodVersions, + DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, + DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, + DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, + DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, + DriveAbciQueryPrefundedSpecializedBalancesVersions, DriveAbciQuerySystemVersions, + DriveAbciQueryVersions, DriveAbciStateTransitionCommonValidationVersions, + DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, + DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, + DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, + DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts, +}; +use crate::version::drive_versions::{ + DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, + DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, + DriveContractGetMethodVersions, DriveContractInsertMethodVersions, DriveContractMethodVersions, + DriveContractProveMethodVersions, DriveContractUpdateMethodVersions, + DriveCreditPoolEpochsMethodVersions, DriveCreditPoolMethodVersions, + DriveCreditPoolPendingEpochRefundsMethodVersions, + DriveCreditPoolStorageFeeDistributionPoolMethodVersions, + DriveCreditPoolUnpaidEpochMethodVersions, DriveDataContractOperationMethodVersions, + DriveDocumentDeleteMethodVersions, DriveDocumentEstimationCostsMethodVersions, + DriveDocumentIndexUniquenessMethodVersions, DriveDocumentInsertContestedMethodVersions, + DriveDocumentInsertMethodVersions, DriveDocumentMethodVersions, + DriveDocumentQueryMethodVersions, DriveDocumentUpdateMethodVersions, + DriveEstimatedCostsMethodVersions, DriveFeesMethodVersions, DriveFetchMethodVersions, + DriveGroveApplyMethodVersions, DriveGroveBasicMethodVersions, DriveGroveBatchMethodVersions, + DriveGroveCostMethodVersions, DriveGroveMethodVersions, + DriveIdentityContractInfoMethodVersions, DriveIdentityCostEstimationMethodVersions, + DriveIdentityFetchAttributesMethodVersions, DriveIdentityFetchFullIdentityMethodVersions, + DriveIdentityFetchMethodVersions, DriveIdentityFetchPartialIdentityMethodVersions, + DriveIdentityFetchPublicKeyHashesMethodVersions, DriveIdentityInsertMethodVersions, + DriveIdentityKeyHashesToIdentityInsertMethodVersions, DriveIdentityKeysFetchMethodVersions, + DriveIdentityKeysInsertMethodVersions, DriveIdentityKeysMethodVersions, + DriveIdentityKeysProveMethodVersions, DriveIdentityMethodVersions, + DriveIdentityProveMethodVersions, DriveIdentityUpdateMethodVersions, + DriveIdentityWithdrawalDocumentMethodVersions, DriveIdentityWithdrawalMethodVersions, + DriveIdentityWithdrawalTransactionIndexMethodVersions, + DriveIdentityWithdrawalTransactionMethodVersions, + DriveIdentityWithdrawalTransactionQueueMethodVersions, DriveInitializationMethodVersions, + DriveMethodVersions, DriveOperationsMethodVersion, DrivePlatformStateMethodVersions, + DrivePlatformSystemMethodVersions, DrivePrefundedSpecializedMethodVersions, + DriveProtocolUpgradeVersions, DriveProveMethodVersions, DriveStateTransitionMethodVersions, + DriveStateTransitionOperationMethodVersions, DriveStructureVersion, + DriveSystemEstimationCostsMethodVersions, DriveVerifyContractMethodVersions, + DriveVerifyDocumentMethodVersions, DriveVerifyIdentityMethodVersions, + DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, + DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, + DriveVerifyVoteMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, + DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, + DriveVoteMethodVersions, DriveVoteSetupMethodVersions, +}; use crate::version::fee::v1::FEE_VERSION1; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; use crate::version::{AbciStructureVersion, PlatformArchitectureVersion}; From 6a2bdb2f50dec0de131809b6b11851d5408ca2e0 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 12 May 2024 00:59:02 +0200 Subject: [PATCH 047/135] more work --- .../protos/platform/v0/platform.proto | 11 ++++ .../proto/org.dash.platform.dapi.v0.rs | 37 ++++++++++++ .../document_create_transition/v0/mod.rs | 2 + .../types/execution_operation/mod.rs | 14 +++++ .../v0/mod.rs | 2 +- .../state_transition/transformer/mod.rs | 7 +++ .../tests/strategy_tests/strategy.rs | 2 + .../verify_state_transitions.rs | 58 +++++++++++++++++++ .../tests/strategy_tests/voting_tests.rs | 7 +-- .../src/drive/batch/transitions/mod.rs | 2 + .../src/state_transition_action/mod.rs | 6 ++ .../src/version/fee/processing/mod.rs | 1 + .../src/version/fee/processing/v1.rs | 1 + 13 files changed, 145 insertions(+), 5 deletions(-) diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index 6182204444..9a4ecc5267 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -311,9 +311,20 @@ message GetProofsRequest { message ContractRequest { bytes contract_id = 1; } + message VoteStatusRequest { + message ContestedResourceVoteStatusRequest { + repeated bytes resource_path = 1; + bytes resource_identifier = 2; + bytes voter_identifier = 3; + } + + oneof request_type { ContestedResourceVoteStatusRequest contested_resource_vote_status_request = 1; } + } + repeated IdentityRequest identities = 1; repeated ContractRequest contracts = 2; repeated DocumentRequest documents = 3; + repeated VoteStatusRequest votes = 4; } oneof version { GetProofsRequestV0 v0 = 1; } diff --git a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs index 1b4efe7d80..60ac13e953 100644 --- a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs +++ b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs @@ -863,6 +863,8 @@ pub mod get_proofs_request { pub contracts: ::prost::alloc::vec::Vec, #[prost(message, repeated, tag = "3")] pub documents: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "4")] + pub votes: ::prost::alloc::vec::Vec, } /// Nested message and enum types in `GetProofsRequestV0`. pub mod get_proofs_request_v0 { @@ -949,6 +951,41 @@ pub mod get_proofs_request { #[prost(bytes = "vec", tag = "1")] pub contract_id: ::prost::alloc::vec::Vec, } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct VoteStatusRequest { + #[prost(oneof = "vote_status_request::RequestType", tags = "1")] + pub request_type: ::core::option::Option, + } + /// Nested message and enum types in `VoteStatusRequest`. + pub mod vote_status_request { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ContestedResourceVoteStatusRequest { + #[prost(bytes = "vec", repeated, tag = "1")] + pub resource_path: ::prost::alloc::vec::Vec< + ::prost::alloc::vec::Vec, + >, + #[prost(bytes = "vec", tag = "2")] + pub resource_identifier: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", tag = "3")] + pub voter_identifier: ::prost::alloc::vec::Vec, + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum RequestType { + #[prost(message, tag = "1")] + ContestedResourceVoteStatusRequest(ContestedResourceVoteStatusRequest), + } + } } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs index f50b6041ce..983f1ec358 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs @@ -5,6 +5,8 @@ use bincode::{Decode, Encode}; #[cfg(feature = "state-transition-value-conversion")] use platform_value::btreemap_extensions::BTreeValueRemoveFromMapHelper; +#[cfg(feature = "state-transition-value-conversion")] +use platform_value::{ValueMap, ValueMapHelper}; use platform_value::{Identifier, Value}; #[cfg(feature = "state-transition-serde-conversion")] use serde::{Deserialize, Serialize}; diff --git a/packages/rs-drive-abci/src/execution/types/execution_operation/mod.rs b/packages/rs-drive-abci/src/execution/types/execution_operation/mod.rs index 7f718137ad..a5b7968207 100644 --- a/packages/rs-drive-abci/src/execution/types/execution_operation/mod.rs +++ b/packages/rs-drive-abci/src/execution/types/execution_operation/mod.rs @@ -162,6 +162,19 @@ impl ValidationOperation { "execution processing fee overflow error", ))?; } + ValidationOperation::RetrievePrefundedSpecializedBalance => { + let operation_cost = platform_version + .fee_version + .processing + .fetch_prefunded_specialized_balance_processing_cost; + + fee_result.processing_fee = fee_result + .processing_fee + .checked_add(operation_cost) + .ok_or(ExecutionError::Overflow( + "execution processing fee overflow error", + ))?; + } ValidationOperation::ValidateKeyStructure(key_count) => { fee_result.processing_fee = fee_result .processing_fee @@ -184,6 +197,7 @@ impl ValidationOperation { "execution processing fee overflow error", ))?; } + } } Ok(()) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_simple_pre_check_balance/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_simple_pre_check_balance/v0/mod.rs index 07c2895c25..1d74659a4b 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_simple_pre_check_balance/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_simple_pre_check_balance/v0/mod.rs @@ -39,7 +39,7 @@ impl ValidateSimplePreCheckBalanceV0 for StateTransition { .state_transition_min_fees .document_batch_sub_transition } - StateTransition::IdentityCreate(_) | StateTransition::IdentityTopUp(_) => 0, + StateTransition::IdentityCreate(_) | StateTransition::IdentityTopUp(_) | StateTransition::MasternodeVote(_) => 0, StateTransition::IdentityCreditWithdrawal(_) => { platform_version .fee_version diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/transformer/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/transformer/mod.rs index c02a228d5d..97144b79ec 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/transformer/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/transformer/mod.rs @@ -112,6 +112,13 @@ impl StateTransitionActionTransformerV0 for StateTransition { execution_context, tx, ), + StateTransition::MasternodeVote(st) => st.transform_into_action( + platform, + block_info, + validation_mode, + execution_context, + tx, + ) } } } diff --git a/packages/rs-drive-abci/tests/strategy_tests/strategy.rs b/packages/rs-drive-abci/tests/strategy_tests/strategy.rs index dae0d7acc8..863e470045 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/strategy.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/strategy.rs @@ -577,6 +577,7 @@ impl NetworkStrategy { .into(), entropy: entropy.to_buffer(), data: document.properties_consumed(), + prefunded_voting_balances: Default::default(), } .into(); @@ -688,6 +689,7 @@ impl NetworkStrategy { .into(), entropy: entropy.to_buffer(), data: document.properties_consumed(), + prefunded_voting_balances: Default::default(), } .into(); diff --git a/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs b/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs index 0a09757567..694f6d9d98 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs @@ -716,6 +716,64 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed( ); } } + StateTransitionAction::MasternodeVoteAction( + masternode_vote_action, + ) => { + proofs_request + .votes + .push(get_proofs_request_v0::VoteStatusRequest{ + request_type: Some(get_proofs_request_v0::vote_status_request::ContestedResourceVoteStatusRequest { + resource_path: vec![], + resource_identifier: vec![], + voter_identifier: vec![], + }) + }); + + proofs_request + .identities + .push(get_proofs_request_v0::IdentityRequest { + identity_id: identity_credit_transfer_action.recipient_id().to_vec(), + request_type: get_proofs_request_v0::identity_request::Type::Balance + .into(), + }); + + let versioned_request = GetProofsRequest { + version: Some(get_proofs_request::Version::V0(proofs_request)), + }; + + let result = abci_app + .platform + .query_proofs(versioned_request, &state, platform_version) + .expect("expected to query proofs"); + let response = result.into_data().expect("expected queries to be valid"); + + let response_proof = response.proof_owned().expect("proof should be present"); + + // we expect to get a vote that matches the state transition + let (root_hash_identity, _balance_identity) = + Drive::verify_identity_balance_for_identity_id( + &response_proof.grovedb_proof, + identity_credit_transfer_action.identity_id().into_buffer(), + true, + platform_version, + ) + .expect("expected to verify balance identity"); + + assert_eq!( + &root_hash_identity, + expected_root_hash, + "state last block info {:?}", + platform.state.last_committed_block_info() + ); + + if *was_executed { + let balance_recipient = balance_recipient.expect("expected a balance"); + + assert!( + balance_recipient >= identity_credit_transfer_action.transfer_amount() + ); + } + } StateTransitionAction::BumpIdentityNonceAction(_) => {} StateTransitionAction::BumpIdentityDataContractNonceAction(_) => {} StateTransitionAction::PartiallyUseAssetLockAction(_) => {} diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index bdb8ec18d9..0f057a8066 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -1,7 +1,7 @@ #[cfg(test)] mod tests { use crate::execution::run_chain_for_strategy; - use crate::strategy::{NetworkStrategy, Strategy}; + use crate::strategy::NetworkStrategy; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::random_document::{ DocumentFieldFillSize, DocumentFieldFillType, @@ -9,7 +9,7 @@ mod tests { use dpp::identity::accessors::IdentityGettersV0; use dpp::identity::Identity; use dpp::platform_value::Value; - use drive_abci::config::{ExecutionConfig, PlatformConfig, PlatformTestConfig}; + use drive_abci::config::{ExecutionConfig, PlatformConfig}; use drive_abci::test::helpers::setup::TestPlatformBuilder; use platform_version::version::PlatformVersion; use rand::prelude::StdRng; @@ -19,8 +19,7 @@ mod tests { use strategy_tests::frequency::Frequency; use strategy_tests::operations::{DocumentAction, DocumentOp, Operation, OperationType}; use strategy_tests::transitions::create_state_transitions_for_identities; - use strategy_tests::{IdentityInsertInfo, StartIdentities}; - use tenderdash_abci::proto::types::CoreChainLock; + use strategy_tests::{IdentityInsertInfo, StartIdentities, Strategy}; #[test] fn run_chain_block_two_state_transitions_conflicting_unique_index() { diff --git a/packages/rs-drive/src/drive/batch/transitions/mod.rs b/packages/rs-drive/src/drive/batch/transitions/mod.rs index c1f4228c98..743e9840eb 100644 --- a/packages/rs-drive/src/drive/batch/transitions/mod.rs +++ b/packages/rs-drive/src/drive/batch/transitions/mod.rs @@ -59,6 +59,7 @@ impl DriveHighLevelOperationConverter for StateTransitionAction { identity_credit_transfer_transition, ) => identity_credit_transfer_transition .into_high_level_drive_operations(epoch, platform_version), + StateTransitionAction::MasternodeVoteAction(masternode_vote_transition) => masternode_vote_transition.into_high_level_drive_operations(epoch, platform_version), StateTransitionAction::BumpIdentityNonceAction(bump_identity_nonce_transition) => { bump_identity_nonce_transition .into_high_level_drive_operations(epoch, platform_version) @@ -71,6 +72,7 @@ impl DriveHighLevelOperationConverter for StateTransitionAction { partially_used_asset_lock_action, ) => partially_used_asset_lock_action .into_high_level_drive_operations(epoch, platform_version), + } } } diff --git a/packages/rs-drive/src/state_transition_action/mod.rs b/packages/rs-drive/src/state_transition_action/mod.rs index 585a51c603..5c2a38f457 100644 --- a/packages/rs-drive/src/state_transition_action/mod.rs +++ b/packages/rs-drive/src/state_transition_action/mod.rs @@ -27,6 +27,7 @@ use crate::state_transition_action::system::partially_use_asset_lock_action::{ }; use derive_more::From; use dpp::prelude::UserFeeIncrease; +use crate::state_transition_action::identity::masternode_vote::MasternodeVoteTransitionAction; /// ST action #[derive(Debug, Clone, From)] @@ -47,6 +48,8 @@ pub enum StateTransitionAction { IdentityUpdateAction(IdentityUpdateTransitionAction), /// identity credit transfer IdentityCreditTransferAction(IdentityCreditTransferTransitionAction), + /// masternode vote action + MasternodeVoteAction(MasternodeVoteTransitionAction), /// bump identity nonce action /// this can only come in this form from identity state transitions that do not use asset locks /// it will also only happen if the state validation fails @@ -83,6 +86,9 @@ impl StateTransitionAction { StateTransitionAction::PartiallyUseAssetLockAction(action) => { action.user_fee_increase() } + StateTransitionAction::MasternodeVoteAction(action) => { + UserFeeIncrease::default() // 0 (or none) + } } } } diff --git a/packages/rs-platform-version/src/version/fee/processing/mod.rs b/packages/rs-platform-version/src/version/fee/processing/mod.rs index 484048f624..4ba72b7456 100644 --- a/packages/rs-platform-version/src/version/fee/processing/mod.rs +++ b/packages/rs-platform-version/src/version/fee/processing/mod.rs @@ -6,6 +6,7 @@ pub struct FeeProcessingVersion { pub fetch_identity_revision_processing_cost: u64, pub fetch_identity_balance_and_revision_processing_cost: u64, pub fetch_identity_cost_per_look_up_key_by_id: u64, + pub fetch_prefunded_specialized_balance_processing_cost: u64, pub fetch_single_identity_key_processing_cost: u64, pub validate_key_structure: u64, } diff --git a/packages/rs-platform-version/src/version/fee/processing/v1.rs b/packages/rs-platform-version/src/version/fee/processing/v1.rs index da0721383c..dbedd153d9 100644 --- a/packages/rs-platform-version/src/version/fee/processing/v1.rs +++ b/packages/rs-platform-version/src/version/fee/processing/v1.rs @@ -5,6 +5,7 @@ pub const FEE_PROCESSING_VERSION1: FeeProcessingVersion = FeeProcessingVersion { fetch_identity_revision_processing_cost: 9000, fetch_identity_balance_and_revision_processing_cost: 15000, fetch_identity_cost_per_look_up_key_by_id: 9000, + fetch_prefunded_specialized_balance_processing_cost: 10000, fetch_single_identity_key_processing_cost: 10000, validate_key_structure: 50, }; From 9ee09fb2967e10178087d48074f489e283d5c19f Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 12 May 2024 02:15:47 +0200 Subject: [PATCH 048/135] more work --- .../protos/platform/v0/platform.proto | 8 ++- .../proto/org.dash.platform.dapi.v0.rs | 16 ++--- .../rs-drive-abci/src/query/proofs/v0/mod.rs | 30 ++++++++- .../verify_state_transitions.rs | 62 +++++++++++-------- 4 files changed, 80 insertions(+), 36 deletions(-) diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index 9a4ecc5267..903837d25c 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -313,9 +313,11 @@ message GetProofsRequest { message VoteStatusRequest { message ContestedResourceVoteStatusRequest { - repeated bytes resource_path = 1; - bytes resource_identifier = 2; - bytes voter_identifier = 3; + bytes contract_id = 1; + string document_type_name = 2; + string index_name = 3; + repeated bytes index_values = 4; + bytes voter_identifier = 5; } oneof request_type { ContestedResourceVoteStatusRequest contested_resource_vote_status_request = 1; } diff --git a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs index 60ac13e953..beed50bb73 100644 --- a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs +++ b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs @@ -968,13 +968,15 @@ pub mod get_proofs_request { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ContestedResourceVoteStatusRequest { - #[prost(bytes = "vec", repeated, tag = "1")] - pub resource_path: ::prost::alloc::vec::Vec< - ::prost::alloc::vec::Vec, - >, - #[prost(bytes = "vec", tag = "2")] - pub resource_identifier: ::prost::alloc::vec::Vec, - #[prost(bytes = "vec", tag = "3")] + #[prost(bytes = "vec", tag = "1")] + pub contract_id: ::prost::alloc::vec::Vec, + #[prost(string, tag = "2")] + pub document_type_name: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub index_name: ::prost::alloc::string::String, + #[prost(bytes = "vec", repeated, tag = "4")] + pub index_values: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, + #[prost(bytes = "vec", tag = "5")] pub voter_identifier: ::prost::alloc::vec::Vec, } #[derive(::serde::Serialize, ::serde::Deserialize)] diff --git a/packages/rs-drive-abci/src/query/proofs/v0/mod.rs b/packages/rs-drive-abci/src/query/proofs/v0/mod.rs index c33d3301b7..e3c57fa0df 100644 --- a/packages/rs-drive-abci/src/query/proofs/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/proofs/v0/mod.rs @@ -19,7 +19,8 @@ impl Platform { GetProofsRequestV0 { identities, contracts, - documents, + documents, + votes, }: GetProofsRequestV0, platform_state: &PlatformState, platform_version: &PlatformVersion, @@ -90,10 +91,37 @@ impl Platform { }) .collect::, QueryError>>()); + let document_queries = check_validation_result_with_data!(votes + .into_iter() + .map(|vote_proof_request| { + let contract_id: Identifier = + document_proof_request.contract_id.try_into().map_err(|_| { + QueryError::InvalidArgument( + "id must be a valid identifier (32 bytes long)".to_string(), + ) + })?; + let document_id: Identifier = + document_proof_request.document_id.try_into().map_err(|_| { + QueryError::InvalidArgument( + "id must be a valid identifier (32 bytes long)".to_string(), + ) + })?; + + Ok(SingleDocumentDriveQuery { + contract_id: contract_id.into_buffer(), + document_type_name: document_proof_request.document_type, + document_type_keeps_history: document_proof_request.document_type_keeps_history, + document_id: document_id.into_buffer(), + block_time_ms: None, //None because we want latest + }) + }) + .collect::, QueryError>>()); + let proof = self.drive.prove_multiple_state_transition_results( &identity_requests, &contract_ids, &document_queries, + &vote_queries, None, platform_version, )?; diff --git a/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs b/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs index 694f6d9d98..612c4d1529 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs @@ -19,8 +19,13 @@ use drive_abci::execution::validation::state_transition::transformer::StateTrans use drive_abci::platform_types::platform::PlatformRef; use drive_abci::rpc::core::MockCoreRPCLike; use tenderdash_abci::proto::abci::ExecTxResult; +use dapi_grpc::platform::v0::get_proofs_request::get_proofs_request_v0::vote_status_request; +use dapi_grpc::platform::v0::get_proofs_request::get_proofs_request_v0::vote_status_request::RequestType; use dpp::state_transition::documents_batch_transition::accessors::DocumentsBatchTransitionAccessorsV0; +use dpp::voting::vote_polls::VotePoll; +use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; +use dpp::voting::votes::Vote; use drive::state_transition_action::document::documents_batch::document_transition::document_base_transition_action::DocumentBaseTransitionActionAccessorsV0; use drive::state_transition_action::document::documents_batch::document_transition::document_create_transition_action::DocumentFromCreateTransitionAction; use drive::state_transition_action::document::documents_batch::document_transition::document_purchase_transition_action::DocumentPurchaseTransitionActionAccessorsV0; @@ -101,6 +106,7 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed( identities: vec![], contracts: vec![], documents: vec![], + votes: vec![], }; if let Some(action) = action { @@ -719,23 +725,28 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed( StateTransitionAction::MasternodeVoteAction( masternode_vote_action, ) => { - proofs_request - .votes - .push(get_proofs_request_v0::VoteStatusRequest{ - request_type: Some(get_proofs_request_v0::vote_status_request::ContestedResourceVoteStatusRequest { - resource_path: vec![], - resource_identifier: vec![], - voter_identifier: vec![], - }) - }); - - proofs_request - .identities - .push(get_proofs_request_v0::IdentityRequest { - identity_id: identity_credit_transfer_action.recipient_id().to_vec(), - request_type: get_proofs_request_v0::identity_request::Type::Balance - .into(), - }); + match masternode_vote_action.vote_ref() { Vote::ResourceVote(resource_vote) => { + + match resource_vote.vote_poll() { VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll) => { + + let config = bincode::config::standard(); + let serialized_index_values = contested_document_resource_vote_poll.index_values.iter().map(|value| + bincode::encode_to_vec(value, config).expect("expected to encode value in path") + ).collect(); + + proofs_request + .votes + .push(get_proofs_request_v0::VoteStatusRequest{ + request_type: Some(RequestType::ContestedResourceVoteStatusRequest(vote_status_request::ContestedResourceVoteStatusRequest { + contract_id: contested_document_resource_vote_poll.contract_id.to_vec(), + document_type_name: contested_document_resource_vote_poll.document_type_name.clone(), + index_name: contested_document_resource_vote_poll.index_name.clone(), + voter_identifier: masternode_vote_action.pro_tx_hash().to_vec(), + index_values: serialized_index_values, + })) + }); + } } + } } let versioned_request = GetProofsRequest { version: Some(get_proofs_request::Version::V0(proofs_request)), @@ -750,27 +761,28 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed( let response_proof = response.proof_owned().expect("proof should be present"); // we expect to get a vote that matches the state transition - let (root_hash_identity, _balance_identity) = - Drive::verify_identity_balance_for_identity_id( + let (root_hash_vote, maybe_vote) = + Drive::verify_masternode_vote( &response_proof.grovedb_proof, - identity_credit_transfer_action.identity_id().into_buffer(), + masternode_vote_action.pro_tx_hash().into_buffer(), + masternode_vote_action.vote_ref(), true, platform_version, ) .expect("expected to verify balance identity"); assert_eq!( - &root_hash_identity, + &root_hash_vote, expected_root_hash, "state last block info {:?}", platform.state.last_committed_block_info() ); - + if *was_executed { - let balance_recipient = balance_recipient.expect("expected a balance"); + let vote = maybe_vote.expect("expected a vote"); - assert!( - balance_recipient >= identity_credit_transfer_action.transfer_amount() + assert_eq!( + &vote, masternode_vote_action.vote_ref() ); } } From 80227786143268c3b4c4efa1a29fdafab6ba5318 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 13 May 2024 01:09:47 +0200 Subject: [PATCH 049/135] finally compiles --- .../document_create_transition/v0/mod.rs | 2 +- .../mod.rs | 6 +- packages/rs-dpp/src/voting/vote_polls/mod.rs | 8 ++ .../types/execution_operation/mod.rs | 5 +- .../v0/mod.rs | 4 +- .../state_transition/transformer/mod.rs | 2 +- .../rs-drive-abci/src/query/proofs/v0/mod.rs | 75 +++++++++++++------ .../verify_state_transitions.rs | 62 ++++++++------- .../src/drive/batch/transitions/mod.rs | 5 +- packages/rs-drive/src/drive/mod.rs | 34 +-------- .../mod.rs | 4 +- .../v0/mod.rs | 17 ++++- packages/rs-drive/src/drive/votes/mod.rs | 12 ++- packages/rs-drive/src/drive/votes/paths.rs | 50 ++++++++----- packages/rs-drive/src/query/mod.rs | 4 + packages/rs-drive/src/query/vote_query.rs | 32 ++++++++ .../document_base_transition_action/v0/mod.rs | 1 - .../document/documents_batch/v0/mod.rs | 1 - .../src/state_transition_action/mod.rs | 2 +- 19 files changed, 211 insertions(+), 115 deletions(-) create mode 100644 packages/rs-drive/src/query/vote_query.rs diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs index 983f1ec358..9f6379d2b2 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs @@ -5,9 +5,9 @@ use bincode::{Decode, Encode}; #[cfg(feature = "state-transition-value-conversion")] use platform_value::btreemap_extensions::BTreeValueRemoveFromMapHelper; +use platform_value::{Identifier, Value}; #[cfg(feature = "state-transition-value-conversion")] use platform_value::{ValueMap, ValueMapHelper}; -use platform_value::{Identifier, Value}; #[cfg(feature = "state-transition-serde-conversion")] use serde::{Deserialize, Serialize}; diff --git a/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs b/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs index 5024c6eb77..6fe66c0c50 100644 --- a/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs +++ b/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs @@ -39,6 +39,10 @@ impl ContestedDocumentResourceVotePoll { } pub fn specialized_balance_id(&self) -> Result { - self.sha256_2_hash().map(|id| Identifier::new(id)) + self.unique_id() + } + + pub fn unique_id(&self) -> Result { + self.sha256_2_hash().map(Identifier::new) } } diff --git a/packages/rs-dpp/src/voting/vote_polls/mod.rs b/packages/rs-dpp/src/voting/vote_polls/mod.rs index 51cc55ab0d..576abdbb10 100644 --- a/packages/rs-dpp/src/voting/vote_polls/mod.rs +++ b/packages/rs-dpp/src/voting/vote_polls/mod.rs @@ -36,4 +36,12 @@ impl VotePoll { } } } + + pub fn unique_id(&self) -> Result { + match self { + VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll) => { + contested_document_resource_vote_poll.unique_id() + } + } + } } diff --git a/packages/rs-drive-abci/src/execution/types/execution_operation/mod.rs b/packages/rs-drive-abci/src/execution/types/execution_operation/mod.rs index a5b7968207..1eff457529 100644 --- a/packages/rs-drive-abci/src/execution/types/execution_operation/mod.rs +++ b/packages/rs-drive-abci/src/execution/types/execution_operation/mod.rs @@ -163,11 +163,11 @@ impl ValidationOperation { ))?; } ValidationOperation::RetrievePrefundedSpecializedBalance => { - let operation_cost = platform_version + let operation_cost = platform_version .fee_version .processing .fetch_prefunded_specialized_balance_processing_cost; - + fee_result.processing_fee = fee_result .processing_fee .checked_add(operation_cost) @@ -197,7 +197,6 @@ impl ValidationOperation { "execution processing fee overflow error", ))?; } - } } Ok(()) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_simple_pre_check_balance/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_simple_pre_check_balance/v0/mod.rs index 1d74659a4b..6f9cfb87ad 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_simple_pre_check_balance/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_simple_pre_check_balance/v0/mod.rs @@ -39,7 +39,9 @@ impl ValidateSimplePreCheckBalanceV0 for StateTransition { .state_transition_min_fees .document_batch_sub_transition } - StateTransition::IdentityCreate(_) | StateTransition::IdentityTopUp(_) | StateTransition::MasternodeVote(_) => 0, + StateTransition::IdentityCreate(_) + | StateTransition::IdentityTopUp(_) + | StateTransition::MasternodeVote(_) => 0, StateTransition::IdentityCreditWithdrawal(_) => { platform_version .fee_version diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/transformer/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/transformer/mod.rs index 97144b79ec..e078e0c8b6 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/transformer/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/transformer/mod.rs @@ -118,7 +118,7 @@ impl StateTransitionActionTransformerV0 for StateTransition { validation_mode, execution_context, tx, - ) + ), } } } diff --git a/packages/rs-drive-abci/src/query/proofs/v0/mod.rs b/packages/rs-drive-abci/src/query/proofs/v0/mod.rs index e3c57fa0df..ac01ac401c 100644 --- a/packages/rs-drive-abci/src/query/proofs/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/proofs/v0/mod.rs @@ -3,6 +3,7 @@ use crate::error::Error; use crate::platform_types::platform::Platform; use crate::platform_types::platform_state::PlatformState; use crate::query::QueryValidationResult; +use dapi_grpc::platform::v0::get_proofs_request::get_proofs_request_v0::vote_status_request::RequestType; use dapi_grpc::platform::v0::get_proofs_request::GetProofsRequestV0; use dapi_grpc::platform::v0::get_proofs_response::{get_proofs_response_v0, GetProofsResponseV0}; use dpp::check_validation_result_with_data; @@ -10,8 +11,9 @@ use dpp::platform_value::Bytes32; use dpp::prelude::Identifier; use dpp::validation::ValidationResult; use dpp::version::PlatformVersion; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use drive::drive::identity::{IdentityDriveQuery, IdentityProveRequestType}; -use drive::query::SingleDocumentDriveQuery; +use drive::query::{IdentityBasedVoteDriveQuery, SingleDocumentDriveQuery}; impl Platform { pub(super) fn query_proofs_v0( @@ -19,7 +21,7 @@ impl Platform { GetProofsRequestV0 { identities, contracts, - documents, + documents, votes, }: GetProofsRequestV0, platform_state: &PlatformState, @@ -91,29 +93,47 @@ impl Platform { }) .collect::, QueryError>>()); - let document_queries = check_validation_result_with_data!(votes + let vote_queries = check_validation_result_with_data!(votes .into_iter() - .map(|vote_proof_request| { - let contract_id: Identifier = - document_proof_request.contract_id.try_into().map_err(|_| { - QueryError::InvalidArgument( - "id must be a valid identifier (32 bytes long)".to_string(), - ) - })?; - let document_id: Identifier = - document_proof_request.document_id.try_into().map_err(|_| { - QueryError::InvalidArgument( - "id must be a valid identifier (32 bytes long)".to_string(), - ) - })?; - - Ok(SingleDocumentDriveQuery { - contract_id: contract_id.into_buffer(), - document_type_name: document_proof_request.document_type, - document_type_keeps_history: document_proof_request.document_type_keeps_history, - document_id: document_id.into_buffer(), - block_time_ms: None, //None because we want latest - }) + .filter_map(|vote_proof_request| { + if let Some(request_type) = vote_proof_request.request_type { + match request_type { + RequestType::ContestedResourceVoteStatusRequest(contested_resource_vote_status_request) => { + let identity_id = match contested_resource_vote_status_request.voter_identifier.try_into() { + Ok(identity_id) => identity_id, + Err(_) => return Some(Err(QueryError::InvalidArgument( + "voter_identifier must be a valid identifier (32 bytes long)".to_string(), + ))), + }; + let contract_id = match contested_resource_vote_status_request.contract_id.try_into() { + Ok(contract_id) => contract_id, + Err(_) => return Some(Err(QueryError::InvalidArgument( + "contract_id must be a valid identifier (32 bytes long)".to_string(), + ))), + }; + let document_type_name = contested_resource_vote_status_request.document_type_name; + let index_name = contested_resource_vote_status_request.index_name; + let index_values = match contested_resource_vote_status_request.index_values.into_iter().enumerate().map(|(pos,serialized_value)| + Ok(bincode::decode_from_slice(serialized_value.as_slice(), bincode::config::standard().with_big_endian() + .with_no_limit()).map_err(|_| QueryError::InvalidArgument( + format!("could not convert {:?} to a value in the index values at position {}", serialized_value, pos), + ))?.0) + ).collect::, QueryError>>() { + Ok(index_values) => index_values, + Err(e) => return Some(Err(e)), + }; + let vote_poll = ContestedDocumentResourceVotePoll { + contract_id, document_type_name, index_name, index_values, + }.into(); + Some(Ok(IdentityBasedVoteDriveQuery { + identity_id, + vote_poll, + })) + } + } + } else { + None + } }) .collect::, QueryError>>()); @@ -156,6 +176,7 @@ mod tests { }], contracts: vec![], documents: vec![], + votes: vec![], }; let result = platform @@ -178,6 +199,7 @@ mod tests { }], contracts: vec![], documents: vec![], + votes: vec![], }; let result = platform @@ -203,6 +225,7 @@ mod tests { contract_id: vec![0; 8], }], documents: vec![], + votes: vec![], }; let result = platform @@ -225,6 +248,7 @@ mod tests { document_type_keeps_history: false, document_id: vec![0; 32], }], + votes: vec![], }; let result = platform @@ -247,6 +271,7 @@ mod tests { document_type_keeps_history: false, document_id: vec![0; 8], }], + votes: vec![], }; let result = platform @@ -269,6 +294,7 @@ mod tests { document_type_keeps_history: false, document_id: vec![0; 32], }], + votes: vec![], }; let validation_result = platform @@ -299,6 +325,7 @@ mod tests { document_type_keeps_history: false, document_id: vec![1; 32], }], + votes: vec![], }; let validation_result = platform diff --git a/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs b/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs index 612c4d1529..a97437d19e 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs @@ -6,6 +6,8 @@ use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::document::{Document, DocumentV0Getters}; use dpp::identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV0; +use dapi_grpc::platform::v0::get_proofs_request::get_proofs_request_v0::vote_status_request; +use dapi_grpc::platform::v0::get_proofs_request::get_proofs_request_v0::vote_status_request::RequestType; use dpp::asset_lock::reduced_asset_lock_value::AssetLockValueGettersV0; use dpp::document::property_names::PRICE; use dpp::state_transition::StateTransition; @@ -19,8 +21,6 @@ use drive_abci::execution::validation::state_transition::transformer::StateTrans use drive_abci::platform_types::platform::PlatformRef; use drive_abci::rpc::core::MockCoreRPCLike; use tenderdash_abci::proto::abci::ExecTxResult; -use dapi_grpc::platform::v0::get_proofs_request::get_proofs_request_v0::vote_status_request; -use dapi_grpc::platform::v0::get_proofs_request::get_proofs_request_v0::vote_status_request::RequestType; use dpp::state_transition::documents_batch_transition::accessors::DocumentsBatchTransitionAccessorsV0; use dpp::voting::vote_polls::VotePoll; @@ -722,19 +722,25 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed( ); } } - StateTransitionAction::MasternodeVoteAction( - masternode_vote_action, - ) => { - match masternode_vote_action.vote_ref() { Vote::ResourceVote(resource_vote) => { - - match resource_vote.vote_poll() { VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll) => { - - let config = bincode::config::standard(); - let serialized_index_values = contested_document_resource_vote_poll.index_values.iter().map(|value| - bincode::encode_to_vec(value, config).expect("expected to encode value in path") - ).collect(); - - proofs_request + StateTransitionAction::MasternodeVoteAction(masternode_vote_action) => { + match masternode_vote_action.vote_ref() { + Vote::ResourceVote(resource_vote) => match resource_vote.vote_poll() { + VotePoll::ContestedDocumentResourceVotePoll( + contested_document_resource_vote_poll, + ) => { + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + let serialized_index_values = contested_document_resource_vote_poll + .index_values + .iter() + .map(|value| { + bincode::encode_to_vec(value, config) + .expect("expected to encode value in path") + }) + .collect(); + + proofs_request .votes .push(get_proofs_request_v0::VoteStatusRequest{ request_type: Some(RequestType::ContestedResourceVoteStatusRequest(vote_status_request::ContestedResourceVoteStatusRequest { @@ -745,8 +751,9 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed( index_values: serialized_index_values, })) }); - } } - } } + } + }, + } let versioned_request = GetProofsRequest { version: Some(get_proofs_request::Version::V0(proofs_request)), @@ -761,15 +768,14 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed( let response_proof = response.proof_owned().expect("proof should be present"); // we expect to get a vote that matches the state transition - let (root_hash_vote, maybe_vote) = - Drive::verify_masternode_vote( - &response_proof.grovedb_proof, - masternode_vote_action.pro_tx_hash().into_buffer(), - masternode_vote_action.vote_ref(), - true, - platform_version, - ) - .expect("expected to verify balance identity"); + let (root_hash_vote, maybe_vote) = Drive::verify_masternode_vote( + &response_proof.grovedb_proof, + masternode_vote_action.pro_tx_hash().into_buffer(), + masternode_vote_action.vote_ref(), + true, + platform_version, + ) + .expect("expected to verify balance identity"); assert_eq!( &root_hash_vote, @@ -781,9 +787,7 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed( if *was_executed { let vote = maybe_vote.expect("expected a vote"); - assert_eq!( - &vote, masternode_vote_action.vote_ref() - ); + assert_eq!(&vote, masternode_vote_action.vote_ref()); } } StateTransitionAction::BumpIdentityNonceAction(_) => {} diff --git a/packages/rs-drive/src/drive/batch/transitions/mod.rs b/packages/rs-drive/src/drive/batch/transitions/mod.rs index 743e9840eb..a8a7c9f55c 100644 --- a/packages/rs-drive/src/drive/batch/transitions/mod.rs +++ b/packages/rs-drive/src/drive/batch/transitions/mod.rs @@ -59,7 +59,9 @@ impl DriveHighLevelOperationConverter for StateTransitionAction { identity_credit_transfer_transition, ) => identity_credit_transfer_transition .into_high_level_drive_operations(epoch, platform_version), - StateTransitionAction::MasternodeVoteAction(masternode_vote_transition) => masternode_vote_transition.into_high_level_drive_operations(epoch, platform_version), + StateTransitionAction::MasternodeVoteAction(masternode_vote_transition) => { + masternode_vote_transition.into_high_level_drive_operations(epoch, platform_version) + } StateTransitionAction::BumpIdentityNonceAction(bump_identity_nonce_transition) => { bump_identity_nonce_transition .into_high_level_drive_operations(epoch, platform_version) @@ -72,7 +74,6 @@ impl DriveHighLevelOperationConverter for StateTransitionAction { partially_used_asset_lock_action, ) => partially_used_asset_lock_action .into_high_level_drive_operations(epoch, platform_version), - } } } diff --git a/packages/rs-drive/src/drive/mod.rs b/packages/rs-drive/src/drive/mod.rs index 42d9954ccb..4f56e0ab55 100644 --- a/packages/rs-drive/src/drive/mod.rs +++ b/packages/rs-drive/src/drive/mod.rs @@ -1,32 +1,3 @@ -// MIT LICENSE -// -// Copyright (c) 2021 Dash Core Group -// -// Permission is hereby granted, free of charge, to any -// person obtaining a copy of this software and associated -// documentation files (the "Software"), to deal in the -// Software without restriction, including without -// limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software -// is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice -// shall be included in all copies or substantial portions -// of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// - #[cfg(any(feature = "server", feature = "verify"))] use grovedb::GroveDb; @@ -95,7 +66,10 @@ mod prove; /// Contains a set of useful grovedb proof verification functions #[cfg(feature = "verify")] pub mod verify; -mod votes; + +/// Vote module +#[cfg(any(feature = "server", feature = "verify"))] +pub mod votes; #[cfg(feature = "server")] use crate::drive::cache::DriveCache; diff --git a/packages/rs-drive/src/drive/prove/prove_multiple_state_transition_results/mod.rs b/packages/rs-drive/src/drive/prove/prove_multiple_state_transition_results/mod.rs index 0840b1199e..309cecc47e 100644 --- a/packages/rs-drive/src/drive/prove/prove_multiple_state_transition_results/mod.rs +++ b/packages/rs-drive/src/drive/prove/prove_multiple_state_transition_results/mod.rs @@ -2,7 +2,7 @@ use crate::drive::identity::IdentityDriveQuery; use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; -use crate::query::SingleDocumentDriveQuery; +use crate::query::{IdentityBasedVoteDriveQuery, SingleDocumentDriveQuery}; use dpp::version::PlatformVersion; use grovedb::TransactionArg; @@ -33,6 +33,7 @@ impl Drive { identity_queries: &[IdentityDriveQuery], contract_ids: &[([u8; 32], Option)], //bool represents if it is historical document_queries: &[SingleDocumentDriveQuery], + vote_queries: &[IdentityBasedVoteDriveQuery], transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { @@ -46,6 +47,7 @@ impl Drive { identity_queries, contract_ids, document_queries, + vote_queries, transaction, platform_version, ), diff --git a/packages/rs-drive/src/drive/prove/prove_multiple_state_transition_results/v0/mod.rs b/packages/rs-drive/src/drive/prove/prove_multiple_state_transition_results/v0/mod.rs index f4267de0ea..f3b94b3609 100644 --- a/packages/rs-drive/src/drive/prove/prove_multiple_state_transition_results/v0/mod.rs +++ b/packages/rs-drive/src/drive/prove/prove_multiple_state_transition_results/v0/mod.rs @@ -2,7 +2,7 @@ use crate::drive::identity::{IdentityDriveQuery, IdentityProveRequestType}; use crate::drive::Drive; use crate::error::query::QuerySyntaxError; use crate::error::Error; -use crate::query::SingleDocumentDriveQuery; +use crate::query::{IdentityBasedVoteDriveQuery, SingleDocumentDriveQuery}; use dpp::version::PlatformVersion; use grovedb::{PathQuery, TransactionArg}; @@ -17,6 +17,8 @@ impl Drive { /// - `contract_ids`: A list of Data Contract IDs to prove /// - `document_queries`: A list of [SingleDocumentDriveQuery]. These specify the documents /// to be proven. + /// - `vote_queries`: A list of [IdentityBasedVoteDriveQuery]. These would be to figure out the + /// result of votes based on identities making them. /// - `transaction`: An optional grovedb transaction /// - `platform_version`: A reference to the [PlatformVersion] object that specifies the version of /// the function to call. @@ -30,6 +32,7 @@ impl Drive { identity_queries: &[IdentityDriveQuery], contract_ids: &[([u8; 32], Option)], //bool is history document_queries: &[SingleDocumentDriveQuery], + vote_queries: &[IdentityBasedVoteDriveQuery], transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { @@ -94,6 +97,18 @@ impl Drive { })); count += document_queries.len(); } + + if !vote_queries.is_empty() { + path_queries.extend(vote_queries.iter().filter_map(|vote_query| { + // The path query construction can only fail if the serialization fails. + // Because the serialization will pretty much never fail, we can do this. + let mut path_query = vote_query.construct_path_query().ok()?; + path_query.query.limit = None; + Some(path_query) + })); + count += path_queries.len(); + } + let verbose = match count { 0 => { return Err(Error::Query(QuerySyntaxError::NoQueryItems( diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index afd3080352..57bd9838a8 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -8,12 +8,22 @@ use dpp::voting::votes::resource_vote::ResourceVote; use dpp::voting::votes::Vote; use dpp::ProtocolError; +#[cfg(feature = "server")] mod cleanup; + +#[cfg(feature = "server")] mod insert; -mod paths; + +/// Paths important for the module +#[cfg(any(feature = "server", feature = "verify"))] +pub mod paths; + +#[cfg(feature = "server")] mod setup; +/// A trait to convert the vote to a tree path usable in grovedb pub trait TreePath { + /// The tree path function fn tree_path<'a>(&'a self, contract: &'a DataContract) -> Result, ProtocolError>; } diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index ca2c49ccc3..22bf8c8941 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -12,52 +12,62 @@ use dpp::identity::TimestampMillis; /// /// +/// A subtree made for polls to the network that represent decisions. pub const VOTE_DECISIONS_TREE_KEY: char = 'd'; +/// A subtree made for contested resources that will be voted on. pub const CONTESTED_RESOURCE_TREE_KEY: char = 'c'; +/// A subtree made for being able to query the end date of votes pub const END_DATE_QUERIES_TREE_KEY: char = 'e'; +/// A subtree made for being able to query votes that an identity has made pub const IDENTITY_VOTES_TREE_KEY: char = 'i'; -pub(in crate::drive::votes) fn vote_root_path<'a>() -> [&'a [u8]; 1] { +/// the root path of the voting branch +pub fn vote_root_path<'a>() -> [&'a [u8]; 1] { [Into::<&[u8; 1]>::into(RootTree::Votes)] } -pub(in crate::drive::votes) fn vote_root_path_vec() -> Vec> { +/// the root path of the voting branch as a vec +pub fn vote_root_path_vec() -> Vec> { vec![vec![RootTree::Votes as u8]] } -pub(in crate::drive::votes) fn vote_decisions_tree_path<'a>() -> [&'a [u8]; 2] { +/// the decisions path of the voting branch +pub fn vote_decisions_tree_path<'a>() -> [&'a [u8]; 2] { [ Into::<&[u8; 1]>::into(RootTree::Votes), &[VOTE_DECISIONS_TREE_KEY as u8], ] } -pub(in crate::drive::votes) fn vote_decisions_tree_path_vec() -> Vec> { +/// the decisions path of the voting branch as a vec +pub fn vote_decisions_tree_path_vec() -> Vec> { vec![ vec![RootTree::Votes as u8], vec![VOTE_DECISIONS_TREE_KEY as u8], ] } -pub(in crate::drive::votes) fn vote_contested_resource_tree_path<'a>() -> [&'a [u8]; 2] { +/// the contested resource tree path of the voting branch +pub fn vote_contested_resource_tree_path<'a>() -> [&'a [u8]; 2] { [ Into::<&[u8; 1]>::into(RootTree::Votes), &[CONTESTED_RESOURCE_TREE_KEY as u8], ] } -pub(in crate::drive::votes) fn vote_contested_resource_tree_path_vec() -> Vec> { +/// the contested resource tree path of the voting branch as a vec +pub fn vote_contested_resource_tree_path_vec() -> Vec> { vec![ vec![RootTree::Votes as u8], vec![CONTESTED_RESOURCE_TREE_KEY as u8], ] } -pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_tree_path<'a>( -) -> [&'a [u8]; 3] { +/// the end dates of contested resources +pub fn vote_contested_resource_end_date_queries_tree_path<'a>() -> [&'a [u8]; 3] { [ Into::<&[u8; 1]>::into(RootTree::Votes), &[CONTESTED_RESOURCE_TREE_KEY as u8], @@ -65,8 +75,8 @@ pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_tree_pat ] } -pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_tree_path_vec( -) -> Vec> { +/// the end dates of contested resources as a vec +pub fn vote_contested_resource_end_date_queries_tree_path_vec() -> Vec> { vec![ vec![RootTree::Votes as u8], vec![CONTESTED_RESOURCE_TREE_KEY as u8], @@ -74,7 +84,9 @@ pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_tree_pat ] } -pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_at_time_tree_path_vec( +/// the specific end date path query of a contested resources as a vec +/// there is no need to ever add a key to this +pub fn vote_contested_resource_end_date_queries_at_time_tree_path_vec( time: TimestampMillis, ) -> Vec> { vec![ @@ -85,8 +97,8 @@ pub(in crate::drive::votes) fn vote_contested_resource_end_date_queries_at_time_ ] } -pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path<'a>( -) -> [&'a [u8]; 3] { +/// the identity votes of contested resources +pub fn vote_contested_resource_identity_votes_tree_path<'a>() -> [&'a [u8]; 3] { [ Into::<&[u8; 1]>::into(RootTree::Votes), &[CONTESTED_RESOURCE_TREE_KEY as u8], @@ -94,8 +106,8 @@ pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path< ] } -pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_vec() -> Vec> -{ +/// the identity votes of contested resources as a vec +pub fn vote_contested_resource_identity_votes_tree_path_vec() -> Vec> { vec![ vec![RootTree::Votes as u8], vec![CONTESTED_RESOURCE_TREE_KEY as u8], @@ -103,7 +115,9 @@ pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_ ] } -pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_for_identity( +/// the qualified identity vote of contested resources +/// this is with the identity id at the end already +pub fn vote_contested_resource_identity_votes_tree_path_for_identity( identity_id: &[u8; 32], ) -> [&[u8]; 4] { [ @@ -114,7 +128,9 @@ pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_ ] } -pub(in crate::drive::votes) fn vote_contested_resource_identity_votes_tree_path_for_identity_vec( +/// the qualified identity vote of contested resources as a vec +/// this is with the identity id at the end already +pub fn vote_contested_resource_identity_votes_tree_path_for_identity_vec( identity_id: &[u8; 32], ) -> Vec> { vec![ diff --git a/packages/rs-drive/src/query/mod.rs b/packages/rs-drive/src/query/mod.rs index 5db17e742c..da2e9b7aa5 100644 --- a/packages/rs-drive/src/query/mod.rs +++ b/packages/rs-drive/src/query/mod.rs @@ -4,6 +4,7 @@ pub use { grovedb::{PathQuery, Query, QueryItem, SizedQuery}, ordering::OrderClause, single_document_drive_query::SingleDocumentDriveQuery, + vote_query::IdentityBasedVoteDriveQuery, }; // Imports available when either "server" or "verify" features are enabled #[cfg(any(feature = "server", feature = "verify"))] @@ -72,6 +73,9 @@ mod single_document_drive_query; #[cfg(feature = "server")] mod test_index; +#[cfg(any(feature = "server", feature = "verify"))] +mod vote_query; + #[cfg(any(feature = "server", feature = "verify"))] /// Internal clauses struct #[derive(Clone, Debug, PartialEq, Default)] diff --git a/packages/rs-drive/src/query/vote_query.rs b/packages/rs-drive/src/query/vote_query.rs new file mode 100644 index 0000000000..e6fb7863c5 --- /dev/null +++ b/packages/rs-drive/src/query/vote_query.rs @@ -0,0 +1,32 @@ +use crate::drive::votes::paths::vote_contested_resource_identity_votes_tree_path_for_identity_vec; +use crate::error::Error; +use crate::query::Query; +use dpp::identifier::Identifier; +use dpp::voting::vote_polls::VotePoll; +use grovedb::{PathQuery, SizedQuery}; + +/// Vote Drive Query struct +#[derive(Debug, PartialEq, Clone)] +pub struct IdentityBasedVoteDriveQuery { + /// The identity who would have made the vote + pub identity_id: Identifier, + /// What vote poll are we asking for? + pub vote_poll: VotePoll, +} + +impl IdentityBasedVoteDriveQuery { + /// Operations to construct a path query. + pub fn construct_path_query(&self) -> Result { + // First we should get the overall document_type_path + let path = vote_contested_resource_identity_votes_tree_path_for_identity_vec( + self.identity_id.as_bytes(), + ); + + let vote_id = self.vote_poll.unique_id()?; + + let mut query = Query::new(); + query.insert_key(vote_id.to_vec()); + + Ok(PathQuery::new(path, SizedQuery::new(query, Some(1), None))) + } +} diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/v0/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/v0/mod.rs index 39677e22ac..4027d10d8e 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_base_transition_action/v0/mod.rs @@ -9,7 +9,6 @@ use dpp::prelude::IdentityNonce; use dpp::ProtocolError; use crate::drive::contract::DataContractFetchInfo; -use crate::state_transition_action::document::documents_batch::document_transition::document_base_transition_action::DocumentBaseTransitionAction; #[derive(Debug, Clone)] /// document base transition action v0 diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs index b93000b15b..36c7fd6434 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs @@ -5,7 +5,6 @@ use dpp::prelude::UserFeeIncrease; use dpp::ProtocolError; use crate::state_transition_action::document::documents_batch::document_transition::document_create_transition_action::DocumentCreateTransitionActionAccessorsV0; use crate::state_transition_action::document::documents_batch::document_transition::document_purchase_transition_action::DocumentPurchaseTransitionActionAccessorsV0; -use crate::state_transition_action::document::documents_batch::DocumentsBatchTransitionAction; /// action v0 #[derive(Default, Debug, Clone)] diff --git a/packages/rs-drive/src/state_transition_action/mod.rs b/packages/rs-drive/src/state_transition_action/mod.rs index 5c2a38f457..824d39fdb9 100644 --- a/packages/rs-drive/src/state_transition_action/mod.rs +++ b/packages/rs-drive/src/state_transition_action/mod.rs @@ -16,6 +16,7 @@ use crate::state_transition_action::identity::identity_credit_transfer::Identity use crate::state_transition_action::identity::identity_credit_withdrawal::IdentityCreditWithdrawalTransitionAction; use crate::state_transition_action::identity::identity_topup::IdentityTopUpTransitionAction; use crate::state_transition_action::identity::identity_update::IdentityUpdateTransitionAction; +use crate::state_transition_action::identity::masternode_vote::MasternodeVoteTransitionAction; use crate::state_transition_action::system::bump_identity_data_contract_nonce_action::{ BumpIdentityDataContractNonceAction, BumpIdentityDataContractNonceActionAccessorsV0, }; @@ -27,7 +28,6 @@ use crate::state_transition_action::system::partially_use_asset_lock_action::{ }; use derive_more::From; use dpp::prelude::UserFeeIncrease; -use crate::state_transition_action::identity::masternode_vote::MasternodeVoteTransitionAction; /// ST action #[derive(Debug, Clone, From)] From 5c21022ec9c7f01cd3aca81efe59380429a68e85 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 13 May 2024 06:21:43 +0200 Subject: [PATCH 050/135] small --- .../create_genesis_state/v0/mod.rs | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs index 73795a0aab..9066561cd3 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs @@ -1,31 +1,3 @@ -// MIT LICENSE -// -// Copyright (c) 2021 Dash Core Group -// -// Permission is hereby granted, free of charge, to any -// person obtaining a copy of this software and associated -// documentation files (the "Software"), to deal in the -// Software without restriction, including without -// limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software -// is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice -// shall be included in all copies or substantial portions -// of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - use crate::error::Error; use crate::platform_types::platform::Platform; From 25ec93a97b080525f4bc3788865e0f747ef950d9 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 13 May 2024 08:11:15 +0200 Subject: [PATCH 051/135] more work --- .../document_type/index_level/mod.rs | 10 + .../find_duplicates_by_id/v0/mod.rs | 1 + .../traits/state_transition_like.rs | 10 + packages/rs-dpp/src/util/json_schema.rs | 22 +- .../tests/strategy_tests/main.rs | 8 +- .../v0/mod.rs | 292 ++++-------------- packages/rs-drive/src/query/test_index.rs | 2 +- .../data_contract_create_transition/mod.rs | 5 + .../data_contract_update_transition/mod.rs | 5 + .../document_batch_transition/mod.rs | 5 + .../src/errors/consensus/consensus_error.rs | 12 + .../identity_create_transition.rs | 5 + .../transition.rs | 5 + .../transition.rs | 5 + .../identity_topup_transition.rs | 5 + .../identity_update_transition.rs | 5 + packages/wasm-dpp/src/lib.rs | 2 + .../state_transition_factory.rs | 4 + packages/wasm-dpp/src/voting/mod.rs | 1 + .../masternode_vote_transition/mod.rs | 292 ++++++++++++++++++ .../masternode_vote_transition/to_object.rs | 47 +++ .../src/voting/state_transition/mod.rs | 1 + 22 files changed, 494 insertions(+), 250 deletions(-) create mode 100644 packages/wasm-dpp/src/voting/mod.rs create mode 100644 packages/wasm-dpp/src/voting/state_transition/masternode_vote_transition/mod.rs create mode 100644 packages/wasm-dpp/src/voting/state_transition/masternode_vote_transition/to_object.rs create mode 100644 packages/wasm-dpp/src/voting/state_transition/mod.rs diff --git a/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs b/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs index 2ab4ae37c8..0118b359f3 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs @@ -25,6 +25,16 @@ pub enum IndexType { ContestedResourceIndex, } +impl IndexType { + pub fn is_unique(&self) -> bool { + match self { + NonUniqueIndex => false, + UniqueIndex => true, + ContestedResourceIndex => true, + } + } +} + #[derive(Debug, PartialEq, Clone)] pub struct IndexLevel { /// the lower index levels from this level diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/validation/find_duplicates_by_id/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/validation/find_duplicates_by_id/v0/mod.rs index 14409746e4..bbf434383d 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/validation/find_duplicates_by_id/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/validation/find_duplicates_by_id/v0/mod.rs @@ -72,6 +72,7 @@ mod test { }), entropy: Default::default(), data: Default::default(), + prefunded_voting_balances: Default::default(), })); let create_transition_duplicate = create_transition.clone(); diff --git a/packages/rs-dpp/src/state_transition/traits/state_transition_like.rs b/packages/rs-dpp/src/state_transition/traits/state_transition_like.rs index a1d78449be..678c21ee10 100644 --- a/packages/rs-dpp/src/state_transition/traits/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/traits/state_transition_like.rs @@ -19,6 +19,10 @@ pub const IDENTITY_TRANSITION_TYPE: [StateTransitionType; 5] = [ StateTransitionType::IdentityCreditWithdrawal, ]; +pub const VOTING_TRANSITION_TYPE: [StateTransitionType; 1] = [ + StateTransitionType::MasternodeVote, +]; + pub const DATA_CONTRACT_TRANSITION_TYPES: [StateTransitionType; 2] = [ StateTransitionType::DataContractCreate, StateTransitionType::DataContractUpdate, @@ -57,6 +61,12 @@ pub trait StateTransitionLike: IDENTITY_TRANSITION_TYPE.contains(&self.state_transition_type()) } + /// return true if state transition is a voting state transition + fn is_voting_state_transition(&self) -> bool { + VOTING_TRANSITION_TYPE.contains(&self.state_transition_type()) + } + + fn set_signature_bytes(&mut self, signature: Vec); /// Get owner ID diff --git a/packages/rs-dpp/src/util/json_schema.rs b/packages/rs-dpp/src/util/json_schema.rs index c0d3aa2926..5974f0771c 100644 --- a/packages/rs-dpp/src/util/json_schema.rs +++ b/packages/rs-dpp/src/util/json_schema.rs @@ -223,16 +223,16 @@ mod test { assert_eq!(indices.len(), 2); - assert_eq!(indices[0].name, "&ownerId"); - assert_eq!(indices[0].properties.len(), 1); - assert_eq!(indices[0].properties[0].name, "$ownerId"); - assert!(indices[0].properties[0].ascending); - assert!(indices[0].unique); - - assert_eq!(indices[1].name, "&ownerId&updatedAt"); - assert_eq!(indices[1].properties.len(), 2); - assert_eq!(indices[1].properties[0].name, "$ownerId"); - assert_eq!(indices[1].properties[1].name, "$updatedAt"); - assert!(!indices[1].unique); + assert_eq!(indices["&ownerId"].name, "&ownerId"); + assert_eq!(indices["&ownerId"].properties.len(), 1); + assert_eq!(indices["&ownerId"].properties[0].name, "$ownerId"); + assert!(indices["&ownerId"].properties[0].ascending); + assert!(indices["&ownerId"].unique); + + assert_eq!(indices["&ownerId&updatedAt"].name, "&ownerId&updatedAt"); + assert_eq!(indices["&ownerId&updatedAt"].properties.len(), 2); + assert_eq!(indices["&ownerId&updatedAt"].properties[0].name, "$ownerId"); + assert_eq!(indices["&ownerId&updatedAt"].properties[1].name, "$updatedAt"); + assert!(!indices["&ownerId&updatedAt"].unique); } } diff --git a/packages/rs-drive-abci/tests/strategy_tests/main.rs b/packages/rs-drive-abci/tests/strategy_tests/main.rs index 8084abddfe..12a1a0a38a 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/main.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/main.rs @@ -499,7 +499,7 @@ mod tests { .expect("expected to fetch balances") .expect("expected to have an identity to get balance from"); - assert_eq!(balance, 99864825980) + assert_eq!(balance, 99864759120) } #[test] @@ -1089,7 +1089,7 @@ mod tests { .unwrap() .unwrap() ), - "3beaf287fb5fb712715e688ef3cf642e3e4042270907ebd022050b06af0cb433".to_string() + "0c39624d8a3ccc771f51dad46587eb1d09b4e233e2ecd94219f20b07f847fddf".to_string() ) } @@ -1779,7 +1779,7 @@ mod tests { .unwrap() .unwrap() ), - "10fbe38850d752b491305b2587468788acbd6dd130272c5a8844d0da05e3a9cf".to_string() + "22c1172ba1d91488baa590a8b295e888061a6d6a5a3d5133749716a129f78d36".to_string() ) } @@ -1904,7 +1904,7 @@ mod tests { .unwrap() .unwrap() ), - "9ed86b1ed5d0f7a981cb0ff2f3943603a095a031c463b3389bce8a6f60e2b21e".to_string() + "995aefbcf840432bf6dd038765a76d16f2c3860dcef0c98641794e94896e71ae".to_string() ) } diff --git a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs index 8a790370e0..e5ed38088d 100644 --- a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -16,14 +16,12 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; use dpp::data_contract::document_type::IndexType; -use dpp::data_contract::document_type::IndexType::{ContestedResourceIndex, NonUniqueIndex}; use dpp::document::DocumentV0Getters; use dpp::version::drive_versions::DriveVersion; use grovedb::batch::key_info::KeyInfo; use grovedb::batch::KeyInfoPath; use grovedb::EstimatedLayerCount::PotentiallyAtMaxElements; -use grovedb::EstimatedLayerSizes::{AllReference, AllSubtrees}; -use grovedb::EstimatedSumTrees::NoSumTrees; +use grovedb::EstimatedLayerSizes::AllReference; use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; @@ -47,9 +45,9 @@ impl Drive { ) -> Result<(), Error> { // unique indexes will be stored under key "0" // non unique indices should have a tree at key "0" that has all elements based off of primary key - if index_type == NonUniqueIndex || index_type == ContestedResourceIndex || any_fields_null { + if !index_type.is_unique() || any_fields_null { // Tree generation, this happens for both non unique indexes, unique indexes with a null inside - // a member of the path and for contested resource indexes + // a member of the path let key_path_info = KeyRef(&[0]); let path_key_info = key_path_info.add_path_info(index_path_info.clone()); @@ -82,241 +80,67 @@ impl Drive { )?; index_path_info.push(Key(vec![0]))?; + // This is the simpler situation + // Under each tree we have all the references + + if let Some(estimated_costs_only_with_layer_info) = + estimated_costs_only_with_layer_info + { + // On this level we will have a 0 and all the top index paths + estimated_costs_only_with_layer_info.insert( + index_path_info.clone().convert_to_key_info_path(), + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: PotentiallyAtMaxElements, + estimated_layer_sizes: AllReference( + DEFAULT_HASH_SIZE_U8, + document_reference_size(document_and_contract_info.document_type), + storage_flags.map(|s| s.serialized_size()), + ), + }, + ); + } - if index_type != ContestedResourceIndex { - // This is the simpler situation - // Under each tree we have all the references - - if let Some(estimated_costs_only_with_layer_info) = - estimated_costs_only_with_layer_info - { - // On this level we will have a 0 and all the top index paths - estimated_costs_only_with_layer_info.insert( - index_path_info.clone().convert_to_key_info_path(), - EstimatedLayerInformation { - is_sum_tree: false, - estimated_layer_count: PotentiallyAtMaxElements, - estimated_layer_sizes: AllReference( - DEFAULT_HASH_SIZE_U8, - document_reference_size(document_and_contract_info.document_type), - storage_flags.map(|s| s.serialized_size()), - ), - }, - ); - } - - let key_element_info = - match &document_and_contract_info.owned_document_info.document_info { - DocumentRefAndSerialization((document, _, storage_flags)) - | DocumentRefInfo((document, storage_flags)) => { - let document_reference = make_document_reference( - document, - document_and_contract_info.document_type, - storage_flags.as_ref().map(|flags| flags.as_ref()), - ); - KeyElement((document.id_ref().as_slice(), document_reference)) - } - DocumentOwnedInfo((document, storage_flags)) - | DocumentAndSerialization((document, _, storage_flags)) => { - let document_reference = make_document_reference( - document, - document_and_contract_info.document_type, - storage_flags.as_ref().map(|flags| flags.as_ref()), - ); - KeyElement((document.id_ref().as_slice(), document_reference)) - } - DocumentEstimatedAverageSize(max_size) => KeyUnknownElementSize(( - KeyInfo::MaxKeySize { - unique_id: document_and_contract_info - .document_type - .unique_id_for_storage() - .to_vec(), - max_size: DEFAULT_HASH_SIZE_U8, - }, - Element::required_item_space(*max_size, STORAGE_FLAGS_SIZE), - )), - }; - - let path_key_element_info = PathKeyElementInfo::from_path_info_and_key_element( - index_path_info, - key_element_info, - )?; - - // here we should return an error if the element already exists - self.batch_insert(path_key_element_info, batch_operations, drive_version)?; - } else { - // Contested Resource Index - // Under each tree we have all identifiers of identities that want the contested resource - // We get something like - // item name contested (there will be another path with item_name) - // | - // Goblet of Fire - // | - // 0 (for the termination of the index) - // / \ - // Sam's Document Id Ivan's Document Id - // / \ / \ - // 0 (ref) 1 (sum tree) 0 (ref) 1 (sum tree) - // - - // Here we are getting the document id and the reference - let (document_id, ref_key_element_info) = - match &document_and_contract_info.owned_document_info.document_info { - DocumentRefAndSerialization((document, _, storage_flags)) - | DocumentRefInfo((document, storage_flags)) => { - let document_reference = make_document_reference( - document, - document_and_contract_info.document_type, - storage_flags.as_ref().map(|flags| flags.as_ref()), - ); - (document.id(), KeyElement((&[0], document_reference))) - } - DocumentOwnedInfo((document, storage_flags)) - | DocumentAndSerialization((document, _, storage_flags)) => { - let document_reference = make_document_reference( - document, - document_and_contract_info.document_type, - storage_flags.as_ref().map(|flags| flags.as_ref()), - ); - (document.id(), KeyElement((&[0], document_reference))) - } - DocumentEstimatedAverageSize(max_size) => { - let unique_id = document_and_contract_info + let key_element_info = + match &document_and_contract_info.owned_document_info.document_info { + DocumentRefAndSerialization((document, _, storage_flags)) + | DocumentRefInfo((document, storage_flags)) => { + let document_reference = make_document_reference( + document, + document_and_contract_info.document_type, + storage_flags.as_ref().map(|flags| flags.as_ref()), + ); + KeyElement((document.id_ref().as_slice(), document_reference)) + } + DocumentOwnedInfo((document, storage_flags)) + | DocumentAndSerialization((document, _, storage_flags)) => { + let document_reference = make_document_reference( + document, + document_and_contract_info.document_type, + storage_flags.as_ref().map(|flags| flags.as_ref()), + ); + KeyElement((document.id_ref().as_slice(), document_reference)) + } + DocumentEstimatedAverageSize(max_size) => KeyUnknownElementSize(( + KeyInfo::MaxKeySize { + unique_id: document_and_contract_info .document_type - .unique_id_for_storage(); - let unique_id_vec = unique_id.to_vec(); - ( - unique_id.into(), - KeyUnknownElementSize(( - KeyInfo::MaxKeySize { - unique_id: unique_id_vec, - max_size: DEFAULT_HASH_SIZE_U8, - }, - Element::required_item_space(*max_size, STORAGE_FLAGS_SIZE), - )), - ) - } - }; - - // Let's start by inserting the document id tree - - // here we are the tree that will contain the ref - // We are inserting this at item name contested / Goblet of Fire / 0 with the key of - // document_key_path_info - - let document_id_key_path_info = KeyRef(document_id.as_slice()); - - let path_key_info = - document_id_key_path_info.add_path_info(index_path_info.clone()); - - index_path_info.push(Key(document_id.to_vec()))?; - - // We check to make sure we are not overridding the tree - let inserted = self.batch_insert_empty_tree_if_not_exists( - path_key_info, - false, - *storage_flags, - apply_type, - transaction, - previous_batch_operations, - batch_operations, - drive_version, - )?; - - if !inserted { - return Err(Error::Drive(DriveError::CorruptedContractIndexes( - "contested votes sub tree document already exists", - ))); - } - - let mut document_path_info = index_path_info.clone(); - - document_path_info.push(KeyRef(document_id.as_slice()))?; - - let votes_key_path_info = KeyRef(&[1]); - - let votes_path_key_info = - votes_key_path_info.add_path_info(document_path_info.clone()); - - if let Some(estimated_costs_only_with_layer_info) = - estimated_costs_only_with_layer_info - { - // On this level we will have a 0 and all the top index paths - estimated_costs_only_with_layer_info.insert( - index_path_info.clone().convert_to_key_info_path(), - EstimatedLayerInformation { - is_sum_tree: false, - estimated_layer_count: PotentiallyAtMaxElements, - estimated_layer_sizes: AllSubtrees( - DEFAULT_HASH_SIZE_U8, - NoSumTrees, - storage_flags.map(|s| s.serialized_size()), - ), - }, - ); - - // On this level we will have a 0 and all the top index paths - estimated_costs_only_with_layer_info.insert( - votes_path_key_info.clone().convert_to_key_info_path()?, - EstimatedLayerInformation { - is_sum_tree: false, - estimated_layer_count: PotentiallyAtMaxElements, - estimated_layer_sizes: AllSubtrees( - DEFAULT_HASH_SIZE_U8, - NoSumTrees, - storage_flags.map(|s| s.serialized_size()), - ), + .unique_id_for_storage() + .to_vec(), + max_size: DEFAULT_HASH_SIZE_U8, }, - ); - } - - let reference_path_key_element_info = - PathKeyElementInfo::from_path_info_and_key_element( - document_path_info.clone(), - ref_key_element_info, - )?; - - // here we are inserting the ref - self.batch_insert( - reference_path_key_element_info, - batch_operations, - drive_version, - )?; - - let apply_type = if estimated_costs_only_with_layer_info.is_none() { - BatchInsertTreeApplyType::StatefulBatchInsertTree - } else { - BatchInsertTreeApplyType::StatelessBatchInsertTree { - in_tree_using_sums: false, - is_sum_tree: true, - flags_len: storage_flags - .map(|s| s.serialized_size()) - .unwrap_or_default(), - } + Element::required_item_space(*max_size, STORAGE_FLAGS_SIZE), + )), }; - // here we are the tree that will contain the voting tree - let inserted = self.batch_insert_empty_tree_if_not_exists( - votes_path_key_info, - true, - *storage_flags, - apply_type, - transaction, - &mut None, - batch_operations, - drive_version, - )?; - - if !inserted { - return Err(Error::Drive(DriveError::CorruptedContractIndexes( - "contested votes tree already exists", - ))); - } - - // Now we need to add a reference to this votes, so we can keep track of it more easily + let path_key_element_info = PathKeyElementInfo::from_path_info_and_key_element( + index_path_info, + key_element_info, + )?; - // self.add_new_masternode_vote_type() - } + // here we should return an error if the element already exists + self.batch_insert(path_key_element_info, batch_operations, drive_version)?; + } else { let key_element_info = match &document_and_contract_info.owned_document_info.document_info { diff --git a/packages/rs-drive/src/query/test_index.rs b/packages/rs-drive/src/query/test_index.rs index 995f21eb97..2e00959b7c 100644 --- a/packages/rs-drive/src/query/test_index.rs +++ b/packages/rs-drive/src/query/test_index.rs @@ -136,7 +136,7 @@ mod tests { let index = query .find_best_index(platform_version) .expect("expected to find index"); - assert_eq!(index, document_type.indexes().first().unwrap()); + assert_eq!(index, document_type.indexes().iter().next().unwrap().1); } #[test] diff --git a/packages/wasm-dpp/src/data_contract/state_transition/data_contract_create_transition/mod.rs b/packages/wasm-dpp/src/data_contract/state_transition/data_contract_create_transition/mod.rs index 9a7aca12b9..536995f2b1 100644 --- a/packages/wasm-dpp/src/data_contract/state_transition/data_contract_create_transition/mod.rs +++ b/packages/wasm-dpp/src/data_contract/state_transition/data_contract_create_transition/mod.rs @@ -141,6 +141,11 @@ impl DataContractCreateTransitionWasm { self.0.is_identity_state_transition() } + #[wasm_bindgen(js_name=isVotingStateTransition)] + pub fn is_voting_state_transition(&self) -> bool { + self.0.is_voting_state_transition() + } + #[wasm_bindgen(js_name=toObject)] pub fn to_object(&self, skip_signature: Option) -> Result { let serde_object = self diff --git a/packages/wasm-dpp/src/data_contract/state_transition/data_contract_update_transition/mod.rs b/packages/wasm-dpp/src/data_contract/state_transition/data_contract_update_transition/mod.rs index bc76954ccd..02fa59c0b1 100644 --- a/packages/wasm-dpp/src/data_contract/state_transition/data_contract_update_transition/mod.rs +++ b/packages/wasm-dpp/src/data_contract/state_transition/data_contract_update_transition/mod.rs @@ -132,6 +132,11 @@ impl DataContractUpdateTransitionWasm { self.0.is_identity_state_transition() } + #[wasm_bindgen(js_name=isVotingStateTransition)] + pub fn is_voting_state_transition(&self) -> bool { + self.0.is_voting_state_transition() + } + // #[wasm_bindgen(js_name=hash)] // pub fn hash(&self, skip_signature: Option) -> Result { // let bytes = self diff --git a/packages/wasm-dpp/src/document/state_transition/document_batch_transition/mod.rs b/packages/wasm-dpp/src/document/state_transition/document_batch_transition/mod.rs index e9eb452e80..8904162c21 100644 --- a/packages/wasm-dpp/src/document/state_transition/document_batch_transition/mod.rs +++ b/packages/wasm-dpp/src/document/state_transition/document_batch_transition/mod.rs @@ -385,6 +385,11 @@ impl DocumentsBatchTransitionWasm { self.0.is_identity_state_transition() } + #[wasm_bindgen(js_name=isVotingStateTransition)] + pub fn is_voting_state_transition(&self) -> bool { + self.0.is_voting_state_transition() + } + #[wasm_bindgen(js_name=toBuffer)] pub fn to_buffer(&self) -> Result { let bytes = PlatformSerializable::serialize_to_bytes(&StateTransition::DocumentsBatch( diff --git a/packages/wasm-dpp/src/errors/consensus/consensus_error.rs b/packages/wasm-dpp/src/errors/consensus/consensus_error.rs index 4f39880387..734aa55fd6 100644 --- a/packages/wasm-dpp/src/errors/consensus/consensus_error.rs +++ b/packages/wasm-dpp/src/errors/consensus/consensus_error.rs @@ -64,11 +64,14 @@ use wasm_bindgen::{JsError, JsValue}; use dpp::consensus::basic::data_contract::{InvalidDocumentTypeRequiredSecurityLevelError, UnknownDocumentCreationRestrictionModeError, UnknownSecurityLevelError, UnknownStorageKeyRequirementsError, UnknownTradeModeError, UnknownTransferableTypeError}; use dpp::consensus::basic::document::{DocumentCreationNotAllowedError, MaxDocumentsTransitionsExceededError, MissingPositionsInDocumentTypePropertiesError}; use dpp::consensus::basic::identity::{DataContractBoundsNotPresentError, DisablingKeyIdAlsoBeingAddedInSameTransitionError, InvalidIdentityCreditWithdrawalTransitionAmountError, InvalidIdentityUpdateTransitionDisableKeysError, InvalidIdentityUpdateTransitionEmptyError, TooManyMasterPublicKeyError}; +use dpp::consensus::basic::overflow_error::OverflowError; use dpp::consensus::state::data_contract::document_type_update_error::DocumentTypeUpdateError; use dpp::consensus::state::document::document_incorrect_purchase_price_error::DocumentIncorrectPurchasePriceError; use dpp::consensus::state::document::document_not_for_sale_error::DocumentNotForSaleError; use dpp::consensus::state::identity::identity_public_key_already_exists_for_unique_contract_bounds_error::IdentityPublicKeyAlreadyExistsForUniqueContractBoundsError; use dpp::consensus::state::identity::master_public_key_update_error::MasterPublicKeyUpdateError; +use dpp::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_insufficient_error::PrefundedSpecializedBalanceInsufficientError; +use dpp::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_not_found_error::PrefundedSpecializedBalanceNotFoundError; use crate::errors::consensus::basic::data_contract::{ DataContractEmptySchemaErrorWasm, DataContractErrorWasm, @@ -237,6 +240,12 @@ pub fn from_state_error(state_error: &StateError) -> JsValue { StateError::DocumentIncorrectPurchasePriceError(e) => { generic_consensus_error!(DocumentIncorrectPurchasePriceError, e).into() } + StateError::PrefundedSpecializedBalanceInsufficientError(e) => { + generic_consensus_error!(PrefundedSpecializedBalanceInsufficientError, e).into() + } + StateError::PrefundedSpecializedBalanceNotFoundError(e) => { + generic_consensus_error!(PrefundedSpecializedBalanceNotFoundError, e).into() + } } } @@ -477,6 +486,9 @@ fn from_basic_error(basic_error: &BasicError) -> JsValue { BasicError::DocumentCreationNotAllowedError(e) => { generic_consensus_error!(DocumentCreationNotAllowedError, e).into() } + BasicError::OverflowError(e) => { + generic_consensus_error!(OverflowError, e).into() + } } } diff --git a/packages/wasm-dpp/src/identity/state_transition/identity_create_transition/identity_create_transition.rs b/packages/wasm-dpp/src/identity/state_transition/identity_create_transition/identity_create_transition.rs index 87b6adb762..ee0fe912f4 100644 --- a/packages/wasm-dpp/src/identity/state_transition/identity_create_transition/identity_create_transition.rs +++ b/packages/wasm-dpp/src/identity/state_transition/identity_create_transition/identity_create_transition.rs @@ -315,6 +315,11 @@ impl IdentityCreateTransitionWasm { pub fn is_identity_state_transition(&self) -> bool { self.0.is_identity_state_transition() } + + #[wasm_bindgen(js_name=isVotingStateTransition)] + pub fn is_voting_state_transition(&self) -> bool { + self.0.is_voting_state_transition() + } #[wasm_bindgen(js_name=signByPrivateKey)] pub fn sign_by_private_key( diff --git a/packages/wasm-dpp/src/identity/state_transition/identity_credit_transfer_transition/transition.rs b/packages/wasm-dpp/src/identity/state_transition/identity_credit_transfer_transition/transition.rs index 93d1a24a27..40fcf84fb9 100644 --- a/packages/wasm-dpp/src/identity/state_transition/identity_credit_transfer_transition/transition.rs +++ b/packages/wasm-dpp/src/identity/state_transition/identity_credit_transfer_transition/transition.rs @@ -266,6 +266,11 @@ impl IdentityCreditTransferTransitionWasm { self.0.is_identity_state_transition() } + #[wasm_bindgen(js_name=isVotingStateTransition)] + pub fn is_voting_state_transition(&self) -> bool { + self.0.is_voting_state_transition() + } + #[wasm_bindgen(js_name=signByPrivateKey)] pub fn sign_by_private_key( &mut self, diff --git a/packages/wasm-dpp/src/identity/state_transition/identity_credit_withdrawal_transition/transition.rs b/packages/wasm-dpp/src/identity/state_transition/identity_credit_withdrawal_transition/transition.rs index e1c960d701..9d75149519 100644 --- a/packages/wasm-dpp/src/identity/state_transition/identity_credit_withdrawal_transition/transition.rs +++ b/packages/wasm-dpp/src/identity/state_transition/identity_credit_withdrawal_transition/transition.rs @@ -341,6 +341,11 @@ impl IdentityCreditWithdrawalTransitionWasm { self.0.is_identity_state_transition() } + #[wasm_bindgen(js_name=isVotingStateTransition)] + pub fn is_voting_state_transition(&self) -> bool { + self.0.is_voting_state_transition() + } + #[wasm_bindgen(js_name=signByPrivateKey)] pub fn sign_by_private_key( &mut self, diff --git a/packages/wasm-dpp/src/identity/state_transition/identity_topup_transition/identity_topup_transition.rs b/packages/wasm-dpp/src/identity/state_transition/identity_topup_transition/identity_topup_transition.rs index bbe6315614..5455e12edc 100644 --- a/packages/wasm-dpp/src/identity/state_transition/identity_topup_transition/identity_topup_transition.rs +++ b/packages/wasm-dpp/src/identity/state_transition/identity_topup_transition/identity_topup_transition.rs @@ -258,6 +258,11 @@ impl IdentityTopUpTransitionWasm { self.0.is_identity_state_transition() } + #[wasm_bindgen(js_name=isVotingStateTransition)] + pub fn is_voting_state_transition(&self) -> bool { + self.0.is_voting_state_transition() + } + #[wasm_bindgen(js_name=signByPrivateKey)] pub fn sign_by_private_key( &mut self, diff --git a/packages/wasm-dpp/src/identity/state_transition/identity_update_transition/identity_update_transition.rs b/packages/wasm-dpp/src/identity/state_transition/identity_update_transition/identity_update_transition.rs index 6f8786a9cb..1d8988ba6f 100644 --- a/packages/wasm-dpp/src/identity/state_transition/identity_update_transition/identity_update_transition.rs +++ b/packages/wasm-dpp/src/identity/state_transition/identity_update_transition/identity_update_transition.rs @@ -361,6 +361,11 @@ impl IdentityUpdateTransitionWasm { self.0.is_identity_state_transition() } + #[wasm_bindgen(js_name=isVotingStateTransition)] + pub fn is_voting_state_transition(&self) -> bool { + self.0.is_voting_state_transition() + } + #[wasm_bindgen(js_name=signByPrivateKey)] pub fn sign_by_private_key( &mut self, diff --git a/packages/wasm-dpp/src/lib.rs b/packages/wasm-dpp/src/lib.rs index ddc83513fe..e814c8a82b 100644 --- a/packages/wasm-dpp/src/lib.rs +++ b/packages/wasm-dpp/src/lib.rs @@ -7,6 +7,7 @@ pub use data_contract::*; pub use document::*; pub use identity::*; pub use metadata::*; +pub use voting::*; // pub use state_transition::*; mod dash_platform_protocol; @@ -31,3 +32,4 @@ mod entropy_generator; mod lodash; mod protocol_version; mod validation; +mod voting; diff --git a/packages/wasm-dpp/src/state_transition/state_transition_factory.rs b/packages/wasm-dpp/src/state_transition/state_transition_factory.rs index 9941bc9a34..ae2d8cb447 100644 --- a/packages/wasm-dpp/src/state_transition/state_transition_factory.rs +++ b/packages/wasm-dpp/src/state_transition/state_transition_factory.rs @@ -12,6 +12,7 @@ use dpp::state_transition::state_transition_factory::StateTransitionFactory; use dpp::state_transition::StateTransition; use dpp::ProtocolError; use wasm_bindgen::{prelude::wasm_bindgen, JsValue}; +use crate::voting::state_transition::masternode_vote_transition::MasternodeVoteTransitionWasm; #[wasm_bindgen(js_name = StateTransitionFactory)] pub struct StateTransitionFactoryWasm(StateTransitionFactory); @@ -58,6 +59,9 @@ impl StateTransitionFactoryWasm { StateTransition::DocumentsBatch(st) => { Ok(DocumentsBatchTransitionWasm::from(st).into()) } + StateTransition::MasternodeVote(st) => { + Ok(MasternodeVoteTransitionWasm::from(st).into()) + } }, Err(dpp::ProtocolError::StateTransitionError(e)) => match e { StateTransitionError::InvalidStateTransitionError { diff --git a/packages/wasm-dpp/src/voting/mod.rs b/packages/wasm-dpp/src/voting/mod.rs new file mode 100644 index 0000000000..19f8d4cabc --- /dev/null +++ b/packages/wasm-dpp/src/voting/mod.rs @@ -0,0 +1 @@ +pub mod state_transition; \ No newline at end of file diff --git a/packages/wasm-dpp/src/voting/state_transition/masternode_vote_transition/mod.rs b/packages/wasm-dpp/src/voting/state_transition/masternode_vote_transition/mod.rs new file mode 100644 index 0000000000..4276a8361d --- /dev/null +++ b/packages/wasm-dpp/src/voting/state_transition/masternode_vote_transition/mod.rs @@ -0,0 +1,292 @@ +mod to_object; + +use wasm_bindgen::{JsError, JsValue}; +use wasm_bindgen::prelude::wasm_bindgen; +use dpp::identifier::Identifier; +use dpp::identity::KeyType; +use dpp::platform_value::{BinaryData, string_encoding}; +use dpp::platform_value::string_encoding::Encoding; +use dpp::serialization::PlatformSerializable; +use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; +use dpp::state_transition::{StateTransition, StateTransitionIdentitySigned, StateTransitionLike}; +use dpp::state_transition::masternode_vote_transition::accessors::MasternodeVoteTransitionAccessorsV0; +use dpp::version::PlatformVersion; +use crate::bls_adapter::{BlsAdapter, JsBlsAdapter}; +use crate::buffer::Buffer; +use crate::errors::from_dpp_err; +use crate::identifier::IdentifierWrapper; +use crate::{IdentityPublicKeyWasm, with_js_error}; +use crate::utils::WithJsError; + +#[derive(Clone)] +#[wasm_bindgen(js_name=MasternodeVoteTransition)] +pub struct MasternodeVoteTransitionWasm(MasternodeVoteTransition); + +impl From for MasternodeVoteTransitionWasm { + fn from(v: MasternodeVoteTransition) -> Self { + MasternodeVoteTransitionWasm(v) + } +} + +impl From for MasternodeVoteTransition { + fn from(val: MasternodeVoteTransitionWasm) -> Self { + val.0 + } +} + +#[wasm_bindgen(js_class=MasternodeVoteTransition)] +impl MasternodeVoteTransitionWasm { + #[wasm_bindgen(constructor)] + pub fn new(platform_version: u32) -> Result { + let platform_version = + &PlatformVersion::get(platform_version).map_err(|e| JsValue::from(e.to_string()))?; + + MasternodeVoteTransition::default_versioned(platform_version) + .map(Into::into) + .map_err(from_dpp_err) + } + + #[wasm_bindgen(js_name=getType)] + pub fn get_type(&self) -> u8 { + self.0.state_transition_type() as u8 + } + + #[wasm_bindgen(getter, js_name=proTxHash)] + pub fn pro_tx_hash(&self) -> IdentifierWrapper { + self.get_pro_tx_hash() + } + + #[wasm_bindgen(js_name=getIdentityId)] + pub fn get_pro_tx_hash(&self) -> IdentifierWrapper { + self.0.pro_tx_hash().into() + } + + #[wasm_bindgen(js_name=setIdentityId)] + pub fn set_pro_tx_hash(&mut self, pro_tx_hash: &IdentifierWrapper) { + self.0.set_pro_tx_hash(pro_tx_hash.into()); + } + #[wasm_bindgen(js_name=toObject)] + pub fn to_object(&self, options: JsValue) -> Result { + let opts: self::to_object::ToObjectOptions = if options.is_object() { + with_js_error!(serde_wasm_bindgen::from_value(options))? + } else { + Default::default() + }; + + let object = self::to_object::to_object_struct(&self.0, opts); + let js_object = js_sys::Object::new(); + + js_sys::Reflect::set( + &js_object, + &"type".to_owned().into(), + &object.transition_type.into(), + )?; + + let version = match self.0 { + MasternodeVoteTransition::V0(_) => "0", + }; + + js_sys::Reflect::set(&js_object, &"$version".to_owned().into(), &version.into())?; + + if let Some(signature) = object.signature { + let signature_value: JsValue = if signature.is_empty() { + JsValue::undefined() + } else { + Buffer::from_bytes(signature.as_slice()).into() + }; + + js_sys::Reflect::set(&js_object, &"signature".to_owned().into(), &signature_value)?; + + if let Some(signature_public_key_id) = object.signature_public_key_id { + js_sys::Reflect::set( + &js_object, + &"signaturePublicKeyId".to_owned().into(), + &JsValue::from(signature_public_key_id), + )?; + } else { + js_sys::Reflect::set( + &js_object, + &"signaturePublicKeyId".to_owned().into(), + &JsValue::undefined(), + )?; + } + } + + js_sys::Reflect::set( + &js_object, + &"proTxHash".to_owned().into(), + &Buffer::from_bytes(object.pro_tx_hash.to_buffer().as_slice()), + )?; + + //todo: reflect vote + + Ok(js_object.into()) + } + + #[wasm_bindgen(js_name=toBuffer)] + pub fn to_buffer(&self) -> Result { + let bytes = PlatformSerializable::serialize_to_bytes( + &StateTransition::MasternodeVote(self.0.clone()), + ) + .with_js_error()?; + Ok(Buffer::from_bytes(&bytes)) + } + + #[wasm_bindgen(js_name=toJSON)] + pub fn to_json(&self) -> Result { + let object = self::to_object::to_object_struct(&self.0, Default::default()); + let js_object = js_sys::Object::new(); + + js_sys::Reflect::set( + &js_object, + &"type".to_owned().into(), + &object.transition_type.into(), + )?; + + let version = match self.0 { + MasternodeVoteTransition::V0(_) => "0", + }; + + js_sys::Reflect::set(&js_object, &"$version".to_owned().into(), &version.into())?; + + if let Some(signature) = object.signature { + let signature_value: JsValue = if signature.is_empty() { + JsValue::undefined() + } else { + string_encoding::encode(signature.as_slice(), Encoding::Base64).into() + }; + + js_sys::Reflect::set(&js_object, &"signature".to_owned().into(), &signature_value)?; + + if let Some(signature_public_key_id) = object.signature_public_key_id { + js_sys::Reflect::set( + &js_object, + &"signaturePublicKeyId".to_owned().into(), + &signature_public_key_id.into(), + )?; + } else { + js_sys::Reflect::set( + &js_object, + &"signaturePublicKeyId".to_owned().into(), + &JsValue::undefined(), + )?; + } + } + + let pro_tx_hash = object.pro_tx_hash.to_string(Encoding::Base58); + + js_sys::Reflect::set( + &js_object, + &"proTxHash".to_owned().into(), + &pro_tx_hash.into(), + )?; + + // todo: reflect vote + + Ok(js_object.into()) + } + + #[wasm_bindgen(js_name=getModifiedDataIds)] + pub fn modified_data_ids(&self) -> Vec { + let ids = self.0.modified_data_ids(); + + ids.into_iter() + .map(|id| >::from(id).into()) + .collect() + } + + #[wasm_bindgen(js_name=isDataContractStateTransition)] + pub fn is_data_contract_state_transition(&self) -> bool { + self.0.is_data_contract_state_transition() + } + + #[wasm_bindgen(js_name=isDocumentStateTransition)] + pub fn is_document_state_transition(&self) -> bool { + self.0.is_document_state_transition() + } + + #[wasm_bindgen(js_name=isIdentityStateTransition)] + pub fn is_identity_state_transition(&self) -> bool { + self.0.is_identity_state_transition() + } + + #[wasm_bindgen(js_name=isVotingStateTransition)] + pub fn is_voting_state_transition(&self) -> bool { + self.0.is_voting_state_transition() + } + + #[wasm_bindgen(js_name=signByPrivateKey)] + pub fn sign_by_private_key( + &mut self, + private_key: Vec, + key_type: u8, + bls: Option, + ) -> Result<(), JsValue> { + let key_type = key_type + .try_into() + .map_err(|e: anyhow::Error| e.to_string())?; + + if bls.is_none() && key_type == KeyType::BLS12_381 { + return Err(JsError::new( + format!("BLS adapter is required for BLS key type '{}'", key_type).as_str(), + ) + .into()); + } + + let bls_adapter = if let Some(adapter) = bls { + BlsAdapter(adapter) + } else { + BlsAdapter(JsValue::undefined().into()) + }; + + // TODO: not the best approach because it involves cloning the transition + // Probably it worth to return `sign_by_private_key` per state transition + let mut wrapper = StateTransition::MasternodeVote(self.0.clone()); + wrapper + .sign_by_private_key(private_key.as_slice(), key_type, &bls_adapter) + .with_js_error()?; + + self.0.set_signature(wrapper.signature().to_owned()); + + Ok(()) + } + + #[wasm_bindgen(js_name=getSignature)] + pub fn get_signature(&self) -> Buffer { + Buffer::from_bytes(self.0.signature().as_slice()) + } + + #[wasm_bindgen(js_name=setSignature)] + pub fn set_signature(&mut self, signature: Option>) { + self.0 + .set_signature(BinaryData::new(signature.unwrap_or_default())) + } + + #[wasm_bindgen] + pub fn sign( + &mut self, + identity_public_key: &IdentityPublicKeyWasm, + private_key: Vec, + bls: JsBlsAdapter, + ) -> Result<(), JsValue> { + let bls_adapter = BlsAdapter(bls); + + // TODO: come up with a better way to set signature to the binding. + let mut state_transition = StateTransition::MasternodeVote(self.0.clone()); + state_transition + .sign( + &identity_public_key.to_owned().into(), + &private_key, + &bls_adapter, + ) + .with_js_error()?; + + let signature = state_transition.signature().to_owned(); + let signature_public_key_id = state_transition.signature_public_key_id().unwrap_or(0); + + self.0.set_signature(signature); + self.0.set_signature_public_key_id(signature_public_key_id); + + Ok(()) + } +} diff --git a/packages/wasm-dpp/src/voting/state_transition/masternode_vote_transition/to_object.rs b/packages/wasm-dpp/src/voting/state_transition/masternode_vote_transition/to_object.rs new file mode 100644 index 0000000000..63eeebb095 --- /dev/null +++ b/packages/wasm-dpp/src/voting/state_transition/masternode_vote_transition/to_object.rs @@ -0,0 +1,47 @@ +use dpp::identity::KeyID; + +use dpp::state_transition::StateTransitionIdentitySigned; +use dpp::{identifier::Identifier, state_transition::StateTransitionLike}; +use serde::Deserialize; +use std::default::Default; +use dpp::state_transition::masternode_vote_transition::accessors::MasternodeVoteTransitionAccessorsV0; +use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; +use dpp::voting::votes::Vote; + +#[derive(Deserialize, Default)] +#[serde(rename_all = "camelCase")] +pub struct ToObjectOptions { + pub skip_signature: Option, +} + +#[derive(Default)] +pub struct ToObject { + pub transition_type: u8, + pub pro_tx_hash: Identifier, + pub vote: Vote, + pub signature: Option>, + pub signature_public_key_id: Option, +} + +pub fn to_object_struct( + transition: &MasternodeVoteTransition, + options: ToObjectOptions, +) -> ToObject { + let mut to_object = ToObject { + transition_type: transition.state_transition_type() as u8, + vote: transition.vote().clone(), + ..ToObject::default() + }; + + if !options.skip_signature.unwrap_or(false) { + let signature = Some(transition.signature().to_vec()); + if let Some(signature) = &signature { + if !signature.is_empty() { + to_object.signature_public_key_id = Some(transition.signature_public_key_id()) + } + } + to_object.signature = signature; + } + + to_object +} diff --git a/packages/wasm-dpp/src/voting/state_transition/mod.rs b/packages/wasm-dpp/src/voting/state_transition/mod.rs new file mode 100644 index 0000000000..95ae4f4550 --- /dev/null +++ b/packages/wasm-dpp/src/voting/state_transition/mod.rs @@ -0,0 +1 @@ +pub mod masternode_vote_transition; \ No newline at end of file From 2665bb76f8c8c8c566a0584eaf8b17a9a3d778a2 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 13 May 2024 09:21:09 +0200 Subject: [PATCH 052/135] more work --- .../data_contract/extra/drive_api_tests.rs | 2 +- .../documents_batch_transition/methods/mod.rs | 1 - .../v0/v0_methods.rs | 4 +-- .../masternode_vote_transition/v0/mod.rs | 27 +++++++++++-------- .../mod.rs | 1 + packages/rs-dpp/src/voting/votes/mod.rs | 19 ++++++------- .../src/voting/votes/resource_vote/mod.rs | 20 +++++++------- packages/rs-drive/src/query/test_index.rs | 5 +++- 8 files changed, 44 insertions(+), 35 deletions(-) diff --git a/packages/rs-dpp/src/data_contract/extra/drive_api_tests.rs b/packages/rs-dpp/src/data_contract/extra/drive_api_tests.rs index 394245a5b4..686a0d0895 100644 --- a/packages/rs-dpp/src/data_contract/extra/drive_api_tests.rs +++ b/packages/rs-dpp/src/data_contract/extra/drive_api_tests.rs @@ -174,7 +174,7 @@ mod test { .document_types .get("contactInfo") .unwrap() - .indexes(); + .indexes().values().collect::>(); assert_eq!(contact_info_indices.len(), 2); assert!(contact_info_indices[0].unique); assert!(!contact_info_indices[1].unique); diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/mod.rs index a8cf00bca3..071ed54f90 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/mod.rs @@ -17,7 +17,6 @@ use crate::state_transition::documents_batch_transition::DocumentsBatchTransitio use crate::state_transition::documents_batch_transition::DocumentsBatchTransitionV0; #[cfg(feature = "state-transition-signing")] use crate::state_transition::StateTransition; -#[cfg(feature = "state-transition-signing")] use crate::ProtocolError; #[cfg(feature = "state-transition-signing")] use platform_value::Identifier; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs index 0ff645aefd..d31cde8cf0 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs @@ -30,7 +30,6 @@ use crate::state_transition::documents_batch_transition::{ }; #[cfg(feature = "state-transition-signing")] use crate::state_transition::StateTransition; -#[cfg(feature = "state-transition-signing")] use crate::ProtocolError; #[cfg(feature = "state-transition-signing")] use platform_value::Identifier; @@ -334,14 +333,13 @@ impl DocumentsBatchTransitionMethodsV0 for DocumentsBatchTransitionV0 { .filter_map(|transition| { transition .as_transition_create() - .map(|document_create_transition| { + .and_then(|document_create_transition| { // Safely sum up values to avoid overflow. document_create_transition .prefunded_voting_balances() .values() .try_fold(0u64, |acc, &val| acc.checked_add(val)) }) - .flatten() }) .fold((None, false), |(acc, _), price| match acc { Some(acc_val) => acc_val diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs index 50e5758d92..0e809163bf 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs @@ -17,6 +17,7 @@ use crate::voting::votes::Vote; use bincode::{Decode, Encode}; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize, PlatformSignable}; use platform_value::BinaryData; +#[cfg(feature = "state-transition-serde-conversion")] use serde::{Deserialize, Serialize}; #[derive( @@ -53,13 +54,15 @@ mod test { use crate::serialization::{PlatformDeserializable, PlatformSerializable}; use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; - use crate::voting::resource_vote::ResourceVote; use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use crate::voting::votes::Vote; - use crate::voting::ContestedDocumentResourceVote; use platform_value::Identifier; use rand::Rng; use std::fmt::Debug; + use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; + use crate::voting::vote_polls::VotePoll; + use crate::voting::votes::resource_vote::ResourceVote; + use crate::voting::votes::resource_vote::v0::ResourceVoteV0; fn test_masternode_vote_transition< T: PlatformSerializable + PlatformDeserializable + Debug + PartialEq, @@ -79,15 +82,17 @@ mod test { let mut rng = rand::thread_rng(); let transition = MasternodeVoteTransitionV0 { pro_tx_hash: Identifier::random(), - vote: Vote::ResourceVote(ContestedDocumentResourceVote { - vote_poll: ContestedDocumentResourceVotePoll { - contract_id: Default::default(), - document_type_name: "hello".to_string(), - index_name: "index_1".to_string(), - index_values: vec![], - }, - resource_vote_choice: ResourceVote::TowardsIdentity(Identifier::random()), - }), + vote: Vote::ResourceVote(ResourceVote::V0(ResourceVoteV0 { + vote_poll: VotePoll::ContestedDocumentResourceVotePoll( + ContestedDocumentResourceVotePoll { + contract_id: Default::default(), + document_type_name: "hello".to_string(), + index_name: "index_1".to_string(), + index_values: vec![], + } + ), + resource_vote_choice: ResourceVoteChoice::TowardsIdentity(Identifier::random()), + })), nonce: 1, signature_public_key_id: rng.gen(), signature: [0; 65].to_vec().into(), diff --git a/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs b/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs index 6fe66c0c50..2e4516d9f2 100644 --- a/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs +++ b/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs @@ -4,6 +4,7 @@ use crate::util::hash::hash_double; use crate::ProtocolError; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use platform_value::{Identifier, Value}; +#[cfg(feature = "vote-serde-conversion")] use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize, PartialEq)] diff --git a/packages/rs-dpp/src/voting/votes/mod.rs b/packages/rs-dpp/src/voting/votes/mod.rs index 488d97b360..810f42b4e7 100644 --- a/packages/rs-dpp/src/voting/votes/mod.rs +++ b/packages/rs-dpp/src/voting/votes/mod.rs @@ -2,26 +2,27 @@ pub mod resource_vote; use crate::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; use crate::voting::votes::resource_vote::ResourceVote; -#[cfg(feature = "vote-serialization")] use crate::ProtocolError; -#[cfg(feature = "vote-serialization")] use bincode::{Decode, Encode}; -#[cfg(feature = "vote-serialization")] use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use platform_value::Identifier; use serde::{Deserialize, Serialize}; -#[derive(Debug, Clone, PartialEq)] +#[derive( +Debug, +Clone, +Encode, +Decode, +PlatformSerialize, +PlatformDeserialize, +PartialEq, +)] #[cfg_attr( feature = "vote-serde-conversion", derive(Serialize, Deserialize), serde(rename_all = "camelCase") )] -#[cfg_attr( - feature = "vote-serialization", - derive(Encode, Decode, PlatformDeserialize, PlatformSerialize), - platform_serialize(limit = 15000, unversioned) -)] +#[platform_serialize(limit = 15000, unversioned)] pub enum Vote { ResourceVote(ResourceVote), } diff --git a/packages/rs-dpp/src/voting/votes/resource_vote/mod.rs b/packages/rs-dpp/src/voting/votes/resource_vote/mod.rs index ea85d777d0..a3ca4ccae4 100644 --- a/packages/rs-dpp/src/voting/votes/resource_vote/mod.rs +++ b/packages/rs-dpp/src/voting/votes/resource_vote/mod.rs @@ -1,26 +1,28 @@ use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; use crate::voting::votes::resource_vote::v0::ResourceVoteV0; use crate::ProtocolError; -use derive_more::From; -#[cfg(feature = "vote-serialization")] use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; #[cfg(feature = "vote-serde-conversion")] use serde::{Deserialize, Serialize}; pub mod accessors; -mod v0; +pub mod v0; -#[derive(Debug, Clone, PartialEq, From)] +#[derive( +Debug, +Clone, +Encode, +Decode, +PlatformSerialize, +PlatformDeserialize, +PartialEq, +)] #[cfg_attr( feature = "vote-serde-conversion", derive(Serialize, Deserialize), serde(tag = "$version") )] -#[cfg_attr( - feature = "vote-serialization", - derive(Encode, Decode, PlatformDeserialize, PlatformSerialize), - platform_serialize(limit = 15000, unversioned) -)] +#[platform_serialize(limit = 15000, unversioned)] pub enum ResourceVote { #[cfg_attr(feature = "vote-serde-conversion", serde(rename = "0"))] V0(ResourceVoteV0), diff --git a/packages/rs-drive/src/query/test_index.rs b/packages/rs-drive/src/query/test_index.rs index 2e00959b7c..7f73d35b0c 100644 --- a/packages/rs-drive/src/query/test_index.rs +++ b/packages/rs-drive/src/query/test_index.rs @@ -117,7 +117,10 @@ mod tests { let index = query .find_best_index(platform_version) .expect("expected to find index"); - assert_eq!(index, document_type.indexes().get(2).unwrap()); + let mut iter = document_type.indexes().iter(); + iter.next(); + iter.next(); + assert_eq!(index, iter.next().unwrap().1); //position 2 let query_value = json!({ "where": [ From 3f21e6e4c66498295920f9a2b50fe477944bb5a3 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 13 May 2024 18:00:38 +0200 Subject: [PATCH 053/135] more fixes --- Cargo.lock | 29 ++++----- packages/rs-dpp/Cargo.toml | 2 +- .../data_contract/extra/drive_api_tests.rs | 14 ++-- packages/rs-dpp/src/identity/signer.rs | 3 +- .../document_create_transition/v0/mod.rs | 2 +- packages/rs-drive-abci/Cargo.toml | 2 +- .../create_genesis_state/v0/mod.rs | 3 +- .../state_transitions/identity_create/mod.rs | 12 ++-- .../state_transitions/identity_top_up/mod.rs | 4 +- .../tests/strategy_tests/strategy.rs | 27 ++++---- .../tests/strategy_tests/voting_tests.rs | 17 +++-- packages/rs-drive/Cargo.toml | 2 +- .../rs-drive/src/drive/document/insert/mod.rs | 2 +- .../src/drive/initialization/v0/mod.rs | 65 ++++++++++++++++--- .../rs-drive/tests/deterministic_root_hash.rs | 2 +- packages/rs-platform-value/Cargo.toml | 2 +- .../src/types/binary_data.rs | 9 ++- packages/rs-sdk/Cargo.toml | 2 +- packages/simple-signer/Cargo.toml | 1 + packages/simple-signer/src/signer.rs | 26 ++++++-- packages/strategy-tests/src/lib.rs | 1 + packages/strategy-tests/src/transitions.rs | 2 +- 22 files changed, 149 insertions(+), 80 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a871a5be5d..be1efd3648 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -301,12 +301,6 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" -[[package]] -name = "base64" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5" - [[package]] name = "base64" version = "0.21.7" @@ -315,9 +309,9 @@ checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base64" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64ct" @@ -1085,7 +1079,7 @@ name = "dash-sdk" version = "1.0.0-dev.12" dependencies = [ "async-trait", - "base64 0.22.0", + "base64 0.22.1", "bincode", "bip37-bloom-filter", "ciborium", @@ -1296,7 +1290,7 @@ version = "1.0.0-dev.12" dependencies = [ "anyhow", "async-trait", - "base64 0.22.0", + "base64 0.22.1", "bincode", "bls-signatures", "bs58 0.4.0", @@ -1345,7 +1339,7 @@ name = "drive" version = "1.0.0-dev.12" dependencies = [ "arc-swap", - "base64 0.21.7", + "base64 0.22.1", "bs58 0.5.1", "byteorder", "chrono", @@ -1383,7 +1377,7 @@ dependencies = [ "arc-swap", "async-trait", "atty", - "base64 0.20.0", + "base64 0.22.1", "bincode", "chrono", "ciborium", @@ -2368,7 +2362,7 @@ source = "git+https://github.com/fominok/jsonschema-rs?branch=feat-unevaluated-p dependencies = [ "ahash 0.8.11", "anyhow", - "base64 0.22.0", + "base64 0.21.7", "bytecount", "fancy-regex", "fraction", @@ -3013,7 +3007,7 @@ dependencies = [ name = "platform-value" version = "1.0.0-dev.12" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "bincode", "bs58 0.5.1", "ciborium", @@ -3723,7 +3717,7 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "rustls-pki-types", ] @@ -3961,7 +3955,7 @@ version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c85f8e96d1d6857f13768fcbd895fcb06225510022a2774ed8b5150581847b0" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "chrono", "hex", "serde", @@ -4049,6 +4043,7 @@ checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" name = "simple-signer" version = "1.0.0-dev.12" dependencies = [ + "base64 0.22.1", "bincode", "dashcore-rpc", "dpp", @@ -4909,7 +4904,7 @@ version = "2.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d11a831e3c0b56e438a28308e7c810799e3c118417f342d30ecec080105395cd" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "flate2", "log", "once_cell", diff --git a/packages/rs-dpp/Cargo.toml b/packages/rs-dpp/Cargo.toml index af9be2d800..b2b68c0cd0 100644 --- a/packages/rs-dpp/Cargo.toml +++ b/packages/rs-dpp/Cargo.toml @@ -14,7 +14,7 @@ authors = [ [dependencies] anyhow = { version = "1.0.81" } async-trait = { version = "0.1.79" } -base64 = "0.22.0" +base64 = "0.22.1" bls-signatures = { git = "https://github.com/dashpay/bls-signatures", tag = "v1.3.1", optional = true } bs58 = "0.4.0" byteorder = { version = "1.4" } diff --git a/packages/rs-dpp/src/data_contract/extra/drive_api_tests.rs b/packages/rs-dpp/src/data_contract/extra/drive_api_tests.rs index 686a0d0895..9d48585768 100644 --- a/packages/rs-dpp/src/data_contract/extra/drive_api_tests.rs +++ b/packages/rs-dpp/src/data_contract/extra/drive_api_tests.rs @@ -176,21 +176,21 @@ mod test { .unwrap() .indexes().values().collect::>(); assert_eq!(contact_info_indices.len(), 2); - assert!(contact_info_indices[0].unique); - assert!(!contact_info_indices[1].unique); - assert_eq!(contact_info_indices[0].properties.len(), 3); + assert!(contact_info_indices[1].unique); + assert!(!contact_info_indices[0].unique); + assert_eq!(contact_info_indices[1].properties.len(), 3); - assert_eq!(contact_info_indices[0].properties[0].name, "$ownerId"); + assert_eq!(contact_info_indices[1].properties[0].name, "$ownerId"); assert_eq!( - contact_info_indices[0].properties[1].name, + contact_info_indices[1].properties[1].name, "rootEncryptionKeyIndex" ); assert_eq!( - contact_info_indices[0].properties[2].name, + contact_info_indices[1].properties[2].name, "derivationEncryptionKeyIndex" ); - assert!(contact_info_indices[0].properties[0].ascending); + assert!(contact_info_indices[1].properties[0].ascending); } #[test] diff --git a/packages/rs-dpp/src/identity/signer.rs b/packages/rs-dpp/src/identity/signer.rs index 51d20dd7cd..b7df7f29f5 100644 --- a/packages/rs-dpp/src/identity/signer.rs +++ b/packages/rs-dpp/src/identity/signer.rs @@ -1,8 +1,9 @@ +use std::fmt::Debug; use crate::prelude::IdentityPublicKey; use crate::ProtocolError; use platform_value::BinaryData; -pub trait Signer: Sync { +pub trait Signer: Sync + Debug { /// the public key bytes are only used to look up the private key fn sign( &self, diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs index 9f6379d2b2..5f1c409b65 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs @@ -98,7 +98,7 @@ impl DocumentCreateTransitionV0 { .remove_hash256_bytes(property_names::ENTROPY) .map_err(ProtocolError::ValueError)?, prefunded_voting_balances: map - .remove_map_as_btree_map(property_names::PREFUNDED_VOTING_BALANCES)?, + .remove_optional_map_as_btree_map(property_names::PREFUNDED_VOTING_BALANCES)?.unwrap_or_default(), data: map, }) } diff --git a/packages/rs-drive-abci/Cargo.toml b/packages/rs-drive-abci/Cargo.toml index db8334cc12..61cb78087e 100644 --- a/packages/rs-drive-abci/Cargo.toml +++ b/packages/rs-drive-abci/Cargo.toml @@ -80,7 +80,7 @@ async-trait = "0.1.77" console-subscriber = { version = "0.2.0", optional = true } [dev-dependencies] -base64 = "0.20.0" +base64 = "0.22.1" platform-version = { path = "../rs-platform-version", features = [ "mock-versions", ] } diff --git a/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs index 9066561cd3..d8c38cb8a7 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs @@ -287,8 +287,7 @@ mod tests { assert_eq!( root_hash, [ - 162, 81, 50, 217, 246, 11, 77, 233, 231, 192, 228, 176, 197, 102, 24, 18, 160, - 5, 182, 75, 119, 174, 75, 155, 86, 92, 88, 197, 201, 60, 60, 157 + 240, 136, 118, 187, 50, 89, 9, 222, 55, 136, 185, 144, 40, 137, 74, 135, 132, 142, 233, 191, 242, 65, 51, 153, 97, 74, 223, 91, 161, 40, 131, 60 ] ) } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create/mod.rs index f68781b6b1..5bcd9fdbfd 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create/mod.rs @@ -301,7 +301,7 @@ mod tests { assert_eq!(processing_result.valid_count(), 1); - assert_eq!(processing_result.aggregated_fees().processing_fee, 2566730); + assert_eq!(processing_result.aggregated_fees().processing_fee, 2633590); platform .drive @@ -316,7 +316,7 @@ mod tests { .expect("expected to get identity balance") .expect("expected there to be an identity balance for this identity"); - assert_eq!(identity_balance, 99916163270); + assert_eq!(identity_balance, 99916096410); } #[test] @@ -515,7 +515,7 @@ mod tests { assert_eq!(processing_result.valid_count(), 1); - assert_eq!(processing_result.aggregated_fees().processing_fee, 3170170); + assert_eq!(processing_result.aggregated_fees().processing_fee, 3237030); platform .drive @@ -530,7 +530,7 @@ mod tests { .expect("expected to get identity balance") .expect("expected there to be an identity balance for this identity"); - assert_eq!(identity_balance, 99911297030); // The identity balance is smaller than if there hadn't been any issue + assert_eq!(identity_balance, 99911230170); // The identity balance is smaller than if there hadn't been any issue } #[test] @@ -1193,7 +1193,7 @@ mod tests { assert_eq!(processing_result.valid_count(), 1); - assert_eq!(processing_result.aggregated_fees().processing_fee, 3170170); + assert_eq!(processing_result.aggregated_fees().processing_fee, 3237030); platform .drive @@ -1208,6 +1208,6 @@ mod tests { .expect("expected to get identity balance") .expect("expected there to be an identity balance for this identity"); - assert_eq!(identity_balance, 99911297030); // The identity balance is smaller than if there hadn't been any issue + assert_eq!(identity_balance, 99911230170); // The identity balance is smaller than if there hadn't been any issue } } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_top_up/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_top_up/mod.rs index 670a1ac80c..820f92f43e 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_top_up/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_top_up/mod.rs @@ -220,7 +220,7 @@ mod tests { assert_eq!(processing_result.valid_count(), 1); - assert_eq!(processing_result.aggregated_fees().processing_fee, 1146640); + assert_eq!(processing_result.aggregated_fees().processing_fee, 1213500); platform .drive @@ -239,6 +239,6 @@ mod tests { .expect("expected to get identity balance") .expect("expected there to be an identity balance for this identity"); - assert_eq!(identity_balance, 149993048360); // about 0.5 Dash starting balance + 1 Dash asset lock top up + assert_eq!(identity_balance, 149992981500); // about 0.5 Dash starting balance + 1 Dash asset lock top up } } diff --git a/packages/rs-drive-abci/tests/strategy_tests/strategy.rs b/packages/rs-drive-abci/tests/strategy_tests/strategy.rs index 863e470045..1cf8e0b02d 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/strategy.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/strategy.rs @@ -368,17 +368,22 @@ impl NetworkStrategy { platform_version: &PlatformVersion, ) -> Result, ProtocolError> { let mut state_transitions = vec![]; - if block_info.height == 1 && self.strategy.start_identities.number_of_identities > 0 { - let mut new_transitions = NetworkStrategy::create_identities_state_transitions( - self.strategy.start_identities.number_of_identities.into(), - self.strategy.identity_inserts.start_keys as KeyID, - &self.strategy.identity_inserts.extra_keys, - signer, - rng, - platform_version, - ); - state_transitions.append(&mut new_transitions); - } + if block_info.height == 1 { + if self.strategy.start_identities.number_of_identities > 0 { + let mut new_transitions = NetworkStrategy::create_identities_state_transitions( + self.strategy.start_identities.number_of_identities.into(), + self.strategy.identity_inserts.start_keys as KeyID, + &self.strategy.identity_inserts.extra_keys, + signer, + rng, + platform_version, + ); + state_transitions.append(&mut new_transitions); + } + if !self.strategy.start_identities.hard_coded.is_empty() { + state_transitions.extend(self.strategy.start_identities.hard_coded.clone()); + } + } let frequency = &self.strategy.identity_inserts.frequency; if frequency.check_hit(rng) { let count = frequency.events(rng); diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index 0f057a8066..412b220582 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -49,7 +49,7 @@ mod tests { let mut simple_signer = SimpleSigner::default(); - let (identity1, keys) = + let (identity1, keys1) = Identity::random_identity_with_main_keys_with_private_key::>( 2, &mut rng, @@ -57,9 +57,9 @@ mod tests { ) .unwrap(); - simple_signer.add_keys(keys); + simple_signer.add_keys(keys1); - let (identity2, keys) = + let (identity2, keys2) = Identity::random_identity_with_main_keys_with_private_key::>( 2, &mut rng, @@ -67,11 +67,11 @@ mod tests { ) .unwrap(); - simple_signer.add_keys(keys); + simple_signer.add_keys(keys2); let start_identities = create_state_transitions_for_identities( vec![identity1, identity2], - &mut simple_signer, + &simple_signer, &mut rng, platform_version, ); @@ -153,7 +153,10 @@ mod tests { }, }, ], - start_identities: StartIdentities::default(), + start_identities: StartIdentities { + hard_coded: start_identities, + ..Default::default() + }, identity_inserts: IdentityInsertInfo { frequency: Frequency { times_per_block_range: 1..2, @@ -163,7 +166,7 @@ mod tests { }, identity_contract_nonce_gaps: None, - signer: None, + signer: Some(simple_signer), }, total_hpmns: 100, extra_normal_mns: 0, diff --git a/packages/rs-drive/Cargo.toml b/packages/rs-drive/Cargo.toml index d2975f1258..3bac23ad69 100644 --- a/packages/rs-drive/Cargo.toml +++ b/packages/rs-drive/Cargo.toml @@ -39,7 +39,7 @@ serde = { version = "1.0.197", features = ["derive"], optional = true } rand = { version = "0.8.4", features = ["small_rng"], optional = true } moka = { version = "0.11.1", features = ["future", "futures-util"], optional = true } bs58 = { version = "0.5.0", optional = true } -base64 = { version = "0.21.0", optional = true } +base64 = { version = "0.22.1", optional = true } tempfile = { version = "3", optional = true } enum-map = { version = "2.0.3", optional = true } intmap = { version = "2.0.0", features = ["serde"], optional = true } diff --git a/packages/rs-drive/src/drive/document/insert/mod.rs b/packages/rs-drive/src/drive/document/insert/mod.rs index d53133f5d7..60f5f82bd3 100644 --- a/packages/rs-drive/src/drive/document/insert/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/mod.rs @@ -461,7 +461,7 @@ mod tests { .unwrap() .cost_for_known_cost_item(StorageDiskUsageCreditPerByte); assert_eq!(1305, added_bytes); - assert_eq!(142936800, processing_fee); + assert_eq!(144784800, processing_fee); } #[test] diff --git a/packages/rs-drive/src/drive/initialization/v0/mod.rs b/packages/rs-drive/src/drive/initialization/v0/mod.rs index 7060a3e17f..72c648dd5a 100644 --- a/packages/rs-drive/src/drive/initialization/v0/mod.rs +++ b/packages/rs-drive/src/drive/initialization/v0/mod.rs @@ -223,7 +223,7 @@ mod tests { &platform_version.drive, ) .expect("expected to get root elements"); - assert_eq!(elements.len(), 11); + assert_eq!(elements.len(), 13); } #[test] @@ -324,8 +324,7 @@ mod tests { drive_version, ) .expect("expected to get root elements"); - assert_eq!(proof.len(), 248); - //it + left + right + parent + sibling + parent sibling + grandparent + assert_eq!(proof.len(), 248); //it + left + right + parent + sibling + parent sibling + grandparent let mut query = Query::new(); query.insert_key(vec![RootTree::Pools as u8]); @@ -347,7 +346,7 @@ mod tests { drive_version, ) .expect("expected to get root elements"); - assert_eq!(proof.len(), 184); //it + parent + sibling + parent sibling + grandparent + assert_eq!(proof.len(), 218); //it + left + parent + sibling + parent sibling + grandparent let mut query = Query::new(); query.insert_key(vec![RootTree::WithdrawalTransactions as u8]); @@ -372,7 +371,7 @@ mod tests { assert_eq!(proof.len(), 216); //it + left + parent + sibling + parent sibling + grandparent let mut query = Query::new(); - query.insert_key(vec![RootTree::Misc as u8]); + query.insert_key(vec![RootTree::Votes as u8]); let root_path_query = PathQuery::new( vec![], SizedQuery { @@ -391,7 +390,7 @@ mod tests { drive_version, ) .expect("expected to get root elements"); - assert_eq!(proof.len(), 216); //it + right + parent + sibling + parent sibling + grandparent + assert_eq!(proof.len(), 250); //it + left + right + parent + sibling + parent sibling + grandparent // Merk Level 3 @@ -415,7 +414,7 @@ mod tests { drive_version, ) .expect("expected to get root elements"); - assert_eq!(proof.len(), 248); + assert_eq!(proof.len(), 248); //it + parent + sibling + parent sibling + grandparent + grandparent sibling + great-grandparent let mut query = Query::new(); query.insert_key(vec![ @@ -439,7 +438,31 @@ mod tests { drive_version, ) .expect("expected to get root elements"); - assert_eq!(proof.len(), 248); + assert_eq!(proof.len(), 248); //it + parent + sibling + parent sibling + grandparent + grandparent sibling + great-grandparent + + let mut query = Query::new(); + query.insert_key(vec![ + RootTree::PreFundedSpecializedBalances as u8, + ]); + let root_path_query = PathQuery::new( + vec![], + SizedQuery { + query, + limit: None, + offset: None, + }, + ); + let mut drive_operations = vec![]; + let proof = drive + .grove_get_proved_path_query( + &root_path_query, + false, + None, + &mut drive_operations, + drive_version, + ) + .expect("expected to get root elements"); + assert_eq!(proof.len(), 217); //it + parent + parent sibling + grandparent + grandparent sibling + great-grandparent let mut query = Query::new(); query.insert_key(vec![RootTree::SpentAssetLockTransactions as u8]); @@ -461,7 +484,29 @@ mod tests { drive_version, ) .expect("expected to get root elements"); - assert_eq!(proof.len(), 214); + assert_eq!(proof.len(), 214); //it + parent + parent sibling + grandparent + grandparent sibling + great-grandparent + + let mut query = Query::new(); + query.insert_key(vec![RootTree::Misc as u8]); + let root_path_query = PathQuery::new( + vec![], + SizedQuery { + query, + limit: None, + offset: None, + }, + ); + let mut drive_operations = vec![]; + let proof = drive + .grove_get_proved_path_query( + &root_path_query, + false, + None, + &mut drive_operations, + drive_version, + ) + .expect("expected to get root elements"); + assert_eq!(proof.len(), 250); //it + parent + sibling + parent sibling + grandparent + grandparent sibling + great-grandparent let mut query = Query::new(); query.insert_key(vec![RootTree::Versions as u8]); @@ -483,6 +528,6 @@ mod tests { drive_version, ) .expect("expected to get root elements"); - assert_eq!(proof.len(), 216); + assert_eq!(proof.len(), 250); //it + parent + sibling + parent sibling + grandparent + grandparent sibling + great-grandparent } } diff --git a/packages/rs-drive/tests/deterministic_root_hash.rs b/packages/rs-drive/tests/deterministic_root_hash.rs index fa6ecc9091..8d88865943 100644 --- a/packages/rs-drive/tests/deterministic_root_hash.rs +++ b/packages/rs-drive/tests/deterministic_root_hash.rs @@ -446,7 +446,7 @@ fn test_root_hash_with_batches(drive: &Drive, db_transaction: &Transaction) { .unwrap() .expect("should return app hash"); - let expected_app_hash = "fa23fefadd8b0254b9e4c594f09026c070148f5de9c39ff9ea227a327761e062"; + let expected_app_hash = "09df2317697bb3cb2c6743f1a53890a9733367781ad87fabb860e042c94bc1b9"; assert_eq!(hex::encode(app_hash), expected_app_hash); } diff --git a/packages/rs-platform-value/Cargo.toml b/packages/rs-platform-value/Cargo.toml index 721e57b446..022ceb7761 100644 --- a/packages/rs-platform-value/Cargo.toml +++ b/packages/rs-platform-value/Cargo.toml @@ -12,7 +12,7 @@ bincode = { version = "2.0.0-rc.3", features = ["serde"] } ciborium = { git = "https://github.com/qrayven/ciborium", branch = "feat-ser-null-as-undefined", optional = true } thiserror = "1.0.58" bs58 = "0.5.1" -base64 = "0.22.0" +base64 = "0.22.1" hex = "0.4.3" serde = { version = "1.0.197", features = ["derive"] } serde_json = { version = "1.0", features = ["preserve_order"], optional = true } diff --git a/packages/rs-platform-value/src/types/binary_data.rs b/packages/rs-platform-value/src/types/binary_data.rs index 8eeb0fdc38..26cb7892fc 100644 --- a/packages/rs-platform-value/src/types/binary_data.rs +++ b/packages/rs-platform-value/src/types/binary_data.rs @@ -8,9 +8,16 @@ use serde::de::Visitor; use serde::{Deserialize, Serialize}; use std::fmt; -#[derive(Default, Debug, Clone, PartialEq, Eq, Ord, PartialOrd, Hash, Encode, Decode)] +#[derive(Default, Clone, PartialEq, Eq, Ord, PartialOrd, Hash, Encode, Decode)] pub struct BinaryData(pub Vec); +impl fmt::Debug for BinaryData { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(&format!("BinaryData(0x{})", hex::encode(&self.0))) + } +} + + impl Serialize for BinaryData { fn serialize(&self, serializer: S) -> Result where diff --git a/packages/rs-sdk/Cargo.toml b/packages/rs-sdk/Cargo.toml index f8a713ba0e..9cbae317ca 100644 --- a/packages/rs-sdk/Cargo.toml +++ b/packages/rs-sdk/Cargo.toml @@ -39,7 +39,7 @@ bip37-bloom-filter = { git = "https://github.com/dashpay/rs-bip37-bloom-filter", [dev-dependencies] tokio = { version = "1.36.0", features = ["macros", "rt-multi-thread"] } rs-dapi-client = { path = "../rs-dapi-client", features = ["mocks"] } -base64 = { version = "0.22.0" } +base64 = { version = "0.22.1" } tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } dpp = { path = "../rs-dpp", features = [ "client", diff --git a/packages/simple-signer/Cargo.toml b/packages/simple-signer/Cargo.toml index 0294a5fda4..216b148d1a 100644 --- a/packages/simple-signer/Cargo.toml +++ b/packages/simple-signer/Cargo.toml @@ -10,3 +10,4 @@ rust-version = "1.76" bincode = { version = "2.0.0-rc.3", features = ["serde"] } dashcore-rpc = { git = "https://github.com/dashpay/rust-dashcore-rpc", tag = "v0.15.2" } dpp = { path = "../rs-dpp", features = ["abci"] } +base64 = { version = "0.22.1"} diff --git a/packages/simple-signer/src/signer.rs b/packages/simple-signer/src/signer.rs index 84221419e0..5c30916a9d 100644 --- a/packages/simple-signer/src/signer.rs +++ b/packages/simple-signer/src/signer.rs @@ -9,15 +9,27 @@ use dpp::state_transition::errors::{ InvalidIdentityPublicKeyTypeError, InvalidSignaturePublicKeyError, }; use dpp::{bls_signatures, ed25519_dalek, ProtocolError}; -use std::collections::HashMap; +use std::collections::{BTreeMap, HashMap}; +use std::fmt::{Debug, Formatter}; +use base64::Engine; +use base64::prelude::BASE64_STANDARD; /// This simple signer is only to be used in tests -#[derive(Default, Clone, Debug, PartialEq, Encode, Decode)] +#[derive(Default, Clone, PartialEq, Encode, Decode)] pub struct SimpleSigner { /// Private keys is a map from the public key to the Private key bytes - pub private_keys: HashMap>, + pub private_keys: BTreeMap>, /// Private keys to be added at the end of a block - pub private_keys_in_creation: HashMap>, + pub private_keys_in_creation: BTreeMap>, +} + +impl Debug for SimpleSigner { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + f.debug_struct("SimpleSigner") + .field("private_keys", &self.private_keys.iter().map(|(k, v)| (k, format!("sk: {}", BASE64_STANDARD.encode(v)))).collect::>()) + .field("private_keys_in_creation", &self.private_keys_in_creation.iter().map(|(k, v)| (k, format!("sk: {}", BASE64_STANDARD.encode(v)))).collect::>()) + .finish() + } } impl SimpleSigner { @@ -34,7 +46,7 @@ impl SimpleSigner { /// Commit keys in creation pub fn commit_block_keys(&mut self) { self.private_keys - .extend(self.private_keys_in_creation.drain()) + .append(&mut self.private_keys_in_creation) } } @@ -48,8 +60,8 @@ impl Signer for SimpleSigner { .private_keys .get(identity_public_key) .or_else(|| self.private_keys_in_creation.get(identity_public_key)) - .ok_or(ProtocolError::InvalidSignaturePublicKeyError( - InvalidSignaturePublicKeyError::new(identity_public_key.data().to_vec()), + .ok_or(ProtocolError::Generic( + format!("{:?} not found in {:?}", identity_public_key, self) ))?; match identity_public_key.key_type() { KeyType::ECDSA_SECP256K1 | KeyType::ECDSA_HASH160 => { diff --git a/packages/strategy-tests/src/lib.rs b/packages/strategy-tests/src/lib.rs index e7259d476b..5be9dc1ea2 100644 --- a/packages/strategy-tests/src/lib.rs +++ b/packages/strategy-tests/src/lib.rs @@ -128,6 +128,7 @@ pub struct StartIdentities { pub keys_per_identity: u8, pub starting_balances: u64, // starting balance in duffs pub extra_keys: KeyMaps, + pub hard_coded: Vec<(Identity, StateTransition)>, } /// Identities to register on the first block of the strategy diff --git a/packages/strategy-tests/src/transitions.rs b/packages/strategy-tests/src/transitions.rs index 0ef26db956..aa2fcd26de 100644 --- a/packages/strategy-tests/src/transitions.rs +++ b/packages/strategy-tests/src/transitions.rs @@ -769,7 +769,7 @@ pub fn create_identities_state_transitions( /// - Conversion and encoding errors related to the cryptographic data. pub fn create_state_transitions_for_identities( identities: Vec, - signer: &mut SimpleSigner, + signer: &SimpleSigner, rng: &mut StdRng, platform_version: &PlatformVersion, ) -> Vec<(Identity, StateTransition)> { From 74ba6528b77c39ec6396351ac642f9234cb3d609 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 13 May 2024 18:32:41 +0200 Subject: [PATCH 054/135] more work --- .../document_type/methods/mod.rs | 30 ++++++++++++++++ .../mod.rs | 1 + .../v0/mod.rs | 35 +++++++++++++++++++ .../src/data_contract/document_type/mod.rs | 25 +++++++++++++ .../data_contract/extra/drive_api_tests.rs | 4 ++- packages/rs-dpp/src/identity/signer.rs | 2 +- .../v0/from_document.rs | 23 ++---------- .../document_create_transition/v0/mod.rs | 3 +- .../masternode_vote_transition/v0/mod.rs | 10 +++--- .../traits/state_transition_like.rs | 5 +-- packages/rs-dpp/src/util/json_schema.rs | 5 ++- packages/rs-dpp/src/voting/votes/mod.rs | 10 +----- .../src/voting/votes/resource_vote/mod.rs | 10 +----- .../create_genesis_state/v0/mod.rs | 3 +- .../tests/strategy_tests/strategy.rs | 24 +++++++++++-- .../v0/mod.rs | 4 +-- .../src/drive/initialization/v0/mod.rs | 4 +-- .../src/types/binary_data.rs | 1 - .../src/version/dpp_versions.rs | 1 + .../src/version/mocks/v2_test.rs | 1 + .../src/version/mocks/v3_test.rs | 1 + .../rs-platform-version/src/version/v1.rs | 1 + packages/simple-signer/src/signer.rs | 32 ++++++++++++----- .../src/errors/consensus/consensus_error.rs | 4 +-- .../identity_create_transition.rs | 2 +- .../state_transition_factory.rs | 2 +- packages/wasm-dpp/src/voting/mod.rs | 2 +- .../masternode_vote_transition/mod.rs | 32 ++++++++--------- .../masternode_vote_transition/to_object.rs | 6 ++-- .../src/voting/state_transition/mod.rs | 2 +- 30 files changed, 188 insertions(+), 97 deletions(-) create mode 100644 packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/mod.rs create mode 100644 packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/v0/mod.rs diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs index c2d8044aa0..5853fb160f 100644 --- a/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs @@ -3,6 +3,7 @@ mod create_document_with_prevalidated_properties; mod estimated_size; mod index_for_types; mod max_size; +mod prefunded_voting_balances_for_document; mod serialize_value_for_key; mod validate_update; @@ -18,6 +19,7 @@ use crate::prelude::{BlockHeight, CoreBlockHeight, Revision}; use crate::version::PlatformVersion; use crate::ProtocolError; +use crate::fee::Credits; use platform_value::{Identifier, Value}; // TODO: Some of those methods are only for tests. Hide under feature @@ -109,6 +111,13 @@ pub trait DocumentTypeV0Methods { properties: BTreeMap, platform_version: &PlatformVersion, ) -> Result; + + /// Figures out the minimum prefunded voting balance needed for a document + fn prefunded_voting_balances_for_document( + &self, + document: &Document, + platform_version: &PlatformVersion, + ) -> Result, ProtocolError>; } impl DocumentTypeV0Methods for DocumentTypeV0 { @@ -293,4 +302,25 @@ impl DocumentTypeV0Methods for DocumentTypeV0 { }), } } + + fn prefunded_voting_balances_for_document( + &self, + document: &Document, + platform_version: &PlatformVersion, + ) -> Result, ProtocolError> { + match platform_version + .dpp + .contract_versions + .document_type_versions + .methods + .create_document_with_prevalidated_properties + { + 0 => Ok(self.prefunded_voting_balances_for_document_v0(document, platform_version)), + version => Err(ProtocolError::UnknownVersionMismatch { + method: "prefunded_voting_balances_for_document".to_string(), + known_versions: vec![0], + received: version, + }), + } + } } diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/mod.rs new file mode 100644 index 0000000000..e084dffc38 --- /dev/null +++ b/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/mod.rs @@ -0,0 +1 @@ +mod v0; diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/v0/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/v0/mod.rs new file mode 100644 index 0000000000..fc820495cb --- /dev/null +++ b/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/v0/mod.rs @@ -0,0 +1,35 @@ +use crate::data_contract::document_type::accessors::DocumentTypeV0Getters; +use crate::data_contract::document_type::v0::DocumentTypeV0; +use crate::document::{Document, DocumentV0Getters}; +use crate::fee::Credits; +use crate::version::PlatformVersion; +use std::collections::BTreeMap; + +impl DocumentTypeV0 { + /// Figures out the prefunded voting balance (v0) for a document in a document type + pub(in crate::data_contract::document_type) fn prefunded_voting_balances_for_document_v0( + &self, + document: &Document, + platform_version: &PlatformVersion, + ) -> BTreeMap { + self.indexes() + .iter() + .filter_map(|(name, index)| { + if let Some(contested_index_info) = &index.contested_index { + if let Some(value) = document.get(&contested_index_info.contested_field_name) { + if contested_index_info.field_match.matches(value) { + return Some(( + name.clone(), + platform_version + .fee_version + .vote_resolution_fund_fees + .conflicting_vote_resolution_fund_required_amount, + )); + } + } + } + None + }) + .collect() + } +} diff --git a/packages/rs-dpp/src/data_contract/document_type/mod.rs b/packages/rs-dpp/src/data_contract/document_type/mod.rs index c9a358ad07..6ce89c0e7b 100644 --- a/packages/rs-dpp/src/data_contract/document_type/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/mod.rs @@ -18,6 +18,7 @@ pub mod v0; use crate::data_contract::document_type::methods::DocumentTypeV0Methods; use crate::data_contract::document_type::v0::DocumentTypeV0; use crate::document::Document; +use crate::fee::Credits; use crate::prelude::{BlockHeight, CoreBlockHeight, Revision}; use crate::version::PlatformVersion; use crate::ProtocolError; @@ -85,6 +86,18 @@ impl DocumentType { DocumentType::V0(v0) => DocumentTypeMutRef::V0(v0), } } + + pub fn prefunded_voting_balances_for_document( + &self, + document: &Document, + platform_version: &PlatformVersion, + ) -> Result, ProtocolError> { + match self { + DocumentType::V0(v0) => { + v0.prefunded_voting_balances_for_document(document, platform_version) + } + } + } } impl<'a> DocumentTypeRef<'a> { @@ -208,4 +221,16 @@ impl<'a> DocumentTypeV0Methods for DocumentTypeRef<'a> { ), } } + + fn prefunded_voting_balances_for_document( + &self, + document: &Document, + platform_version: &PlatformVersion, + ) -> Result, ProtocolError> { + match self { + DocumentTypeRef::V0(v0) => { + v0.prefunded_voting_balances_for_document(document, platform_version) + } + } + } } diff --git a/packages/rs-dpp/src/data_contract/extra/drive_api_tests.rs b/packages/rs-dpp/src/data_contract/extra/drive_api_tests.rs index 9d48585768..0bec6871af 100644 --- a/packages/rs-dpp/src/data_contract/extra/drive_api_tests.rs +++ b/packages/rs-dpp/src/data_contract/extra/drive_api_tests.rs @@ -174,7 +174,9 @@ mod test { .document_types .get("contactInfo") .unwrap() - .indexes().values().collect::>(); + .indexes() + .values() + .collect::>(); assert_eq!(contact_info_indices.len(), 2); assert!(contact_info_indices[1].unique); assert!(!contact_info_indices[0].unique); diff --git a/packages/rs-dpp/src/identity/signer.rs b/packages/rs-dpp/src/identity/signer.rs index b7df7f29f5..549a55da42 100644 --- a/packages/rs-dpp/src/identity/signer.rs +++ b/packages/rs-dpp/src/identity/signer.rs @@ -1,7 +1,7 @@ -use std::fmt::Debug; use crate::prelude::IdentityPublicKey; use crate::ProtocolError; use platform_value::BinaryData; +use std::fmt::Debug; pub trait Signer: Sync + Debug { /// the public key bytes are only used to look up the private key diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/from_document.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/from_document.rs index e7ad6adb44..8d7be64dd8 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/from_document.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/from_document.rs @@ -1,4 +1,5 @@ use crate::data_contract::document_type::accessors::DocumentTypeV0Getters; +use crate::data_contract::document_type::methods::DocumentTypeV0Methods; use crate::data_contract::document_type::DocumentTypeRef; use crate::document::{Document, DocumentV0Getters}; use crate::prelude::IdentityNonce; @@ -16,26 +17,8 @@ impl DocumentCreateTransitionV0 { platform_version: &PlatformVersion, base_feature_version: Option, ) -> Result { - let prefunded_voting_balances = document_type - .indexes() - .iter() - .filter_map(|(name, index)| { - if let Some(contested_index_info) = &index.contested_index { - if let Some(value) = document.get(&contested_index_info.contested_field_name) { - if contested_index_info.field_match.matches(value) { - return Some(( - name.clone(), - platform_version - .fee_version - .vote_resolution_fund_fees - .conflicting_vote_resolution_fund_required_amount, - )); - } - } - } - None - }) - .collect(); + let prefunded_voting_balances = + document_type.prefunded_voting_balances_for_document(&document, platform_version)?; Ok(DocumentCreateTransitionV0 { base: DocumentBaseTransition::from_document( &document, diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs index 5f1c409b65..aa555122e5 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs @@ -98,7 +98,8 @@ impl DocumentCreateTransitionV0 { .remove_hash256_bytes(property_names::ENTROPY) .map_err(ProtocolError::ValueError)?, prefunded_voting_balances: map - .remove_optional_map_as_btree_map(property_names::PREFUNDED_VOTING_BALANCES)?.unwrap_or_default(), + .remove_optional_map_as_btree_map(property_names::PREFUNDED_VOTING_BALANCES)? + .unwrap_or_default(), data: map, }) } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs index 0e809163bf..4d707ea1c3 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/mod.rs @@ -54,15 +54,15 @@ mod test { use crate::serialization::{PlatformDeserializable, PlatformSerializable}; use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; + use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; + use crate::voting::vote_polls::VotePoll; + use crate::voting::votes::resource_vote::v0::ResourceVoteV0; + use crate::voting::votes::resource_vote::ResourceVote; use crate::voting::votes::Vote; use platform_value::Identifier; use rand::Rng; use std::fmt::Debug; - use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; - use crate::voting::vote_polls::VotePoll; - use crate::voting::votes::resource_vote::ResourceVote; - use crate::voting::votes::resource_vote::v0::ResourceVoteV0; fn test_masternode_vote_transition< T: PlatformSerializable + PlatformDeserializable + Debug + PartialEq, @@ -89,7 +89,7 @@ mod test { document_type_name: "hello".to_string(), index_name: "index_1".to_string(), index_values: vec![], - } + }, ), resource_vote_choice: ResourceVoteChoice::TowardsIdentity(Identifier::random()), })), diff --git a/packages/rs-dpp/src/state_transition/traits/state_transition_like.rs b/packages/rs-dpp/src/state_transition/traits/state_transition_like.rs index 678c21ee10..6af9b7a2fc 100644 --- a/packages/rs-dpp/src/state_transition/traits/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/traits/state_transition_like.rs @@ -19,9 +19,7 @@ pub const IDENTITY_TRANSITION_TYPE: [StateTransitionType; 5] = [ StateTransitionType::IdentityCreditWithdrawal, ]; -pub const VOTING_TRANSITION_TYPE: [StateTransitionType; 1] = [ - StateTransitionType::MasternodeVote, -]; +pub const VOTING_TRANSITION_TYPE: [StateTransitionType; 1] = [StateTransitionType::MasternodeVote]; pub const DATA_CONTRACT_TRANSITION_TYPES: [StateTransitionType; 2] = [ StateTransitionType::DataContractCreate, @@ -66,7 +64,6 @@ pub trait StateTransitionLike: VOTING_TRANSITION_TYPE.contains(&self.state_transition_type()) } - fn set_signature_bytes(&mut self, signature: Vec); /// Get owner ID diff --git a/packages/rs-dpp/src/util/json_schema.rs b/packages/rs-dpp/src/util/json_schema.rs index 5974f0771c..10eb520568 100644 --- a/packages/rs-dpp/src/util/json_schema.rs +++ b/packages/rs-dpp/src/util/json_schema.rs @@ -232,7 +232,10 @@ mod test { assert_eq!(indices["&ownerId&updatedAt"].name, "&ownerId&updatedAt"); assert_eq!(indices["&ownerId&updatedAt"].properties.len(), 2); assert_eq!(indices["&ownerId&updatedAt"].properties[0].name, "$ownerId"); - assert_eq!(indices["&ownerId&updatedAt"].properties[1].name, "$updatedAt"); + assert_eq!( + indices["&ownerId&updatedAt"].properties[1].name, + "$updatedAt" + ); assert!(!indices["&ownerId&updatedAt"].unique); } } diff --git a/packages/rs-dpp/src/voting/votes/mod.rs b/packages/rs-dpp/src/voting/votes/mod.rs index 810f42b4e7..636cd5d302 100644 --- a/packages/rs-dpp/src/voting/votes/mod.rs +++ b/packages/rs-dpp/src/voting/votes/mod.rs @@ -8,15 +8,7 @@ use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use platform_value::Identifier; use serde::{Deserialize, Serialize}; -#[derive( -Debug, -Clone, -Encode, -Decode, -PlatformSerialize, -PlatformDeserialize, -PartialEq, -)] +#[derive(Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize, PartialEq)] #[cfg_attr( feature = "vote-serde-conversion", derive(Serialize, Deserialize), diff --git a/packages/rs-dpp/src/voting/votes/resource_vote/mod.rs b/packages/rs-dpp/src/voting/votes/resource_vote/mod.rs index a3ca4ccae4..8ee89fe371 100644 --- a/packages/rs-dpp/src/voting/votes/resource_vote/mod.rs +++ b/packages/rs-dpp/src/voting/votes/resource_vote/mod.rs @@ -8,15 +8,7 @@ use serde::{Deserialize, Serialize}; pub mod accessors; pub mod v0; -#[derive( -Debug, -Clone, -Encode, -Decode, -PlatformSerialize, -PlatformDeserialize, -PartialEq, -)] +#[derive(Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize, PartialEq)] #[cfg_attr( feature = "vote-serde-conversion", derive(Serialize, Deserialize), diff --git a/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs index d8c38cb8a7..1cfabd0a77 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs @@ -287,7 +287,8 @@ mod tests { assert_eq!( root_hash, [ - 240, 136, 118, 187, 50, 89, 9, 222, 55, 136, 185, 144, 40, 137, 74, 135, 132, 142, 233, 191, 242, 65, 51, 153, 97, 74, 223, 91, 161, 40, 131, 60 + 240, 136, 118, 187, 50, 89, 9, 222, 55, 136, 185, 144, 40, 137, 74, 135, 132, + 142, 233, 191, 242, 65, 51, 153, 97, 74, 223, 91, 161, 40, 131, 60 ] ) } diff --git a/packages/rs-drive-abci/tests/strategy_tests/strategy.rs b/packages/rs-drive-abci/tests/strategy_tests/strategy.rs index 1cf8e0b02d..87e50df1c7 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/strategy.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/strategy.rs @@ -383,7 +383,7 @@ impl NetworkStrategy { if !self.strategy.start_identities.hard_coded.is_empty() { state_transitions.extend(self.strategy.start_identities.hard_coded.clone()); } - } + } let frequency = &self.strategy.identity_inserts.frequency; if frequency.check_hit(rng) { let count = frequency.events(rng); @@ -571,6 +571,15 @@ impl NetworkStrategy { as u64; *identity_contract_nonce += 1 + gap; + let prefunded_voting_balances = document_type + .prefunded_voting_balances_for_document( + &document, + platform_version, + ) + .expect( + "expected to get prefunded voting balances for document", + ); + let document_create_transition: DocumentCreateTransition = DocumentCreateTransitionV0 { base: DocumentBaseTransitionV0 { @@ -582,7 +591,7 @@ impl NetworkStrategy { .into(), entropy: entropy.to_buffer(), data: document.properties_consumed(), - prefunded_voting_balances: Default::default(), + prefunded_voting_balances, } .into(); @@ -683,6 +692,15 @@ impl NetworkStrategy { .or_default(); *identity_contract_nonce += 1; + let prefunded_voting_balances = document_type + .prefunded_voting_balances_for_document( + &document, + platform_version, + ) + .expect( + "expected to get prefunded voting balances for document", + ); + let document_create_transition: DocumentCreateTransition = DocumentCreateTransitionV0 { base: DocumentBaseTransitionV0 { @@ -694,7 +712,7 @@ impl NetworkStrategy { .into(), entropy: entropy.to_buffer(), data: document.properties_consumed(), - prefunded_voting_balances: Default::default(), + prefunded_voting_balances, } .into(); diff --git a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs index e5ed38088d..acc1453e53 100644 --- a/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -83,8 +83,7 @@ impl Drive { // This is the simpler situation // Under each tree we have all the references - if let Some(estimated_costs_only_with_layer_info) = - estimated_costs_only_with_layer_info + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { // On this level we will have a 0 and all the top index paths estimated_costs_only_with_layer_info.insert( @@ -140,7 +139,6 @@ impl Drive { // here we should return an error if the element already exists self.batch_insert(path_key_element_info, batch_operations, drive_version)?; - } else { let key_element_info = match &document_and_contract_info.owned_document_info.document_info { diff --git a/packages/rs-drive/src/drive/initialization/v0/mod.rs b/packages/rs-drive/src/drive/initialization/v0/mod.rs index 72c648dd5a..47feebe364 100644 --- a/packages/rs-drive/src/drive/initialization/v0/mod.rs +++ b/packages/rs-drive/src/drive/initialization/v0/mod.rs @@ -441,9 +441,7 @@ mod tests { assert_eq!(proof.len(), 248); //it + parent + sibling + parent sibling + grandparent + grandparent sibling + great-grandparent let mut query = Query::new(); - query.insert_key(vec![ - RootTree::PreFundedSpecializedBalances as u8, - ]); + query.insert_key(vec![RootTree::PreFundedSpecializedBalances as u8]); let root_path_query = PathQuery::new( vec![], SizedQuery { diff --git a/packages/rs-platform-value/src/types/binary_data.rs b/packages/rs-platform-value/src/types/binary_data.rs index 26cb7892fc..538978425a 100644 --- a/packages/rs-platform-value/src/types/binary_data.rs +++ b/packages/rs-platform-value/src/types/binary_data.rs @@ -17,7 +17,6 @@ impl fmt::Debug for BinaryData { } } - impl Serialize for BinaryData { fn serialize(&self, serializer: S) -> Result where diff --git a/packages/rs-platform-version/src/version/dpp_versions.rs b/packages/rs-platform-version/src/version/dpp_versions.rs index 766e1502b7..ac56351bad 100644 --- a/packages/rs-platform-version/src/version/dpp_versions.rs +++ b/packages/rs-platform-version/src/version/dpp_versions.rs @@ -184,6 +184,7 @@ pub struct DocumentTypeVersions { pub struct DocumentTypeMethodVersions { pub create_document_from_data: FeatureVersion, pub create_document_with_prevalidated_properties: FeatureVersion, + pub prefunded_voting_balances_for_document: FeatureVersion, pub estimated_size: FeatureVersion, pub index_for_types: FeatureVersion, pub max_size: FeatureVersion, diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index a31e023026..3a49006c8f 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -1073,6 +1073,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { methods: DocumentTypeMethodVersions { create_document_from_data: 0, create_document_with_prevalidated_properties: 0, + prefunded_voting_balances_for_document: 0, estimated_size: 0, index_for_types: 0, max_size: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 22129bdf0d..6e33b29796 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -1073,6 +1073,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { methods: DocumentTypeMethodVersions { create_document_from_data: 0, create_document_with_prevalidated_properties: 0, + prefunded_voting_balances_for_document: 0, estimated_size: 0, index_for_types: 0, max_size: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 909155db00..8568168490 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -1072,6 +1072,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { methods: DocumentTypeMethodVersions { create_document_from_data: 0, create_document_with_prevalidated_properties: 0, + prefunded_voting_balances_for_document: 0, estimated_size: 0, index_for_types: 0, max_size: 0, diff --git a/packages/simple-signer/src/signer.rs b/packages/simple-signer/src/signer.rs index 5c30916a9d..b894a9a565 100644 --- a/packages/simple-signer/src/signer.rs +++ b/packages/simple-signer/src/signer.rs @@ -1,3 +1,5 @@ +use base64::prelude::BASE64_STANDARD; +use base64::Engine; use dashcore_rpc::dashcore::signer; use dpp::bincode::{Decode, Encode}; use dpp::ed25519_dalek::Signer as BlsSigner; @@ -11,8 +13,6 @@ use dpp::state_transition::errors::{ use dpp::{bls_signatures, ed25519_dalek, ProtocolError}; use std::collections::{BTreeMap, HashMap}; use std::fmt::{Debug, Formatter}; -use base64::Engine; -use base64::prelude::BASE64_STANDARD; /// This simple signer is only to be used in tests #[derive(Default, Clone, PartialEq, Encode, Decode)] @@ -26,8 +26,22 @@ pub struct SimpleSigner { impl Debug for SimpleSigner { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { f.debug_struct("SimpleSigner") - .field("private_keys", &self.private_keys.iter().map(|(k, v)| (k, format!("sk: {}", BASE64_STANDARD.encode(v)))).collect::>()) - .field("private_keys_in_creation", &self.private_keys_in_creation.iter().map(|(k, v)| (k, format!("sk: {}", BASE64_STANDARD.encode(v)))).collect::>()) + .field( + "private_keys", + &self + .private_keys + .iter() + .map(|(k, v)| (k, format!("sk: {}", BASE64_STANDARD.encode(v)))) + .collect::>(), + ) + .field( + "private_keys_in_creation", + &self + .private_keys_in_creation + .iter() + .map(|(k, v)| (k, format!("sk: {}", BASE64_STANDARD.encode(v)))) + .collect::>(), + ) .finish() } } @@ -45,8 +59,7 @@ impl SimpleSigner { /// Commit keys in creation pub fn commit_block_keys(&mut self) { - self.private_keys - .append(&mut self.private_keys_in_creation) + self.private_keys.append(&mut self.private_keys_in_creation) } } @@ -60,9 +73,10 @@ impl Signer for SimpleSigner { .private_keys .get(identity_public_key) .or_else(|| self.private_keys_in_creation.get(identity_public_key)) - .ok_or(ProtocolError::Generic( - format!("{:?} not found in {:?}", identity_public_key, self) - ))?; + .ok_or(ProtocolError::Generic(format!( + "{:?} not found in {:?}", + identity_public_key, self + )))?; match identity_public_key.key_type() { KeyType::ECDSA_SECP256K1 | KeyType::ECDSA_HASH160 => { let signature = signer::sign(data, private_key)?; diff --git a/packages/wasm-dpp/src/errors/consensus/consensus_error.rs b/packages/wasm-dpp/src/errors/consensus/consensus_error.rs index 734aa55fd6..ff680bc364 100644 --- a/packages/wasm-dpp/src/errors/consensus/consensus_error.rs +++ b/packages/wasm-dpp/src/errors/consensus/consensus_error.rs @@ -486,9 +486,7 @@ fn from_basic_error(basic_error: &BasicError) -> JsValue { BasicError::DocumentCreationNotAllowedError(e) => { generic_consensus_error!(DocumentCreationNotAllowedError, e).into() } - BasicError::OverflowError(e) => { - generic_consensus_error!(OverflowError, e).into() - } + BasicError::OverflowError(e) => generic_consensus_error!(OverflowError, e).into(), } } diff --git a/packages/wasm-dpp/src/identity/state_transition/identity_create_transition/identity_create_transition.rs b/packages/wasm-dpp/src/identity/state_transition/identity_create_transition/identity_create_transition.rs index ee0fe912f4..86681592df 100644 --- a/packages/wasm-dpp/src/identity/state_transition/identity_create_transition/identity_create_transition.rs +++ b/packages/wasm-dpp/src/identity/state_transition/identity_create_transition/identity_create_transition.rs @@ -315,7 +315,7 @@ impl IdentityCreateTransitionWasm { pub fn is_identity_state_transition(&self) -> bool { self.0.is_identity_state_transition() } - + #[wasm_bindgen(js_name=isVotingStateTransition)] pub fn is_voting_state_transition(&self) -> bool { self.0.is_voting_state_transition() diff --git a/packages/wasm-dpp/src/state_transition/state_transition_factory.rs b/packages/wasm-dpp/src/state_transition/state_transition_factory.rs index ae2d8cb447..8b3f8bfa86 100644 --- a/packages/wasm-dpp/src/state_transition/state_transition_factory.rs +++ b/packages/wasm-dpp/src/state_transition/state_transition_factory.rs @@ -7,12 +7,12 @@ use crate::identity::state_transition::{ IdentityUpdateTransitionWasm, }; use crate::state_transition::errors::invalid_state_transition_error::InvalidStateTransitionErrorWasm; +use crate::voting::state_transition::masternode_vote_transition::MasternodeVoteTransitionWasm; use dpp::state_transition::errors::StateTransitionError; use dpp::state_transition::state_transition_factory::StateTransitionFactory; use dpp::state_transition::StateTransition; use dpp::ProtocolError; use wasm_bindgen::{prelude::wasm_bindgen, JsValue}; -use crate::voting::state_transition::masternode_vote_transition::MasternodeVoteTransitionWasm; #[wasm_bindgen(js_name = StateTransitionFactory)] pub struct StateTransitionFactoryWasm(StateTransitionFactory); diff --git a/packages/wasm-dpp/src/voting/mod.rs b/packages/wasm-dpp/src/voting/mod.rs index 19f8d4cabc..189974a343 100644 --- a/packages/wasm-dpp/src/voting/mod.rs +++ b/packages/wasm-dpp/src/voting/mod.rs @@ -1 +1 @@ -pub mod state_transition; \ No newline at end of file +pub mod state_transition; diff --git a/packages/wasm-dpp/src/voting/state_transition/masternode_vote_transition/mod.rs b/packages/wasm-dpp/src/voting/state_transition/masternode_vote_transition/mod.rs index 4276a8361d..fb6b05e3c5 100644 --- a/packages/wasm-dpp/src/voting/state_transition/masternode_vote_transition/mod.rs +++ b/packages/wasm-dpp/src/voting/state_transition/masternode_vote_transition/mod.rs @@ -1,22 +1,22 @@ mod to_object; -use wasm_bindgen::{JsError, JsValue}; -use wasm_bindgen::prelude::wasm_bindgen; +use crate::bls_adapter::{BlsAdapter, JsBlsAdapter}; +use crate::buffer::Buffer; +use crate::errors::from_dpp_err; +use crate::identifier::IdentifierWrapper; +use crate::utils::WithJsError; +use crate::{with_js_error, IdentityPublicKeyWasm}; use dpp::identifier::Identifier; use dpp::identity::KeyType; -use dpp::platform_value::{BinaryData, string_encoding}; use dpp::platform_value::string_encoding::Encoding; +use dpp::platform_value::{string_encoding, BinaryData}; use dpp::serialization::PlatformSerializable; +use dpp::state_transition::masternode_vote_transition::accessors::MasternodeVoteTransitionAccessorsV0; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; use dpp::state_transition::{StateTransition, StateTransitionIdentitySigned, StateTransitionLike}; -use dpp::state_transition::masternode_vote_transition::accessors::MasternodeVoteTransitionAccessorsV0; use dpp::version::PlatformVersion; -use crate::bls_adapter::{BlsAdapter, JsBlsAdapter}; -use crate::buffer::Buffer; -use crate::errors::from_dpp_err; -use crate::identifier::IdentifierWrapper; -use crate::{IdentityPublicKeyWasm, with_js_error}; -use crate::utils::WithJsError; +use wasm_bindgen::prelude::wasm_bindgen; +use wasm_bindgen::{JsError, JsValue}; #[derive(Clone)] #[wasm_bindgen(js_name=MasternodeVoteTransition)] @@ -60,7 +60,7 @@ impl MasternodeVoteTransitionWasm { pub fn get_pro_tx_hash(&self) -> IdentifierWrapper { self.0.pro_tx_hash().into() } - + #[wasm_bindgen(js_name=setIdentityId)] pub fn set_pro_tx_hash(&mut self, pro_tx_hash: &IdentifierWrapper) { self.0.set_pro_tx_hash(pro_tx_hash.into()); @@ -125,10 +125,10 @@ impl MasternodeVoteTransitionWasm { #[wasm_bindgen(js_name=toBuffer)] pub fn to_buffer(&self) -> Result { - let bytes = PlatformSerializable::serialize_to_bytes( - &StateTransition::MasternodeVote(self.0.clone()), - ) - .with_js_error()?; + let bytes = PlatformSerializable::serialize_to_bytes(&StateTransition::MasternodeVote( + self.0.clone(), + )) + .with_js_error()?; Ok(Buffer::from_bytes(&bytes)) } @@ -230,7 +230,7 @@ impl MasternodeVoteTransitionWasm { return Err(JsError::new( format!("BLS adapter is required for BLS key type '{}'", key_type).as_str(), ) - .into()); + .into()); } let bls_adapter = if let Some(adapter) = bls { diff --git a/packages/wasm-dpp/src/voting/state_transition/masternode_vote_transition/to_object.rs b/packages/wasm-dpp/src/voting/state_transition/masternode_vote_transition/to_object.rs index 63eeebb095..bdc8ba6d14 100644 --- a/packages/wasm-dpp/src/voting/state_transition/masternode_vote_transition/to_object.rs +++ b/packages/wasm-dpp/src/voting/state_transition/masternode_vote_transition/to_object.rs @@ -1,12 +1,12 @@ use dpp::identity::KeyID; +use dpp::state_transition::masternode_vote_transition::accessors::MasternodeVoteTransitionAccessorsV0; +use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; use dpp::state_transition::StateTransitionIdentitySigned; +use dpp::voting::votes::Vote; use dpp::{identifier::Identifier, state_transition::StateTransitionLike}; use serde::Deserialize; use std::default::Default; -use dpp::state_transition::masternode_vote_transition::accessors::MasternodeVoteTransitionAccessorsV0; -use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; -use dpp::voting::votes::Vote; #[derive(Deserialize, Default)] #[serde(rename_all = "camelCase")] diff --git a/packages/wasm-dpp/src/voting/state_transition/mod.rs b/packages/wasm-dpp/src/voting/state_transition/mod.rs index 95ae4f4550..e7283f9c79 100644 --- a/packages/wasm-dpp/src/voting/state_transition/mod.rs +++ b/packages/wasm-dpp/src/voting/state_transition/mod.rs @@ -1 +1 @@ -pub mod masternode_vote_transition; \ No newline at end of file +pub mod masternode_vote_transition; From 0454ce18aa155e4957c43a1b40b8afd97218a90c Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 14 May 2024 04:53:58 +0200 Subject: [PATCH 055/135] a lot more work --- .../contested_vote_poll_for_document/mod.rs | 1 + .../v0/mod.rs | 36 +++ .../document_type/methods/mod.rs | 44 +++- .../v0/mod.rs | 31 ++- .../src/data_contract/document_type/mod.rs | 19 +- .../v0/from_document.rs | 6 +- .../document_create_transition/v0/mod.rs | 6 +- .../v0/v0_methods.rs | 25 +- .../document_create_transition/v0_methods.rs | 18 +- .../v0/v0_methods.rs | 4 +- .../find_duplicates_by_id/v0/mod.rs | 2 +- .../tests/strategy_tests/strategy.rs | 4 +- .../drive/batch/drive_op_batch/document.rs | 13 +- .../document/document_create_transition.rs | 49 ++-- .../v0/mod.rs | 2 +- .../v0/mod.rs | 2 +- .../v0/mod.rs | 3 +- .../mod.rs | 65 ++++++ .../v0/mod.rs | 90 ++++++++ .../mod.rs | 2 +- .../v0/mod.rs | 2 +- .../drive/document/estimation_costs/mod.rs | 2 + .../v0/mod.rs | 2 +- .../add_document_to_primary_storage/v0/mod.rs | 8 +- .../v0/mod.rs | 3 +- .../add_contested_document/mod.rs | 11 +- .../add_contested_document/v0/mod.rs | 14 +- .../mod.rs | 7 +- .../v0/mod.rs | 7 +- .../mod.rs | 7 +- .../v0/mod.rs | 10 +- .../mod.rs | 7 +- .../v0/mod.rs | 77 ++----- .../mod.rs | 2 - .../v0/mod.rs | 218 +----------------- .../v0/mod.rs | 3 +- packages/rs-drive/src/drive/document/mod.rs | 135 +---------- packages/rs-drive/src/drive/document/paths.rs | 105 +++++++++ .../v0/mod.rs | 7 +- .../mod.rs | 2 +- .../v0/mod.rs | 23 +- .../src/drive/votes/insert/vote_poll/mod.rs | 2 +- packages/rs-drive/src/drive/votes/mod.rs | 2 +- packages/rs-drive/src/drive/votes/paths.rs | 39 ++++ .../src/query/single_document_drive_query.rs | 2 +- .../document_create_transition_action/mod.rs | 10 +- .../v0/mod.rs | 8 +- .../v0/transformer.rs | 26 +-- .../document/documents_batch/v0/mod.rs | 2 +- .../src/version/dpp_versions.rs | 9 +- .../src/version/drive_versions.rs | 1 + .../src/version/mocks/v2_test.rs | 18 +- .../src/version/mocks/v3_test.rs | 18 +- .../rs-platform-version/src/version/v1.rs | 18 +- packages/strategy-tests/src/lib.rs | 4 +- 55 files changed, 611 insertions(+), 622 deletions(-) create mode 100644 packages/rs-dpp/src/data_contract/document_type/methods/contested_vote_poll_for_document/mod.rs create mode 100644 packages/rs-dpp/src/data_contract/document_type/methods/contested_vote_poll_for_document/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/mod.rs create mode 100644 packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/document/paths.rs diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/contested_vote_poll_for_document/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/contested_vote_poll_for_document/mod.rs new file mode 100644 index 0000000000..e084dffc38 --- /dev/null +++ b/packages/rs-dpp/src/data_contract/document_type/methods/contested_vote_poll_for_document/mod.rs @@ -0,0 +1 @@ +mod v0; diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/contested_vote_poll_for_document/v0/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/contested_vote_poll_for_document/v0/mod.rs new file mode 100644 index 0000000000..33156402f4 --- /dev/null +++ b/packages/rs-dpp/src/data_contract/document_type/methods/contested_vote_poll_for_document/v0/mod.rs @@ -0,0 +1,36 @@ +use crate::data_contract::document_type::accessors::DocumentTypeV0Getters; +use crate::data_contract::document_type::v0::DocumentTypeV0; +use crate::document::{Document, DocumentV0Getters}; +use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use crate::voting::vote_polls::VotePoll; + +impl DocumentTypeV0 { + /// Figures out the prefunded voting balance (v0) for a document in a document type + pub(in crate::data_contract::document_type) fn contested_vote_poll_for_document_v0( + &self, + document: &Document, + ) -> Option { + self.indexes() + .iter() + .find(|(name, index)| { + if let Some(contested_index_info) = &index.contested_index { + if let Some(value) = document.get(&contested_index_info.contested_field_name) { + contested_index_info.field_match.matches(value) + } else { + false + } + } else { + false + } + }).map(|(name, index)| { + + let index_values = index.extract_values(document.properties()); + VotePoll::ContestedDocumentResourceVotePoll(ContestedDocumentResourceVotePoll { + contract_id: self.data_contract_id, + document_type_name: self.name.clone(), + index_name: index.name.clone(), + index_values, + }) + }) + } +} diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs index 5853fb160f..2728aafe2c 100644 --- a/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs @@ -6,6 +6,7 @@ mod max_size; mod prefunded_voting_balances_for_document; mod serialize_value_for_key; mod validate_update; +mod contested_vote_poll_for_document; use std::collections::BTreeMap; @@ -21,6 +22,7 @@ use crate::ProtocolError; use crate::fee::Credits; use platform_value::{Identifier, Value}; +use crate::voting::vote_polls::VotePoll; // TODO: Some of those methods are only for tests. Hide under feature pub trait DocumentTypeV0Methods { @@ -113,11 +115,18 @@ pub trait DocumentTypeV0Methods { ) -> Result; /// Figures out the minimum prefunded voting balance needed for a document - fn prefunded_voting_balances_for_document( + fn prefunded_voting_balance_for_document( &self, document: &Document, platform_version: &PlatformVersion, - ) -> Result, ProtocolError>; + ) -> Result, ProtocolError>; + + /// Gets the vote poll associated with a document + fn contested_vote_poll_for_document( + &self, + document: &Document, + platform_version: &PlatformVersion, + ) -> Result, ProtocolError>; } impl DocumentTypeV0Methods for DocumentTypeV0 { @@ -303,19 +312,19 @@ impl DocumentTypeV0Methods for DocumentTypeV0 { } } - fn prefunded_voting_balances_for_document( + fn prefunded_voting_balance_for_document( &self, document: &Document, platform_version: &PlatformVersion, - ) -> Result, ProtocolError> { + ) -> Result, ProtocolError> { match platform_version .dpp .contract_versions .document_type_versions .methods - .create_document_with_prevalidated_properties + .prefunded_voting_balance_for_document { - 0 => Ok(self.prefunded_voting_balances_for_document_v0(document, platform_version)), + 0 => Ok(self.prefunded_voting_balance_for_document_v0(document, platform_version)), version => Err(ProtocolError::UnknownVersionMismatch { method: "prefunded_voting_balances_for_document".to_string(), known_versions: vec![0], @@ -323,4 +332,27 @@ impl DocumentTypeV0Methods for DocumentTypeV0 { }), } } + + /// Gets the vote poll associated with a document + fn contested_vote_poll_for_document( + &self, + document: &Document, + platform_version: &PlatformVersion, + ) -> Result, ProtocolError> { + match platform_version + .dpp + .contract_versions + .document_type_versions + .methods + .contested_vote_poll_for_document + { + 0 => Ok(self.contested_vote_poll_for_document_v0(document)), + version => Err(ProtocolError::UnknownVersionMismatch { + method: "contested_vote_poll_for_document".to_string(), + known_versions: vec![0], + received: version, + }), + } + } + } diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/v0/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/v0/mod.rs index fc820495cb..07843bae95 100644 --- a/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/v0/mod.rs @@ -3,33 +3,32 @@ use crate::data_contract::document_type::v0::DocumentTypeV0; use crate::document::{Document, DocumentV0Getters}; use crate::fee::Credits; use crate::version::PlatformVersion; -use std::collections::BTreeMap; impl DocumentTypeV0 { /// Figures out the prefunded voting balance (v0) for a document in a document type - pub(in crate::data_contract::document_type) fn prefunded_voting_balances_for_document_v0( + pub(in crate::data_contract::document_type) fn prefunded_voting_balance_for_document_v0( &self, document: &Document, platform_version: &PlatformVersion, - ) -> BTreeMap { + ) -> Option<(String, Credits)> { self.indexes() .iter() - .filter_map(|(name, index)| { + .find(|(name, index)| { if let Some(contested_index_info) = &index.contested_index { if let Some(value) = document.get(&contested_index_info.contested_field_name) { - if contested_index_info.field_match.matches(value) { - return Some(( - name.clone(), - platform_version - .fee_version - .vote_resolution_fund_fees - .conflicting_vote_resolution_fund_required_amount, - )); - } + contested_index_info.field_match.matches(value) + } else { + false } + } else { + false } - None - }) - .collect() + }).map(|(index_name, _)| ( + index_name.clone(), + platform_version + .fee_version + .vote_resolution_fund_fees + .conflicting_vote_resolution_fund_required_amount, + )) } } diff --git a/packages/rs-dpp/src/data_contract/document_type/mod.rs b/packages/rs-dpp/src/data_contract/document_type/mod.rs index 6ce89c0e7b..b866844bc7 100644 --- a/packages/rs-dpp/src/data_contract/document_type/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/mod.rs @@ -25,6 +25,7 @@ use crate::ProtocolError; use derive_more::From; use platform_value::{Identifier, Value}; use std::collections::BTreeMap; +use crate::voting::vote_polls::VotePoll; mod property_names { pub const DOCUMENTS_KEEP_HISTORY: &str = "documentsKeepHistory"; @@ -91,10 +92,10 @@ impl DocumentType { &self, document: &Document, platform_version: &PlatformVersion, - ) -> Result, ProtocolError> { + ) -> Result, ProtocolError> { match self { DocumentType::V0(v0) => { - v0.prefunded_voting_balances_for_document(document, platform_version) + v0.prefunded_voting_balance_for_document(document, platform_version) } } } @@ -222,14 +223,22 @@ impl<'a> DocumentTypeV0Methods for DocumentTypeRef<'a> { } } - fn prefunded_voting_balances_for_document( + fn prefunded_voting_balance_for_document( &self, document: &Document, platform_version: &PlatformVersion, - ) -> Result, ProtocolError> { + ) -> Result, ProtocolError> { match self { DocumentTypeRef::V0(v0) => { - v0.prefunded_voting_balances_for_document(document, platform_version) + v0.prefunded_voting_balance_for_document(document, platform_version) + } + } + } + + fn contested_vote_poll_for_document(&self, document: &Document, platform_version: &PlatformVersion) -> Result, ProtocolError> { + match self { + DocumentTypeRef::V0(v0) => { + v0.contested_vote_poll_for_document(document, platform_version) } } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/from_document.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/from_document.rs index 8d7be64dd8..b334ae71e5 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/from_document.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/from_document.rs @@ -17,8 +17,8 @@ impl DocumentCreateTransitionV0 { platform_version: &PlatformVersion, base_feature_version: Option, ) -> Result { - let prefunded_voting_balances = - document_type.prefunded_voting_balances_for_document(&document, platform_version)?; + let prefunded_voting_balance = + document_type.prefunded_voting_balance_for_document(&document, platform_version)?; Ok(DocumentCreateTransitionV0 { base: DocumentBaseTransition::from_document( &document, @@ -29,7 +29,7 @@ impl DocumentCreateTransitionV0 { )?, entropy, data: document.properties_consumed(), - prefunded_voting_balances, + prefunded_voting_balance, }) } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs index aa555122e5..ce84f01d27 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs @@ -76,7 +76,7 @@ pub struct DocumentCreateTransitionV0 { /// aside that will be used by voters to vote) /// This is a map of index names to the amount we want to prefund them for /// Since index conflict resolution is not a common feature most often nothing should be added here. - pub prefunded_voting_balances: BTreeMap, + pub prefunded_voting_balance: Option<(String, Credits)>, } impl DocumentCreateTransitionV0 { @@ -97,7 +97,7 @@ impl DocumentCreateTransitionV0 { entropy: map .remove_hash256_bytes(property_names::ENTROPY) .map_err(ProtocolError::ValueError)?, - prefunded_voting_balances: map + prefunded_voting_balance: map .remove_optional_map_as_btree_map(property_names::PREFUNDED_VOTING_BALANCES)? .unwrap_or_default(), data: map, @@ -115,7 +115,7 @@ impl DocumentCreateTransitionV0 { transition_base_map.insert( property_names::PREFUNDED_VOTING_BALANCES.to_string(), Value::Map(ValueMap::from_btree_map( - self.prefunded_voting_balances.clone(), + self.prefunded_voting_balance.clone(), )), ); diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/v0_methods.rs index 045f749cd1..e5e2aa8710 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/v0_methods.rs @@ -42,10 +42,10 @@ pub trait DocumentCreateTransitionV0Methods { /// /// * `data` - An `Option` containing a `BTreeMap` to set. fn set_data(&mut self, data: BTreeMap); - fn prefunded_voting_balances(&self) -> &BTreeMap; - fn prefunded_voting_balances_mut(&mut self) -> &mut BTreeMap; - fn add_prefunded_voting_balance(&mut self, index_name: String, amount: Credits); - fn clear_prefunded_voting_balances(&mut self); + fn prefunded_voting_balance(&self) -> &Option<(String, Credits)>; + fn prefunded_voting_balances_mut(&mut self) -> &mut Option<(String, Credits)>; + fn set_prefunded_voting_balance(&mut self, index_name: String, amount: Credits); + fn clear_prefunded_voting_balance(&mut self); } impl DocumentCreateTransitionV0Methods for DocumentCreateTransitionV0 { @@ -81,19 +81,18 @@ impl DocumentCreateTransitionV0Methods for DocumentCreateTransitionV0 { self.data = data; } - fn prefunded_voting_balances(&self) -> &BTreeMap { - &self.prefunded_voting_balances + fn prefunded_voting_balance(&self) -> &Option<(String, Credits)> { + &self.prefunded_voting_balance } - fn prefunded_voting_balances_mut(&mut self) -> &mut BTreeMap { - &mut self.prefunded_voting_balances + fn prefunded_voting_balances_mut(&mut self) -> &mut Option<(String, Credits)> { + &mut self.prefunded_voting_balance } - fn add_prefunded_voting_balance(&mut self, index_name: String, amount: Credits) { - self.prefunded_voting_balances.insert(index_name, amount); + fn set_prefunded_voting_balance(&mut self, index_name: String, amount: Credits) { + self.prefunded_voting_balance = Some((index_name, amount)); } - - fn clear_prefunded_voting_balances(&mut self) { - self.prefunded_voting_balances.clear() + fn clear_prefunded_voting_balance(&mut self) { + self.prefunded_voting_balance = None; } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0_methods.rs index 33af476a3b..11d349f56c 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0_methods.rs @@ -54,29 +54,27 @@ impl DocumentCreateTransitionV0Methods for DocumentCreateTransition { } } - fn prefunded_voting_balances(&self) -> &BTreeMap { + fn prefunded_voting_balance(&self) -> &Option<(String, Credits)> { match self { - DocumentCreateTransition::V0(v0) => &v0.prefunded_voting_balances, + DocumentCreateTransition::V0(v0) => v0.prefunded_voting_balance(), } } - fn prefunded_voting_balances_mut(&mut self) -> &mut BTreeMap { + fn prefunded_voting_balances_mut(&mut self) -> &mut Option<(String, Credits)> { match self { - DocumentCreateTransition::V0(v0) => &mut v0.prefunded_voting_balances, + DocumentCreateTransition::V0(v0) => v0.prefunded_voting_balances_mut(), } } - fn add_prefunded_voting_balance(&mut self, index_name: String, amount: Credits) { + fn set_prefunded_voting_balance(&mut self, index_name: String, amount: Credits) { match self { - DocumentCreateTransition::V0(v0) => { - v0.prefunded_voting_balances.insert(index_name, amount); - } + DocumentCreateTransition::V0(v0) => v0.set_prefunded_voting_balance(index_name, amount), } } - fn clear_prefunded_voting_balances(&mut self) { + fn clear_prefunded_voting_balance(&mut self) { match self { - DocumentCreateTransition::V0(v0) => v0.prefunded_voting_balances.clear(), + DocumentCreateTransition::V0(v0) => v0.clear_prefunded_voting_balance(), } } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs index d31cde8cf0..cd6408b48c 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs @@ -336,9 +336,7 @@ impl DocumentsBatchTransitionMethodsV0 for DocumentsBatchTransitionV0 { .and_then(|document_create_transition| { // Safely sum up values to avoid overflow. document_create_transition - .prefunded_voting_balances() - .values() - .try_fold(0u64, |acc, &val| acc.checked_add(val)) + .prefunded_voting_balance().as_ref().map(|(_, credits)| *credits) }) }) .fold((None, false), |(acc, _), price| match acc { diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/validation/find_duplicates_by_id/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/validation/find_duplicates_by_id/v0/mod.rs index bbf434383d..71e1b19b29 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/validation/find_duplicates_by_id/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/validation/find_duplicates_by_id/v0/mod.rs @@ -72,7 +72,7 @@ mod test { }), entropy: Default::default(), data: Default::default(), - prefunded_voting_balances: Default::default(), + prefunded_voting_balance: Default::default(), })); let create_transition_duplicate = create_transition.clone(); diff --git a/packages/rs-drive-abci/tests/strategy_tests/strategy.rs b/packages/rs-drive-abci/tests/strategy_tests/strategy.rs index 87e50df1c7..2c7fb68f25 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/strategy.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/strategy.rs @@ -591,7 +591,7 @@ impl NetworkStrategy { .into(), entropy: entropy.to_buffer(), data: document.properties_consumed(), - prefunded_voting_balances, + prefunded_voting_balance: prefunded_voting_balances, } .into(); @@ -712,7 +712,7 @@ impl NetworkStrategy { .into(), entropy: entropy.to_buffer(), data: document.properties_consumed(), - prefunded_voting_balances, + prefunded_voting_balance: prefunded_voting_balances, } .into(); diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/document.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/document.rs index fcd79d86f0..7615e7319c 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/document.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/document.rs @@ -22,6 +22,7 @@ use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::borrow::Cow; use std::collections::HashMap; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; /// A wrapper for a document operation #[derive(Clone, Debug)] @@ -68,12 +69,14 @@ pub enum DocumentOperationType<'a> { AddContestedDocument { /// The document and contract info, also may contain the owner_id owned_document_info: OwnedDocumentInfo<'a>, + /// The vote poll in question that will should be created + contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll, /// Data Contract info to potentially be resolved if needed contract_info: DataContractInfo<'a>, /// Document type document_type_info: DocumentTypeInfo<'a>, - /// Should we override the document if one already exists? - override_document: bool, + /// Should we insert without verifying first that the document doesn't already exist + insert_without_check: bool, }, /// Updates a document and returns the associated fee. UpdateDocument { @@ -153,9 +156,10 @@ impl DriveLowLevelOperationConverter for DocumentOperationType<'_> { } DocumentOperationType::AddContestedDocument { owned_document_info, + contested_document_resource_vote_poll, contract_info, document_type_info, - override_document, + insert_without_check, } => { let mut drive_operations: Vec = vec![]; let contract_resolved_info = contract_info.resolve( @@ -175,7 +179,8 @@ impl DriveLowLevelOperationConverter for DocumentOperationType<'_> { }; let mut operations = drive.add_contested_document_for_contract_operations( document_and_contract_info, - override_document, + contested_document_resource_vote_poll, + insert_without_check, block_info, &mut None, estimated_costs_only_with_layer_info, diff --git a/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs b/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs index 4b90a79ffe..c66d6f39d0 100644 --- a/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs +++ b/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs @@ -33,7 +33,7 @@ impl DriveHighLevelDocumentOperationConverter for DocumentCreateTransitionAction let identity_contract_nonce = self.base().identity_contract_nonce(); - let prefunded_voting_balances = self.take_prefunded_voting_balances(); + let maybe_prefunded_voting_balance = self.take_prefunded_voting_balance(); let document = Document::try_from_owned_create_transition_action(self, owner_id, platform_version)?; @@ -48,30 +48,17 @@ impl DriveHighLevelDocumentOperationConverter for DocumentCreateTransitionAction }, )]; - if prefunded_voting_balances.is_empty() { - // Just add the document - ops.push(DocumentOperation(DocumentOperationType::AddDocument { - owned_document_info: OwnedDocumentInfo { - document_info: DocumentOwnedInfo((document, Some(Cow::Owned(storage_flags)))), - owner_id: Some(owner_id.into_buffer()), + if let Some((contested_document_resource_vote_poll, credits)) = maybe_prefunded_voting_balance { + let prefunded_specialized_balance_id = + contested_document_resource_vote_poll.specialized_balance_id()?; + // We are in the situation of a contested document + // We prefund the voting balances first + ops.push(PrefundedSpecializedBalanceOperation( + PrefundedSpecializedBalanceOperationType::CreateNewPrefundedBalance { + prefunded_specialized_balance_id, + add_balance: credits, }, - contract_info: DataContractFetchInfo(contract_fetch_info), - document_type_info: DocumentTypeInfo::DocumentTypeName(document_type_name), - override_document: false, - })); - } else { - for (contested_document_resource_vote_poll, credits) in prefunded_voting_balances { - let prefunded_specialized_balance_id = - contested_document_resource_vote_poll.specialized_balance_id()?; - // We are in the situation of a contested document - // We prefund the voting balances first - ops.push(PrefundedSpecializedBalanceOperation( - PrefundedSpecializedBalanceOperationType::CreateNewPrefundedBalance { - prefunded_specialized_balance_id, - add_balance: credits, - }, - )); - } + )); // We add the contested document // The contested document resides in a special location in grovedb until a time where the @@ -85,11 +72,23 @@ impl DriveHighLevelDocumentOperationConverter for DocumentCreateTransitionAction )), owner_id: Some(owner_id.into_buffer()), }, + contested_document_resource_vote_poll, contract_info: DataContractFetchInfo(contract_fetch_info), document_type_info: DocumentTypeInfo::DocumentTypeName(document_type_name), - override_document: false, + insert_without_check: false, //todo: consider setting to true }, )); + } else { + // Just add the document + ops.push(DocumentOperation(DocumentOperationType::AddDocument { + owned_document_info: OwnedDocumentInfo { + document_info: DocumentOwnedInfo((document, Some(Cow::Owned(storage_flags)))), + owner_id: Some(owner_id.into_buffer()), + }, + contract_info: DataContractFetchInfo(contract_fetch_info), + document_type_info: DocumentTypeInfo::DocumentTypeName(document_type_name), + override_document: false, + })); } Ok(ops) diff --git a/packages/rs-drive/src/drive/contract/estimation_costs/add_estimation_costs_for_contract_insertion/v0/mod.rs b/packages/rs-drive/src/drive/contract/estimation_costs/add_estimation_costs_for_contract_insertion/v0/mod.rs index cf3ab59645..6ee52c33c4 100644 --- a/packages/rs-drive/src/drive/contract/estimation_costs/add_estimation_costs_for_contract_insertion/v0/mod.rs +++ b/packages/rs-drive/src/drive/contract/estimation_costs/add_estimation_costs_for_contract_insertion/v0/mod.rs @@ -3,7 +3,7 @@ use crate::drive::defaults::{ AVERAGE_NUMBER_OF_UPDATES, DEFAULT_FLOAT_SIZE, DEFAULT_FLOAT_SIZE_U8, ESTIMATED_AVERAGE_INDEX_NAME_SIZE, }; -use crate::drive::document::contract_document_type_path; +use crate::drive::document::paths::contract_document_type_path; use crate::drive::flags::StorageFlags; use crate::drive::Drive; 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 e972831bb1..e6c202b20f 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 @@ -6,7 +6,7 @@ use dpp::data_contract::document_type::DocumentTypeRef; use std::collections::HashMap; -use crate::drive::document::contract_documents_primary_key_path; +use crate::drive::document::paths::contract_documents_primary_key_path; use crate::drive::flags::StorageFlags; use crate::drive::object_size_info::DocumentInfo::{ DocumentEstimatedAverageSize, DocumentOwnedInfo, diff --git a/packages/rs-drive/src/drive/document/delete/remove_indices_for_top_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/delete/remove_indices_for_top_index_level_for_contract_operations/v0/mod.rs index 19ad064164..663beb7fdb 100644 --- a/packages/rs-drive/src/drive/document/delete/remove_indices_for_top_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/remove_indices_for_top_index_level_for_contract_operations/v0/mod.rs @@ -8,7 +8,7 @@ use grovedb::EstimatedSumTrees::NoSumTrees; use std::collections::HashMap; use crate::drive::defaults::DEFAULT_HASH_SIZE_U8; -use crate::drive::document::{contract_document_type_path_vec, unique_event_id}; +use crate::drive::document::unique_event_id; use crate::drive::object_size_info::{DocumentAndContractInfo, DocumentInfoV0Methods, PathInfo}; use crate::drive::Drive; @@ -22,6 +22,7 @@ use dpp::data_contract::config::v0::DataContractConfigGettersV0; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::version::PlatformVersion; +use crate::drive::document::paths::contract_document_type_path_vec; impl Drive { /// Removes indices for the top index level and calls for lower levels. diff --git a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/mod.rs b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/mod.rs new file mode 100644 index 0000000000..fbb1d444e2 --- /dev/null +++ b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/mod.rs @@ -0,0 +1,65 @@ +use crate::drive::object_size_info::DocumentAndContractInfo; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use dpp::version::PlatformVersion; +use grovedb::batch::KeyInfoPath; +use grovedb::EstimatedLayerInformation; +use std::collections::HashMap; + +mod v0; + +impl Drive { + /// Adds estimated storage costs for adding a document to primary storage based on platform version. + /// + /// This function uses the platform version to determine the appropriate method to estimate storage costs + /// for adding a document to the primary storage. Currently, it supports version `0` and delegates the estimation + /// to `add_estimation_costs_for_add_document_to_primary_storage_v0`. + /// + /// If an unsupported version is provided, an error indicating a version mismatch will be returned. + /// + /// # Arguments + /// * `document_and_contract_info`: Information about the document and its associated contract. + /// * `primary_key_path`: Key path where the document should be stored in primary storage. + /// * `estimated_costs_only_with_layer_info`: A mutable reference to a hashmap where the estimated layer + /// information will be stored for the given key path. + /// * `platform_version`: Version of the platform being used, which determines the estimation method. + /// + /// # Returns + /// * `Result<(), Error>`: Returns `Ok(())` if the operation succeeds. Returns an `Error` if the provided platform + /// version method is unsupported or if there's any other issue. + /// + /// # Errors + /// * `DriveError::UnknownVersionMismatch`: Returned if the platform version method specified is unsupported. + /// + /// # Panics + /// This function will not panic under normal circumstances. However, unexpected behavior may result + /// from incorrect arguments or unforeseen edge cases. + pub(crate) fn add_estimation_costs_for_add_contested_document_to_primary_storage( + document_and_contract_info: &DocumentAndContractInfo, + primary_key_path: [&[u8]; 7], + estimated_costs_only_with_layer_info: &mut HashMap, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive + .methods + .document + .estimation_costs + .add_estimation_costs_for_add_contested_document_to_primary_storage + { + 0 => Self::add_estimation_costs_for_add_contested_document_to_primary_storage_v0( + document_and_contract_info, + primary_key_path, + estimated_costs_only_with_layer_info, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "Drive::add_estimation_costs_for_add_contested_document_to_primary_storage" + .to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/v0/mod.rs b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/v0/mod.rs new file mode 100644 index 0000000000..cf6b39ff37 --- /dev/null +++ b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/v0/mod.rs @@ -0,0 +1,90 @@ +use crate::drive::defaults::{ + AVERAGE_NUMBER_OF_UPDATES, AVERAGE_UPDATE_BYTE_COUNT_REQUIRED_SIZE, DEFAULT_HASH_SIZE_U8, +}; +use crate::drive::flags::StorageFlags; + +use crate::drive::object_size_info::{DocumentAndContractInfo, DocumentInfoV0Methods}; +use crate::drive::Drive; + +use crate::error::Error; + +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; +use dpp::version::PlatformVersion; +use grovedb::batch::KeyInfoPath; +use grovedb::EstimatedLayerCount::PotentiallyAtMaxElements; +use grovedb::EstimatedLayerInformation; +use grovedb::EstimatedLayerSizes::AllItems; + +use std::collections::HashMap; + +impl Drive { + /// Adds estimated storage costs for adding a document to primary storage. + /// + /// This function computes and updates the expected costs associated with storing + /// a document in primary storage. Depending on the type and history preservation + /// properties of the document, the costs are determined differently. + /// + /// - If the document type retains history, the function will account for costs + /// associated with trees and potential flags for deletion. + /// - Otherwise, the function will only account for the cost of storing the elements. + /// + /// # Arguments + /// * `document_and_contract_info`: Information about the document and its associated contract. + /// * `primary_key_path`: Key path where the document should be stored in primary storage. + /// * `estimated_costs_only_with_layer_info`: A mutable reference to a hashmap where the estimated layer + /// information will be stored for the given key path. + /// * `platform_version`: Version of the platform being used, potentially affecting some estimates. + /// + /// # Returns + /// * `Result<(), Error>`: Returns `Ok(())` if the operation succeeds, otherwise it returns an `Error`. + /// + /// # Errors + /// This function might return an `Error` if there's a problem estimating the document's size for the + /// given platform version. + /// + /// # Panics + /// This function will not panic under normal circumstances. However, unexpected behavior may result + /// from incorrect arguments or unforeseen edge cases. + #[inline(always)] + pub(super) fn add_estimation_costs_for_add_contested_document_to_primary_storage_v0( + document_and_contract_info: &DocumentAndContractInfo, + primary_key_path: [&[u8]; 7], + estimated_costs_only_with_layer_info: &mut HashMap, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + if document_and_contract_info + .owned_document_info + .document_info + .get_borrowed_document().is_none() + { + return Ok(()); + }; + let document_type = document_and_contract_info.document_type; + // we just have the elements + let approximate_size = if document_type.documents_mutable() { + //todo: have the contract say how often we expect documents to mutate + Some(( + AVERAGE_NUMBER_OF_UPDATES as u16, + AVERAGE_UPDATE_BYTE_COUNT_REQUIRED_SIZE, + )) + } else { + None + }; + let flags_size = StorageFlags::approximate_size(true, approximate_size); + estimated_costs_only_with_layer_info.insert( + KeyInfoPath::from_known_path(primary_key_path), + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: PotentiallyAtMaxElements, + estimated_layer_sizes: AllItems( + DEFAULT_HASH_SIZE_U8, + document_type.estimated_size(platform_version)? as u32, + Some(flags_size), + ), + }, + ); + Ok(()) + } +} diff --git a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_document_to_primary_storage/mod.rs b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_document_to_primary_storage/mod.rs index 5c4662c28f..4b53fcabef 100644 --- a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_document_to_primary_storage/mod.rs +++ b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_document_to_primary_storage/mod.rs @@ -55,7 +55,7 @@ impl Drive { platform_version, ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "Drive::add_estimation_costs_for_add_document_to_primary_storage_v0" + method: "Drive::add_estimation_costs_for_add_document_to_primary_storage" .to_string(), known_versions: vec![0], received: version, diff --git a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_document_to_primary_storage/v0/mod.rs b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_document_to_primary_storage/v0/mod.rs index 50466ab471..678f8e9bad 100644 --- a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_document_to_primary_storage/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_document_to_primary_storage/v0/mod.rs @@ -2,7 +2,7 @@ use crate::drive::defaults::{ AVERAGE_NUMBER_OF_UPDATES, AVERAGE_UPDATE_BYTE_COUNT_REQUIRED_SIZE, DEFAULT_FLOAT_SIZE, DEFAULT_FLOAT_SIZE_U8, DEFAULT_HASH_SIZE_U8, }; -use crate::drive::document::contract_documents_keeping_history_primary_key_path_for_document_id; +use crate::drive::document::paths::contract_documents_keeping_history_primary_key_path_for_document_id; use crate::drive::flags::StorageFlags; use crate::drive::object_size_info::{DocumentAndContractInfo, DocumentInfoV0Methods}; diff --git a/packages/rs-drive/src/drive/document/estimation_costs/mod.rs b/packages/rs-drive/src/drive/document/estimation_costs/mod.rs index 609c8ef518..7831d47184 100644 --- a/packages/rs-drive/src/drive/document/estimation_costs/mod.rs +++ b/packages/rs-drive/src/drive/document/estimation_costs/mod.rs @@ -1,3 +1,5 @@ mod stateless_delete_of_non_tree_for_costs; mod add_estimation_costs_for_add_document_to_primary_storage; + +mod add_estimation_costs_for_add_contested_document_to_primary_storage; diff --git a/packages/rs-drive/src/drive/document/insert/add_document_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_document_for_contract_operations/v0/mod.rs index c949041ec1..255ec1cf6f 100644 --- a/packages/rs-drive/src/drive/document/insert/add_document_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_document_for_contract_operations/v0/mod.rs @@ -1,4 +1,4 @@ -use crate::drive::document::contract_documents_primary_key_path; +use crate::drive::document::paths::contract_documents_primary_key_path; use crate::drive::grove_operations::DirectQueryType::{StatefulDirectQuery, StatelessDirectQuery}; use crate::drive::grove_operations::QueryTarget::QueryTargetValue; use crate::drive::object_size_info::{DocumentAndContractInfo, DocumentInfoV0Methods}; diff --git a/packages/rs-drive/src/drive/document/insert/add_document_to_primary_storage/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_document_to_primary_storage/v0/mod.rs index 6a9b69949a..b7d6818d89 100644 --- a/packages/rs-drive/src/drive/document/insert/add_document_to_primary_storage/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_document_to_primary_storage/v0/mod.rs @@ -11,13 +11,6 @@ use std::collections::HashMap; use std::option::Option::None; use crate::drive::defaults::{DEFAULT_HASH_SIZE_U8, STORAGE_FLAGS_SIZE}; -use crate::drive::document::{ - contract_documents_keeping_history_primary_key_path_for_document_id, - contract_documents_keeping_history_primary_key_path_for_unknown_document_id, - contract_documents_keeping_history_storage_time_reference_path_size, - contract_documents_primary_key_path, -}; - use crate::drive::flags::StorageFlags; use crate::drive::object_size_info::DocumentInfo::{ DocumentAndSerialization, DocumentEstimatedAverageSize, DocumentOwnedInfo, @@ -46,6 +39,7 @@ use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use dpp::document::DocumentV0Getters; use dpp::version::PlatformVersion; +use crate::drive::document::paths::{contract_documents_keeping_history_primary_key_path_for_document_id, contract_documents_keeping_history_primary_key_path_for_unknown_document_id, contract_documents_keeping_history_storage_time_reference_path_size, contract_documents_primary_key_path}; impl Drive { /// Adds a document to primary storage. diff --git a/packages/rs-drive/src/drive/document/insert/add_indices_for_top_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_indices_for_top_index_level_for_contract_operations/v0/mod.rs index 24a69d40be..35f908bfea 100644 --- a/packages/rs-drive/src/drive/document/insert/add_indices_for_top_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_indices_for_top_index_level_for_contract_operations/v0/mod.rs @@ -1,5 +1,5 @@ use crate::drive::defaults::DEFAULT_HASH_SIZE_U8; -use crate::drive::document::{contract_document_type_path_vec, unique_event_id}; +use crate::drive::document::unique_event_id; use crate::drive::grove_operations::BatchInsertTreeApplyType; @@ -21,6 +21,7 @@ use grovedb::EstimatedLayerSizes::AllSubtrees; use grovedb::EstimatedSumTrees::NoSumTrees; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; +use crate::drive::document::paths::contract_document_type_path_vec; impl Drive { /// Adds indices for the top index level and calls for lower levels. diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs index a606a96e25..228ecb15a8 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs @@ -12,6 +12,7 @@ use dpp::identifier::Identifier; use dpp::version::PlatformVersion; use grovedb::TransactionArg; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; impl Drive { /// Adds a contested document using bincode serialization @@ -32,9 +33,8 @@ impl Drive { pub fn add_contested_document( &self, owned_document_info: OwnedDocumentInfo, - data_contract_id: Identifier, - document_type_name: &str, - override_document: bool, + contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll, + insert_without_check: bool, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, @@ -49,9 +49,8 @@ impl Drive { { 0 => self.add_contested_document_v0( owned_document_info, - data_contract_id, - document_type_name, - override_document, + contested_document_resource_vote_poll, + insert_without_check, block_info, apply, transaction, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/v0/mod.rs index cd4a7fa0e3..8af8032369 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/v0/mod.rs @@ -6,10 +6,10 @@ use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::fee::fee_result::FeeResult; -use dpp::identifier::Identifier; use dpp::version::PlatformVersion; use grovedb::TransactionArg; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; impl Drive { /// Adds a contested document using bincode serialization @@ -17,9 +17,8 @@ impl Drive { pub(super) fn add_contested_document_v0( &self, owned_document_info: OwnedDocumentInfo, - data_contract_id: Identifier, - document_type_name: &str, - override_document: bool, + contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll, + insert_without_check: bool, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, @@ -29,7 +28,7 @@ impl Drive { let contract_fetch_info = self .get_contract_with_fetch_info_and_add_to_operations( - data_contract_id.into_buffer(), + contested_document_resource_vote_poll.contract_id.into_buffer(), Some(&block_info.epoch), true, transaction, @@ -40,7 +39,7 @@ impl Drive { let contract = &contract_fetch_info.contract; - let document_type = contract.document_type_for_name(document_type_name)?; + let document_type = contract.document_type_for_name(contested_document_resource_vote_poll.document_type_name.as_str())?; let document_and_contract_info = DocumentAndContractInfo { owned_document_info, @@ -50,7 +49,8 @@ impl Drive { let mut drive_operations: Vec = vec![]; self.add_contested_document_for_contract_apply_and_add_to_operations( document_and_contract_info, - override_document, + contested_document_resource_vote_poll, + insert_without_check, block_info, true, apply, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/mod.rs index 3f16f3c8b1..cadf1450a8 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/mod.rs @@ -11,6 +11,7 @@ use dpp::fee::fee_result::FeeResult; use dpp::version::PlatformVersion; use grovedb::TransactionArg; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; impl Drive { /// Adds a contested document to a contract. @@ -29,7 +30,8 @@ impl Drive { pub fn add_contested_document_for_contract( &self, document_and_contract_info: DocumentAndContractInfo, - override_document: bool, + contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll, + insert_without_check: bool, block_info: BlockInfo, apply: bool, transaction: TransactionArg, @@ -44,7 +46,8 @@ impl Drive { { 0 => self.add_contested_document_for_contract_v0( document_and_contract_info, - override_document, + contested_document_resource_vote_poll, + insert_without_check, block_info, apply, transaction, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/v0/mod.rs index 8877bc89af..f8f06064c1 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/v0/mod.rs @@ -8,6 +8,7 @@ use dpp::fee::fee_result::FeeResult; use dpp::version::PlatformVersion; use grovedb::TransactionArg; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; impl Drive { /// Adds a contested document to a contract. @@ -15,7 +16,8 @@ impl Drive { pub(super) fn add_contested_document_for_contract_v0( &self, document_and_contract_info: DocumentAndContractInfo, - override_document: bool, + contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll, + insert_without_check: bool, block_info: BlockInfo, apply: bool, transaction: TransactionArg, @@ -24,7 +26,8 @@ impl Drive { let mut drive_operations: Vec = vec![]; self.add_contested_document_for_contract_apply_and_add_to_operations( document_and_contract_info, - override_document, + contested_document_resource_vote_poll, + insert_without_check, &block_info, true, apply, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs index 3fa4e292a6..15f2ee510d 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs @@ -10,6 +10,7 @@ use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; use grovedb::TransactionArg; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; impl Drive { /// Performs the operations to add a contested document to a contract. @@ -31,7 +32,8 @@ impl Drive { pub(crate) fn add_contested_document_for_contract_apply_and_add_to_operations( &self, document_and_contract_info: DocumentAndContractInfo, - override_document: bool, + contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll, + insert_without_check: bool, block_info: &BlockInfo, document_is_unique_for_document_type_in_batch: bool, stateful: bool, @@ -48,7 +50,8 @@ impl Drive { { 0 => self.add_contested_document_for_contract_apply_and_add_to_operations_v0( document_and_contract_info, - override_document, + contested_document_resource_vote_poll, + insert_without_check, block_info, document_is_unique_for_document_type_in_batch, stateful, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/v0/mod.rs index 75364b4376..ee71c1759e 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/v0/mod.rs @@ -8,6 +8,7 @@ use dpp::version::PlatformVersion; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; impl Drive { /// Performs the operations to add a document to a contract. @@ -15,7 +16,8 @@ impl Drive { pub(super) fn add_contested_document_for_contract_apply_and_add_to_operations_v0( &self, document_and_contract_info: DocumentAndContractInfo, - override_document: bool, + contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll, + insert_without_check: bool, block_info: &BlockInfo, document_is_unique_for_document_type_in_batch: bool, stateful: bool, @@ -31,7 +33,8 @@ impl Drive { if document_is_unique_for_document_type_in_batch { let batch_operations = self.add_contested_document_for_contract_operations( document_and_contract_info, - override_document, + contested_document_resource_vote_poll, + insert_without_check, block_info, &mut None, &mut estimated_costs_only_with_layer_info, @@ -48,7 +51,8 @@ impl Drive { } else { let batch_operations = self.add_contested_document_for_contract_operations( document_and_contract_info, - override_document, + contested_document_resource_vote_poll, + insert_without_check, block_info, &mut Some(drive_operations), &mut estimated_costs_only_with_layer_info, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/mod.rs index 39255402e6..40a68d4845 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/mod.rs @@ -11,13 +11,15 @@ use dpp::version::PlatformVersion; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; impl Drive { /// Gathers the operations to add a contested document to a contract. pub(crate) fn add_contested_document_for_contract_operations( &self, document_and_contract_info: DocumentAndContractInfo, - override_document: bool, + contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll, + insert_without_check: bool, block_info: &BlockInfo, previous_batch_operations: &mut Option<&mut Vec>, estimated_costs_only_with_layer_info: &mut Option< @@ -35,7 +37,8 @@ impl Drive { { 0 => self.add_contested_document_for_contract_operations_v0( document_and_contract_info, - override_document, + contested_document_resource_vote_poll, + insert_without_check, block_info, previous_batch_operations, estimated_costs_only_with_layer_info, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs index 993202499c..54b63451ec 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs @@ -1,4 +1,4 @@ -use crate::drive::document::contract_documents_primary_key_path; +use crate::drive::document::paths::contract_documents_primary_key_path; use crate::drive::grove_operations::DirectQueryType::{StatefulDirectQuery, StatelessDirectQuery}; use crate::drive::grove_operations::QueryTarget::QueryTargetValue; use crate::drive::object_size_info::{DocumentAndContractInfo, DocumentInfoV0Methods}; @@ -14,6 +14,9 @@ use dpp::version::PlatformVersion; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::voting::vote_polls::VotePoll; +use crate::drive::votes::paths::vote_contested_resource_contract_documents_primary_key_path; impl Drive { /// Gathers the operations to add a contested document to a contract. @@ -21,7 +24,8 @@ impl Drive { pub(super) fn add_contested_document_for_contract_operations_v0( &self, document_and_contract_info: DocumentAndContractInfo, - override_document: bool, + contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll, + insert_without_check: bool, block_info: &BlockInfo, previous_batch_operations: &mut Option<&mut Vec>, estimated_costs_only_with_layer_info: &mut Option< @@ -31,66 +35,6 @@ impl Drive { platform_version: &PlatformVersion, ) -> Result, Error> { let mut batch_operations: Vec = vec![]; - let primary_key_path = contract_documents_primary_key_path( - document_and_contract_info.contract.id_ref().as_bytes(), - document_and_contract_info.document_type.name().as_str(), - ); - - // Apply means stateful query - let query_type = if estimated_costs_only_with_layer_info.is_none() { - StatefulDirectQuery - } else { - StatelessDirectQuery { - in_tree_using_sums: false, - query_target: QueryTargetValue( - document_and_contract_info - .document_type - .estimated_size(platform_version)? as u32, - ), - } - }; - - // To update but not create: - - // 1. Override should be allowed - let could_be_update = override_document; - - // 2. Is not a dry run - let could_be_update = could_be_update - && !document_and_contract_info - .owned_document_info - .document_info - .is_document_size(); - - // 3. Document exists in storage - let is_update = could_be_update - && self.grove_has_raw( - primary_key_path.as_ref().into(), - document_and_contract_info - .owned_document_info - .document_info - .id_key_value_info() - .as_key_ref_request()?, - query_type, - transaction, - &mut batch_operations, - &platform_version.drive, - )?; - - if is_update { - let update_operations = self.update_document_for_contract_operations( - document_and_contract_info, - block_info, - previous_batch_operations, - estimated_costs_only_with_layer_info, - transaction, - platform_version, - )?; - - batch_operations.extend(update_operations); - - return Ok(batch_operations); - } // if we are trying to get estimated costs we need to add the upper levels if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { @@ -104,13 +48,18 @@ impl Drive { // if we have override_document set that means we already checked if it exists self.add_contested_document_to_primary_storage( &document_and_contract_info, - block_info, - override_document, + insert_without_check, estimated_costs_only_with_layer_info, transaction, &mut batch_operations, platform_version, )?; + + let end_date = block_info.time_ms.saturating_add(platform_version.dpp.voting_versions.default_vote_time_ms); + + + self.add_vote_poll_end_date_query_operations(document_and_contract_info.owned_document_info.owner_id, + VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll), end_date, block_info, estimated_costs_only_with_layer_info, previous_batch_operations, &mut batch_operations, transaction, platform_version)?; self.add_contested_indices_for_top_index_level_for_contract_operations( &document_and_contract_info, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/mod.rs index 76c2f0d3fd..64ed61ce32 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/mod.rs @@ -33,7 +33,6 @@ impl Drive { pub(crate) fn add_contested_document_to_primary_storage( &self, document_and_contract_info: &DocumentAndContractInfo, - block_info: &BlockInfo, insert_without_check: bool, estimated_costs_only_with_layer_info: &mut Option< HashMap, @@ -51,7 +50,6 @@ impl Drive { { 0 => self.add_contested_document_to_primary_storage_0( document_and_contract_info, - block_info, insert_without_check, estimated_costs_only_with_layer_info, transaction, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/v0/mod.rs index 9e8b657dc2..12bc04d640 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/v0/mod.rs @@ -11,13 +11,6 @@ use std::collections::HashMap; use std::option::Option::None; use crate::drive::defaults::{DEFAULT_HASH_SIZE_U8, STORAGE_FLAGS_SIZE}; -use crate::drive::document::{ - contract_documents_keeping_history_primary_key_path_for_document_id, - contract_documents_keeping_history_primary_key_path_for_unknown_document_id, - contract_documents_keeping_history_storage_time_reference_path_size, - contract_documents_primary_key_path, -}; - use crate::drive::flags::StorageFlags; use crate::drive::object_size_info::DocumentInfo::{ DocumentAndSerialization, DocumentEstimatedAverageSize, DocumentOwnedInfo, @@ -46,6 +39,8 @@ use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use dpp::document::DocumentV0Getters; use dpp::version::PlatformVersion; +use crate::drive::document::paths::{contract_documents_keeping_history_primary_key_path_for_document_id, contract_documents_keeping_history_primary_key_path_for_unknown_document_id, contract_documents_keeping_history_storage_time_reference_path_size, contract_documents_primary_key_path}; +use crate::drive::votes::paths::vote_contested_resource_contract_documents_primary_key_path; impl Drive { /// Adds a document to primary storage. @@ -54,7 +49,6 @@ impl Drive { pub(super) fn add_contested_document_to_primary_storage_0( &self, document_and_contract_info: &DocumentAndContractInfo, - block_info: &BlockInfo, insert_without_check: bool, estimated_costs_only_with_layer_info: &mut Option< HashMap, @@ -66,221 +60,21 @@ impl Drive { let drive_version = &platform_version.drive; let contract = document_and_contract_info.contract; let document_type = document_and_contract_info.document_type; - let primary_key_path = contract_documents_primary_key_path( + let primary_key_path = vote_contested_resource_contract_documents_primary_key_path( contract.id_ref().as_bytes(), document_type.name().as_str(), ); // if we are trying to get estimated costs we should add this level if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { - Self::add_estimation_costs_for_add_document_to_primary_storage( + Self::add_estimation_costs_for_add_contested_document_to_primary_storage( document_and_contract_info, primary_key_path, estimated_costs_only_with_layer_info, platform_version, )?; } - - if document_type.documents_keep_history() { - let (path_key_info, storage_flags) = if document_and_contract_info - .owned_document_info - .document_info - .is_document_size() - { - ( - PathKeySize( - KeyInfoPath::from_known_path(primary_key_path), - KeyInfo::MaxKeySize { - unique_id: document_type.unique_id_for_storage().to_vec(), - max_size: DEFAULT_HASH_SIZE_U8, - }, - ), - StorageFlags::optional_default_as_ref(), - ) - } else { - let inserted_storage_flags = if contract.config().can_be_deleted() { - document_and_contract_info - .owned_document_info - .document_info - .get_storage_flags_ref() - } else { - // there are no need for storage flags if the contract can not be deleted - // as this tree can never be deleted - None - }; - ( - PathFixedSizeKeyRef(( - primary_key_path, - document_and_contract_info - .owned_document_info - .document_info - .get_document_id_as_slice() - .ok_or(Error::Drive(DriveError::CorruptedCodeExecution( - "can not get document id from estimated document", - )))?, - )), - inserted_storage_flags, - ) - }; - let apply_type = if estimated_costs_only_with_layer_info.is_none() { - BatchInsertTreeApplyType::StatefulBatchInsertTree - } else { - BatchInsertTreeApplyType::StatelessBatchInsertTree { - in_tree_using_sums: false, - is_sum_tree: false, - flags_len: storage_flags - .map(|s| s.serialized_size()) - .unwrap_or_default(), - } - }; - // we first insert an empty tree if the document is new - self.batch_insert_empty_tree_if_not_exists( - path_key_info, - false, - storage_flags, - apply_type, - transaction, - &mut None, //not going to have multiple same documents in same batch - drive_operations, - drive_version, - )?; - let encoded_time = DocumentPropertyType::encode_date_timestamp(block_info.time_ms); - let path_key_element_info = match &document_and_contract_info - .owned_document_info - .document_info - { - DocumentRefAndSerialization((document, serialized_document, storage_flags)) => { - let element = Element::Item( - serialized_document.to_vec(), - StorageFlags::map_borrowed_cow_to_some_element_flags(storage_flags), - ); - let document_id_in_primary_path = - contract_documents_keeping_history_primary_key_path_for_document_id( - contract.id_ref().as_bytes(), - document_type.name().as_str(), - document.id_ref().as_slice(), - ); - PathFixedSizeKeyRefElement(( - document_id_in_primary_path, - encoded_time.as_slice(), - element, - )) - } - DocumentAndSerialization((document, serialized_document, storage_flags)) => { - let element = Element::Item( - serialized_document.to_vec(), - StorageFlags::map_borrowed_cow_to_some_element_flags(storage_flags), - ); - let document_id_in_primary_path = - contract_documents_keeping_history_primary_key_path_for_document_id( - contract.id_ref().as_bytes(), - document_type.name().as_str(), - document.id_ref().as_slice(), - ); - PathFixedSizeKeyRefElement(( - document_id_in_primary_path, - encoded_time.as_slice(), - element, - )) - } - DocumentOwnedInfo((document, storage_flags)) => { - let serialized_document = document - .serialize(document_and_contract_info.document_type, platform_version)?; - let element = Element::Item( - serialized_document, - StorageFlags::map_borrowed_cow_to_some_element_flags(storage_flags), - ); - let document_id_in_primary_path = - contract_documents_keeping_history_primary_key_path_for_document_id( - contract.id_ref().as_bytes(), - document_type.name().as_str(), - document.id_ref().as_slice(), - ); - PathFixedSizeKeyRefElement(( - document_id_in_primary_path, - encoded_time.as_slice(), - element, - )) - } - DocumentRefInfo((document, storage_flags)) => { - let serialized_document = document - .serialize(document_and_contract_info.document_type, platform_version)?; - let element = Element::Item( - serialized_document, - StorageFlags::map_borrowed_cow_to_some_element_flags(storage_flags), - ); - let document_id_in_primary_path = - contract_documents_keeping_history_primary_key_path_for_document_id( - contract.id_ref().as_bytes(), - document_type.name().as_str(), - document.id_ref().as_slice(), - ); - PathFixedSizeKeyRefElement(( - document_id_in_primary_path, - encoded_time.as_slice(), - element, - )) - } - DocumentEstimatedAverageSize(max_size) => { - let document_id_in_primary_path = - contract_documents_keeping_history_primary_key_path_for_unknown_document_id( - contract.id_ref().as_bytes(), - document_type, - ); - PathKeyUnknownElementSize(( - document_id_in_primary_path, - KnownKey(encoded_time.clone()), - Element::required_item_space(*max_size, STORAGE_FLAGS_SIZE), - )) - } - }; - self.batch_insert(path_key_element_info, drive_operations, drive_version)?; - let path_key_element_info = if document_and_contract_info - .owned_document_info - .document_info - .is_document_size() - { - let document_id_in_primary_path = - contract_documents_keeping_history_primary_key_path_for_unknown_document_id( - contract.id_ref().as_bytes(), - document_type, - ); - let reference_max_size = - contract_documents_keeping_history_storage_time_reference_path_size( - document_type.name().len() as u32, - ); - PathKeyUnknownElementSize(( - document_id_in_primary_path, - KnownKey(vec![0]), - Element::required_item_space(reference_max_size, STORAGE_FLAGS_SIZE), - )) - } else { - // we should also insert a reference at 0 to the current value - // todo: we could construct this only once - let document_id_in_primary_path = - contract_documents_keeping_history_primary_key_path_for_document_id( - contract.id_ref().as_bytes(), - document_type.name().as_str(), - document_and_contract_info - .owned_document_info - .document_info - .get_document_id_as_slice() - .ok_or(Error::Drive(DriveError::CorruptedCodeExecution( - "can not get document id from estimated document", - )))?, - ); - PathFixedSizeKeyRefElement(( - document_id_in_primary_path, - &[0], - Element::Reference( - SiblingReference(encoded_time), - Some(1), - StorageFlags::map_to_some_element_flags(storage_flags), - ), - )) - }; - - self.batch_insert(path_key_element_info, drive_operations, drive_version)?; - } else if insert_without_check { + + if insert_without_check { let path_key_element_info = match &document_and_contract_info .owned_document_info .document_info diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs index c0acd51bfa..defd9c72b5 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs @@ -1,5 +1,5 @@ use crate::drive::defaults::DEFAULT_HASH_SIZE_U8; -use crate::drive::document::{contract_document_type_path_vec, unique_event_id}; +use crate::drive::document::unique_event_id; use crate::drive::grove_operations::BatchInsertTreeApplyType; @@ -21,6 +21,7 @@ use grovedb::EstimatedLayerSizes::AllSubtrees; use grovedb::EstimatedSumTrees::NoSumTrees; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; +use crate::drive::document::paths::contract_document_type_path_vec; impl Drive { /// Adds indices for the top index level and calls for lower levels. diff --git a/packages/rs-drive/src/drive/document/mod.rs b/packages/rs-drive/src/drive/document/mod.rs index d378a61260..08d0f2d101 100644 --- a/packages/rs-drive/src/drive/document/mod.rs +++ b/packages/rs-drive/src/drive/document/mod.rs @@ -1,44 +1,11 @@ -// MIT LICENSE -// -// Copyright (c) 2022 Dash Core Group -// -// Permission is hereby granted, free of charge, to any -// person obtaining a copy of this software and associated -// documentation files (the "Software"), to deal in the -// Software without restriction, including without -// limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software -// is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice -// shall be included in all copies or substantial portions -// of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// - //! General Drive Document Functions //! //! This module defines general functions relevant to Documents in Drive. //! Namely functions to return the paths to certain objects and the path sizes. //! -#[cfg(feature = "server")] -use crate::drive::defaults::DEFAULT_HASH_SIZE_U8; #[cfg(feature = "server")] use crate::drive::flags::StorageFlags; -#[cfg(any(feature = "server", feature = "verify"))] -use crate::drive::{defaults, RootTree}; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; #[cfg(any(feature = "server", feature = "verify"))] @@ -47,10 +14,6 @@ use dpp::data_contract::document_type::DocumentTypeRef; use dpp::document::Document; use dpp::document::DocumentV0Getters; #[cfg(feature = "server")] -use grovedb::batch::key_info::KeyInfo; -#[cfg(feature = "server")] -use grovedb::batch::KeyInfoPath; -#[cfg(feature = "server")] use grovedb::reference_path::ReferencePathType::UpstreamRootHeightReference; #[cfg(feature = "server")] use grovedb::Element; @@ -70,103 +33,9 @@ pub mod query; #[cfg(any(feature = "server", feature = "fixtures-and-mocks"))] mod update; +/// paths #[cfg(any(feature = "server", feature = "verify"))] -/// Returns the path to a contract document type. -pub(crate) fn contract_document_type_path<'a>( - contract_id: &'a [u8; 32], - document_type_name: &'a str, -) -> [&'a [u8]; 4] { - [ - Into::<&[u8; 1]>::into(RootTree::DataContractDocuments), - contract_id, - &[1], - document_type_name.as_bytes(), - ] -} - -#[cfg(feature = "server")] -/// Returns the path to a contract document type. -pub(crate) fn contract_document_type_path_vec( - contract_id: &[u8], - document_type_name: &str, -) -> Vec> { - vec![ - vec![RootTree::DataContractDocuments as u8], - contract_id.to_vec(), - vec![1u8], - document_type_name.as_bytes().to_vec(), - ] -} - -#[cfg(feature = "server")] -/// Returns the path to the primary keys of a contract document type. -pub(crate) fn contract_documents_primary_key_path<'a>( - contract_id: &'a [u8], - document_type_name: &'a str, -) -> [&'a [u8]; 5] { - [ - Into::<&[u8; 1]>::into(RootTree::DataContractDocuments), // 1 - contract_id, // 32 - &[1], // 1 - document_type_name.as_bytes(), - &[0], // 1 - ] -} - -#[cfg(feature = "server")] -/// Returns the path to a contract document. -fn contract_documents_keeping_history_primary_key_path_for_document_id<'a>( - contract_id: &'a [u8], - document_type_name: &'a str, - document_id: &'a [u8], -) -> [&'a [u8]; 6] { - [ - Into::<&[u8; 1]>::into(RootTree::DataContractDocuments), - contract_id, - &[1], - document_type_name.as_bytes(), - &[0], - document_id, - ] -} - -#[cfg(feature = "server")] -/// Returns the path to a contract document when the document id isn't known. -fn contract_documents_keeping_history_primary_key_path_for_unknown_document_id( - contract_id: &[u8], - document_type: DocumentTypeRef, -) -> KeyInfoPath { - let mut key_info_path = KeyInfoPath::from_known_path(contract_documents_primary_key_path( - contract_id, - document_type.name().as_str(), - )); - key_info_path.push(KeyInfo::MaxKeySize { - unique_id: document_type.unique_id_for_storage().to_vec(), - max_size: DEFAULT_HASH_SIZE_U8, - }); - key_info_path -} - -#[cfg(any(feature = "server", feature = "verify"))] -#[allow(dead_code)] -#[deprecated(note = "This function is marked as unused.")] -#[allow(deprecated)] -/// Returns the size of the path to a contract document. -fn contract_documents_keeping_history_primary_key_path_for_document_id_size( - document_type_name_len: u32, -) -> u32 { - defaults::BASE_CONTRACT_DOCUMENTS_KEEPING_HISTORY_PRIMARY_KEY_PATH_FOR_DOCUMENT_ID_SIZE - + document_type_name_len -} - -#[cfg(feature = "server")] -/// Returns the size of the path to the time at which a document type was stored. -fn contract_documents_keeping_history_storage_time_reference_path_size( - document_type_name_len: u32, -) -> u32 { - defaults::BASE_CONTRACT_DOCUMENTS_KEEPING_HISTORY_STORAGE_TIME_REFERENCE_PATH - + document_type_name_len -} +pub mod paths; #[cfg(feature = "server")] /// Creates a reference to a document. diff --git a/packages/rs-drive/src/drive/document/paths.rs b/packages/rs-drive/src/drive/document/paths.rs new file mode 100644 index 0000000000..58d086a788 --- /dev/null +++ b/packages/rs-drive/src/drive/document/paths.rs @@ -0,0 +1,105 @@ +use dpp::data_contract::document_type::DocumentTypeRef; +use grovedb::batch::KeyInfoPath; +use grovedb::batch::key_info::KeyInfo; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; +use crate::drive::{defaults, RootTree}; +use crate::drive::defaults::DEFAULT_HASH_SIZE_U8; + +#[cfg(any(feature = "server", feature = "verify"))] +/// Returns the path to a contract document type. +pub(crate) fn contract_document_type_path<'a>( + contract_id: &'a [u8; 32], + document_type_name: &'a str, +) -> [&'a [u8]; 4] { + [ + Into::<&[u8; 1]>::into(RootTree::DataContractDocuments), + contract_id, + &[1], + document_type_name.as_bytes(), + ] +} + +#[cfg(feature = "server")] +/// Returns the path to a contract document type. +pub(crate) fn contract_document_type_path_vec( + contract_id: &[u8], + document_type_name: &str, +) -> Vec> { + vec![ + vec![RootTree::DataContractDocuments as u8], + contract_id.to_vec(), + vec![1u8], + document_type_name.as_bytes().to_vec(), + ] +} + +#[cfg(feature = "server")] +/// Returns the path to the primary keys of a contract document type. +pub(crate) fn contract_documents_primary_key_path<'a>( + contract_id: &'a [u8], + document_type_name: &'a str, +) -> [&'a [u8]; 5] { + [ + Into::<&[u8; 1]>::into(RootTree::DataContractDocuments), // 1 + contract_id, // 32 + &[1], // 1 + document_type_name.as_bytes(), + &[0], // 1 + ] +} + +#[cfg(feature = "server")] +/// Returns the path to a contract document. +pub fn contract_documents_keeping_history_primary_key_path_for_document_id<'a>( + contract_id: &'a [u8], + document_type_name: &'a str, + document_id: &'a [u8], +) -> [&'a [u8]; 6] { + [ + Into::<&[u8; 1]>::into(RootTree::DataContractDocuments), + contract_id, + &[1], + document_type_name.as_bytes(), + &[0], + document_id, + ] +} + +#[cfg(feature = "server")] +/// Returns the path to a contract document when the document id isn't known. +pub fn contract_documents_keeping_history_primary_key_path_for_unknown_document_id( + contract_id: &[u8], + document_type: DocumentTypeRef, +) -> KeyInfoPath { + let mut key_info_path = KeyInfoPath::from_known_path(contract_documents_primary_key_path( + contract_id, + document_type.name().as_str(), + )); + key_info_path.push(KeyInfo::MaxKeySize { + unique_id: document_type.unique_id_for_storage().to_vec(), + max_size: DEFAULT_HASH_SIZE_U8, + }); + key_info_path +} + +#[cfg(any(feature = "server", feature = "verify"))] +#[allow(dead_code)] +#[deprecated(note = "This function is marked as unused.")] +#[allow(deprecated)] +/// Returns the size of the path to a contract document. +fn contract_documents_keeping_history_primary_key_path_for_document_id_size( + document_type_name_len: u32, +) -> u32 { + defaults::BASE_CONTRACT_DOCUMENTS_KEEPING_HISTORY_PRIMARY_KEY_PATH_FOR_DOCUMENT_ID_SIZE + + document_type_name_len +} + +#[cfg(feature = "server")] +/// Returns the size of the path to the time at which a document type was stored. +pub fn contract_documents_keeping_history_storage_time_reference_path_size( + document_type_name_len: u32, +) -> u32 { + defaults::BASE_CONTRACT_DOCUMENTS_KEEPING_HISTORY_STORAGE_TIME_REFERENCE_PATH + + document_type_name_len +} diff --git a/packages/rs-drive/src/drive/document/update/internal/update_document_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/update/internal/update_document_for_contract_operations/v0/mod.rs index 039ccf4dec..c75b6c3cd7 100644 --- a/packages/rs-drive/src/drive/document/update/internal/update_document_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/update/internal/update_document_for_contract_operations/v0/mod.rs @@ -1,9 +1,5 @@ use crate::drive::defaults::CONTRACT_DOCUMENTS_PATH_HEIGHT; -use crate::drive::document::{ - contract_document_type_path, - contract_documents_keeping_history_primary_key_path_for_document_id, - contract_documents_primary_key_path, make_document_reference, -}; +use crate::drive::document::make_document_reference; use crate::drive::flags::StorageFlags; use crate::drive::grove_operations::{ @@ -36,6 +32,7 @@ use grovedb::batch::KeyInfoPath; use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; use std::borrow::Cow; use std::collections::{HashMap, HashSet}; +use crate::drive::document::paths::{contract_document_type_path, contract_documents_keeping_history_primary_key_path_for_document_id, contract_documents_primary_key_path}; impl Drive { /// Gathers operations for updating a document. diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs index 583776e5f6..d30364ce41 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs @@ -20,7 +20,7 @@ impl Drive { /// any votes poll should be closed. pub fn add_vote_poll_end_date_query_operations( &self, - creator_identity_id: Option, + creator_identity_id: Option<[u8;32]>, vote_poll: VotePoll, end_date: TimestampMillis, block_info: &BlockInfo, diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs index 373d235a0f..dddca3da28 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs @@ -1,5 +1,5 @@ use crate::drive::flags::StorageFlags; -use crate::drive::grove_operations::BatchInsertTreeApplyType; +use crate::drive::grove_operations::{BatchInsertApplyType, BatchInsertTreeApplyType}; use crate::drive::object_size_info::PathKeyElementInfo::{PathKeyElementSize, PathKeyRefElement}; use crate::drive::object_size_info::{DriveKeyInfo, PathInfo, PathKeyElementInfo}; use crate::drive::votes::paths::{ @@ -19,13 +19,14 @@ use grovedb::batch::KeyInfoPath; use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; use platform_version::version::PlatformVersion; use std::collections::HashMap; +use crate::drive::grove_operations::QueryTarget::QueryTargetValue; impl Drive { /// We add votes poll references by end date in order to be able to check on every new block if /// any vote polls should be closed. pub(in crate::drive::votes::insert) fn add_vote_poll_end_date_query_operations_v0( &self, - creator_identity_id: Option, + creator_identity_id: Option<[u8;32]>, vote_poll: VotePoll, end_date: TimestampMillis, block_info: &BlockInfo, @@ -40,7 +41,7 @@ impl Drive { let storage_flags = creator_identity_id.map(|creator_identity_id| { StorageFlags::new_single_epoch( block_info.epoch.index, - Some(creator_identity_id.to_buffer()), + Some(creator_identity_id), ) }); @@ -92,6 +93,16 @@ impl Drive { StorageFlags::map_to_some_element_flags(storage_flags.as_ref()), ); + let apply_type = if estimated_costs_only_with_layer_info.is_none() { + BatchInsertApplyType::StatefulBatchInsert + } else { + BatchInsertApplyType::StatelessBatchInsert { + in_tree_using_sums: false, + // todo: figure out a default serialized size to make this faster + target: QueryTargetValue(item.serialized_size()? as u32), + } + }; + let path_key_element_info: PathKeyElementInfo<'_, 0> = if estimated_costs_only_with_layer_info.is_none() { PathKeyRefElement((time_path, &[0], item)) @@ -103,8 +114,12 @@ impl Drive { )) }; - self.batch_insert( + + + self.batch_insert_if_not_exists( path_key_element_info, + apply_type, + transaction, batch_operations, &platform_version.drive, )?; diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/mod.rs index 26d37fb179..091a558c5d 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/mod.rs @@ -1 +1 @@ -mod add_vote_poll_end_date_query_operations; +mod add_vote_poll_end_date_query_operations; \ No newline at end of file diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 57bd9838a8..610f627054 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -1,4 +1,4 @@ -use crate::drive::document::contract_document_type_path; +use crate::drive::document::paths::contract_document_type_path; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::DataContract; diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index 22bf8c8941..eb2b6cb993 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -8,6 +8,7 @@ use dpp::identity::TimestampMillis; /// |- Decisions [key: "d"] /// |- Contested Resource [key: "c"] /// |- End date Queries [key: "e"] +/// |- Active polls [key: "p"] /// |- Identifier Votes Query [key: "i"] /// /// @@ -21,6 +22,9 @@ pub const CONTESTED_RESOURCE_TREE_KEY: char = 'c'; /// A subtree made for being able to query the end date of votes pub const END_DATE_QUERIES_TREE_KEY: char = 'e'; +/// The currently active polls +pub const ACTIVE_POLLS_TREE_KEY: char = 'p'; + /// A subtree made for being able to query votes that an identity has made pub const IDENTITY_VOTES_TREE_KEY: char = 'i'; @@ -84,6 +88,41 @@ pub fn vote_contested_resource_end_date_queries_tree_path_vec() -> Vec> ] } +/// this is the path where votes are actually kept +pub fn vote_contested_resource_active_polls_tree_path<'a>() -> [&'a [u8]; 3] { + [ + Into::<&[u8; 1]>::into(RootTree::Votes), + &[CONTESTED_RESOURCE_TREE_KEY as u8], + &[ACTIVE_POLLS_TREE_KEY as u8], + ] +} + +/// this is the path where votes are actually kept as a vec +pub fn vote_contested_resource_active_polls_tree_path_vec() -> Vec> { + vec![ + vec![RootTree::Votes as u8], + vec![CONTESTED_RESOURCE_TREE_KEY as u8], + vec![ACTIVE_POLLS_TREE_KEY as u8], + ] +} + +#[cfg(feature = "server")] +/// Returns the path to the primary keys of a contract document type. +pub fn vote_contested_resource_contract_documents_primary_key_path<'a>( + contract_id: &'a [u8], + document_type_name: &'a str, +) -> [&'a [u8]; 7] { + [ + Into::<&[u8; 1]>::into(RootTree::Votes), // 1 + &[CONTESTED_RESOURCE_TREE_KEY as u8], // 1 + &[ACTIVE_POLLS_TREE_KEY as u8], // 1 + contract_id, // 32 + &[1], // 1 + document_type_name.as_bytes(), + &[0], // 1 + ] +} + /// the specific end date path query of a contested resources as a vec /// there is no need to ever add a key to this pub fn vote_contested_resource_end_date_queries_at_time_tree_path_vec( diff --git a/packages/rs-drive/src/query/single_document_drive_query.rs b/packages/rs-drive/src/query/single_document_drive_query.rs index 0d45086e0e..6e1202db9e 100644 --- a/packages/rs-drive/src/query/single_document_drive_query.rs +++ b/packages/rs-drive/src/query/single_document_drive_query.rs @@ -1,5 +1,5 @@ use crate::common::encode::encode_u64; -use crate::drive::document::contract_document_type_path; +use crate::drive::document::paths::contract_document_type_path; use crate::query::Query; use grovedb::{PathQuery, SizedQuery}; diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs index bb05c2088f..a9e31885f9 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs @@ -63,19 +63,19 @@ impl DocumentCreateTransitionActionAccessorsV0 for DocumentCreateTransitionActio } } - fn take_prefunded_voting_balances( + fn take_prefunded_voting_balance( &mut self, - ) -> Vec<(ContestedDocumentResourceVotePoll, Credits)> { + ) -> Option<(ContestedDocumentResourceVotePoll, Credits)> { match self { DocumentCreateTransitionAction::V0(v0) => { - mem::replace(&mut v0.prefunded_voting_balances, vec![]) + v0.prefunded_voting_balance.take() } } } - fn prefunded_voting_balances(&self) -> &Vec<(ContestedDocumentResourceVotePoll, Credits)> { + fn prefunded_voting_balance(&self) -> &Option<(ContestedDocumentResourceVotePoll, Credits)> { match self { - DocumentCreateTransitionAction::V0(v0) => &v0.prefunded_voting_balances, + DocumentCreateTransitionAction::V0(v0) => &v0.prefunded_voting_balance, } } } diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs index 4a2ea259fd..c1f48a169c 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs @@ -34,7 +34,7 @@ pub struct DocumentCreateTransitionActionV0 { pub data: BTreeMap, /// Pre funded balance (for unique index conflict resolution voting - the identity will put money /// aside that will be used by voters to vote) - pub prefunded_voting_balances: Vec<(ContestedDocumentResourceVotePoll, Credits)>, + pub prefunded_voting_balance: Option<(ContestedDocumentResourceVotePoll, Credits)>, } /// document create transition action accessors v0 @@ -53,13 +53,13 @@ pub trait DocumentCreateTransitionActionAccessorsV0 { fn data_owned(self) -> BTreeMap; /// Take the prefunded voting balance vec (and replace it with an empty vec). - fn take_prefunded_voting_balances( + fn take_prefunded_voting_balance( &mut self, - ) -> Vec<(ContestedDocumentResourceVotePoll, Credits)>; + ) -> Option<(ContestedDocumentResourceVotePoll, Credits)>; /// pre funded balance (for unique index conflict resolution voting - the identity will put money /// aside that will be used by voters to vote) - fn prefunded_voting_balances(&self) -> &Vec<(ContestedDocumentResourceVotePoll, Credits)>; + fn prefunded_voting_balance(&self) -> &Option<(ContestedDocumentResourceVotePoll, Credits)>; } /// documents from create transition v0 diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs index 3c9368f770..020f10bf22 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs @@ -21,7 +21,7 @@ impl DocumentCreateTransitionActionV0 { let DocumentCreateTransitionV0 { base, data, - prefunded_voting_balances, + prefunded_voting_balance, .. } = value; let base = DocumentBaseTransitionAction::from_base_transition_with_contract_lookup( @@ -33,8 +33,7 @@ impl DocumentCreateTransitionActionV0 { let document_type_indexes = document_type.indexes(); - let prefunded_voting_balances_by_vote_poll = prefunded_voting_balances - .into_iter() + let prefunded_voting_balances_by_vote_poll = prefunded_voting_balance .map(|(index_name, credits)| { let index = document_type_indexes.get(&index_name).ok_or( ProtocolError::UnknownContestedIndexResolution(format!( @@ -52,16 +51,14 @@ impl DocumentCreateTransitionActionV0 { index_values, }; - Ok((vote_poll, credits)) - }) - .collect::, ProtocolError>>( - )?; + Ok::<_, ProtocolError>((vote_poll, credits)) + }).transpose()?; Ok(DocumentCreateTransitionActionV0 { base, block_info: *block_info, data, - prefunded_voting_balances: prefunded_voting_balances_by_vote_poll, + prefunded_voting_balance: prefunded_voting_balances_by_vote_poll, }) } @@ -74,7 +71,7 @@ impl DocumentCreateTransitionActionV0 { let DocumentCreateTransitionV0 { base, data, - prefunded_voting_balances, + prefunded_voting_balance, .. } = value; let base = @@ -87,8 +84,7 @@ impl DocumentCreateTransitionActionV0 { let document_type_indexes = document_type.indexes(); - let prefunded_voting_balances_by_vote_poll = prefunded_voting_balances - .into_iter() + let prefunded_voting_balances_by_vote_poll = prefunded_voting_balance.as_ref() .map(|(index_name, credits)| { let index = document_type_indexes.get(index_name).ok_or( ProtocolError::UnknownContestedIndexResolution(format!( @@ -106,17 +102,15 @@ impl DocumentCreateTransitionActionV0 { index_values, }; - Ok((vote_poll, *credits)) - }) - .collect::, ProtocolError>>( - )?; + Ok::<_, ProtocolError>((vote_poll, *credits)) + }).transpose()?; Ok(DocumentCreateTransitionActionV0 { base, block_info: *block_info, //todo: get rid of clone data: data.clone(), - prefunded_voting_balances: prefunded_voting_balances_by_vote_poll, + prefunded_voting_balance: prefunded_voting_balances_by_vote_poll, }) } } diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs index 36c7fd6434..295f0c45b4 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs @@ -57,7 +57,7 @@ impl DocumentsBatchTransitionActionV0 { .filter_map(|transition| match transition { DocumentTransitionAction::CreateAction(document_create_transition_action) => { document_create_transition_action - .prefunded_voting_balances() + .prefunded_voting_balance() .iter() .try_fold(0u64, |acc, &(_, val)| acc.checked_add(val)) } diff --git a/packages/rs-platform-version/src/version/dpp_versions.rs b/packages/rs-platform-version/src/version/dpp_versions.rs index ac56351bad..ec83575ddc 100644 --- a/packages/rs-platform-version/src/version/dpp_versions.rs +++ b/packages/rs-platform-version/src/version/dpp_versions.rs @@ -12,6 +12,7 @@ pub struct DPPVersion { pub contract_versions: ContractVersions, pub document_versions: DocumentVersions, pub identity_versions: IdentityVersions, + pub voting_versions: VotingVersions, pub asset_lock_versions: AssetLockVersions, } @@ -184,7 +185,8 @@ pub struct DocumentTypeVersions { pub struct DocumentTypeMethodVersions { pub create_document_from_data: FeatureVersion, pub create_document_with_prevalidated_properties: FeatureVersion, - pub prefunded_voting_balances_for_document: FeatureVersion, + pub prefunded_voting_balance_for_document: FeatureVersion, + pub contested_vote_poll_for_document: FeatureVersion, pub estimated_size: FeatureVersion, pub index_for_types: FeatureVersion, pub max_size: FeatureVersion, @@ -221,6 +223,11 @@ pub struct IdentityVersions { pub identity_key_type_method_versions: IdentityKeyTypeMethodVersions, } +#[derive(Clone, Debug, Default)] +pub struct VotingVersions { + pub default_vote_time_ms: u64, +} + #[derive(Clone, Debug, Default)] pub struct IdentityKeyTypeMethodVersions { pub random_public_key_data: FeatureVersion, diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 046ac0cae0..0b3d715a06 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -305,6 +305,7 @@ pub struct DriveDocumentQueryMethodVersions { #[derive(Clone, Debug, Default)] pub struct DriveDocumentEstimationCostsMethodVersions { pub add_estimation_costs_for_add_document_to_primary_storage: FeatureVersion, + pub add_estimation_costs_for_add_contested_document_to_primary_storage: FeatureVersion, pub stateless_delete_of_non_tree_for_costs: FeatureVersion, } diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 3a49006c8f..37a4a1b04a 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -1,16 +1,5 @@ use crate::version::contracts::SystemDataContractVersions; -use crate::version::dpp_versions::{ - AssetLockVersions, ContractVersions, CostVersions, DPPValidationVersions, DPPVersion, - DataContractMethodVersions, DataContractValidationVersions, DocumentFeatureVersionBounds, - DocumentMethodVersions, DocumentTransitionVersions, DocumentTypeClassMethodVersions, - DocumentTypeIndexVersions, DocumentTypeMethodVersions, DocumentTypeSchemaVersions, - DocumentTypeValidationVersions, DocumentTypeVersions, DocumentVersions, - DocumentsBatchTransitionValidationVersions, DocumentsBatchTransitionVersions, - IdentityKeyTypeMethodVersions, IdentityTransitionAssetLockVersions, IdentityTransitionVersions, - IdentityVersions, JsonSchemaValidatorVersions, PublicKeyInCreationMethodVersions, - RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, - StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, -}; +use crate::version::dpp_versions::{AssetLockVersions, ContractVersions, CostVersions, DPPValidationVersions, DPPVersion, DataContractMethodVersions, DataContractValidationVersions, DocumentFeatureVersionBounds, DocumentMethodVersions, DocumentTransitionVersions, DocumentTypeClassMethodVersions, DocumentTypeIndexVersions, DocumentTypeMethodVersions, DocumentTypeSchemaVersions, DocumentTypeValidationVersions, DocumentTypeVersions, DocumentVersions, DocumentsBatchTransitionValidationVersions, DocumentsBatchTransitionVersions, IdentityKeyTypeMethodVersions, IdentityTransitionAssetLockVersions, IdentityTransitionVersions, IdentityVersions, JsonSchemaValidatorVersions, PublicKeyInCreationMethodVersions, RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, VotingVersions}; use crate::version::drive_abci_versions::{ DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, @@ -209,6 +198,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { }, estimation_costs: DriveDocumentEstimationCostsMethodVersions { add_estimation_costs_for_add_document_to_primary_storage: 0, + add_estimation_costs_for_add_contested_document_to_primary_storage: 0, stateless_delete_of_non_tree_for_costs: 0, }, index_uniqueness: DriveDocumentIndexUniquenessMethodVersions { @@ -1073,7 +1063,8 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { methods: DocumentTypeMethodVersions { create_document_from_data: 0, create_document_with_prevalidated_properties: 0, - prefunded_voting_balances_for_document: 0, + prefunded_voting_balance_for_document: 0, + contested_vote_poll_for_document: 0, estimated_size: 0, index_for_types: 0, max_size: 0, @@ -1114,6 +1105,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { random_public_and_private_key_data: 0, }, }, + voting_versions: VotingVersions { default_vote_time_ms: 0 }, asset_lock_versions: AssetLockVersions { reduced_asset_lock_value: FeatureVersionBounds { min_version: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 6e33b29796..e01e0af759 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -1,16 +1,5 @@ use crate::version::contracts::SystemDataContractVersions; -use crate::version::dpp_versions::{ - AssetLockVersions, ContractVersions, CostVersions, DPPValidationVersions, DPPVersion, - DataContractMethodVersions, DataContractValidationVersions, DocumentFeatureVersionBounds, - DocumentMethodVersions, DocumentTransitionVersions, DocumentTypeClassMethodVersions, - DocumentTypeIndexVersions, DocumentTypeMethodVersions, DocumentTypeSchemaVersions, - DocumentTypeValidationVersions, DocumentTypeVersions, DocumentVersions, - DocumentsBatchTransitionValidationVersions, DocumentsBatchTransitionVersions, - IdentityKeyTypeMethodVersions, IdentityTransitionAssetLockVersions, IdentityTransitionVersions, - IdentityVersions, JsonSchemaValidatorVersions, PublicKeyInCreationMethodVersions, - RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, - StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, -}; +use crate::version::dpp_versions::{AssetLockVersions, ContractVersions, CostVersions, DPPValidationVersions, DPPVersion, DataContractMethodVersions, DataContractValidationVersions, DocumentFeatureVersionBounds, DocumentMethodVersions, DocumentTransitionVersions, DocumentTypeClassMethodVersions, DocumentTypeIndexVersions, DocumentTypeMethodVersions, DocumentTypeSchemaVersions, DocumentTypeValidationVersions, DocumentTypeVersions, DocumentVersions, DocumentsBatchTransitionValidationVersions, DocumentsBatchTransitionVersions, IdentityKeyTypeMethodVersions, IdentityTransitionAssetLockVersions, IdentityTransitionVersions, IdentityVersions, JsonSchemaValidatorVersions, PublicKeyInCreationMethodVersions, RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, VotingVersions}; use crate::version::drive_abci_versions::{ DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, @@ -217,6 +206,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { }, estimation_costs: DriveDocumentEstimationCostsMethodVersions { add_estimation_costs_for_add_document_to_primary_storage: 0, + add_estimation_costs_for_add_contested_document_to_primary_storage: 0, stateless_delete_of_non_tree_for_costs: 0, }, index_uniqueness: DriveDocumentIndexUniquenessMethodVersions { @@ -1073,7 +1063,8 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { methods: DocumentTypeMethodVersions { create_document_from_data: 0, create_document_with_prevalidated_properties: 0, - prefunded_voting_balances_for_document: 0, + prefunded_voting_balance_for_document: 0, + contested_vote_poll_for_document: 0, estimated_size: 0, index_for_types: 0, max_size: 0, @@ -1114,6 +1105,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { random_public_and_private_key_data: 0, }, }, + voting_versions: VotingVersions { default_vote_time_ms: 0 }, asset_lock_versions: AssetLockVersions { reduced_asset_lock_value: FeatureVersionBounds { min_version: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 8568168490..878379876b 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -1,16 +1,5 @@ use crate::version::contracts::SystemDataContractVersions; -use crate::version::dpp_versions::{ - AssetLockVersions, ContractVersions, CostVersions, DPPValidationVersions, DPPVersion, - DataContractMethodVersions, DataContractValidationVersions, DocumentFeatureVersionBounds, - DocumentMethodVersions, DocumentTransitionVersions, DocumentTypeClassMethodVersions, - DocumentTypeIndexVersions, DocumentTypeMethodVersions, DocumentTypeSchemaVersions, - DocumentTypeValidationVersions, DocumentTypeVersions, DocumentVersions, - DocumentsBatchTransitionValidationVersions, DocumentsBatchTransitionVersions, - IdentityKeyTypeMethodVersions, IdentityTransitionAssetLockVersions, IdentityTransitionVersions, - IdentityVersions, JsonSchemaValidatorVersions, PublicKeyInCreationMethodVersions, - RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, - StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, -}; +use crate::version::dpp_versions::{AssetLockVersions, ContractVersions, CostVersions, DPPValidationVersions, DPPVersion, DataContractMethodVersions, DataContractValidationVersions, DocumentFeatureVersionBounds, DocumentMethodVersions, DocumentTransitionVersions, DocumentTypeClassMethodVersions, DocumentTypeIndexVersions, DocumentTypeMethodVersions, DocumentTypeSchemaVersions, DocumentTypeValidationVersions, DocumentTypeVersions, DocumentVersions, DocumentsBatchTransitionValidationVersions, DocumentsBatchTransitionVersions, IdentityKeyTypeMethodVersions, IdentityTransitionAssetLockVersions, IdentityTransitionVersions, IdentityVersions, JsonSchemaValidatorVersions, PublicKeyInCreationMethodVersions, RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, VotingVersions}; use crate::version::drive_abci_versions::{ DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, @@ -208,6 +197,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { }, estimation_costs: DriveDocumentEstimationCostsMethodVersions { add_estimation_costs_for_add_document_to_primary_storage: 0, + add_estimation_costs_for_add_contested_document_to_primary_storage: 0, stateless_delete_of_non_tree_for_costs: 0, }, index_uniqueness: DriveDocumentIndexUniquenessMethodVersions { @@ -1072,7 +1062,8 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { methods: DocumentTypeMethodVersions { create_document_from_data: 0, create_document_with_prevalidated_properties: 0, - prefunded_voting_balances_for_document: 0, + prefunded_voting_balance_for_document: 0, + contested_vote_poll_for_document: 0, estimated_size: 0, index_for_types: 0, max_size: 0, @@ -1113,6 +1104,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { random_public_and_private_key_data: 0, }, }, + voting_versions: VotingVersions { default_vote_time_ms: 0 }, asset_lock_versions: AssetLockVersions { reduced_asset_lock_value: FeatureVersionBounds { min_version: 0, diff --git a/packages/strategy-tests/src/lib.rs b/packages/strategy-tests/src/lib.rs index 5be9dc1ea2..29dd8efd44 100644 --- a/packages/strategy-tests/src/lib.rs +++ b/packages/strategy-tests/src/lib.rs @@ -610,7 +610,7 @@ impl Strategy { .into(), entropy: entropy.to_buffer(), data: document.properties_consumed(), - prefunded_voting_balances: Default::default(), + prefunded_voting_balance: Default::default(), } .into(); @@ -721,7 +721,7 @@ impl Strategy { .into(), entropy: entropy.to_buffer(), data: document.properties_consumed(), - prefunded_voting_balances: Default::default(), + prefunded_voting_balance: Default::default(), } .into(); From 3580baefbeff1eb8f0b26e51007041d63522c330 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 14 May 2024 14:10:15 +0200 Subject: [PATCH 056/135] more work --- .../schema/v1/dpns-contract-documents.json | 9 +- .../document/v0/document-meta.json | 35 +++--- .../data_contract/document_type/index/mod.rs | 109 ++++++++++-------- .../document_type/index_level/mod.rs | 88 +++++++------- .../v0/mod.rs | 35 +++--- .../document_type/methods/mod.rs | 7 +- .../v0/mod.rs | 32 +++-- .../src/data_contract/document_type/mod.rs | 8 +- .../v0/v0_methods.rs | 4 +- .../process_raw_state_transitions/v0/mod.rs | 3 + .../tests/strategy_tests/voting_tests.rs | 10 +- .../drive/batch/drive_op_batch/document.rs | 4 +- .../document/document_create_transition.rs | 4 +- .../v0/mod.rs | 2 +- .../v0/mod.rs | 5 +- .../add_document_to_primary_storage/v0/mod.rs | 7 +- .../v0/mod.rs | 2 +- .../add_contested_document/mod.rs | 2 +- .../add_contested_document/v0/mod.rs | 12 +- .../mod.rs | 2 +- .../v0/mod.rs | 2 +- .../mod.rs | 2 +- .../v0/mod.rs | 2 +- .../mod.rs | 2 +- .../v0/mod.rs | 28 +++-- .../v0/mod.rs | 16 +-- .../v0/mod.rs | 2 +- packages/rs-drive/src/drive/document/paths.rs | 10 +- .../v0/mod.rs | 6 +- .../drive/object_size_info/document_info.rs | 13 ++- .../mod.rs | 2 +- .../v0/mod.rs | 11 +- .../src/drive/votes/insert/vote_poll/mod.rs | 2 +- packages/rs-drive/src/drive/votes/mod.rs | 17 +-- packages/rs-drive/src/drive/votes/paths.rs | 8 +- packages/rs-drive/src/error/fee.rs | 2 +- .../document_create_transition_action/mod.rs | 4 +- .../v0/transformer.rs | 9 +- .../src/version/mocks/v2_test.rs | 18 ++- .../src/version/mocks/v3_test.rs | 18 ++- .../rs-platform-version/src/version/v1.rs | 18 ++- 41 files changed, 334 insertions(+), 238 deletions(-) diff --git a/packages/dpns-contract/schema/v1/dpns-contract-documents.json b/packages/dpns-contract/schema/v1/dpns-contract-documents.json index 5f6d88ca15..63fe579816 100644 --- a/packages/dpns-contract/schema/v1/dpns-contract-documents.json +++ b/packages/dpns-contract/schema/v1/dpns-contract-documents.json @@ -14,9 +14,12 @@ ], "unique": true, "contested": { - "name": "normalizedLabelContested", - "fieldMatch": "normalizedLabel", - "regexPattern": "^[a-zA-Z01]{3,19}$", + "fieldMatches": [ + { + "field": "normalizedLabel", + "regexPattern": "^[a-zA-Z01]{3,19}$" + } + ], "resolution": 0, "description": "If the normalized label part of this index is less than 20 characters (all alphabet a-z and 0 and 1) then this index is non unique while contest resolution takes place." } diff --git a/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json b/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json index e3d7d719d4..197a302e66 100644 --- a/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json +++ b/packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json @@ -464,20 +464,27 @@ "contested": { "type": "object", "properties": { - "name": { - "type": "string", - "minLength": 1, - "maxLength": 256 - }, - "fieldMatch": { - "type": "string", - "minLength": 1, - "maxLength": 256 - }, - "regexPattern": { - "type": "string", - "minLength": 1, - "maxLength": 256 + "fieldMatches": { + "type": "array", + "items": { + "type": "object", + "properties": { + "field": { + "type": "string", + "minLength": 1, + "maxLength": 256 + }, + "regexPattern": { + "type": "string", + "minLength": 1, + "maxLength": 256 + } + }, + "required": [ + "field", + "regexPattern" + ] + } }, "resolution": { "type": "integer", diff --git a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs index 5569860d0a..a76b9c76cb 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs @@ -48,7 +48,6 @@ impl TryFrom for ContestedIndexResolution { pub enum ContestedIndexFieldMatch { Regex(regex::Regex), PositiveIntegerMatch(u128), - All, } impl PartialOrd for ContestedIndexFieldMatch { @@ -64,12 +63,6 @@ impl PartialOrd for ContestedIndexFieldMatch { // Comparing Regex with Regex, perhaps based on pattern length (Regex(a), Regex(b)) => a.as_str().len().partial_cmp(&b.as_str().len()), - - // Handling the `All` variant: - // All is greater than any other variant - (All, All) => Some(Ordering::Equal), - (All, _) => Some(Ordering::Greater), - (_, All) => Some(Ordering::Less), } } } @@ -87,11 +80,6 @@ impl Ord for ContestedIndexFieldMatch { // Regex is considered less than a positive integer (Regex(_), PositiveIntegerMatch(_)) => Ordering::Less, (PositiveIntegerMatch(_), Regex(_)) => Ordering::Greater, - - // All is always the greatest - (All, All) => Ordering::Equal, - (All, _) => Ordering::Greater, - (_, All) => Ordering::Less, } } } @@ -100,7 +88,6 @@ impl Clone for ContestedIndexFieldMatch { fn clone(&self) -> Self { match self { Regex(regex) => Regex(regex::Regex::new(regex.as_str()).unwrap()), - ContestedIndexFieldMatch::All => ContestedIndexFieldMatch::All, ContestedIndexFieldMatch::PositiveIntegerMatch(int) => { ContestedIndexFieldMatch::PositiveIntegerMatch(*int) } @@ -115,10 +102,6 @@ impl PartialEq for ContestedIndexFieldMatch { Regex(other_regex) => regex.as_str() == other_regex.as_str(), _ => false, }, - ContestedIndexFieldMatch::All => match other { - ContestedIndexFieldMatch::All => true, - _ => false, - }, ContestedIndexFieldMatch::PositiveIntegerMatch(int) => match other { ContestedIndexFieldMatch::PositiveIntegerMatch(other_int) => int == other_int, _ => false, @@ -139,7 +122,6 @@ impl ContestedIndexFieldMatch { false } } - ContestedIndexFieldMatch::All => true, ContestedIndexFieldMatch::PositiveIntegerMatch(int) => value .as_integer::() .map(|i| i == *int) @@ -150,18 +132,14 @@ impl ContestedIndexFieldMatch { #[derive(Clone, Debug, PartialEq, Eq, Ord, PartialOrd)] pub struct ContestedIndexInformation { - pub contested_field_temp_replacement_name: String, - pub contested_field_name: String, - pub field_match: ContestedIndexFieldMatch, + pub field_matches: BTreeMap, pub resolution: ContestedIndexResolution, } impl Default for ContestedIndexInformation { fn default() -> Self { ContestedIndexInformation { - contested_field_temp_replacement_name: "".to_string(), - contested_field_name: "".to_string(), - field_match: ContestedIndexFieldMatch::All, //by default always contest + field_matches: BTreeMap::new(), resolution: ContestedIndexResolution::MasternodeVote, } } @@ -375,24 +353,62 @@ impl TryFrom<&[(Value, Value)]> for Index { .to_str() .map_err(|e| DataContractError::ValueDecodingError(e.to_string()))?; match contested_key { - "regexPattern" => { - let regex = contested_value.to_str()?.to_owned(); - contested_index_information.field_match = - Regex(regex::Regex::new(®ex).map_err(|e| { - RegexError(format!( - "invalid field match regex: {}", - e.to_string() - )) - })?); - } - "name" => { - let field = contested_value.to_str()?.to_owned(); - contested_index_information.contested_field_temp_replacement_name = - field; - } - "fieldMatch" => { - let field = contested_value.to_str()?.to_owned(); - contested_index_information.contested_field_name = field; + "fieldMatches" => { + let field_matches_array = contested_value.to_array_ref()?; + for field_match in field_matches_array { + let field_match_map = field_match.to_map()?; + let mut name = None; + let mut field_matches = None; + for (field_match_key_as_value, field_match_value) in + field_match_map + { + let field_match_key = + field_match_key_as_value.to_str().map_err(|e| { + DataContractError::ValueDecodingError(e.to_string()) + })?; + match field_match_key { + "field" => { + let field = field_match_value.to_str()?.to_owned(); + name = Some(field); + } + "regexPattern" => { + let regex = field_match_value.to_str()?.to_owned(); + field_matches = Some(Regex( + regex::Regex::new(®ex).map_err(|e| { + RegexError(format!( + "invalid field match regex: {}", + e.to_string() + )) + })?, + )); + } + key => { + return Err(DataContractError::ValueWrongType( + format!("unexpected field match key {}", key), + )); + } + } + } + if name.is_none() { + return Err(DataContractError::FieldRequirementUnmet( + format!( + "field not present in contested fieldMatches {}", + key + ), + )); + } + if field_matches.is_none() { + return Err(DataContractError::FieldRequirementUnmet( + format!( + "field not present in contested fieldMatches {}", + key + ), + )); + } + contested_index_information + .field_matches + .insert(name.unwrap(), field_matches.unwrap()); + } } "resolution" => { let resolution_int = contested_value.to_integer::()?; @@ -402,10 +418,11 @@ impl TryFrom<&[(Value, Value)]> for Index { })?; } "description" => {} - _ => { - return Err(DataContractError::ValueWrongType( - "unexpected contested key".to_string(), - )); + key => { + return Err(DataContractError::ValueWrongType(format!( + "unexpected contested key {}", + key + ))); } } } diff --git a/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs b/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs index 0118b359f3..87b9f83da7 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs @@ -198,50 +198,50 @@ impl IndexLevel { current_level.has_index_with_type = Some(index_type); } } - - if let Some(contested_index) = &index.contested_index { - let mut current_level = &mut index_level; - let mut properties_iter = index.properties.iter().peekable(); - - while let Some(index_part) = properties_iter.next() { - let level_name = if contested_index.contested_field_name == index_part.name { - &contested_index.contested_field_temp_replacement_name - } else { - &index_part.name - }; - current_level = current_level - .sub_index_levels - .entry(level_name.clone()) - .or_insert_with(|| { - counter += 1; - IndexLevel { - level_identifier: counter, - sub_index_levels: Default::default(), - has_index_with_type: None, - } - }); - - // The last property - if properties_iter.peek().is_none() { - // This level already has been initialized. - // It means there are two indices with the same combination of properties. - - // We might need to take into account the sorting order when we have it - if current_level.has_index_with_type.is_some() { - // an index already exists return error - return Err(ConsensusError::BasicError( - BasicError::DuplicateIndexError(DuplicateIndexError::new( - document_type_name.to_owned(), - level_name.clone(), - )), - ) - .into()); - } - - current_level.has_index_with_type = Some(ContestedResourceIndex); - } - } - } + // + // if let Some(contested_index) = &index.contested_index { + // let mut current_level = &mut index_level; + // let mut properties_iter = index.properties.iter().peekable(); + // + // while let Some(index_part) = properties_iter.next() { + // let level_name = if contested_index.contested_field_name == index_part.name { + // &contested_index.contested_field_temp_replacement_name + // } else { + // &index_part.name + // }; + // current_level = current_level + // .sub_index_levels + // .entry(level_name.clone()) + // .or_insert_with(|| { + // counter += 1; + // IndexLevel { + // level_identifier: counter, + // sub_index_levels: Default::default(), + // has_index_with_type: None, + // } + // }); + // + // // The last property + // if properties_iter.peek().is_none() { + // // This level already has been initialized. + // // It means there are two indices with the same combination of properties. + // + // // We might need to take into account the sorting order when we have it + // if current_level.has_index_with_type.is_some() { + // // an index already exists return error + // return Err(ConsensusError::BasicError( + // BasicError::DuplicateIndexError(DuplicateIndexError::new( + // document_type_name.to_owned(), + // level_name.clone(), + // )), + // ) + // .into()); + // } + // + // current_level.has_index_with_type = Some(ContestedResourceIndex); + // } + // } + // } } Ok(index_level) diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/contested_vote_poll_for_document/v0/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/contested_vote_poll_for_document/v0/mod.rs index 33156402f4..8067ef598b 100644 --- a/packages/rs-dpp/src/data_contract/document_type/methods/contested_vote_poll_for_document/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/methods/contested_vote_poll_for_document/v0/mod.rs @@ -14,23 +14,28 @@ impl DocumentTypeV0 { .iter() .find(|(name, index)| { if let Some(contested_index_info) = &index.contested_index { - if let Some(value) = document.get(&contested_index_info.contested_field_name) { - contested_index_info.field_match.matches(value) - } else { - false - } + contested_index_info + .field_matches + .iter() + .all(|(field, field_match)| { + if let Some(value) = document.get(field) { + field_match.matches(value) + } else { + false + } + }) } else { false } - }).map(|(name, index)| { - - let index_values = index.extract_values(document.properties()); - VotePoll::ContestedDocumentResourceVotePoll(ContestedDocumentResourceVotePoll { - contract_id: self.data_contract_id, - document_type_name: self.name.clone(), - index_name: index.name.clone(), - index_values, - }) - }) + }) + .map(|(name, index)| { + let index_values = index.extract_values(document.properties()); + VotePoll::ContestedDocumentResourceVotePoll(ContestedDocumentResourceVotePoll { + contract_id: self.data_contract_id, + document_type_name: self.name.clone(), + index_name: index.name.clone(), + index_values, + }) + }) } } diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs index 2728aafe2c..824785aa4d 100644 --- a/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs @@ -1,3 +1,4 @@ +mod contested_vote_poll_for_document; mod create_document_from_data; mod create_document_with_prevalidated_properties; mod estimated_size; @@ -6,7 +7,6 @@ mod max_size; mod prefunded_voting_balances_for_document; mod serialize_value_for_key; mod validate_update; -mod contested_vote_poll_for_document; use std::collections::BTreeMap; @@ -21,8 +21,8 @@ use crate::version::PlatformVersion; use crate::ProtocolError; use crate::fee::Credits; -use platform_value::{Identifier, Value}; use crate::voting::vote_polls::VotePoll; +use platform_value::{Identifier, Value}; // TODO: Some of those methods are only for tests. Hide under feature pub trait DocumentTypeV0Methods { @@ -120,7 +120,7 @@ pub trait DocumentTypeV0Methods { document: &Document, platform_version: &PlatformVersion, ) -> Result, ProtocolError>; - + /// Gets the vote poll associated with a document fn contested_vote_poll_for_document( &self, @@ -354,5 +354,4 @@ impl DocumentTypeV0Methods for DocumentTypeV0 { }), } } - } diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/v0/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/v0/mod.rs index 07843bae95..15311deae3 100644 --- a/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/v0/mod.rs @@ -15,20 +15,28 @@ impl DocumentTypeV0 { .iter() .find(|(name, index)| { if let Some(contested_index_info) = &index.contested_index { - if let Some(value) = document.get(&contested_index_info.contested_field_name) { - contested_index_info.field_match.matches(value) - } else { - false - } + contested_index_info + .field_matches + .iter() + .all(|(field, field_match)| { + if let Some(value) = document.get(field) { + field_match.matches(value) + } else { + false + } + }) } else { false } - }).map(|(index_name, _)| ( - index_name.clone(), - platform_version - .fee_version - .vote_resolution_fund_fees - .conflicting_vote_resolution_fund_required_amount, - )) + }) + .map(|(index_name, _)| { + ( + index_name.clone(), + platform_version + .fee_version + .vote_resolution_fund_fees + .conflicting_vote_resolution_fund_required_amount, + ) + }) } } diff --git a/packages/rs-dpp/src/data_contract/document_type/mod.rs b/packages/rs-dpp/src/data_contract/document_type/mod.rs index b866844bc7..4269d570d8 100644 --- a/packages/rs-dpp/src/data_contract/document_type/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/mod.rs @@ -21,11 +21,11 @@ use crate::document::Document; use crate::fee::Credits; use crate::prelude::{BlockHeight, CoreBlockHeight, Revision}; use crate::version::PlatformVersion; +use crate::voting::vote_polls::VotePoll; use crate::ProtocolError; use derive_more::From; use platform_value::{Identifier, Value}; use std::collections::BTreeMap; -use crate::voting::vote_polls::VotePoll; mod property_names { pub const DOCUMENTS_KEEP_HISTORY: &str = "documentsKeepHistory"; @@ -235,7 +235,11 @@ impl<'a> DocumentTypeV0Methods for DocumentTypeRef<'a> { } } - fn contested_vote_poll_for_document(&self, document: &Document, platform_version: &PlatformVersion) -> Result, ProtocolError> { + fn contested_vote_poll_for_document( + &self, + document: &Document, + platform_version: &PlatformVersion, + ) -> Result, ProtocolError> { match self { DocumentTypeRef::V0(v0) => { v0.contested_vote_poll_for_document(document, platform_version) diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs index cd6408b48c..0bafe6b8ae 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs @@ -336,7 +336,9 @@ impl DocumentsBatchTransitionMethodsV0 for DocumentsBatchTransitionV0 { .and_then(|document_create_transition| { // Safely sum up values to avoid overflow. document_create_transition - .prefunded_voting_balance().as_ref().map(|(_, credits)| *credits) + .prefunded_voting_balance() + .as_ref() + .map(|(_, credits)| *credits) }) }) .fold((None, false), |(acc, _), price| match acc { diff --git a/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/process_raw_state_transitions/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/process_raw_state_transitions/v0/mod.rs index 1b04c8f64a..03dc37d05c 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/process_raw_state_transitions/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/process_raw_state_transitions/v0/mod.rs @@ -18,6 +18,7 @@ use crate::platform_types::state_transitions_processing_result::{ use dpp::version::PlatformVersion; use drive::grovedb::Transaction; +#[derive(Debug)] struct StateTransitionAwareError { error: Error, raw_state_transition: Vec, @@ -98,6 +99,7 @@ where platform_version, ) .unwrap_or_else(|execution_error| { + panic!("{:?}", execution_error); let mut st_hash = String::new(); if tracing::enabled!(tracing::Level::ERROR) { st_hash = hex::encode( @@ -118,6 +120,7 @@ where }) }) .unwrap_or_else(|processing_error| { + panic!("{}", processing_error); let mut st_hash = String::new(); if tracing::enabled!(tracing::Level::ERROR) { st_hash = hex::encode( diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index 412b220582..4b066feba1 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -157,13 +157,7 @@ mod tests { hard_coded: start_identities, ..Default::default() }, - identity_inserts: IdentityInsertInfo { - frequency: Frequency { - times_per_block_range: 1..2, - chance_per_block: None, - }, - ..Default::default() - }, + identity_inserts: Default::default(), identity_contract_nonce_gaps: None, signer: Some(simple_signer), @@ -186,7 +180,7 @@ mod tests { let outcome = run_chain_for_strategy(&mut platform, 2, strategy.clone(), config.clone(), 15); - let state_transitions_block_2 = &outcome + let state_transitions_block_2 = outcome .state_transition_results_per_block .get(&2) .expect("expected to get block 2"); diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/document.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/document.rs index 7615e7319c..fc168f0c44 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/document.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/document.rs @@ -17,12 +17,12 @@ use dpp::prelude::Identifier; use dpp::system_data_contracts::withdrawals_contract::v1::document_types::withdrawal; use dpp::version::PlatformVersion; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::ProtocolError; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::borrow::Cow; use std::collections::HashMap; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; /// A wrapper for a document operation #[derive(Clone, Debug)] @@ -156,7 +156,7 @@ impl DriveLowLevelOperationConverter for DocumentOperationType<'_> { } DocumentOperationType::AddContestedDocument { owned_document_info, - contested_document_resource_vote_poll, + contested_document_resource_vote_poll, contract_info, document_type_info, insert_without_check, diff --git a/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs b/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs index c66d6f39d0..f0a86b2cfd 100644 --- a/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs +++ b/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs @@ -48,7 +48,9 @@ impl DriveHighLevelDocumentOperationConverter for DocumentCreateTransitionAction }, )]; - if let Some((contested_document_resource_vote_poll, credits)) = maybe_prefunded_voting_balance { + if let Some((contested_document_resource_vote_poll, credits)) = + maybe_prefunded_voting_balance + { let prefunded_specialized_balance_id = contested_document_resource_vote_poll.specialized_balance_id()?; // We are in the situation of a contested document diff --git a/packages/rs-drive/src/drive/document/delete/remove_indices_for_top_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/delete/remove_indices_for_top_index_level_for_contract_operations/v0/mod.rs index 663beb7fdb..c76f060061 100644 --- a/packages/rs-drive/src/drive/document/delete/remove_indices_for_top_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/delete/remove_indices_for_top_index_level_for_contract_operations/v0/mod.rs @@ -21,8 +21,8 @@ use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::config::v0::DataContractConfigGettersV0; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; -use dpp::version::PlatformVersion; use crate::drive::document::paths::contract_document_type_path_vec; +use dpp::version::PlatformVersion; impl Drive { /// Removes indices for the top index level and calls for lower levels. diff --git a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/v0/mod.rs b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/v0/mod.rs index cf6b39ff37..80cfa41c6e 100644 --- a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/v0/mod.rs @@ -57,7 +57,8 @@ impl Drive { if document_and_contract_info .owned_document_info .document_info - .get_borrowed_document().is_none() + .get_borrowed_document() + .is_none() { return Ok(()); }; @@ -84,7 +85,7 @@ impl Drive { Some(flags_size), ), }, - ); + ); Ok(()) } } diff --git a/packages/rs-drive/src/drive/document/insert/add_document_to_primary_storage/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_document_to_primary_storage/v0/mod.rs index b7d6818d89..273b4cceef 100644 --- a/packages/rs-drive/src/drive/document/insert/add_document_to_primary_storage/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_document_to_primary_storage/v0/mod.rs @@ -38,8 +38,13 @@ use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use dpp::document::DocumentV0Getters; +use crate::drive::document::paths::{ + contract_documents_keeping_history_primary_key_path_for_document_id, + contract_documents_keeping_history_primary_key_path_for_unknown_document_id, + contract_documents_keeping_history_storage_time_reference_path_size, + contract_documents_primary_key_path, +}; use dpp::version::PlatformVersion; -use crate::drive::document::paths::{contract_documents_keeping_history_primary_key_path_for_document_id, contract_documents_keeping_history_primary_key_path_for_unknown_document_id, contract_documents_keeping_history_storage_time_reference_path_size, contract_documents_primary_key_path}; impl Drive { /// Adds a document to primary storage. diff --git a/packages/rs-drive/src/drive/document/insert/add_indices_for_top_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert/add_indices_for_top_index_level_for_contract_operations/v0/mod.rs index 35f908bfea..95c638b71c 100644 --- a/packages/rs-drive/src/drive/document/insert/add_indices_for_top_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert/add_indices_for_top_index_level_for_contract_operations/v0/mod.rs @@ -15,13 +15,13 @@ use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::version::PlatformVersion; +use crate::drive::document::paths::contract_document_type_path_vec; use grovedb::batch::KeyInfoPath; use grovedb::EstimatedLayerCount::{ApproximateElements, PotentiallyAtMaxElements}; use grovedb::EstimatedLayerSizes::AllSubtrees; use grovedb::EstimatedSumTrees::NoSumTrees; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; -use crate::drive::document::paths::contract_document_type_path_vec; impl Drive { /// Adds indices for the top index level and calls for lower levels. diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs index 228ecb15a8..0d17e2ed69 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs @@ -11,8 +11,8 @@ use dpp::fee::fee_result::FeeResult; use dpp::identifier::Identifier; use dpp::version::PlatformVersion; -use grovedb::TransactionArg; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use grovedb::TransactionArg; impl Drive { /// Adds a contested document using bincode serialization diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/v0/mod.rs index 8af8032369..4fda31d05b 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/v0/mod.rs @@ -8,8 +8,8 @@ use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::fee::fee_result::FeeResult; use dpp::version::PlatformVersion; -use grovedb::TransactionArg; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use grovedb::TransactionArg; impl Drive { /// Adds a contested document using bincode serialization @@ -28,7 +28,9 @@ impl Drive { let contract_fetch_info = self .get_contract_with_fetch_info_and_add_to_operations( - contested_document_resource_vote_poll.contract_id.into_buffer(), + contested_document_resource_vote_poll + .contract_id + .into_buffer(), Some(&block_info.epoch), true, transaction, @@ -39,7 +41,11 @@ impl Drive { let contract = &contract_fetch_info.contract; - let document_type = contract.document_type_for_name(contested_document_resource_vote_poll.document_type_name.as_str())?; + let document_type = contract.document_type_for_name( + contested_document_resource_vote_poll + .document_type_name + .as_str(), + )?; let document_and_contract_info = DocumentAndContractInfo { owned_document_info, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/mod.rs index cadf1450a8..cb7eb31518 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/mod.rs @@ -10,8 +10,8 @@ use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; use dpp::version::PlatformVersion; -use grovedb::TransactionArg; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use grovedb::TransactionArg; impl Drive { /// Adds a contested document to a contract. diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/v0/mod.rs index f8f06064c1..a19b641428 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/v0/mod.rs @@ -7,8 +7,8 @@ use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; use dpp::version::PlatformVersion; -use grovedb::TransactionArg; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use grovedb::TransactionArg; impl Drive { /// Adds a contested document to a contract. diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs index 15f2ee510d..f3810ed3e9 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs @@ -9,8 +9,8 @@ use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; -use grovedb::TransactionArg; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use grovedb::TransactionArg; impl Drive { /// Performs the operations to add a contested document to a contract. diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/v0/mod.rs index ee71c1759e..9d75179d01 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/v0/mod.rs @@ -5,10 +5,10 @@ use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; impl Drive { /// Performs the operations to add a document to a contract. diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/mod.rs index 40a68d4845..7b8c1badb3 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/mod.rs @@ -8,10 +8,10 @@ use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; impl Drive { /// Gathers the operations to add a contested document to a contract. diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs index 54b63451ec..3e19fcc727 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs @@ -10,13 +10,13 @@ use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; +use crate::drive::votes::paths::vote_contested_resource_contract_documents_primary_key_path; use dpp::version::PlatformVersion; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::voting::vote_polls::VotePoll; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; -use dpp::voting::vote_polls::VotePoll; -use crate::drive::votes::paths::vote_contested_resource_contract_documents_primary_key_path; impl Drive { /// Gathers the operations to add a contested document to a contract. @@ -54,12 +54,22 @@ impl Drive { &mut batch_operations, platform_version, )?; - - let end_date = block_info.time_ms.saturating_add(platform_version.dpp.voting_versions.default_vote_time_ms); - - - self.add_vote_poll_end_date_query_operations(document_and_contract_info.owned_document_info.owner_id, - VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll), end_date, block_info, estimated_costs_only_with_layer_info, previous_batch_operations, &mut batch_operations, transaction, platform_version)?; + + let end_date = block_info + .time_ms + .saturating_add(platform_version.dpp.voting_versions.default_vote_time_ms); + + self.add_vote_poll_end_date_query_operations( + document_and_contract_info.owned_document_info.owner_id, + VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll), + end_date, + block_info, + estimated_costs_only_with_layer_info, + previous_batch_operations, + &mut batch_operations, + transaction, + platform_version, + )?; self.add_contested_indices_for_top_index_level_for_contract_operations( &document_and_contract_info, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/v0/mod.rs index 12bc04d640..7476724981 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/v0/mod.rs @@ -1,14 +1,9 @@ -use dpp::data_contract::document_type::DocumentPropertyType; - use grovedb::batch::key_info::KeyInfo; -use grovedb::batch::key_info::KeyInfo::KnownKey; use grovedb::batch::KeyInfoPath; -use grovedb::reference_path::ReferencePathType::SiblingReference; use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; -use std::option::Option::None; use crate::drive::defaults::{DEFAULT_HASH_SIZE_U8, STORAGE_FLAGS_SIZE}; use crate::drive::flags::StorageFlags; @@ -38,9 +33,14 @@ use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use dpp::document::DocumentV0Getters; -use dpp::version::PlatformVersion; -use crate::drive::document::paths::{contract_documents_keeping_history_primary_key_path_for_document_id, contract_documents_keeping_history_primary_key_path_for_unknown_document_id, contract_documents_keeping_history_storage_time_reference_path_size, contract_documents_primary_key_path}; +use crate::drive::document::paths::{ + contract_documents_keeping_history_primary_key_path_for_document_id, + contract_documents_keeping_history_primary_key_path_for_unknown_document_id, + contract_documents_keeping_history_storage_time_reference_path_size, + contract_documents_primary_key_path, +}; use crate::drive::votes::paths::vote_contested_resource_contract_documents_primary_key_path; +use dpp::version::PlatformVersion; impl Drive { /// Adds a document to primary storage. @@ -73,7 +73,7 @@ impl Drive { platform_version, )?; } - + if insert_without_check { let path_key_element_info = match &document_and_contract_info .owned_document_info diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs index defd9c72b5..c814c9a049 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs @@ -15,13 +15,13 @@ use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::version::PlatformVersion; +use crate::drive::document::paths::contract_document_type_path_vec; use grovedb::batch::KeyInfoPath; use grovedb::EstimatedLayerCount::{ApproximateElements, PotentiallyAtMaxElements}; use grovedb::EstimatedLayerSizes::AllSubtrees; use grovedb::EstimatedSumTrees::NoSumTrees; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; -use crate::drive::document::paths::contract_document_type_path_vec; impl Drive { /// Adds indices for the top index level and calls for lower levels. diff --git a/packages/rs-drive/src/drive/document/paths.rs b/packages/rs-drive/src/drive/document/paths.rs index 58d086a788..6fe1639fc6 100644 --- a/packages/rs-drive/src/drive/document/paths.rs +++ b/packages/rs-drive/src/drive/document/paths.rs @@ -1,10 +1,10 @@ -use dpp::data_contract::document_type::DocumentTypeRef; -use grovedb::batch::KeyInfoPath; -use grovedb::batch::key_info::KeyInfo; +use crate::drive::defaults::DEFAULT_HASH_SIZE_U8; +use crate::drive::{defaults, RootTree}; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; -use crate::drive::{defaults, RootTree}; -use crate::drive::defaults::DEFAULT_HASH_SIZE_U8; +use dpp::data_contract::document_type::DocumentTypeRef; +use grovedb::batch::key_info::KeyInfo; +use grovedb::batch::KeyInfoPath; #[cfg(any(feature = "server", feature = "verify"))] /// Returns the path to a contract document type. diff --git a/packages/rs-drive/src/drive/document/update/internal/update_document_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/update/internal/update_document_for_contract_operations/v0/mod.rs index c75b6c3cd7..fba1406ba8 100644 --- a/packages/rs-drive/src/drive/document/update/internal/update_document_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/update/internal/update_document_for_contract_operations/v0/mod.rs @@ -24,6 +24,11 @@ use dpp::document::document_methods::DocumentMethodsV0; use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use dpp::document::{Document, DocumentV0Getters}; +use crate::drive::document::paths::{ + contract_document_type_path, + contract_documents_keeping_history_primary_key_path_for_document_id, + contract_documents_primary_key_path, +}; use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; use dpp::version::PlatformVersion; use grovedb::batch::key_info::KeyInfo; @@ -32,7 +37,6 @@ use grovedb::batch::KeyInfoPath; use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; use std::borrow::Cow; use std::collections::{HashMap, HashSet}; -use crate::drive::document::paths::{contract_document_type_path, contract_documents_keeping_history_primary_key_path_for_document_id, contract_documents_primary_key_path}; impl Drive { /// Gathers operations for updating a document. diff --git a/packages/rs-drive/src/drive/object_size_info/document_info.rs b/packages/rs-drive/src/drive/object_size_info/document_info.rs index 1901f0eb97..0d9a8d2028 100644 --- a/packages/rs-drive/src/drive/object_size_info/document_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/document_info.rs @@ -121,11 +121,12 @@ impl<'a> DocumentInfoV0Methods for DocumentInfo<'a> { "$createdAtCoreBlockHeight" | "$updatedAtCoreBlockHeight" | "$transferredAtCoreBlockHeight" => Ok(U32_SIZE_U16), - _ => { + key_path => { let property = document_type.flattened_properties().get(key_path).ok_or({ - Error::Fee(FeeError::DocumentTypeFieldNotFoundForEstimation( - "incorrect key path for document type for estimated sizes", - )) + Error::Fee(FeeError::DocumentTypeFieldNotFoundForEstimation(format!( + "incorrect key path [{}] for document type for estimated sizes", + key_path + ))) })?; let estimated_size = property.property_type.middle_byte_size_ceil().ok_or({ Error::Drive(DriveError::CorruptedCodeExecution( @@ -208,11 +209,11 @@ impl<'a> DocumentInfoV0Methods for DocumentInfo<'a> { .to_vec(), max_size: U32_SIZE_U8, }))), - _ => { + key_path => { let property = document_type.flattened_properties().get(key_path).ok_or({ Error::Fee(FeeError::DocumentTypeFieldNotFoundForEstimation( - "incorrect key path for document type", + format!("incorrect key path [{}] for document type for get_raw_for_document_type", key_path) )) })?; diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs index d30364ce41..b4a4b2a946 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs @@ -20,7 +20,7 @@ impl Drive { /// any votes poll should be closed. pub fn add_vote_poll_end_date_query_operations( &self, - creator_identity_id: Option<[u8;32]>, + creator_identity_id: Option<[u8; 32]>, vote_poll: VotePoll, end_date: TimestampMillis, block_info: &BlockInfo, diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs index dddca3da28..88c35e0b03 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs @@ -1,4 +1,5 @@ use crate::drive::flags::StorageFlags; +use crate::drive::grove_operations::QueryTarget::QueryTargetValue; use crate::drive::grove_operations::{BatchInsertApplyType, BatchInsertTreeApplyType}; use crate::drive::object_size_info::PathKeyElementInfo::{PathKeyElementSize, PathKeyRefElement}; use crate::drive::object_size_info::{DriveKeyInfo, PathInfo, PathKeyElementInfo}; @@ -19,14 +20,13 @@ use grovedb::batch::KeyInfoPath; use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; use platform_version::version::PlatformVersion; use std::collections::HashMap; -use crate::drive::grove_operations::QueryTarget::QueryTargetValue; impl Drive { /// We add votes poll references by end date in order to be able to check on every new block if /// any vote polls should be closed. pub(in crate::drive::votes::insert) fn add_vote_poll_end_date_query_operations_v0( &self, - creator_identity_id: Option<[u8;32]>, + creator_identity_id: Option<[u8; 32]>, vote_poll: VotePoll, end_date: TimestampMillis, block_info: &BlockInfo, @@ -39,10 +39,7 @@ impl Drive { platform_version: &PlatformVersion, ) -> Result<(), Error> { let storage_flags = creator_identity_id.map(|creator_identity_id| { - StorageFlags::new_single_epoch( - block_info.epoch.index, - Some(creator_identity_id), - ) + StorageFlags::new_single_epoch(block_info.epoch.index, Some(creator_identity_id)) }); // This is a GroveDB Tree (Not Sub Tree Merk representation) @@ -114,8 +111,6 @@ impl Drive { )) }; - - self.batch_insert_if_not_exists( path_key_element_info, apply_type, diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/mod.rs index 091a558c5d..26d37fb179 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/mod.rs @@ -1 +1 @@ -mod add_vote_poll_end_date_query_operations; \ No newline at end of file +mod add_vote_poll_end_date_query_operations; diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 610f627054..a4a48235d6 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -61,30 +61,17 @@ impl TreePath for ResourceVote { contract.id() )))?; let mut path = contract_document_type_path( - &contested_document_vote_poll.contract_id.as_bytes(), + contested_document_vote_poll.contract_id.as_bytes(), &contested_document_vote_poll.document_type_name, ) .to_vec(); // at this point the path only contains the parts before the index - let Some(contested_index) = &index.contested_index else { - return Err(ProtocolError::VoteError( - "we expect the index in a contested document resource votes type to be contested" - .to_string(), - )); - }; - let mut properties_iter = index.properties.iter(); while let Some(index_part) = properties_iter.next() { - let level_name = if contested_index.contested_field_name == index_part.name { - &contested_index.contested_field_temp_replacement_name - } else { - &index_part.name - }; - - path.push(level_name.as_bytes()); + path.push(index_part.name.as_bytes()); } Ok(path) } diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index eb2b6cb993..e51df191a3 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -114,10 +114,10 @@ pub fn vote_contested_resource_contract_documents_primary_key_path<'a>( ) -> [&'a [u8]; 7] { [ Into::<&[u8; 1]>::into(RootTree::Votes), // 1 - &[CONTESTED_RESOURCE_TREE_KEY as u8], // 1 - &[ACTIVE_POLLS_TREE_KEY as u8], // 1 - contract_id, // 32 - &[1], // 1 + &[CONTESTED_RESOURCE_TREE_KEY as u8], // 1 + &[ACTIVE_POLLS_TREE_KEY as u8], // 1 + contract_id, // 32 + &[1], // 1 document_type_name.as_bytes(), &[0], // 1 ] diff --git a/packages/rs-drive/src/error/fee.rs b/packages/rs-drive/src/error/fee.rs index b7721b1749..cb079cace4 100644 --- a/packages/rs-drive/src/error/fee.rs +++ b/packages/rs-drive/src/error/fee.rs @@ -32,5 +32,5 @@ pub enum FeeError { /// Document type field not found for estimation #[error("document type field not found for estimation error: {0}")] - DocumentTypeFieldNotFoundForEstimation(&'static str), + DocumentTypeFieldNotFoundForEstimation(String), } diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs index a9e31885f9..6a8b7a48b5 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs @@ -67,9 +67,7 @@ impl DocumentCreateTransitionActionAccessorsV0 for DocumentCreateTransitionActio &mut self, ) -> Option<(ContestedDocumentResourceVotePoll, Credits)> { match self { - DocumentCreateTransitionAction::V0(v0) => { - v0.prefunded_voting_balance.take() - } + DocumentCreateTransitionAction::V0(v0) => v0.prefunded_voting_balance.take(), } } diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs index 020f10bf22..ef3791593f 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs @@ -52,7 +52,8 @@ impl DocumentCreateTransitionActionV0 { }; Ok::<_, ProtocolError>((vote_poll, credits)) - }).transpose()?; + }) + .transpose()?; Ok(DocumentCreateTransitionActionV0 { base, @@ -84,7 +85,8 @@ impl DocumentCreateTransitionActionV0 { let document_type_indexes = document_type.indexes(); - let prefunded_voting_balances_by_vote_poll = prefunded_voting_balance.as_ref() + let prefunded_voting_balances_by_vote_poll = prefunded_voting_balance + .as_ref() .map(|(index_name, credits)| { let index = document_type_indexes.get(index_name).ok_or( ProtocolError::UnknownContestedIndexResolution(format!( @@ -103,7 +105,8 @@ impl DocumentCreateTransitionActionV0 { }; Ok::<_, ProtocolError>((vote_poll, *credits)) - }).transpose()?; + }) + .transpose()?; Ok(DocumentCreateTransitionActionV0 { base, diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 37a4a1b04a..7d8b774604 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -1,5 +1,17 @@ use crate::version::contracts::SystemDataContractVersions; -use crate::version::dpp_versions::{AssetLockVersions, ContractVersions, CostVersions, DPPValidationVersions, DPPVersion, DataContractMethodVersions, DataContractValidationVersions, DocumentFeatureVersionBounds, DocumentMethodVersions, DocumentTransitionVersions, DocumentTypeClassMethodVersions, DocumentTypeIndexVersions, DocumentTypeMethodVersions, DocumentTypeSchemaVersions, DocumentTypeValidationVersions, DocumentTypeVersions, DocumentVersions, DocumentsBatchTransitionValidationVersions, DocumentsBatchTransitionVersions, IdentityKeyTypeMethodVersions, IdentityTransitionAssetLockVersions, IdentityTransitionVersions, IdentityVersions, JsonSchemaValidatorVersions, PublicKeyInCreationMethodVersions, RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, VotingVersions}; +use crate::version::dpp_versions::{ + AssetLockVersions, ContractVersions, CostVersions, DPPValidationVersions, DPPVersion, + DataContractMethodVersions, DataContractValidationVersions, DocumentFeatureVersionBounds, + DocumentMethodVersions, DocumentTransitionVersions, DocumentTypeClassMethodVersions, + DocumentTypeIndexVersions, DocumentTypeMethodVersions, DocumentTypeSchemaVersions, + DocumentTypeValidationVersions, DocumentTypeVersions, DocumentVersions, + DocumentsBatchTransitionValidationVersions, DocumentsBatchTransitionVersions, + IdentityKeyTypeMethodVersions, IdentityTransitionAssetLockVersions, IdentityTransitionVersions, + IdentityVersions, JsonSchemaValidatorVersions, PublicKeyInCreationMethodVersions, + RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, + StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, + VotingVersions, +}; use crate::version::drive_abci_versions::{ DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, @@ -1105,7 +1117,9 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { random_public_and_private_key_data: 0, }, }, - voting_versions: VotingVersions { default_vote_time_ms: 0 }, + voting_versions: VotingVersions { + default_vote_time_ms: 0, + }, asset_lock_versions: AssetLockVersions { reduced_asset_lock_value: FeatureVersionBounds { min_version: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index e01e0af759..78c81ae42a 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -1,5 +1,17 @@ use crate::version::contracts::SystemDataContractVersions; -use crate::version::dpp_versions::{AssetLockVersions, ContractVersions, CostVersions, DPPValidationVersions, DPPVersion, DataContractMethodVersions, DataContractValidationVersions, DocumentFeatureVersionBounds, DocumentMethodVersions, DocumentTransitionVersions, DocumentTypeClassMethodVersions, DocumentTypeIndexVersions, DocumentTypeMethodVersions, DocumentTypeSchemaVersions, DocumentTypeValidationVersions, DocumentTypeVersions, DocumentVersions, DocumentsBatchTransitionValidationVersions, DocumentsBatchTransitionVersions, IdentityKeyTypeMethodVersions, IdentityTransitionAssetLockVersions, IdentityTransitionVersions, IdentityVersions, JsonSchemaValidatorVersions, PublicKeyInCreationMethodVersions, RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, VotingVersions}; +use crate::version::dpp_versions::{ + AssetLockVersions, ContractVersions, CostVersions, DPPValidationVersions, DPPVersion, + DataContractMethodVersions, DataContractValidationVersions, DocumentFeatureVersionBounds, + DocumentMethodVersions, DocumentTransitionVersions, DocumentTypeClassMethodVersions, + DocumentTypeIndexVersions, DocumentTypeMethodVersions, DocumentTypeSchemaVersions, + DocumentTypeValidationVersions, DocumentTypeVersions, DocumentVersions, + DocumentsBatchTransitionValidationVersions, DocumentsBatchTransitionVersions, + IdentityKeyTypeMethodVersions, IdentityTransitionAssetLockVersions, IdentityTransitionVersions, + IdentityVersions, JsonSchemaValidatorVersions, PublicKeyInCreationMethodVersions, + RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, + StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, + VotingVersions, +}; use crate::version::drive_abci_versions::{ DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, @@ -1105,7 +1117,9 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { random_public_and_private_key_data: 0, }, }, - voting_versions: VotingVersions { default_vote_time_ms: 0 }, + voting_versions: VotingVersions { + default_vote_time_ms: 0, + }, asset_lock_versions: AssetLockVersions { reduced_asset_lock_value: FeatureVersionBounds { min_version: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 878379876b..d4450952d1 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -1,5 +1,17 @@ use crate::version::contracts::SystemDataContractVersions; -use crate::version::dpp_versions::{AssetLockVersions, ContractVersions, CostVersions, DPPValidationVersions, DPPVersion, DataContractMethodVersions, DataContractValidationVersions, DocumentFeatureVersionBounds, DocumentMethodVersions, DocumentTransitionVersions, DocumentTypeClassMethodVersions, DocumentTypeIndexVersions, DocumentTypeMethodVersions, DocumentTypeSchemaVersions, DocumentTypeValidationVersions, DocumentTypeVersions, DocumentVersions, DocumentsBatchTransitionValidationVersions, DocumentsBatchTransitionVersions, IdentityKeyTypeMethodVersions, IdentityTransitionAssetLockVersions, IdentityTransitionVersions, IdentityVersions, JsonSchemaValidatorVersions, PublicKeyInCreationMethodVersions, RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, VotingVersions}; +use crate::version::dpp_versions::{ + AssetLockVersions, ContractVersions, CostVersions, DPPValidationVersions, DPPVersion, + DataContractMethodVersions, DataContractValidationVersions, DocumentFeatureVersionBounds, + DocumentMethodVersions, DocumentTransitionVersions, DocumentTypeClassMethodVersions, + DocumentTypeIndexVersions, DocumentTypeMethodVersions, DocumentTypeSchemaVersions, + DocumentTypeValidationVersions, DocumentTypeVersions, DocumentVersions, + DocumentsBatchTransitionValidationVersions, DocumentsBatchTransitionVersions, + IdentityKeyTypeMethodVersions, IdentityTransitionAssetLockVersions, IdentityTransitionVersions, + IdentityVersions, JsonSchemaValidatorVersions, PublicKeyInCreationMethodVersions, + RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, + StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, + VotingVersions, +}; use crate::version::drive_abci_versions::{ DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, @@ -1104,7 +1116,9 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { random_public_and_private_key_data: 0, }, }, - voting_versions: VotingVersions { default_vote_time_ms: 0 }, + voting_versions: VotingVersions { + default_vote_time_ms: 0, + }, asset_lock_versions: AssetLockVersions { reduced_asset_lock_value: FeatureVersionBounds { min_version: 0, From e8fd6f8e8a716cd16c9dd5caddf76c42ab9fd44b Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 14 May 2024 15:35:38 +0200 Subject: [PATCH 057/135] worked on estimated costs --- packages/rs-drive/src/drive/defaults.rs | 3 + .../mod.rs | 4 +- .../v0/mod.rs | 4 +- .../mod.rs | 46 +++++++ .../v0/mod.rs | 114 ++++++++++++++++++ .../drive/document/estimation_costs/mod.rs | 1 + .../v0/mod.rs | 2 +- .../v0/mod.rs | 3 +- packages/rs-drive/src/drive/mod.rs | 2 +- .../v0/mod.rs | 32 +++-- .../prefunded_specialized_balances/mod.rs | 15 ++- .../v0/mod.rs | 48 ++++++-- packages/rs-drive/src/drive/votes/paths.rs | 46 ++++++- .../src/version/drive_versions.rs | 1 + .../src/version/mocks/v2_test.rs | 1 + .../src/version/mocks/v3_test.rs | 1 + .../rs-platform-version/src/version/v1.rs | 1 + 17 files changed, 286 insertions(+), 38 deletions(-) create mode 100644 packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/mod.rs create mode 100644 packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/v0/mod.rs diff --git a/packages/rs-drive/src/drive/defaults.rs b/packages/rs-drive/src/drive/defaults.rs index 19bad96478..5cdd4968da 100644 --- a/packages/rs-drive/src/drive/defaults.rs +++ b/packages/rs-drive/src/drive/defaults.rs @@ -116,3 +116,6 @@ pub const ESTIMATED_AVERAGE_INDEX_NAME_SIZE: u8 = 16; /// The estimated count of identities having the same key if they are not unique pub const ESTIMATED_NON_UNIQUE_KEY_DUPLICATES: u32 = 2; + +/// The average size of an item that is acting as a tree reference towards the contested item vote +pub const AVERAGE_CONTESTED_RESOURCE_ITEM_REFERENCE_SIZE: u32 = 150; diff --git a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/mod.rs b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/mod.rs index fbb1d444e2..909f5bbfd8 100644 --- a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/mod.rs +++ b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/mod.rs @@ -35,9 +35,9 @@ impl Drive { /// # Panics /// This function will not panic under normal circumstances. However, unexpected behavior may result /// from incorrect arguments or unforeseen edge cases. - pub(crate) fn add_estimation_costs_for_add_contested_document_to_primary_storage( + pub(crate) fn add_estimation_costs_for_add_contested_document_to_primary_storage( document_and_contract_info: &DocumentAndContractInfo, - primary_key_path: [&[u8]; 7], + primary_key_path: [&[u8]; N], estimated_costs_only_with_layer_info: &mut HashMap, platform_version: &PlatformVersion, ) -> Result<(), Error> { diff --git a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/v0/mod.rs b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/v0/mod.rs index 80cfa41c6e..120098f81b 100644 --- a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/v0/mod.rs @@ -48,9 +48,9 @@ impl Drive { /// This function will not panic under normal circumstances. However, unexpected behavior may result /// from incorrect arguments or unforeseen edge cases. #[inline(always)] - pub(super) fn add_estimation_costs_for_add_contested_document_to_primary_storage_v0( + pub(super) fn add_estimation_costs_for_add_contested_document_to_primary_storage_v0( document_and_contract_info: &DocumentAndContractInfo, - primary_key_path: [&[u8]; 7], + primary_key_path: [&[u8]; N], estimated_costs_only_with_layer_info: &mut HashMap, platform_version: &PlatformVersion, ) -> Result<(), Error> { diff --git a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/mod.rs b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/mod.rs new file mode 100644 index 0000000000..65fe9e7fb5 --- /dev/null +++ b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/mod.rs @@ -0,0 +1,46 @@ +mod v0; + +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use dpp::version::drive_versions::DriveVersion; +use grovedb::batch::KeyInfoPath; + +use grovedb::EstimatedLayerInformation; + +use std::collections::HashMap; +use dpp::data_contract::DataContract; + +impl Drive { + /// This function calls the versioned `add_estimation_costs_for_contested_document_tree_levels_up_to_contract_v0` + /// function based on the version provided in the `DriveVersion` parameter. It returns an error if the + /// version doesn't match any existing versioned functions. + /// + /// # Parameters + /// - `estimated_costs_only_with_layer_info`: A mutable reference to a `HashMap` that holds the estimated layer information. + /// - `drive_version`: A reference to the `DriveVersion` object that specifies the version of the function to call. + pub(in crate::drive) fn add_estimation_costs_for_contested_document_tree_levels_up_to_contract( + contract: &DataContract, + estimated_costs_only_with_layer_info: &mut HashMap, + drive_version: &DriveVersion, + ) -> Result<(), Error> { + match drive_version + .methods + .estimated_costs + .add_estimation_costs_for_contested_document_tree_levels_up_to_contract + { + 0 => { + Self::add_estimation_costs_for_contested_document_tree_levels_up_to_contract_v0( + contract, + estimated_costs_only_with_layer_info, + ); + Ok(()) + } + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "add_estimation_costs_for_contested_document_tree_levels_up_to_contract".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/v0/mod.rs b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/v0/mod.rs new file mode 100644 index 0000000000..87d0e4d6aa --- /dev/null +++ b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/v0/mod.rs @@ -0,0 +1,114 @@ +use crate::drive::defaults::{DEFAULT_HASH_SIZE_U8, ESTIMATED_AVERAGE_DOCUMENT_TYPE_NAME_SIZE}; + +use crate::drive::flags::StorageFlags; +use crate::drive::{contract_documents_path, Drive}; + +use grovedb::batch::KeyInfoPath; +use grovedb::EstimatedLayerCount::{ApproximateElements, EstimatedLevel, PotentiallyAtMaxElements}; +use grovedb::EstimatedLayerInformation; +use grovedb::EstimatedLayerSizes::AllSubtrees; + +use grovedb::EstimatedSumTrees::{NoSumTrees, SomeSumTrees}; +use std::collections::HashMap; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::DataContract; +use crate::drive::votes::paths::{vote_contested_resource_active_polls_contract_tree_path, vote_contested_resource_active_polls_tree_path, vote_contested_resource_tree_path, vote_root_path}; + +impl Drive { + /// Adds estimated costs for layers up to the contract level. + /// + /// This function populates the `estimated_costs_only_with_layer_info` hashmap with estimated layer information for the top level and the contract layer. + /// These estimates are useful for optimizing GroveDB operations. + /// + /// # Parameters + /// + /// - `estimated_costs_only_with_layer_info`: A mutable reference to a hashmap that will be populated with estimated layer information for the top level and the contract layer. + /// + /// # Estimated Layer Information + /// + /// The function estimates two layers: + /// + /// 1. The top layer, which is an empty layer. + /// 2. The contract layer, which contains all global contracts. + /// + /// These estimates are useful for optimizing batch insertions, deletions, and other operations in GroveDB. + /// + /// # Usage + /// + /// This function is intended to be used internally within the Drive implementation. + /// + pub(super) fn add_estimation_costs_for_contested_document_tree_levels_up_to_contract_v0( + contract: &DataContract, + estimated_costs_only_with_layer_info: &mut HashMap, + ) { + // we have constructed the top layer so contract/documents tree are at the top + estimated_costs_only_with_layer_info.insert( + KeyInfoPath::from_known_path([]), + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: EstimatedLevel(2, false), //voting is on level 2 + // We have balances in the middle which is a sum tree + estimated_layer_sizes: AllSubtrees(1, SomeSumTrees { sum_trees_weight: 1, non_sum_trees_weight: 2 }, None), + }, + ); + + // we then need to insert the contract layer + estimated_costs_only_with_layer_info.insert( + KeyInfoPath::from_known_path(vote_root_path()), + EstimatedLayerInformation { + is_sum_tree: false, + // contested resource tree is a key of "c" so it should be on the top layer of the merk + estimated_layer_count: EstimatedLevel(0, false), + estimated_layer_sizes: AllSubtrees( + 1, + NoSumTrees, + Some(StorageFlags::approximate_size(false, None)), + ), + }, + ); + + // we then need to insert the contract layer + estimated_costs_only_with_layer_info.insert( + KeyInfoPath::from_known_path(vote_contested_resource_tree_path()), + EstimatedLayerInformation { + is_sum_tree: false, + // active poll "p", with "e" and "i" first so it should be on the second layer of the merk + estimated_layer_count: EstimatedLevel(1, false), + estimated_layer_sizes: AllSubtrees( + 1, + NoSumTrees, + Some(StorageFlags::approximate_size(false, None)), + ), + }, + ); + + // we then need to insert the contract layer + estimated_costs_only_with_layer_info.insert( + KeyInfoPath::from_known_path(vote_contested_resource_active_polls_tree_path()), + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: PotentiallyAtMaxElements, + estimated_layer_sizes: AllSubtrees( + DEFAULT_HASH_SIZE_U8, + NoSumTrees, + Some(StorageFlags::approximate_size(false, None)), + ), + }, + ); + + let document_type_count = contract.document_types().len() as u32; + + estimated_costs_only_with_layer_info.insert( + KeyInfoPath::from_known_path(vote_contested_resource_active_polls_contract_tree_path(contract.id_ref().as_bytes())), + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: ApproximateElements(document_type_count), + estimated_layer_sizes: AllSubtrees( + ESTIMATED_AVERAGE_DOCUMENT_TYPE_NAME_SIZE, + NoSumTrees, + Some(StorageFlags::approximate_size(true, None)), + ), + }, + ); + } +} diff --git a/packages/rs-drive/src/drive/document/estimation_costs/mod.rs b/packages/rs-drive/src/drive/document/estimation_costs/mod.rs index 7831d47184..0d8e554cdc 100644 --- a/packages/rs-drive/src/drive/document/estimation_costs/mod.rs +++ b/packages/rs-drive/src/drive/document/estimation_costs/mod.rs @@ -3,3 +3,4 @@ mod stateless_delete_of_non_tree_for_costs; mod add_estimation_costs_for_add_document_to_primary_storage; mod add_estimation_costs_for_add_contested_document_to_primary_storage; +mod add_estimation_costs_for_contested_document_tree_levels_up_to_contract; diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs index 3e19fcc727..67e0ef548e 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs @@ -38,7 +38,7 @@ impl Drive { // if we are trying to get estimated costs we need to add the upper levels if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { - Self::add_estimation_costs_for_levels_up_to_contract_document_type_excluded( + Self::add_estimation_costs_for_contested_document_tree_levels_up_to_contract( document_and_contract_info.contract, estimated_costs_only_with_layer_info, &platform_version.drive, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs index c814c9a049..1a90da208b 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs @@ -22,6 +22,7 @@ use grovedb::EstimatedLayerSizes::AllSubtrees; use grovedb::EstimatedSumTrees::NoSumTrees; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; +use crate::drive::votes::paths::vote_contested_resource_active_polls_contract_document_tree_path_vec; impl Drive { /// Adds indices for the top index level and calls for lower levels. @@ -58,7 +59,7 @@ impl Drive { // * Document and DataContract root tree // * DataContract ID recovered from document // * 0 to signify Documents and notDataContract - let contract_document_type_path = contract_document_type_path_vec( + let contract_document_type_path = vote_contested_resource_active_polls_contract_document_tree_path_vec( document_and_contract_info.contract.id_ref().as_bytes(), document_and_contract_info.document_type.name(), ); diff --git a/packages/rs-drive/src/drive/mod.rs b/packages/rs-drive/src/drive/mod.rs index 4f56e0ab55..1075819162 100644 --- a/packages/rs-drive/src/drive/mod.rs +++ b/packages/rs-drive/src/drive/mod.rs @@ -110,7 +110,7 @@ pub enum RootTree { Identities = 32, /// Unique Public Key Hashes to Identities UniquePublicKeyHashesToIdentities = 24, // UPKH->I above - /// Non Unique Public Key Hashes to Identities, useful for Masternode Identities + /// Non-Unique Public Key Hashes to Identities, useful for Masternode Identities NonUniquePublicKeyKeyHashesToIdentities = 8, // NUPKH->I /// Pools Pools = 48, diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs index d4b0061427..72705a085c 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs @@ -1,13 +1,14 @@ use crate::drive::Drive; use grovedb::batch::KeyInfoPath; -use grovedb::EstimatedLayerCount::{ApproximateElements, EstimatedLevel}; +use grovedb::EstimatedLayerCount::{ApproximateElements, EstimatedLevel, PotentiallyAtMaxElements}; use grovedb::EstimatedLayerInformation; use grovedb::EstimatedLayerSizes::{AllItems, AllSubtrees}; -use crate::drive::prefunded_specialized_balances::prefunded_specialized_balances_for_voting_path_vec; -use grovedb::EstimatedSumTrees::SomeSumTrees; +use crate::drive::prefunded_specialized_balances::{prefunded_specialized_balances_for_voting_path_vec, prefunded_specialized_balances_path}; +use grovedb::EstimatedSumTrees::{AllSumTrees, SomeSumTrees}; use std::collections::HashMap; +use crate::drive::defaults::{AVERAGE_BALANCE_SIZE, DEFAULT_HASH_SIZE_U8, U64_SIZE_U8}; impl Drive { /// Adds estimation costs for total system credits update. @@ -18,15 +19,15 @@ impl Drive { pub(super) fn add_estimation_costs_for_prefunded_specialized_balance_update_v0( estimated_costs_only_with_layer_info: &mut HashMap, ) { - //todo: verify (this is wrong) - // we have constructed the top layer so contract/documents tree are at the top - // since balance will be on layer 2, updating will mean we will update 1 sum tree - // and 1 normal tree, hence we should give an equal weight to both + // todo: this will be inserted at the same time as other estimated costs for documents, + // hence we add the full information, but it would be much better that estimated costs would + // be merged instead of overwritten estimated_costs_only_with_layer_info.insert( KeyInfoPath::from_known_path([]), EstimatedLayerInformation { is_sum_tree: false, - estimated_layer_count: EstimatedLevel(1, false), + // We are on the 3rd level + estimated_layer_count: EstimatedLevel(3, false), estimated_layer_sizes: AllSubtrees( 1, SomeSumTrees { @@ -38,14 +39,21 @@ impl Drive { }, ); - //todo : verify this - // we then need to insert the contract layer + estimated_costs_only_with_layer_info.insert( + KeyInfoPath::from_known_path(prefunded_specialized_balances_path()), + EstimatedLayerInformation { + is_sum_tree: true, + estimated_layer_count: EstimatedLevel(0, false), + estimated_layer_sizes: AllSubtrees(1, AllSumTrees, None), + }, + ); + estimated_costs_only_with_layer_info.insert( KeyInfoPath::from_known_owned_path(prefunded_specialized_balances_for_voting_path_vec()), EstimatedLayerInformation { is_sum_tree: true, - estimated_layer_count: ApproximateElements(0), - estimated_layer_sizes: AllItems(1, 8, None), + estimated_layer_count: PotentiallyAtMaxElements, + estimated_layer_sizes: AllItems(DEFAULT_HASH_SIZE_U8, AVERAGE_BALANCE_SIZE, None), }, ); } diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs index 05baa3d8b3..2bd6585f3a 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs @@ -10,13 +10,20 @@ use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; use crate::drive::batch::GroveDbOpBatch; use crate::drive::{Drive, RootTree}; -pub const PREFUNDED_BALANCES_FOR_VOTING: [u8; 1] = [128]; +pub const PREFUNDED_BALANCES_FOR_VOTING: u8 = 128; + +/// prefunded specialized balances for voting +pub(crate) fn prefunded_specialized_balances_path() -> [&'static [u8]; 1] { + [ + Into::<&[u8; 1]>::into(RootTree::PreFundedSpecializedBalances), + ] +} /// prefunded specialized balances for voting pub(crate) fn prefunded_specialized_balances_for_voting_path() -> [&'static [u8]; 2] { [ Into::<&[u8; 1]>::into(RootTree::PreFundedSpecializedBalances), - &PREFUNDED_BALANCES_FOR_VOTING, + &[PREFUNDED_BALANCES_FOR_VOTING], ] } @@ -24,7 +31,7 @@ pub(crate) fn prefunded_specialized_balances_for_voting_path() -> [&'static [u8] pub(crate) fn prefunded_specialized_balances_for_voting_path_vec() -> Vec> { vec![ Into::<&[u8; 1]>::into(RootTree::PreFundedSpecializedBalances).to_vec(), - PREFUNDED_BALANCES_FOR_VOTING.to_vec(), + vec![PREFUNDED_BALANCES_FOR_VOTING], ] } @@ -39,7 +46,7 @@ impl Drive { pub fn add_initial_prefunded_specialized_balances_operations(batch: &mut GroveDbOpBatch) { batch.add_insert_empty_sum_tree( vec![vec![RootTree::PreFundedSpecializedBalances as u8]], - PREFUNDED_BALANCES_FOR_VOTING.to_vec(), + vec![PREFUNDED_BALANCES_FOR_VOTING], ); } } diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs index 88c35e0b03..3199a214b0 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs @@ -3,10 +3,7 @@ use crate::drive::grove_operations::QueryTarget::QueryTargetValue; use crate::drive::grove_operations::{BatchInsertApplyType, BatchInsertTreeApplyType}; use crate::drive::object_size_info::PathKeyElementInfo::{PathKeyElementSize, PathKeyRefElement}; use crate::drive::object_size_info::{DriveKeyInfo, PathInfo, PathKeyElementInfo}; -use crate::drive::votes::paths::{ - vote_contested_resource_end_date_queries_at_time_tree_path_vec, - vote_contested_resource_end_date_queries_tree_path_vec, -}; +use crate::drive::votes::paths::{vote_contested_resource_active_polls_contract_tree_path, vote_contested_resource_end_date_queries_at_time_tree_path_vec, vote_contested_resource_end_date_queries_tree_path, vote_contested_resource_end_date_queries_tree_path_vec}; use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; @@ -20,6 +17,10 @@ use grovedb::batch::KeyInfoPath; use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; use platform_version::version::PlatformVersion; use std::collections::HashMap; +use grovedb::EstimatedLayerCount::ApproximateElements; +use grovedb::EstimatedLayerSizes::{AllItems, AllSubtrees}; +use grovedb::EstimatedSumTrees::NoSumTrees; +use crate::drive::defaults::{AVERAGE_CONTESTED_RESOURCE_ITEM_REFERENCE_SIZE, DEFAULT_HASH_SIZE_U8, ESTIMATED_AVERAGE_DOCUMENT_TYPE_NAME_SIZE, U64_SIZE_U8}; impl Drive { /// We add votes poll references by end date in order to be able to check on every new block if @@ -42,6 +43,36 @@ impl Drive { StorageFlags::new_single_epoch(block_info.epoch.index, Some(creator_identity_id)) }); + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info + { + estimated_costs_only_with_layer_info.insert( + KeyInfoPath::from_known_path(vote_contested_resource_end_date_queries_tree_path()), + EstimatedLayerInformation { + is_sum_tree: false, + // We can estimate that there is at least a vote concluding every block, and we put blocks at 6 seconds. + estimated_layer_count: ApproximateElements(201_600), + estimated_layer_sizes: AllSubtrees( + U64_SIZE_U8, + NoSumTrees, + Some(StorageFlags::approximate_size(true, None)), + ), + }); + + estimated_costs_only_with_layer_info.insert( + KeyInfoPath::from_known_owned_path(vote_contested_resource_end_date_queries_at_time_tree_path_vec(end_date)), + EstimatedLayerInformation { + is_sum_tree: false, + // We can estimate that there is 2 votes ending per block. + estimated_layer_count: ApproximateElements(2), + estimated_layer_sizes: AllItems( + DEFAULT_HASH_SIZE_U8, + AVERAGE_CONTESTED_RESOURCE_ITEM_REFERENCE_SIZE, + Some(StorageFlags::approximate_size(true, None)), + ), + }, + ); + } + // This is a GroveDB Tree (Not Sub Tree Merk representation) // End Date queries // / \ @@ -121,14 +152,5 @@ impl Drive { Ok(()) - //todo - // if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info - // { - // Self::add_estimation_costs_for_levels_up_to_contract_document_type_excluded( - // contract, - // estimated_costs_only_with_layer_info, - // drive_version, - // )?; - // } } } diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index e51df191a3..c0e93d3cbc 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -106,18 +106,60 @@ pub fn vote_contested_resource_active_polls_tree_path_vec() -> Vec> { ] } +#[cfg(feature = "server")] +/// Returns the path to the primary keys of a contract document type. +pub fn vote_contested_resource_active_polls_contract_tree_path( + contract_id: &[u8], +) -> [&[u8]; 4] { + [ + Into::<&[u8; 1]>::into(RootTree::Votes), // 1 + &[CONTESTED_RESOURCE_TREE_KEY as u8], // 1 + &[ACTIVE_POLLS_TREE_KEY as u8], // 1 + contract_id, // 32 + ] +} + +#[cfg(feature = "server")] +/// Returns the path to the primary keys of a contract document type. +pub fn vote_contested_resource_active_polls_contract_document_tree_path<'a>( + contract_id: &'a [u8], + document_type_name: &'a str, +) -> [&'a [u8]; 5] { + [ + Into::<&[u8; 1]>::into(RootTree::Votes), // 1 + &[CONTESTED_RESOURCE_TREE_KEY as u8], // 1 + &[ACTIVE_POLLS_TREE_KEY as u8], // 1 + contract_id, // 32 + document_type_name.as_bytes(), + ] +} + +#[cfg(feature = "server")] +/// Returns the path to the root of document type in the contested tree +pub fn vote_contested_resource_active_polls_contract_document_tree_path_vec( + contract_id: &[u8], + document_type_name: &str, +) -> Vec> { + vec![ + vec![RootTree::Votes as u8], + vec![CONTESTED_RESOURCE_TREE_KEY as u8], + vec![ACTIVE_POLLS_TREE_KEY as u8], + contract_id.to_vec(), + document_type_name.as_bytes().to_vec(), + ] +} + #[cfg(feature = "server")] /// Returns the path to the primary keys of a contract document type. pub fn vote_contested_resource_contract_documents_primary_key_path<'a>( contract_id: &'a [u8], document_type_name: &'a str, -) -> [&'a [u8]; 7] { +) -> [&'a [u8]; 6] { [ Into::<&[u8; 1]>::into(RootTree::Votes), // 1 &[CONTESTED_RESOURCE_TREE_KEY as u8], // 1 &[ACTIVE_POLLS_TREE_KEY as u8], // 1 contract_id, // 32 - &[1], // 1 document_type_name.as_bytes(), &[0], // 1 ] diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 0b3d715a06..d5dc648b1e 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -682,4 +682,5 @@ pub struct DriveIdentityUpdateMethodVersions { pub struct DriveEstimatedCostsMethodVersions { pub add_estimation_costs_for_levels_up_to_contract: FeatureVersion, pub add_estimation_costs_for_levels_up_to_contract_document_type_excluded: FeatureVersion, + pub add_estimation_costs_for_contested_document_tree_levels_up_to_contract: FeatureVersion, } diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 7d8b774604..eefb9e9f3f 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -269,6 +269,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { estimated_costs: DriveEstimatedCostsMethodVersions { add_estimation_costs_for_levels_up_to_contract: 0, add_estimation_costs_for_levels_up_to_contract_document_type_excluded: 0, + add_estimation_costs_for_contested_document_tree_levels_up_to_contract: 0, }, asset_lock: DriveAssetLockMethodVersions { add_asset_lock_outpoint: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 78c81ae42a..e80f0d5c7b 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -277,6 +277,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { estimated_costs: DriveEstimatedCostsMethodVersions { add_estimation_costs_for_levels_up_to_contract: 0, add_estimation_costs_for_levels_up_to_contract_document_type_excluded: 0, + add_estimation_costs_for_contested_document_tree_levels_up_to_contract: 0, }, asset_lock: DriveAssetLockMethodVersions { add_asset_lock_outpoint: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index d4450952d1..b99f6b0970 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -268,6 +268,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { estimated_costs: DriveEstimatedCostsMethodVersions { add_estimation_costs_for_levels_up_to_contract: 0, add_estimation_costs_for_levels_up_to_contract_document_type_excluded: 0, + add_estimation_costs_for_contested_document_tree_levels_up_to_contract: 0, }, asset_lock: DriveAssetLockMethodVersions { add_asset_lock_outpoint: 0, From acfa5abb968a9f8d90f556b0af269293b2b9d319 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Thu, 16 May 2024 01:01:21 +0200 Subject: [PATCH 058/135] got the trees inserted in contested area --- .../protos/platform/v0/platform.proto | 6 + .../proto/org.dash.platform.dapi.v0.rs | 49 +++++ .../rs-dpp/src/data_contract/accessors/mod.rs | 6 + .../src/data_contract/accessors/v0/mod.rs | 3 +- .../document_type/accessors/mod.rs | 18 ++ .../document_type/accessors/v0/mod.rs | 3 + .../document_type/methods/mod.rs | 21 +- .../src/data_contract/document_type/mod.rs | 6 + .../document_type/v0/accessors.rs | 4 + .../src/data_contract/v0/accessors/mod.rs | 5 + .../rs-drive-abci/src/query/proofs/v0/mod.rs | 10 +- .../tests/strategy_tests/main.rs | 6 +- .../verify_state_transitions.rs | 25 ++- .../tests/strategy_tests/voting_tests.rs | 1 + .../contract/insert/insert_contract/v0/mod.rs | 78 +++++++- .../drive/document/estimation_costs/mod.rs | 1 - .../v0/mod.rs | 5 +- .../mod.rs | 49 +++++ .../v0/mod.rs | 184 ++++++++---------- .../mod.rs | 1 - .../drive/document/insert_contested/mod.rs | 6 +- .../rs-drive/src/drive/initialization/mod.rs | 29 --- .../drive/object_size_info/path_key_info.rs | 15 ++ .../v0/mod.rs | 7 +- .../mod.rs | 7 +- .../v0/mod.rs | 35 +++- .../src/drive/shared_estimation_costs/mod.rs | 1 + .../verify_proof_keep_serialized/v0/mod.rs | 2 +- .../v0/mod.rs | 23 ++- packages/rs-drive/src/drive/votes/paths.rs | 16 ++ .../v0/mod.rs | 10 +- packages/rs-drive/src/error/drive.rs | 12 ++ packages/rs-drive/src/query/mod.rs | 1 + .../src/query/single_document_drive_query.rs | 82 +++++++- .../src/version/drive_versions.rs | 4 +- .../src/version/mocks/v2_test.rs | 4 +- .../src/version/mocks/v3_test.rs | 4 +- .../rs-platform-version/src/version/v1.rs | 4 +- 38 files changed, 552 insertions(+), 191 deletions(-) create mode 100644 packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/mod.rs rename packages/rs-drive/src/drive/document/insert_contested/{add_contested_indices_for_top_index_level_for_contract_operations => add_contested_indices_for_contract_operations}/v0/mod.rs (62%) delete mode 100644 packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/mod.rs rename packages/rs-drive/src/drive/{document/estimation_costs => shared_estimation_costs}/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/mod.rs (89%) rename packages/rs-drive/src/drive/{document/estimation_costs => shared_estimation_costs}/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/v0/mod.rs (75%) diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index 903837d25c..212bbd9e7f 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -292,10 +292,16 @@ message GetIdentitiesContractKeysResponse { message GetProofsRequest { message GetProofsRequestV0 { message DocumentRequest { + enum DocumentContestedStatus { + NOT_CONTESTED = 0; + MAYBE_CONTESTED = 1; + CONTESTED = 2; + } bytes contract_id = 1; string document_type = 2; bool document_type_keeps_history = 3; bytes document_id = 4; + DocumentContestedStatus document_contested_status = 5; } message IdentityRequest { diff --git a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs index beed50bb73..3880bd3e78 100644 --- a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs +++ b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs @@ -882,6 +882,55 @@ pub mod get_proofs_request { pub document_type_keeps_history: bool, #[prost(bytes = "vec", tag = "4")] pub document_id: ::prost::alloc::vec::Vec, + #[prost( + enumeration = "document_request::DocumentContestedStatus", + tag = "5" + )] + pub document_contested_status: i32, + } + /// Nested message and enum types in `DocumentRequest`. + pub mod document_request { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum DocumentContestedStatus { + NotContested = 0, + MaybeContested = 1, + Contested = 2, + } + impl DocumentContestedStatus { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + DocumentContestedStatus::NotContested => "NOT_CONTESTED", + DocumentContestedStatus::MaybeContested => "MAYBE_CONTESTED", + DocumentContestedStatus::Contested => "CONTESTED", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "NOT_CONTESTED" => Some(Self::NotContested), + "MAYBE_CONTESTED" => Some(Self::MaybeContested), + "CONTESTED" => Some(Self::Contested), + _ => None, + } + } + } } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] diff --git a/packages/rs-dpp/src/data_contract/accessors/mod.rs b/packages/rs-dpp/src/data_contract/accessors/mod.rs index 25a22800df..fc5dc0789b 100644 --- a/packages/rs-dpp/src/data_contract/accessors/mod.rs +++ b/packages/rs-dpp/src/data_contract/accessors/mod.rs @@ -76,6 +76,12 @@ impl DataContractV0Getters for DataContract { } } + fn document_types_with_contested_indexes(&self) -> BTreeMap<&DocumentName, &DocumentType> { + match self { + DataContract::V0(v0) => v0.document_types_with_contested_indexes(), + } + } + fn document_types(&self) -> &BTreeMap { match self { DataContract::V0(v0) => v0.document_types(), diff --git a/packages/rs-dpp/src/data_contract/accessors/v0/mod.rs b/packages/rs-dpp/src/data_contract/accessors/v0/mod.rs index 9999e9b173..32b53e9572 100644 --- a/packages/rs-dpp/src/data_contract/accessors/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/accessors/v0/mod.rs @@ -1,7 +1,7 @@ use crate::data_contract::config::DataContractConfig; use crate::data_contract::document_type::{DocumentType, DocumentTypeRef}; use crate::data_contract::errors::DataContractError; -use crate::data_contract::DocumentName; +use crate::data_contract::{DataContract, DocumentName}; use crate::metadata::Metadata; use platform_value::Identifier; @@ -31,6 +31,7 @@ pub trait DataContractV0Getters { fn document_type_cloned_optional_for_name(&self, name: &str) -> Option; fn has_document_type_for_name(&self, name: &str) -> bool; + fn document_types_with_contested_indexes(&self) -> BTreeMap<&DocumentName, &DocumentType>; /// Returns a mapping of document names to their corresponding document types. fn document_types(&self) -> &BTreeMap; diff --git a/packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs b/packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs index 87759b0ee0..004044bed5 100644 --- a/packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs @@ -136,6 +136,12 @@ impl DocumentTypeV0Getters for DocumentType { DocumentType::V0(v0) => v0.security_level_requirement(), } } + + fn find_contested_index(&self) -> Option<&Index> { + match self { + DocumentType::V0(v0) => v0.find_contested_index(), + } + } } impl<'a> DocumentTypeV0Getters for DocumentTypeRef<'a> { @@ -258,6 +264,12 @@ impl<'a> DocumentTypeV0Getters for DocumentTypeRef<'a> { DocumentTypeRef::V0(v0) => v0.security_level_requirement(), } } + + fn find_contested_index(&self) -> Option<&Index> { + match self { + DocumentTypeRef::V0(v0) => v0.find_contested_index(), + } + } } impl<'a> DocumentTypeV0Getters for DocumentTypeMutRef<'a> { @@ -380,4 +392,10 @@ impl<'a> DocumentTypeV0Getters for DocumentTypeMutRef<'a> { DocumentTypeMutRef::V0(v0) => v0.security_level_requirement(), } } + + fn find_contested_index(&self) -> Option<&Index> { + match self { + DocumentTypeMutRef::V0(v0) => v0.find_contested_index(), + } + } } diff --git a/packages/rs-dpp/src/data_contract/document_type/accessors/v0/mod.rs b/packages/rs-dpp/src/data_contract/document_type/accessors/v0/mod.rs index 342e109e33..0042346db9 100644 --- a/packages/rs-dpp/src/data_contract/document_type/accessors/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/accessors/v0/mod.rs @@ -22,6 +22,9 @@ pub trait DocumentTypeV0Getters { /// Returns the indices of the document type. fn indexes(&self) -> &BTreeMap; + + /// The contested index if one exists + fn find_contested_index(&self) -> Option<&Index>; /// Returns the index structure of the document type. fn index_structure(&self) -> &IndexLevel; diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs index 824785aa4d..80d52140a4 100644 --- a/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs @@ -64,6 +64,9 @@ pub trait DocumentTypeV0Methods { /// Non versioned fn top_level_indices(&self) -> Vec<&IndexProperty>; + /// Non versioned + fn top_level_indices_of_contested_unique_indexes(&self) -> Vec<&IndexProperty>; + fn create_document_from_data( &self, data: Value, @@ -239,13 +242,19 @@ impl DocumentTypeV0Methods for DocumentTypeV0 { } fn top_level_indices(&self) -> Vec<&IndexProperty> { - let mut index_properties: Vec<&IndexProperty> = Vec::with_capacity(self.indices.len()); - for (_, index) in &self.indices { - if let Some(property) = index.properties.first() { - index_properties.push(property); + self.indices.values().filter_map(|index| index.properties.first()).collect() + } + + // This should normally just be 1 item, however we keep a vec in case we want to change things + // in the future. + fn top_level_indices_of_contested_unique_indexes(&self) -> Vec<&IndexProperty> { + self.indices.values().filter_map(|index| { + if index.contested_index.is_some() { + index.properties.first() + } else { + None } - } - index_properties + }).collect() } fn create_document_from_data( diff --git a/packages/rs-dpp/src/data_contract/document_type/mod.rs b/packages/rs-dpp/src/data_contract/document_type/mod.rs index 4269d570d8..3f37e60ac2 100644 --- a/packages/rs-dpp/src/data_contract/document_type/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/mod.rs @@ -181,6 +181,12 @@ impl<'a> DocumentTypeV0Methods for DocumentTypeRef<'a> { } } + fn top_level_indices_of_contested_unique_indexes(&self) -> Vec<&IndexProperty> { + match self { + DocumentTypeRef::V0(v0) => v0.top_level_indices_of_contested_unique_indexes(), + } + } + fn create_document_from_data( &self, data: Value, diff --git a/packages/rs-dpp/src/data_contract/document_type/v0/accessors.rs b/packages/rs-dpp/src/data_contract/document_type/v0/accessors.rs index 99353db701..b16c585505 100644 --- a/packages/rs-dpp/src/data_contract/document_type/v0/accessors.rs +++ b/packages/rs-dpp/src/data_contract/document_type/v0/accessors.rs @@ -31,6 +31,10 @@ impl DocumentTypeV0Getters for DocumentTypeV0 { &self.indices } + fn find_contested_index(&self) -> Option<&Index> { + self.indices.iter().find(|(_, index)| index.contested_index.is_some()).map(|(_, contested_index)| contested_index) + } + fn index_structure(&self) -> &IndexLevel { &self.index_structure } diff --git a/packages/rs-dpp/src/data_contract/v0/accessors/mod.rs b/packages/rs-dpp/src/data_contract/v0/accessors/mod.rs index ed1efb3115..afb5b273dd 100644 --- a/packages/rs-dpp/src/data_contract/v0/accessors/mod.rs +++ b/packages/rs-dpp/src/data_contract/v0/accessors/mod.rs @@ -9,6 +9,7 @@ use crate::metadata::Metadata; use platform_value::Identifier; use std::collections::BTreeMap; +use crate::data_contract::document_type::accessors::DocumentTypeV0Getters; impl DataContractV0Getters for DataContractV0 { fn id(&self) -> Identifier { @@ -69,6 +70,10 @@ impl DataContractV0Getters for DataContractV0 { self.document_types.get(name).is_some() } + fn document_types_with_contested_indexes(&self) -> BTreeMap<&DocumentName, &DocumentType> { + self.document_types.iter().filter(|(_, document_type)| document_type.indexes().iter().any(|(_, index)| index.contested_index.is_some())).collect() + } + fn document_types(&self) -> &BTreeMap { &self.document_types } diff --git a/packages/rs-drive-abci/src/query/proofs/v0/mod.rs b/packages/rs-drive-abci/src/query/proofs/v0/mod.rs index ac01ac401c..0138692e31 100644 --- a/packages/rs-drive-abci/src/query/proofs/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/proofs/v0/mod.rs @@ -82,6 +82,8 @@ impl Platform { "id must be a valid identifier (32 bytes long)".to_string(), ) })?; + + let contested_status = document_proof_request.document_contested_status.try_into()?; Ok(SingleDocumentDriveQuery { contract_id: contract_id.into_buffer(), @@ -89,9 +91,9 @@ impl Platform { document_type_keeps_history: document_proof_request.document_type_keeps_history, document_id: document_id.into_buffer(), block_time_ms: None, //None because we want latest + contested_status, }) - }) - .collect::, QueryError>>()); + }).collect::, QueryError>>()); let vote_queries = check_validation_result_with_data!(votes .into_iter() @@ -247,6 +249,7 @@ mod tests { document_type: "niceDocument".to_string(), document_type_keeps_history: false, document_id: vec![0; 32], + document_contested_status: 0, }], votes: vec![], }; @@ -270,6 +273,7 @@ mod tests { document_type: "niceDocument".to_string(), document_type_keeps_history: false, document_id: vec![0; 8], + document_contested_status: 0, }], votes: vec![], }; @@ -293,6 +297,7 @@ mod tests { document_type: "niceDocument".to_string(), document_type_keeps_history: false, document_id: vec![0; 32], + document_contested_status: 0, }], votes: vec![], }; @@ -324,6 +329,7 @@ mod tests { document_type: "niceDocument".to_string(), document_type_keeps_history: false, document_id: vec![1; 32], + document_contested_status: 0, }], votes: vec![], }; diff --git a/packages/rs-drive-abci/tests/strategy_tests/main.rs b/packages/rs-drive-abci/tests/strategy_tests/main.rs index 12a1a0a38a..89cf24bbaf 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/main.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/main.rs @@ -1089,7 +1089,7 @@ mod tests { .unwrap() .unwrap() ), - "0c39624d8a3ccc771f51dad46587eb1d09b4e233e2ecd94219f20b07f847fddf".to_string() + "437e90db3d155d1a2db90d21c2a1996c02ee1853e1da5a1b6805f6ce5260890a".to_string() ) } @@ -1779,7 +1779,7 @@ mod tests { .unwrap() .unwrap() ), - "22c1172ba1d91488baa590a8b295e888061a6d6a5a3d5133749716a129f78d36".to_string() + "8bb1546dba61beb571cd289b2f4e872900776d2c73fe698d14e8124de6bf9e57".to_string() ) } @@ -1904,7 +1904,7 @@ mod tests { .unwrap() .unwrap() ), - "995aefbcf840432bf6dd038765a76d16f2c3860dcef0c98641794e94896e71ae".to_string() + "3e0e25e19ab7f517d0256e53b85bdfecdc1614014fc0ef02b4698c270a47442a".to_string() ) } diff --git a/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs b/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs index a97437d19e..2cb2a96860 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs @@ -14,7 +14,7 @@ use dpp::state_transition::StateTransition; use dpp::version::PlatformVersion; use drive::drive::identity::key::fetch::IdentityKeysRequest; use drive::drive::Drive; -use drive::query::SingleDocumentDriveQuery; +use drive::query::{SingleDocumentDriveQuery, SingleDocumentDriveQueryContestedStatus}; use drive::state_transition_action::document::documents_batch::document_transition::DocumentTransitionAction; use drive::state_transition_action::StateTransitionAction; use drive_abci::execution::validation::state_transition::transformer::StateTransitionActionTransformerV0; @@ -27,7 +27,7 @@ use dpp::voting::vote_polls::VotePoll; use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; use dpp::voting::votes::Vote; use drive::state_transition_action::document::documents_batch::document_transition::document_base_transition_action::DocumentBaseTransitionActionAccessorsV0; -use drive::state_transition_action::document::documents_batch::document_transition::document_create_transition_action::DocumentFromCreateTransitionAction; +use drive::state_transition_action::document::documents_batch::document_transition::document_create_transition_action::{DocumentCreateTransitionActionAccessorsV0, DocumentFromCreateTransitionAction}; use drive::state_transition_action::document::documents_batch::document_transition::document_purchase_transition_action::DocumentPurchaseTransitionActionAccessorsV0; use drive::state_transition_action::document::documents_batch::document_transition::document_replace_transition_action::DocumentFromReplaceTransitionAction; use drive::state_transition_action::document::documents_batch::document_transition::document_transfer_transition_action::DocumentTransferTransitionActionAccessorsV0; @@ -213,6 +213,15 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed( .transitions() .iter() .for_each(|transition| { + let document_contested_status = if let DocumentTransitionAction::CreateAction(create_action) = transition { + if create_action.prefunded_voting_balance().is_some() { + SingleDocumentDriveQueryContestedStatus::Contested as u8 + } else { + SingleDocumentDriveQueryContestedStatus::NotContested as u8 + } + } else { + SingleDocumentDriveQueryContestedStatus::NotContested as u8 + }; proofs_request .documents .push(get_proofs_request_v0::DocumentRequest { @@ -247,6 +256,7 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed( .expect("expected a base for the document transition") .id() .to_vec(), + document_contested_status: document_contested_status as i32, }); }); let versioned_request = GetProofsRequest { @@ -278,6 +288,16 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed( .as_str(), ) .expect("get document type"); + let contested_status = if let DocumentTransitionAction::CreateAction(create_action) = document_transition_action { + if create_action.prefunded_voting_balance().is_some() { + SingleDocumentDriveQueryContestedStatus::Contested + } else { + SingleDocumentDriveQueryContestedStatus::NotContested + } + } else { + SingleDocumentDriveQueryContestedStatus::NotContested + }; + let query = SingleDocumentDriveQuery { contract_id: document_transition_action .base() @@ -296,6 +316,7 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed( .id() .into_buffer(), block_time_ms: None, //None because we want latest + contested_status, }; // dbg!( diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index 4b066feba1..fd508576a7 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -16,6 +16,7 @@ mod tests { use rand::SeedableRng; use simple_signer::signer::SimpleSigner; use std::collections::BTreeMap; + use drive::drive::config::DriveConfig; use strategy_tests::frequency::Frequency; use strategy_tests::operations::{DocumentAction, DocumentOp, Operation, OperationType}; use strategy_tests::transitions::create_state_transitions_for_identities; diff --git a/packages/rs-drive/src/drive/contract/insert/insert_contract/v0/mod.rs b/packages/rs-drive/src/drive/contract/insert/insert_contract/v0/mod.rs index 2d7bc1f9c3..77271b9579 100644 --- a/packages/rs-drive/src/drive/contract/insert/insert_contract/v0/mod.rs +++ b/packages/rs-drive/src/drive/contract/insert/insert_contract/v0/mod.rs @@ -2,7 +2,7 @@ use crate::drive::contract::paths; use crate::drive::flags::StorageFlags; use crate::drive::object_size_info::DriveKeyInfo::{Key, KeyRef}; -use crate::drive::{contract_documents_path, Drive, RootTree}; +use crate::drive::{contract_documents_path, Drive, RootTree, votes}; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; @@ -185,9 +185,83 @@ impl Drive { &platform_version.drive, )?; + // If the contract happens to contain any contested indexes then we add the contract to the + // contested contracts + + let document_types_with_contested_indexes = contract.document_types_with_contested_indexes(); + + if !document_types_with_contested_indexes.is_empty() { + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { + Self::add_estimation_costs_for_contested_document_tree_levels_up_to_contract( + contract, + None, + estimated_costs_only_with_layer_info, + &platform_version.drive, + )?; + } + + let contested_contract_root_path = votes::paths::vote_contested_resource_active_polls_tree_path(); + + self.batch_insert_empty_tree( + contested_contract_root_path, + KeyRef(contract.id_ref().as_bytes()), + storage_flags.as_ref(), + &mut batch_operations, + &platform_version.drive, + )?; + + let contested_unique_index_contract_document_types_path = votes::paths::vote_contested_resource_active_polls_contract_tree_path(contract.id_ref().as_bytes()); + + for (type_key, document_type) in document_types_with_contested_indexes.into_iter() { + + self.batch_insert_empty_tree( + contested_unique_index_contract_document_types_path, + KeyRef(type_key.as_bytes()), + storage_flags.as_ref(), + &mut batch_operations, + &platform_version.drive, + )?; + + let type_path = [ + contested_unique_index_contract_document_types_path[0], + contested_unique_index_contract_document_types_path[1], + contested_unique_index_contract_document_types_path[2], + contested_unique_index_contract_document_types_path[3], + type_key.as_bytes(), + ]; + + // primary key tree + let key_info = Key(vec![0]); + self.batch_insert_empty_tree( + type_path, + key_info, + storage_flags.as_ref(), + &mut batch_operations, + &platform_version.drive, + )?; + + let mut index_cache: HashSet<&[u8]> = HashSet::new(); + // for each type we should insert the indices that are top level + for index in document_type.as_ref().top_level_indices_of_contested_unique_indexes() { + // toDo: change this to be a reference by index + let index_bytes = index.name.as_bytes(); + if !index_cache.contains(index_bytes) { + self.batch_insert_empty_tree( + type_path, + KeyRef(index_bytes), + storage_flags.as_ref(), + &mut batch_operations, + &platform_version.drive, + )?; + index_cache.insert(index_bytes); + } + } + } + } + // next we should store each document type // right now we are referring them by name - // toDo: change this to be a reference by index + // todo: maybe change this to be a reference by index let contract_documents_path = contract_documents_path(contract.id_ref().as_bytes()); for (type_key, document_type) in contract.document_types().iter() { diff --git a/packages/rs-drive/src/drive/document/estimation_costs/mod.rs b/packages/rs-drive/src/drive/document/estimation_costs/mod.rs index 0d8e554cdc..7831d47184 100644 --- a/packages/rs-drive/src/drive/document/estimation_costs/mod.rs +++ b/packages/rs-drive/src/drive/document/estimation_costs/mod.rs @@ -3,4 +3,3 @@ mod stateless_delete_of_non_tree_for_costs; mod add_estimation_costs_for_add_document_to_primary_storage; mod add_estimation_costs_for_add_contested_document_to_primary_storage; -mod add_estimation_costs_for_contested_document_tree_levels_up_to_contract; diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs index 67e0ef548e..ba3adaed07 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs @@ -40,6 +40,7 @@ impl Drive { if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { Self::add_estimation_costs_for_contested_document_tree_levels_up_to_contract( document_and_contract_info.contract, + Some(document_and_contract_info.document_type), estimated_costs_only_with_layer_info, &platform_version.drive, )?; @@ -70,8 +71,8 @@ impl Drive { transaction, platform_version, )?; - - self.add_contested_indices_for_top_index_level_for_contract_operations( + + self.add_contested_indices_for_contract_operations( &document_and_contract_info, previous_batch_operations, estimated_costs_only_with_layer_info, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/mod.rs new file mode 100644 index 0000000000..913af4a39f --- /dev/null +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/mod.rs @@ -0,0 +1,49 @@ +use std::collections::HashMap; +use grovedb::batch::KeyInfoPath; +use grovedb::{EstimatedLayerInformation, TransactionArg}; +use platform_version::version::PlatformVersion; +use crate::drive::Drive; +use crate::drive::object_size_info::DocumentAndContractInfo; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; + +mod v0; + + +impl Drive { + /// Adds indices for an index level and recurses. + pub(crate) fn add_contested_indices_for_contract_operations( + &self, + document_and_contract_info: &DocumentAndContractInfo, + previous_batch_operations: &mut Option<&mut Vec>, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + transaction: TransactionArg, + batch_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive + .methods + .document + .insert_contested + .add_contested_indices_for_contract_operations + { + 0 => self.add_contested_indices_for_contract_operations_v0( + document_and_contract_info, + previous_batch_operations, + estimated_costs_only_with_layer_info, + transaction, + batch_operations, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "add_contested_indices_for_contract_operations".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs similarity index 62% rename from packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs rename to packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs index 1a90da208b..284640a25c 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs @@ -1,32 +1,29 @@ -use crate::drive::defaults::DEFAULT_HASH_SIZE_U8; -use crate::drive::document::unique_event_id; - use crate::drive::grove_operations::BatchInsertTreeApplyType; -use crate::drive::object_size_info::{DocumentAndContractInfo, DocumentInfoV0Methods, PathInfo}; +use crate::drive::object_size_info::{DocumentAndContractInfo, DocumentInfoV0Methods, DriveKeyInfo, PathInfo}; use crate::drive::Drive; use crate::error::fee::FeeError; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::data_contract::accessors::v0::DataContractV0Getters; -use dpp::data_contract::config::v0::DataContractConfigGettersV0; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::version::PlatformVersion; - -use crate::drive::document::paths::contract_document_type_path_vec; use grovedb::batch::KeyInfoPath; -use grovedb::EstimatedLayerCount::{ApproximateElements, PotentiallyAtMaxElements}; +use grovedb::EstimatedLayerCount::PotentiallyAtMaxElements; use grovedb::EstimatedLayerSizes::AllSubtrees; use grovedb::EstimatedSumTrees::NoSumTrees; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; +use dpp::data_contract::document_type::IndexProperty; +use crate::drive::defaults::DEFAULT_HASH_SIZE_U8; use crate::drive::votes::paths::vote_contested_resource_active_polls_contract_document_tree_path_vec; +use crate::error::drive::DriveError; impl Drive { /// Adds indices for the top index level and calls for lower levels. - pub(crate) fn add_contested_indices_for_top_index_level_for_contract_operations( + pub(crate) fn add_contested_indices_for_contract_operations_v0( &self, document_and_contract_info: &DocumentAndContractInfo, previous_batch_operations: &mut Option<&mut Vec>, @@ -38,21 +35,13 @@ impl Drive { platform_version: &PlatformVersion, ) -> Result<(), Error> { let drive_version = &platform_version.drive; - let index_level = &document_and_contract_info.document_type.index_structure(); - let contract = document_and_contract_info.contract; - let event_id = unique_event_id(); + let owner_id = document_and_contract_info.owned_document_info.owner_id.ok_or(Error::Drive(DriveError::ContestedDocumentMissingOwnerId("expecting an owner id")))?; + let contested_index = document_and_contract_info.document_type.find_contested_index().ok_or(Error::Drive(DriveError::ContestedIndexNotFound("a contested index is expected")))?; let document_type = document_and_contract_info.document_type; - let storage_flags = - if document_type.documents_mutable() || contract.config().can_be_deleted() { - document_and_contract_info + let storage_flags = document_and_contract_info .owned_document_info .document_info - .get_storage_flags_ref() - } else { - None //there are no need for storage flags if documents are not mutable and contract can not be deleted - }; - - // dbg!(&estimated_costs_only_with_layer_info); + .get_storage_flags_ref(); // we need to construct the path for documents on the contract // the path is @@ -64,24 +53,6 @@ impl Drive { document_and_contract_info.document_type.name(), ); - let sub_level_index_count = index_level.sub_levels().len() as u32; - - if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { - // On this level we will have a 0 and all the top index paths - estimated_costs_only_with_layer_info.insert( - KeyInfoPath::from_known_owned_path(contract_document_type_path.clone()), - EstimatedLayerInformation { - is_sum_tree: false, - estimated_layer_count: ApproximateElements(sub_level_index_count + 1), - estimated_layer_sizes: AllSubtrees( - DEFAULT_HASH_SIZE_U8, - NoSumTrees, - storage_flags.map(|s| s.serialized_size()), - ), - }, - ); - } - let apply_type = if estimated_costs_only_with_layer_info.is_none() { BatchInsertTreeApplyType::StatefulBatchInsertTree } else { @@ -94,41 +65,28 @@ impl Drive { } }; - // next we need to store a reference to the document for each index - for (name, sub_level) in index_level.sub_levels() { - // at this point the contract path is to the contract documents - // for each index the top index component will already have been added - // when the contract itself was created - let mut index_path: Vec> = contract_document_type_path.clone(); - index_path.push(Vec::from(name.as_bytes())); + // at this point the contract path is to the contract documents + // for each index the top index component will already have been added + // when the contract itself was created + let index_path: Vec> = contract_document_type_path.clone(); + + let mut index_path_info = if document_and_contract_info + .owned_document_info + .document_info + .is_document_size() + { + // This is a stateless operation + PathInfo::PathWithSizes(KeyInfoPath::from_known_owned_path(index_path)) + } else { + PathInfo::PathAsVec::<0>(index_path) + }; - // with the example of the dashpay contract's first index - // the index path is now something likeDataContracts/ContractID/Documents(1)/$ownerId - let document_top_field = document_and_contract_info - .owned_document_info - .document_info - .get_raw_for_document_type( - name, - document_type, - document_and_contract_info.owned_document_info.owner_id, - Some((sub_level, event_id)), - platform_version, - )? - .unwrap_or_default(); - // The zero will not matter here, because the PathKeyInfo is variable - let path_key_info = document_top_field.clone().add_path::<0>(index_path.clone()); - // here we are inserting an empty tree that will have a subtree of all other index properties - self.batch_insert_empty_tree_if_not_exists( - path_key_info.clone(), - false, - storage_flags, - apply_type, - transaction, - previous_batch_operations, - batch_operations, - drive_version, - )?; + // next we need to store a reference to the document for each index + for IndexProperty{ name, .. } in &contested_index.properties { + // We on purpose do not want to put index names + // This is different from document secondary indexes + // The reason is that there is only one index so we already know the structure if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { @@ -142,10 +100,10 @@ impl Drive { "document field is too big for being an index on delete", ))); } - + // On this level we will have all the user defined values for the paths estimated_costs_only_with_layer_info.insert( - KeyInfoPath::from_known_owned_path(index_path.clone()), + index_path_info.clone().convert_to_key_info_path(), EstimatedLayerInformation { is_sum_tree: false, estimated_layer_count: PotentiallyAtMaxElements, @@ -157,38 +115,66 @@ impl Drive { }, ); } - - let any_fields_null = document_top_field.is_empty(); - - let mut index_path_info = if document_and_contract_info + + // with the example of the dashpay contract's first index + // the index path is now something likeDataContracts/ContractID/Documents(1)/$ownerId + let document_top_field = document_and_contract_info .owned_document_info .document_info - .is_document_size() - { - // This is a stateless operation - PathInfo::PathWithSizes(KeyInfoPath::from_known_owned_path(index_path)) - } else { - PathInfo::PathAsVec::<0>(index_path) - }; - - // we push the actual value of the index path - index_path_info.push(document_top_field)?; - // the index path is now something likeDataContracts/ContractID/Documents(1)/$ownerId/ + .get_raw_for_document_type( + name, + document_type, + document_and_contract_info.owned_document_info.owner_id, + None, //we should never need this in contested documents + platform_version, + )? + .unwrap_or_default(); - self.add_contested_indices_for_index_level_for_contract_operations( - document_and_contract_info, - index_path_info, - sub_level, - any_fields_null, - previous_batch_operations, - &storage_flags, - estimated_costs_only_with_layer_info, - event_id, + // here we are inserting an empty tree that will have a subtree of all other index properties + self.batch_insert_empty_tree_if_not_exists( + document_top_field.clone().add_path_info(index_path_info.clone()), + false, + storage_flags, + apply_type, transaction, + previous_batch_operations, batch_operations, - platform_version, + drive_version, )?; + + index_path_info.push(document_top_field)?; + } + + // at the end of all of this we put the identity tree that will hold the votes + + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info + { + // On this level we will have all the identities + estimated_costs_only_with_layer_info.insert( + index_path_info.clone().convert_to_key_info_path(), + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: PotentiallyAtMaxElements, + estimated_layer_sizes: AllSubtrees( + DEFAULT_HASH_SIZE_U8, + NoSumTrees, + storage_flags.map(|s| s.serialized_size()), + ), + }, + ); } + + self.batch_insert_empty_tree_if_not_exists( + DriveKeyInfo::Key(owner_id.to_vec()).add_path_info(index_path_info.clone()), + false, + storage_flags, + apply_type, + transaction, + previous_batch_operations, + batch_operations, + drive_version, + )?; + Ok(()) } } diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/mod.rs deleted file mode 100644 index e084dffc38..0000000000 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_top_index_level_for_contract_operations/mod.rs +++ /dev/null @@ -1 +0,0 @@ -mod v0; diff --git a/packages/rs-drive/src/drive/document/insert_contested/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/mod.rs index f3cd5e798e..d133b66cbb 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/mod.rs @@ -25,15 +25,15 @@ mod add_contested_document_to_primary_storage; // Module: add_contested_indices_for_index_level_for_contract_operations // This module contains functionality for adding indices for an index level for contract operations -mod add_contested_indices_for_index_level_for_contract_operations; +// mod add_contested_indices_for_index_level_for_contract_operations; // Module: add_contested_indices_for_top_index_level_for_contract_operations // This module contains functionality for adding indices for the top index level for contract operations -mod add_contested_indices_for_top_index_level_for_contract_operations; +mod add_contested_indices_for_contract_operations; // Module: add_contested_reference_for_index_level_for_contract_operations // This module contains functionality for adding a reference for an index level for contract operations -mod add_contested_reference_for_index_level_for_contract_operations; +// mod add_contested_reference_for_index_level_for_contract_operations; #[cfg(all( feature = "fixtures-and-mocks", diff --git a/packages/rs-drive/src/drive/initialization/mod.rs b/packages/rs-drive/src/drive/initialization/mod.rs index 248bd6aad8..5ee4f4ca7e 100644 --- a/packages/rs-drive/src/drive/initialization/mod.rs +++ b/packages/rs-drive/src/drive/initialization/mod.rs @@ -1,32 +1,3 @@ -// MIT LICENSE -// -// Copyright (c) 2021 Dash Core Group -// -// Permission is hereby granted, free of charge, to any -// person obtaining a copy of this software and associated -// documentation files (the "Software"), to deal in the -// Software without restriction, including without -// limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software -// is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice -// shall be included in all copies or substantial portions -// of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// - //! Drive Initialization mod v0; diff --git a/packages/rs-drive/src/drive/object_size_info/path_key_info.rs b/packages/rs-drive/src/drive/object_size_info/path_key_info.rs index 6589cf2ce7..d423aaaa57 100644 --- a/packages/rs-drive/src/drive/object_size_info/path_key_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/path_key_info.rs @@ -7,6 +7,8 @@ use grovedb::batch::key_info::KeyInfo::KnownKey; use grovedb::batch::KeyInfoPath; use grovedb_storage::worst_case_costs::WorstKeyLength; use std::collections::HashSet; +use crate::drive::object_size_info::PathInfo; +use crate::error::drive::DriveError; /// Path key info #[derive(Clone)] @@ -24,6 +26,19 @@ pub enum PathKeyInfo<'a, const N: usize> { PathKeySize(KeyInfoPath, KeyInfo), } +impl<'a> TryFrom>> for PathKeyInfo<'a, 0> { + type Error = Error; + + fn try_from(mut value: Vec>) -> Result { + if value.is_empty() { + Err(Error::Drive(DriveError::InvalidPath("path must not be none to convert into a path key info"))) + } else { + let last = value.remove(value.len() - 1); + Ok(PathKey((value, last))) + } + } +} + impl<'a, const N: usize> PathKeyInfo<'a, N> { /// Returns the length of the path with key as a usize. pub fn len(&'a self) -> u32 { diff --git a/packages/rs-drive/src/drive/prove/prove_multiple_state_transition_results/v0/mod.rs b/packages/rs-drive/src/drive/prove/prove_multiple_state_transition_results/v0/mod.rs index f3b94b3609..2497218325 100644 --- a/packages/rs-drive/src/drive/prove/prove_multiple_state_transition_results/v0/mod.rs +++ b/packages/rs-drive/src/drive/prove/prove_multiple_state_transition_results/v0/mod.rs @@ -90,10 +90,11 @@ impl Drive { count += historical_contract_ids.len(); } if !document_queries.is_empty() { - path_queries.extend(document_queries.iter().map(|drive_query| { - let mut path_query = drive_query.construct_path_query(); + path_queries.extend(document_queries.iter().filter_map(|drive_query| { + // The path query construction can only fail in extremely rare circumstances. + let mut path_query = drive_query.construct_path_query().ok()?; path_query.query.limit = None; - path_query + Some(path_query) })); count += document_queries.len(); } diff --git a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/mod.rs b/packages/rs-drive/src/drive/shared_estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/mod.rs similarity index 89% rename from packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/mod.rs rename to packages/rs-drive/src/drive/shared_estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/mod.rs index 65fe9e7fb5..0451dc5009 100644 --- a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/mod.rs +++ b/packages/rs-drive/src/drive/shared_estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/mod.rs @@ -10,6 +10,7 @@ use grovedb::EstimatedLayerInformation; use std::collections::HashMap; use dpp::data_contract::DataContract; +use dpp::data_contract::document_type::DocumentTypeRef; impl Drive { /// This function calls the versioned `add_estimation_costs_for_contested_document_tree_levels_up_to_contract_v0` @@ -19,8 +20,9 @@ impl Drive { /// # Parameters /// - `estimated_costs_only_with_layer_info`: A mutable reference to a `HashMap` that holds the estimated layer information. /// - `drive_version`: A reference to the `DriveVersion` object that specifies the version of the function to call. - pub(in crate::drive) fn add_estimation_costs_for_contested_document_tree_levels_up_to_contract( - contract: &DataContract, + pub(in crate::drive) fn add_estimation_costs_for_contested_document_tree_levels_up_to_contract<'a>( + contract: &'a DataContract, + document_type: Option>, estimated_costs_only_with_layer_info: &mut HashMap, drive_version: &DriveVersion, ) -> Result<(), Error> { @@ -32,6 +34,7 @@ impl Drive { 0 => { Self::add_estimation_costs_for_contested_document_tree_levels_up_to_contract_v0( contract, + document_type, estimated_costs_only_with_layer_info, ); Ok(()) diff --git a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/v0/mod.rs b/packages/rs-drive/src/drive/shared_estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/v0/mod.rs similarity index 75% rename from packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/v0/mod.rs rename to packages/rs-drive/src/drive/shared_estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/v0/mod.rs index 87d0e4d6aa..7e64d9778b 100644 --- a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/v0/mod.rs +++ b/packages/rs-drive/src/drive/shared_estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/v0/mod.rs @@ -1,4 +1,4 @@ -use crate::drive::defaults::{DEFAULT_HASH_SIZE_U8, ESTIMATED_AVERAGE_DOCUMENT_TYPE_NAME_SIZE}; +use crate::drive::defaults::{DEFAULT_HASH_SIZE_U8, ESTIMATED_AVERAGE_DOCUMENT_TYPE_NAME_SIZE, ESTIMATED_AVERAGE_INDEX_NAME_SIZE}; use crate::drive::flags::StorageFlags; use crate::drive::{contract_documents_path, Drive}; @@ -12,7 +12,10 @@ use grovedb::EstimatedSumTrees::{NoSumTrees, SomeSumTrees}; use std::collections::HashMap; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::DataContract; -use crate::drive::votes::paths::{vote_contested_resource_active_polls_contract_tree_path, vote_contested_resource_active_polls_tree_path, vote_contested_resource_tree_path, vote_root_path}; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::data_contract::document_type::DocumentTypeRef; +use crate::drive::object_size_info::DocumentAndContractInfo; +use crate::drive::votes::paths::{vote_contested_resource_active_polls_contract_document_tree_path, vote_contested_resource_active_polls_contract_tree_path, vote_contested_resource_active_polls_tree_path, vote_contested_resource_tree_path, vote_root_path}; impl Drive { /// Adds estimated costs for layers up to the contract level. @@ -37,8 +40,9 @@ impl Drive { /// /// This function is intended to be used internally within the Drive implementation. /// - pub(super) fn add_estimation_costs_for_contested_document_tree_levels_up_to_contract_v0( - contract: &DataContract, + pub(in crate::drive) fn add_estimation_costs_for_contested_document_tree_levels_up_to_contract_v0<'a>( + contract: &'a DataContract, + document_type: Option>, estimated_costs_only_with_layer_info: &mut HashMap, ) { // we have constructed the top layer so contract/documents tree are at the top @@ -62,7 +66,7 @@ impl Drive { estimated_layer_sizes: AllSubtrees( 1, NoSumTrees, - Some(StorageFlags::approximate_size(false, None)), + None, ), }, ); @@ -77,7 +81,7 @@ impl Drive { estimated_layer_sizes: AllSubtrees( 1, NoSumTrees, - Some(StorageFlags::approximate_size(false, None)), + None, ), }, ); @@ -91,7 +95,7 @@ impl Drive { estimated_layer_sizes: AllSubtrees( DEFAULT_HASH_SIZE_U8, NoSumTrees, - Some(StorageFlags::approximate_size(false, None)), + None, ), }, ); @@ -106,9 +110,24 @@ impl Drive { estimated_layer_sizes: AllSubtrees( ESTIMATED_AVERAGE_DOCUMENT_TYPE_NAME_SIZE, NoSumTrees, - Some(StorageFlags::approximate_size(true, None)), + None, ), }, ); + + if let Some(document_type) = document_type { + estimated_costs_only_with_layer_info.insert( + KeyInfoPath::from_known_path(vote_contested_resource_active_polls_contract_document_tree_path(contract.id_ref().as_bytes(), document_type.name().as_str())), + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: ApproximateElements(document_type_count), + estimated_layer_sizes: AllSubtrees( + ESTIMATED_AVERAGE_INDEX_NAME_SIZE, + NoSumTrees, + None, + ), + }, + ); + } } } diff --git a/packages/rs-drive/src/drive/shared_estimation_costs/mod.rs b/packages/rs-drive/src/drive/shared_estimation_costs/mod.rs index 052c33641a..67c97a619a 100644 --- a/packages/rs-drive/src/drive/shared_estimation_costs/mod.rs +++ b/packages/rs-drive/src/drive/shared_estimation_costs/mod.rs @@ -1,2 +1,3 @@ mod add_estimation_costs_for_levels_up_to_contract; mod add_estimation_costs_for_levels_up_to_contract_document_type_excluded; +mod add_estimation_costs_for_contested_document_tree_levels_up_to_contract; diff --git a/packages/rs-drive/src/drive/verify/single_document/verify_proof_keep_serialized/v0/mod.rs b/packages/rs-drive/src/drive/verify/single_document/verify_proof_keep_serialized/v0/mod.rs index 6eb25d7581..df6fefb03e 100644 --- a/packages/rs-drive/src/drive/verify/single_document/verify_proof_keep_serialized/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/single_document/verify_proof_keep_serialized/v0/mod.rs @@ -34,7 +34,7 @@ impl SingleDocumentDriveQuery { is_subset: bool, proof: &[u8], ) -> Result<(RootHash, Option>), Error> { - let path_query = self.construct_path_query(); + let path_query = self.construct_path_query()?; let (root_hash, mut proved_key_values) = if is_subset { GroveDb::verify_subset_query_with_absence_proof(proof, &path_query)? } else { diff --git a/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs b/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs index 4f679200ee..a7fcdacd6c 100644 --- a/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs @@ -40,7 +40,7 @@ use crate::drive::identity::key::fetch::IdentityKeysRequest; use crate::drive::verify::RootHash; use crate::error::Error; use crate::error::proof::ProofError; -use crate::query::SingleDocumentDriveQuery; +use crate::query::{SingleDocumentDriveQuery, SingleDocumentDriveQueryContestedStatus}; impl Drive { #[inline(always)] @@ -120,6 +120,26 @@ impl Drive { transition.data_contract_id() ))) })?; + + let contested_status = if let DocumentTransition::Create(create_transition) = transition { + if create_transition.prefunded_voting_balance().is_some() { + SingleDocumentDriveQueryContestedStatus::Contested + } else { + SingleDocumentDriveQueryContestedStatus::NotContested + } + } else { + SingleDocumentDriveQueryContestedStatus::NotContested + }; + + match transition { + DocumentTransition::Create(_) => {} + DocumentTransition::Replace(_) => {} + DocumentTransition::Delete(_) => {} + DocumentTransition::Transfer(_) => {} + DocumentTransition::UpdatePrice(_) => {} + DocumentTransition::Purchase(_) => {} + } + let query = SingleDocumentDriveQuery { contract_id: transition.data_contract_id().into_buffer(), @@ -127,6 +147,7 @@ impl Drive { document_type_keeps_history: document_type.documents_keep_history(), document_id: transition.base().id().into_buffer(), block_time_ms: None, //None because we want latest + contested_status, }; let (root_hash, document) = query.verify_proof(false, proof, document_type, platform_version)?; diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index c0e93d3cbc..dac2aa491e 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -165,6 +165,22 @@ pub fn vote_contested_resource_contract_documents_primary_key_path<'a>( ] } +#[cfg(feature = "server")] +/// Returns the path to the primary keys of a contract document type as a vec. +pub fn vote_contested_resource_active_polls_contract_documents_primary_key_path_vec( + contract_id: &[u8], + document_type_name: &str, +) -> Vec> { + vec![ + vec![RootTree::Votes as u8], + vec![CONTESTED_RESOURCE_TREE_KEY as u8], + vec![ACTIVE_POLLS_TREE_KEY as u8], + contract_id.to_vec(), + document_type_name.as_bytes().to_vec(), + vec![0], + ] +} + /// the specific end date path query of a contested resources as a vec /// there is no need to ever add a key to this pub fn vote_contested_resource_end_date_queries_at_time_tree_path_vec( diff --git a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs index a8dc952472..084809d2d4 100644 --- a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs @@ -1,9 +1,6 @@ use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; use crate::drive::batch::GroveDbOpBatch; -use crate::drive::votes::paths::{ - vote_contested_resource_tree_path_vec, vote_root_path_vec, CONTESTED_RESOURCE_TREE_KEY, - END_DATE_QUERIES_TREE_KEY, IDENTITY_VOTES_TREE_KEY, VOTE_DECISIONS_TREE_KEY, -}; +use crate::drive::votes::paths::{vote_contested_resource_tree_path_vec, vote_root_path_vec, CONTESTED_RESOURCE_TREE_KEY, END_DATE_QUERIES_TREE_KEY, IDENTITY_VOTES_TREE_KEY, VOTE_DECISIONS_TREE_KEY, ACTIVE_POLLS_TREE_KEY}; use crate::drive::Drive; use crate::error::Error; @@ -23,6 +20,11 @@ impl Drive { vec![END_DATE_QUERIES_TREE_KEY as u8], ); + batch.add_insert_empty_tree( + vote_contested_resource_tree_path_vec(), + vec![ACTIVE_POLLS_TREE_KEY as u8], + ); + batch.add_insert_empty_tree( vote_contested_resource_tree_path_vec(), vec![IDENTITY_VOTES_TREE_KEY as u8], diff --git a/packages/rs-drive/src/error/drive.rs b/packages/rs-drive/src/error/drive.rs index 741dacd9bf..ac7b7e1eae 100644 --- a/packages/rs-drive/src/error/drive.rs +++ b/packages/rs-drive/src/error/drive.rs @@ -73,6 +73,14 @@ pub enum DriveError { #[error("changing contract keeps history error: {0}")] ChangingContractKeepsHistory(&'static str), + /// Error + #[error("contested index not found error: {0}")] + ContestedIndexNotFound(&'static str), + + /// Error + #[error("contested document missing owner error: {0}")] + ContestedDocumentMissingOwnerId(&'static str), + /// Error #[error("updating contract with history error: {0}")] UpdatingContractWithHistoryError(&'static str), @@ -90,6 +98,10 @@ pub enum DriveError { #[error("changing document type keeps history error: {0}")] ChangingDocumentTypeKeepsHistory(&'static str), + /// Error + #[error("invalid path error: {0}")] + InvalidPath(&'static str), + /// Error #[error("corrupted contract path error: {0}")] CorruptedContractPath(&'static str), diff --git a/packages/rs-drive/src/query/mod.rs b/packages/rs-drive/src/query/mod.rs index da2e9b7aa5..f2f49ac149 100644 --- a/packages/rs-drive/src/query/mod.rs +++ b/packages/rs-drive/src/query/mod.rs @@ -4,6 +4,7 @@ pub use { grovedb::{PathQuery, Query, QueryItem, SizedQuery}, ordering::OrderClause, single_document_drive_query::SingleDocumentDriveQuery, + single_document_drive_query::SingleDocumentDriveQueryContestedStatus, vote_query::IdentityBasedVoteDriveQuery, }; // Imports available when either "server" or "verify" features are enabled diff --git a/packages/rs-drive/src/query/single_document_drive_query.rs b/packages/rs-drive/src/query/single_document_drive_query.rs index 6e1202db9e..8080263312 100644 --- a/packages/rs-drive/src/query/single_document_drive_query.rs +++ b/packages/rs-drive/src/query/single_document_drive_query.rs @@ -1,8 +1,39 @@ use crate::common::encode::encode_u64; -use crate::drive::document::paths::contract_document_type_path; +use crate::drive::document::paths::contract_document_type_path_vec; use crate::query::Query; use grovedb::{PathQuery, SizedQuery}; +use crate::drive::votes; +use crate::error::Error; +use crate::error::query::QuerySyntaxError; + +/// The expected contested status of a document +/// Drives stores the document in either the not contested location (most of the time) +/// Or a temporary contested area while the contest is ongoing +#[derive(Debug, PartialEq, Clone)] +#[repr(u8)] +pub enum SingleDocumentDriveQueryContestedStatus { + /// The document was not contested by the system. + NotContested = 0, + /// We don't know if the document was contested by the system, or we are not sure if the contest + /// is already over or not. + MaybeContested = 1, + /// We know that the document was contested by the system and the contest is not over. + Contested = 2, +} + +impl TryFrom for SingleDocumentDriveQueryContestedStatus { + type Error = Error; + + fn try_from(value: i32) -> Result { + match value { + 0 => Ok(SingleDocumentDriveQueryContestedStatus::NotContested), + 1 => Ok(SingleDocumentDriveQueryContestedStatus::MaybeContested), + 2 => Ok(SingleDocumentDriveQueryContestedStatus::Contested), + n => Err(Error::Query(QuerySyntaxError::Unsupported(format!("unsupported contested status {}, only 0, 1 and 2 are supported", n)))), + } + } +} /// Drive query struct #[derive(Debug, PartialEq, Clone)] @@ -17,17 +48,33 @@ pub struct SingleDocumentDriveQuery { pub document_id: [u8; 32], /// Block time pub block_time_ms: Option, + /// True if the document might have gone to a contested resolution + pub contested_status: SingleDocumentDriveQueryContestedStatus, } impl SingleDocumentDriveQuery { /// Operations to construct a path query. - pub fn construct_path_query(&self) -> PathQuery { + pub fn construct_path_query(&self) -> Result { + match self.contested_status { + SingleDocumentDriveQueryContestedStatus::NotContested => { + Ok(self.construct_non_contested_path_query(true)) + } + SingleDocumentDriveQueryContestedStatus::MaybeContested => { + let non_contested = self.construct_non_contested_path_query(true); + let contested = self.construct_contested_path_query(true); + PathQuery::merge(vec![&non_contested, &contested]).map_err(Error::GroveDB) + } + SingleDocumentDriveQueryContestedStatus::Contested => { + Ok(self.construct_contested_path_query(true)) + } + } + } + + /// Operations to construct the normal path query. + fn construct_non_contested_path_query(&self, with_limit_1: bool) -> PathQuery { // First we should get the overall document_type_path let mut path = - contract_document_type_path(&self.contract_id, self.document_type_name.as_str()) - .into_iter() - .map(|a| a.to_vec()) - .collect::>>(); + contract_document_type_path_vec(&self.contract_id, self.document_type_name.as_str()); path.push(vec![0]); @@ -45,13 +92,30 @@ impl SingleDocumentDriveQuery { query.set_subquery_key(vec![0]); } } + + let limit = if with_limit_1 { Some(1) } else { None } ; + + PathQuery::new(path, SizedQuery::new(query, limit, None)) + } + + /// Operations to construct the contested path query. + fn construct_contested_path_query(&self, with_limit_1: bool) -> PathQuery { + // First we should get the overall document_type_path + let path = + votes::paths::vote_contested_resource_active_polls_contract_documents_primary_key_path_vec(&self.contract_id, self.document_type_name.as_str()); + + let mut query = Query::new(); + query.insert_key(self.document_id.to_vec()); + + let limit = if with_limit_1 { Some(1) } else { None } ; - PathQuery::new(path, SizedQuery::new(query, Some(1), None)) + PathQuery::new(path, SizedQuery::new(query, limit, None)) } } -impl From for PathQuery { - fn from(value: SingleDocumentDriveQuery) -> Self { +impl TryFrom for PathQuery { + type Error = Error; + fn try_from(value: SingleDocumentDriveQuery) -> Result { value.construct_path_query() } } diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index d5dc648b1e..319b130d4e 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -328,9 +328,7 @@ pub struct DriveDocumentInsertContestedMethodVersions { pub add_contested_document_for_contract_apply_and_add_to_operations: FeatureVersion, pub add_contested_document_for_contract_operations: FeatureVersion, pub add_contested_document_to_primary_storage: FeatureVersion, - pub add_contested_indices_for_index_level_for_contract_operations: FeatureVersion, - pub add_contested_indices_for_top_index_level_for_contract_operations: FeatureVersion, - pub add_contested_reference_for_index_level_for_contract_operations: FeatureVersion, + pub add_contested_indices_for_contract_operations: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index eefb9e9f3f..8b8ff8cc52 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -195,9 +195,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { add_contested_document_for_contract_apply_and_add_to_operations: 0, add_contested_document_for_contract_operations: 0, add_contested_document_to_primary_storage: 0, - add_contested_indices_for_index_level_for_contract_operations: 0, - add_contested_indices_for_top_index_level_for_contract_operations: 0, - add_contested_reference_for_index_level_for_contract_operations: 0, + add_contested_indices_for_contract_operations: 0, }, update: DriveDocumentUpdateMethodVersions { add_update_multiple_documents_operations: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index e80f0d5c7b..c425b1a925 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -203,9 +203,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { add_contested_document_for_contract_apply_and_add_to_operations: 0, add_contested_document_for_contract_operations: 0, add_contested_document_to_primary_storage: 0, - add_contested_indices_for_index_level_for_contract_operations: 0, - add_contested_indices_for_top_index_level_for_contract_operations: 0, - add_contested_reference_for_index_level_for_contract_operations: 0, + add_contested_indices_for_contract_operations: 0, }, update: DriveDocumentUpdateMethodVersions { add_update_multiple_documents_operations: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index b99f6b0970..ccf3c3bde7 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -194,9 +194,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { add_contested_document_for_contract_apply_and_add_to_operations: 0, add_contested_document_for_contract_operations: 0, add_contested_document_to_primary_storage: 0, - add_contested_indices_for_index_level_for_contract_operations: 0, - add_contested_indices_for_top_index_level_for_contract_operations: 0, - add_contested_reference_for_index_level_for_contract_operations: 0, + add_contested_indices_for_contract_operations: 0, }, update: DriveDocumentUpdateMethodVersions { add_update_multiple_documents_operations: 0, From a6857e6d2bb8da4eccaefa8de12c0f2757470297 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Thu, 16 May 2024 01:36:51 +0200 Subject: [PATCH 059/135] more work --- .../document_type/accessors/v0/mod.rs | 2 +- .../document_type/methods/mod.rs | 22 +- .../document_type/v0/accessors.rs | 5 +- .../src/data_contract/v0/accessors/mod.rs | 12 +- .../rs-drive-abci/src/query/proofs/v0/mod.rs | 9 +- .../verify_state_transitions.rs | 36 +- .../tests/strategy_tests/voting_tests.rs | 2 +- .../contract/insert/insert_contract/v0/mod.rs | 24 +- .../mod.rs | 4 +- .../v0/mod.rs | 4 +- .../v0/mod.rs | 2 +- .../mod.rs | 11 +- .../v0/mod.rs | 60 ++- .../mod.rs | 12 +- .../v0/mod.rs | 470 ++++++------------ .../drive/document/insert_contested/mod.rs | 2 +- packages/rs-drive/src/drive/document/mod.rs | 30 ++ .../drive/object_size_info/path_key_info.rs | 8 +- .../v0/mod.rs | 8 +- .../prefunded_specialized_balances/mod.rs | 6 +- .../mod.rs | 11 +- .../v0/mod.rs | 64 ++- .../src/drive/shared_estimation_costs/mod.rs | 2 +- .../v0/mod.rs | 20 +- .../v0/mod.rs | 31 +- packages/rs-drive/src/drive/votes/paths.rs | 4 +- .../v0/mod.rs | 6 +- packages/rs-drive/src/error/drive.rs | 2 +- .../src/query/single_document_drive_query.rs | 19 +- .../src/version/drive_versions.rs | 1 + .../src/version/mocks/v2_test.rs | 1 + .../src/version/mocks/v3_test.rs | 1 + .../rs-platform-version/src/version/v1.rs | 1 + 33 files changed, 421 insertions(+), 471 deletions(-) diff --git a/packages/rs-dpp/src/data_contract/document_type/accessors/v0/mod.rs b/packages/rs-dpp/src/data_contract/document_type/accessors/v0/mod.rs index 0042346db9..77c4aaf896 100644 --- a/packages/rs-dpp/src/data_contract/document_type/accessors/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/accessors/v0/mod.rs @@ -22,7 +22,7 @@ pub trait DocumentTypeV0Getters { /// Returns the indices of the document type. fn indexes(&self) -> &BTreeMap; - + /// The contested index if one exists fn find_contested_index(&self) -> Option<&Index>; diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs index 80d52140a4..0c891cb53e 100644 --- a/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs @@ -242,19 +242,25 @@ impl DocumentTypeV0Methods for DocumentTypeV0 { } fn top_level_indices(&self) -> Vec<&IndexProperty> { - self.indices.values().filter_map(|index| index.properties.first()).collect() + self.indices + .values() + .filter_map(|index| index.properties.first()) + .collect() } // This should normally just be 1 item, however we keep a vec in case we want to change things // in the future. fn top_level_indices_of_contested_unique_indexes(&self) -> Vec<&IndexProperty> { - self.indices.values().filter_map(|index| { - if index.contested_index.is_some() { - index.properties.first() - } else { - None - } - }).collect() + self.indices + .values() + .filter_map(|index| { + if index.contested_index.is_some() { + index.properties.first() + } else { + None + } + }) + .collect() } fn create_document_from_data( diff --git a/packages/rs-dpp/src/data_contract/document_type/v0/accessors.rs b/packages/rs-dpp/src/data_contract/document_type/v0/accessors.rs index b16c585505..90f8fb6197 100644 --- a/packages/rs-dpp/src/data_contract/document_type/v0/accessors.rs +++ b/packages/rs-dpp/src/data_contract/document_type/v0/accessors.rs @@ -32,7 +32,10 @@ impl DocumentTypeV0Getters for DocumentTypeV0 { } fn find_contested_index(&self) -> Option<&Index> { - self.indices.iter().find(|(_, index)| index.contested_index.is_some()).map(|(_, contested_index)| contested_index) + self.indices + .iter() + .find(|(_, index)| index.contested_index.is_some()) + .map(|(_, contested_index)| contested_index) } fn index_structure(&self) -> &IndexLevel { diff --git a/packages/rs-dpp/src/data_contract/v0/accessors/mod.rs b/packages/rs-dpp/src/data_contract/v0/accessors/mod.rs index afb5b273dd..a8fd5cc933 100644 --- a/packages/rs-dpp/src/data_contract/v0/accessors/mod.rs +++ b/packages/rs-dpp/src/data_contract/v0/accessors/mod.rs @@ -7,9 +7,9 @@ use crate::data_contract::v0::DataContractV0; use crate::data_contract::DocumentName; use crate::metadata::Metadata; +use crate::data_contract::document_type::accessors::DocumentTypeV0Getters; use platform_value::Identifier; use std::collections::BTreeMap; -use crate::data_contract::document_type::accessors::DocumentTypeV0Getters; impl DataContractV0Getters for DataContractV0 { fn id(&self) -> Identifier { @@ -71,7 +71,15 @@ impl DataContractV0Getters for DataContractV0 { } fn document_types_with_contested_indexes(&self) -> BTreeMap<&DocumentName, &DocumentType> { - self.document_types.iter().filter(|(_, document_type)| document_type.indexes().iter().any(|(_, index)| index.contested_index.is_some())).collect() + self.document_types + .iter() + .filter(|(_, document_type)| { + document_type + .indexes() + .iter() + .any(|(_, index)| index.contested_index.is_some()) + }) + .collect() } fn document_types(&self) -> &BTreeMap { diff --git a/packages/rs-drive-abci/src/query/proofs/v0/mod.rs b/packages/rs-drive-abci/src/query/proofs/v0/mod.rs index 0138692e31..8bbe23eff9 100644 --- a/packages/rs-drive-abci/src/query/proofs/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/proofs/v0/mod.rs @@ -82,8 +82,10 @@ impl Platform { "id must be a valid identifier (32 bytes long)".to_string(), ) })?; - - let contested_status = document_proof_request.document_contested_status.try_into()?; + + let contested_status = document_proof_request + .document_contested_status + .try_into()?; Ok(SingleDocumentDriveQuery { contract_id: contract_id.into_buffer(), @@ -93,7 +95,8 @@ impl Platform { block_time_ms: None, //None because we want latest contested_status, }) - }).collect::, QueryError>>()); + }) + .collect::, QueryError>>()); let vote_queries = check_validation_result_with_data!(votes .into_iter() diff --git a/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs b/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs index 2cb2a96860..98eac5773f 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs @@ -213,15 +213,18 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed( .transitions() .iter() .for_each(|transition| { - let document_contested_status = if let DocumentTransitionAction::CreateAction(create_action) = transition { - if create_action.prefunded_voting_balance().is_some() { - SingleDocumentDriveQueryContestedStatus::Contested as u8 + let document_contested_status = + if let DocumentTransitionAction::CreateAction(create_action) = + transition + { + if create_action.prefunded_voting_balance().is_some() { + SingleDocumentDriveQueryContestedStatus::Contested as u8 + } else { + SingleDocumentDriveQueryContestedStatus::NotContested as u8 + } } else { SingleDocumentDriveQueryContestedStatus::NotContested as u8 - } - } else { - SingleDocumentDriveQueryContestedStatus::NotContested as u8 - }; + }; proofs_request .documents .push(get_proofs_request_v0::DocumentRequest { @@ -288,16 +291,19 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed( .as_str(), ) .expect("get document type"); - let contested_status = if let DocumentTransitionAction::CreateAction(create_action) = document_transition_action { - if create_action.prefunded_voting_balance().is_some() { - SingleDocumentDriveQueryContestedStatus::Contested + let contested_status = + if let DocumentTransitionAction::CreateAction(create_action) = + document_transition_action + { + if create_action.prefunded_voting_balance().is_some() { + SingleDocumentDriveQueryContestedStatus::Contested + } else { + SingleDocumentDriveQueryContestedStatus::NotContested + } } else { SingleDocumentDriveQueryContestedStatus::NotContested - } - } else { - SingleDocumentDriveQueryContestedStatus::NotContested - }; - + }; + let query = SingleDocumentDriveQuery { contract_id: document_transition_action .base() diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index fd508576a7..1d3d8cf14e 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -9,6 +9,7 @@ mod tests { use dpp::identity::accessors::IdentityGettersV0; use dpp::identity::Identity; use dpp::platform_value::Value; + use drive::drive::config::DriveConfig; use drive_abci::config::{ExecutionConfig, PlatformConfig}; use drive_abci::test::helpers::setup::TestPlatformBuilder; use platform_version::version::PlatformVersion; @@ -16,7 +17,6 @@ mod tests { use rand::SeedableRng; use simple_signer::signer::SimpleSigner; use std::collections::BTreeMap; - use drive::drive::config::DriveConfig; use strategy_tests::frequency::Frequency; use strategy_tests::operations::{DocumentAction, DocumentOp, Operation, OperationType}; use strategy_tests::transitions::create_state_transitions_for_identities; diff --git a/packages/rs-drive/src/drive/contract/insert/insert_contract/v0/mod.rs b/packages/rs-drive/src/drive/contract/insert/insert_contract/v0/mod.rs index 77271b9579..11876d174f 100644 --- a/packages/rs-drive/src/drive/contract/insert/insert_contract/v0/mod.rs +++ b/packages/rs-drive/src/drive/contract/insert/insert_contract/v0/mod.rs @@ -2,7 +2,7 @@ use crate::drive::contract::paths; use crate::drive::flags::StorageFlags; use crate::drive::object_size_info::DriveKeyInfo::{Key, KeyRef}; -use crate::drive::{contract_documents_path, Drive, RootTree, votes}; +use crate::drive::{contract_documents_path, votes, Drive, RootTree}; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; @@ -188,10 +188,12 @@ impl Drive { // If the contract happens to contain any contested indexes then we add the contract to the // contested contracts - let document_types_with_contested_indexes = contract.document_types_with_contested_indexes(); + let document_types_with_contested_indexes = + contract.document_types_with_contested_indexes(); if !document_types_with_contested_indexes.is_empty() { - if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info + { Self::add_estimation_costs_for_contested_document_tree_levels_up_to_contract( contract, None, @@ -200,7 +202,8 @@ impl Drive { )?; } - let contested_contract_root_path = votes::paths::vote_contested_resource_active_polls_tree_path(); + let contested_contract_root_path = + votes::paths::vote_contested_resource_active_polls_tree_path(); self.batch_insert_empty_tree( contested_contract_root_path, @@ -209,11 +212,13 @@ impl Drive { &mut batch_operations, &platform_version.drive, )?; - - let contested_unique_index_contract_document_types_path = votes::paths::vote_contested_resource_active_polls_contract_tree_path(contract.id_ref().as_bytes()); + + let contested_unique_index_contract_document_types_path = + votes::paths::vote_contested_resource_active_polls_contract_tree_path( + contract.id_ref().as_bytes(), + ); for (type_key, document_type) in document_types_with_contested_indexes.into_iter() { - self.batch_insert_empty_tree( contested_unique_index_contract_document_types_path, KeyRef(type_key.as_bytes()), @@ -242,7 +247,10 @@ impl Drive { let mut index_cache: HashSet<&[u8]> = HashSet::new(); // for each type we should insert the indices that are top level - for index in document_type.as_ref().top_level_indices_of_contested_unique_indexes() { + for index in document_type + .as_ref() + .top_level_indices_of_contested_unique_indexes() + { // toDo: change this to be a reference by index let index_bytes = index.name.as_bytes(); if !index_cache.contains(index_bytes) { diff --git a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/mod.rs b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/mod.rs index 909f5bbfd8..e70c218d1f 100644 --- a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/mod.rs +++ b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/mod.rs @@ -35,7 +35,9 @@ impl Drive { /// # Panics /// This function will not panic under normal circumstances. However, unexpected behavior may result /// from incorrect arguments or unforeseen edge cases. - pub(crate) fn add_estimation_costs_for_add_contested_document_to_primary_storage( + pub(crate) fn add_estimation_costs_for_add_contested_document_to_primary_storage< + const N: usize, + >( document_and_contract_info: &DocumentAndContractInfo, primary_key_path: [&[u8]; N], estimated_costs_only_with_layer_info: &mut HashMap, diff --git a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/v0/mod.rs b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/v0/mod.rs index 120098f81b..4dcb5e79cb 100644 --- a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/v0/mod.rs @@ -48,7 +48,9 @@ impl Drive { /// This function will not panic under normal circumstances. However, unexpected behavior may result /// from incorrect arguments or unforeseen edge cases. #[inline(always)] - pub(super) fn add_estimation_costs_for_add_contested_document_to_primary_storage_v0( + pub(super) fn add_estimation_costs_for_add_contested_document_to_primary_storage_v0< + const N: usize, + >( document_and_contract_info: &DocumentAndContractInfo, primary_key_path: [&[u8]; N], estimated_costs_only_with_layer_info: &mut HashMap, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs index ba3adaed07..687064bfca 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs @@ -71,7 +71,7 @@ impl Drive { transaction, platform_version, )?; - + self.add_contested_indices_for_contract_operations( &document_and_contract_info, previous_batch_operations, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/mod.rs index 913af4a39f..161038e7d9 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/mod.rs @@ -1,16 +1,15 @@ -use std::collections::HashMap; -use grovedb::batch::KeyInfoPath; -use grovedb::{EstimatedLayerInformation, TransactionArg}; -use platform_version::version::PlatformVersion; -use crate::drive::Drive; use crate::drive::object_size_info::DocumentAndContractInfo; +use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; +use grovedb::batch::KeyInfoPath; +use grovedb::{EstimatedLayerInformation, TransactionArg}; +use platform_version::version::PlatformVersion; +use std::collections::HashMap; mod v0; - impl Drive { /// Adds indices for an index level and recurses. pub(crate) fn add_contested_indices_for_contract_operations( diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs index 284640a25c..c274265522 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs @@ -1,6 +1,8 @@ use crate::drive::grove_operations::BatchInsertTreeApplyType; -use crate::drive::object_size_info::{DocumentAndContractInfo, DocumentInfoV0Methods, DriveKeyInfo, PathInfo}; +use crate::drive::object_size_info::{ + DocumentAndContractInfo, DocumentInfoV0Methods, DriveKeyInfo, PathInfo, +}; use crate::drive::Drive; use crate::error::fee::FeeError; @@ -9,6 +11,10 @@ use crate::fee::op::LowLevelDriveOperation; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use crate::drive::defaults::DEFAULT_HASH_SIZE_U8; +use crate::drive::votes::paths::vote_contested_resource_active_polls_contract_document_tree_path_vec; +use crate::error::drive::DriveError; +use dpp::data_contract::document_type::IndexProperty; use dpp::version::PlatformVersion; use grovedb::batch::KeyInfoPath; use grovedb::EstimatedLayerCount::PotentiallyAtMaxElements; @@ -16,10 +22,6 @@ use grovedb::EstimatedLayerSizes::AllSubtrees; use grovedb::EstimatedSumTrees::NoSumTrees; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; -use dpp::data_contract::document_type::IndexProperty; -use crate::drive::defaults::DEFAULT_HASH_SIZE_U8; -use crate::drive::votes::paths::vote_contested_resource_active_polls_contract_document_tree_path_vec; -use crate::error::drive::DriveError; impl Drive { /// Adds indices for the top index level and calls for lower levels. @@ -35,23 +37,34 @@ impl Drive { platform_version: &PlatformVersion, ) -> Result<(), Error> { let drive_version = &platform_version.drive; - let owner_id = document_and_contract_info.owned_document_info.owner_id.ok_or(Error::Drive(DriveError::ContestedDocumentMissingOwnerId("expecting an owner id")))?; - let contested_index = document_and_contract_info.document_type.find_contested_index().ok_or(Error::Drive(DriveError::ContestedIndexNotFound("a contested index is expected")))?; + let owner_id = document_and_contract_info + .owned_document_info + .owner_id + .ok_or(Error::Drive(DriveError::ContestedDocumentMissingOwnerId( + "expecting an owner id", + )))?; + let contested_index = document_and_contract_info + .document_type + .find_contested_index() + .ok_or(Error::Drive(DriveError::ContestedIndexNotFound( + "a contested index is expected", + )))?; let document_type = document_and_contract_info.document_type; let storage_flags = document_and_contract_info - .owned_document_info - .document_info - .get_storage_flags_ref(); + .owned_document_info + .document_info + .get_storage_flags_ref(); // we need to construct the path for documents on the contract // the path is // * Document and DataContract root tree // * DataContract ID recovered from document // * 0 to signify Documents and notDataContract - let contract_document_type_path = vote_contested_resource_active_polls_contract_document_tree_path_vec( - document_and_contract_info.contract.id_ref().as_bytes(), - document_and_contract_info.document_type.name(), - ); + let contract_document_type_path = + vote_contested_resource_active_polls_contract_document_tree_path_vec( + document_and_contract_info.contract.id_ref().as_bytes(), + document_and_contract_info.document_type.name(), + ); let apply_type = if estimated_costs_only_with_layer_info.is_none() { BatchInsertTreeApplyType::StatefulBatchInsertTree @@ -81,9 +94,8 @@ impl Drive { PathInfo::PathAsVec::<0>(index_path) }; - // next we need to store a reference to the document for each index - for IndexProperty{ name, .. } in &contested_index.properties { + for IndexProperty { name, .. } in &contested_index.properties { // We on purpose do not want to put index names // This is different from document secondary indexes // The reason is that there is only one index so we already know the structure @@ -100,7 +112,7 @@ impl Drive { "document field is too big for being an index on delete", ))); } - + // On this level we will have all the user defined values for the paths estimated_costs_only_with_layer_info.insert( index_path_info.clone().convert_to_key_info_path(), @@ -115,7 +127,7 @@ impl Drive { }, ); } - + // with the example of the dashpay contract's first index // the index path is now something likeDataContracts/ContractID/Documents(1)/$ownerId let document_top_field = document_and_contract_info @@ -132,7 +144,9 @@ impl Drive { // here we are inserting an empty tree that will have a subtree of all other index properties self.batch_insert_empty_tree_if_not_exists( - document_top_field.clone().add_path_info(index_path_info.clone()), + document_top_field + .clone() + .add_path_info(index_path_info.clone()), false, storage_flags, apply_type, @@ -144,11 +158,10 @@ impl Drive { index_path_info.push(document_top_field)?; } - + // at the end of all of this we put the identity tree that will hold the votes - if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info - { + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { // On this level we will have all the identities estimated_costs_only_with_layer_info.insert( index_path_info.clone().convert_to_key_info_path(), @@ -175,6 +188,7 @@ impl Drive { drive_version, )?; - Ok(()) + self.add_contested_reference_to_document_operations(document_and_contract_info, index_path_info, previous_batch_operations, storage_flags, estimated_costs_only_with_layer_info, transaction, batch_operations, drive_version) + } } diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs index 3207e356a2..885d4ad3da 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs @@ -17,14 +17,12 @@ use std::collections::HashMap; impl Drive { /// Adds the terminal reference. - pub fn add_contested_reference_for_index_level_for_contract_operations( + pub fn add_contested_reference_to_document_operations( &self, document_and_contract_info: &DocumentAndContractInfo, index_path_info: PathInfo<0>, - index_type: IndexType, - any_fields_null: bool, previous_batch_operations: &mut Option<&mut Vec>, - storage_flags: &Option<&StorageFlags>, + storage_flags: Option<&StorageFlags>, estimated_costs_only_with_layer_info: &mut Option< HashMap, >, @@ -36,13 +34,11 @@ impl Drive { .methods .document .insert_contested - .add_contested_reference_for_index_level_for_contract_operations + .add_contested_reference_to_document_operations { - 0 => self.add_contested_reference_for_index_level_for_contract_operations_v0( + 0 => self.add_contested_reference_to_document_operations_v0( document_and_contract_info, index_path_info, - index_type, - any_fields_null, previous_batch_operations, storage_flags, estimated_costs_only_with_layer_info, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs index f634ee2136..d18043cbeb 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -1,5 +1,7 @@ use crate::drive::defaults::{DEFAULT_HASH_SIZE_U8, STORAGE_FLAGS_SIZE}; -use crate::drive::document::{document_reference_size, make_document_reference}; +use crate::drive::document::{ + document_reference_size, make_document_contested_reference, make_document_reference, +}; use crate::drive::flags::StorageFlags; use crate::drive::grove_operations::QueryTarget::QueryTargetValue; use crate::drive::grove_operations::{BatchInsertApplyType, BatchInsertTreeApplyType}; @@ -15,8 +17,6 @@ use crate::error::drive::DriveError; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; -use dpp::data_contract::document_type::IndexType; -use dpp::data_contract::document_type::IndexType::{ContestedResourceIndex, NonUniqueIndex}; use dpp::document::DocumentV0Getters; use dpp::version::drive_versions::DriveVersion; use grovedb::batch::key_info::KeyInfo; @@ -30,14 +30,12 @@ use std::collections::HashMap; impl Drive { /// Adds the terminal reference. #[inline(always)] - pub(super) fn add_contested_reference_for_index_level_for_contract_operations_v0( + pub(super) fn add_contested_reference_to_document_operations_v0( &self, document_and_contract_info: &DocumentAndContractInfo, mut index_path_info: PathInfo<0>, - index_type: IndexType, - any_fields_null: bool, previous_batch_operations: &mut Option<&mut Vec>, - storage_flags: &Option<&StorageFlags>, + storage_flags: Option<&StorageFlags>, estimated_costs_only_with_layer_info: &mut Option< HashMap, >, @@ -45,344 +43,182 @@ impl Drive { batch_operations: &mut Vec, drive_version: &DriveVersion, ) -> Result<(), Error> { - // unique indexes will be stored under key "0" - // non unique indices should have a tree at key "0" that has all elements based off of primary key - if index_type == NonUniqueIndex || index_type == ContestedResourceIndex || any_fields_null { - // Tree generation, this happens for both non unique indexes, unique indexes with a null inside - // a member of the path and for contested resource indexes - let key_path_info = KeyRef(&[0]); - - let path_key_info = key_path_info.add_path_info(index_path_info.clone()); - - let apply_type = if estimated_costs_only_with_layer_info.is_none() { - BatchInsertTreeApplyType::StatefulBatchInsertTree - } else { - BatchInsertTreeApplyType::StatelessBatchInsertTree { - in_tree_using_sums: false, - is_sum_tree: false, - flags_len: storage_flags - .map(|s| s.serialized_size()) - .unwrap_or_default(), + // Contested Resource Index + // Under each tree we have all identifiers of identities that want the contested resource + // Contrary to normal secondary indexes there are no property names and there is no termination key "0" + // We get something like + // Inter-wizard championship (event type) + // | + // Goblet of Fire (event name) + // / \ + // Sam's Document ID Ivan's Document ID + // / \ / \ + // 0 (ref) 1 (sum tree) 0 (ref) 1 (sum tree) + // + + let apply_type = if estimated_costs_only_with_layer_info.is_none() { + BatchInsertTreeApplyType::StatefulBatchInsertTree + } else { + BatchInsertTreeApplyType::StatelessBatchInsertTree { + in_tree_using_sums: false, + is_sum_tree: false, + flags_len: storage_flags + .map(|s| s.serialized_size()) + .unwrap_or_default(), + } + }; + + // Here we are getting the document id and the reference + let (document_id, ref_key_element_info) = + match &document_and_contract_info.owned_document_info.document_info { + DocumentRefAndSerialization((document, _, storage_flags)) + | DocumentRefInfo((document, storage_flags)) => { + let document_reference = make_document_contested_reference( + document, + storage_flags.as_ref().map(|flags| flags.as_ref()), + ); + (document.id(), KeyElement((&[0], document_reference))) } - }; - - // Here we are inserting an empty tree that will have a subtree of all other index properties - // It is basically the 0 - // Underneath we will have all elements if non unique index, or all identity contenders if - // a contested resource index - self.batch_insert_empty_tree_if_not_exists( - path_key_info, - false, - *storage_flags, - apply_type, - transaction, - previous_batch_operations, - batch_operations, - drive_version, - )?; - - index_path_info.push(Key(vec![0]))?; - - if index_type != ContestedResourceIndex { - // This is the simpler situation - // Under each tree we have all the references - - if let Some(estimated_costs_only_with_layer_info) = - estimated_costs_only_with_layer_info - { - // On this level we will have a 0 and all the top index paths - estimated_costs_only_with_layer_info.insert( - index_path_info.clone().convert_to_key_info_path(), - EstimatedLayerInformation { - is_sum_tree: false, - estimated_layer_count: PotentiallyAtMaxElements, - estimated_layer_sizes: AllReference( - DEFAULT_HASH_SIZE_U8, - document_reference_size(document_and_contract_info.document_type), - storage_flags.map(|s| s.serialized_size()), - ), - }, + DocumentOwnedInfo((document, storage_flags)) + | DocumentAndSerialization((document, _, storage_flags)) => { + let document_reference = make_document_contested_reference( + document, + storage_flags.as_ref().map(|flags| flags.as_ref()), ); + (document.id(), KeyElement((&[0], document_reference))) } - - let key_element_info = - match &document_and_contract_info.owned_document_info.document_info { - DocumentRefAndSerialization((document, _, storage_flags)) - | DocumentRefInfo((document, storage_flags)) => { - let document_reference = make_document_reference( - document, - document_and_contract_info.document_type, - storage_flags.as_ref().map(|flags| flags.as_ref()), - ); - KeyElement((document.id_ref().as_slice(), document_reference)) - } - DocumentOwnedInfo((document, storage_flags)) - | DocumentAndSerialization((document, _, storage_flags)) => { - let document_reference = make_document_reference( - document, - document_and_contract_info.document_type, - storage_flags.as_ref().map(|flags| flags.as_ref()), - ); - KeyElement((document.id_ref().as_slice(), document_reference)) - } - DocumentEstimatedAverageSize(max_size) => KeyUnknownElementSize(( + DocumentEstimatedAverageSize(max_size) => { + let unique_id = document_and_contract_info + .document_type + .unique_id_for_storage(); + let unique_id_vec = unique_id.to_vec(); + ( + unique_id.into(), + KeyUnknownElementSize(( KeyInfo::MaxKeySize { - unique_id: document_and_contract_info - .document_type - .unique_id_for_storage() - .to_vec(), + unique_id: unique_id_vec, max_size: DEFAULT_HASH_SIZE_U8, }, Element::required_item_space(*max_size, STORAGE_FLAGS_SIZE), )), - }; - - let path_key_element_info = PathKeyElementInfo::from_path_info_and_key_element( - index_path_info, - key_element_info, - )?; - - // here we should return an error if the element already exists - self.batch_insert(path_key_element_info, batch_operations, drive_version)?; - } else { - // Contested Resource Index - // Under each tree we have all identifiers of identities that want the contested resource - // We get something like - // item name contested (there will be another path with item_name) - // | - // Goblet of Fire - // | - // 0 (for the termination of the index) - // / \ - // Sam's Document Id Ivan's Document Id - // / \ / \ - // 0 (ref) 1 (sum tree) 0 (ref) 1 (sum tree) - // - - // Here we are getting the document id and the reference - let (document_id, ref_key_element_info) = - match &document_and_contract_info.owned_document_info.document_info { - DocumentRefAndSerialization((document, _, storage_flags)) - | DocumentRefInfo((document, storage_flags)) => { - let document_reference = make_document_reference( - document, - document_and_contract_info.document_type, - storage_flags.as_ref().map(|flags| flags.as_ref()), - ); - (document.id(), KeyElement((&[0], document_reference))) - } - DocumentOwnedInfo((document, storage_flags)) - | DocumentAndSerialization((document, _, storage_flags)) => { - let document_reference = make_document_reference( - document, - document_and_contract_info.document_type, - storage_flags.as_ref().map(|flags| flags.as_ref()), - ); - (document.id(), KeyElement((&[0], document_reference))) - } - DocumentEstimatedAverageSize(max_size) => { - let unique_id = document_and_contract_info - .document_type - .unique_id_for_storage(); - let unique_id_vec = unique_id.to_vec(); - ( - unique_id.into(), - KeyUnknownElementSize(( - KeyInfo::MaxKeySize { - unique_id: unique_id_vec, - max_size: DEFAULT_HASH_SIZE_U8, - }, - Element::required_item_space(*max_size, STORAGE_FLAGS_SIZE), - )), - ) - } - }; - - // Let's start by inserting the document id tree - - // here we are the tree that will contain the ref - // We are inserting this at item name contested / Goblet of Fire / 0 with the key of - // document_key_path_info - - let document_id_key_path_info = KeyRef(document_id.as_slice()); - - let path_key_info = - document_id_key_path_info.add_path_info(index_path_info.clone()); + ) + } + }; - index_path_info.push(Key(document_id.to_vec()))?; + // Let's start by inserting the document id tree - // We check to make sure we are not overridding the tree - let inserted = self.batch_insert_empty_tree_if_not_exists( - path_key_info, - false, - *storage_flags, - apply_type, - transaction, - previous_batch_operations, - batch_operations, - drive_version, - )?; + // here we are the tree that will contain the ref + // We are inserting this at item name contested / Goblet of Fire / 0 with the key of + // document_key_path_info - if !inserted { - return Err(Error::Drive(DriveError::CorruptedContractIndexes( - "contested votes sub tree document already exists", - ))); - } + let document_id_key_path_info = KeyRef(document_id.as_slice()); - let mut document_path_info = index_path_info.clone(); + let path_key_info = document_id_key_path_info.add_path_info(index_path_info.clone()); - document_path_info.push(KeyRef(document_id.as_slice()))?; + index_path_info.push(Key(document_id.to_vec()))?; - let votes_key_path_info = KeyRef(&[1]); + // We check to make sure we are not overriding the tree + let inserted = self.batch_insert_empty_tree_if_not_exists( + path_key_info, + false, + storage_flags, + apply_type, + transaction, + previous_batch_operations, + batch_operations, + drive_version, + )?; - let votes_path_key_info = - votes_key_path_info.add_path_info(document_path_info.clone()); + if !inserted { + return Err(Error::Drive(DriveError::CorruptedContractIndexes( + "contested votes sub tree document already exists", + ))); + } - if let Some(estimated_costs_only_with_layer_info) = - estimated_costs_only_with_layer_info - { - // On this level we will have a 0 and all the top index paths - estimated_costs_only_with_layer_info.insert( - index_path_info.clone().convert_to_key_info_path(), - EstimatedLayerInformation { - is_sum_tree: false, - estimated_layer_count: PotentiallyAtMaxElements, - estimated_layer_sizes: AllSubtrees( - DEFAULT_HASH_SIZE_U8, - NoSumTrees, - storage_flags.map(|s| s.serialized_size()), - ), - }, - ); + let mut document_path_info = index_path_info.clone(); - // On this level we will have a 0 and all the top index paths - estimated_costs_only_with_layer_info.insert( - votes_path_key_info.clone().convert_to_key_info_path()?, - EstimatedLayerInformation { - is_sum_tree: false, - estimated_layer_count: PotentiallyAtMaxElements, - estimated_layer_sizes: AllSubtrees( - DEFAULT_HASH_SIZE_U8, - NoSumTrees, - storage_flags.map(|s| s.serialized_size()), - ), - }, - ); - } + document_path_info.push(KeyRef(document_id.as_slice()))?; - let reference_path_key_element_info = - PathKeyElementInfo::from_path_info_and_key_element( - document_path_info.clone(), - ref_key_element_info, - )?; + let votes_key_path_info = KeyRef(&[1]); - // here we are inserting the ref - self.batch_insert( - reference_path_key_element_info, - batch_operations, - drive_version, - )?; + let votes_path_key_info = votes_key_path_info.add_path_info(document_path_info.clone()); - let apply_type = if estimated_costs_only_with_layer_info.is_none() { - BatchInsertTreeApplyType::StatefulBatchInsertTree - } else { - BatchInsertTreeApplyType::StatelessBatchInsertTree { - in_tree_using_sums: false, - is_sum_tree: true, - flags_len: storage_flags - .map(|s| s.serialized_size()) - .unwrap_or_default(), - } - }; + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { + // On this level we will have a 0 and all the top index paths + estimated_costs_only_with_layer_info.insert( + index_path_info.clone().convert_to_key_info_path(), + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: PotentiallyAtMaxElements, + estimated_layer_sizes: AllSubtrees( + DEFAULT_HASH_SIZE_U8, + NoSumTrees, + storage_flags.map(|s| s.serialized_size()), + ), + }, + ); - // here we are the tree that will contain the voting tree - let inserted = self.batch_insert_empty_tree_if_not_exists( - votes_path_key_info, - true, - *storage_flags, - apply_type, - transaction, - &mut None, - batch_operations, - drive_version, - )?; + // On this level we will have a 0 and all the top index paths + estimated_costs_only_with_layer_info.insert( + votes_path_key_info.clone().convert_to_key_info_path()?, + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: PotentiallyAtMaxElements, + estimated_layer_sizes: AllSubtrees( + DEFAULT_HASH_SIZE_U8, + NoSumTrees, + storage_flags.map(|s| s.serialized_size()), + ), + }, + ); + } - if !inserted { - return Err(Error::Drive(DriveError::CorruptedContractIndexes( - "contested votes tree already exists", - ))); - } + let reference_path_key_element_info = PathKeyElementInfo::from_path_info_and_key_element( + document_path_info.clone(), + ref_key_element_info, + )?; - // Now we need to add a reference to this votes, so we can keep track of it more easily + // here we are inserting the ref + self.batch_insert( + reference_path_key_element_info, + batch_operations, + drive_version, + )?; - // self.add_new_masternode_vote_type() - } + let apply_type = if estimated_costs_only_with_layer_info.is_none() { + BatchInsertTreeApplyType::StatefulBatchInsertTree } else { - let key_element_info = - match &document_and_contract_info.owned_document_info.document_info { - DocumentRefAndSerialization((document, _, storage_flags)) - | DocumentRefInfo((document, storage_flags)) => { - let document_reference = make_document_reference( - document, - document_and_contract_info.document_type, - storage_flags.as_ref().map(|flags| flags.as_ref()), - ); - KeyElement((&[0], document_reference)) - } - DocumentOwnedInfo((document, storage_flags)) - | DocumentAndSerialization((document, _, storage_flags)) => { - let document_reference = make_document_reference( - document, - document_and_contract_info.document_type, - storage_flags.as_ref().map(|flags| flags.as_ref()), - ); - KeyElement((&[0], document_reference)) - } - DocumentEstimatedAverageSize(estimated_size) => KeyUnknownElementSize(( - KeyInfo::MaxKeySize { - unique_id: document_and_contract_info - .document_type - .unique_id_for_storage() - .to_vec(), - max_size: 1, - }, - Element::required_item_space(*estimated_size, STORAGE_FLAGS_SIZE), - )), - }; + BatchInsertTreeApplyType::StatelessBatchInsertTree { + in_tree_using_sums: false, + is_sum_tree: true, + flags_len: storage_flags + .map(|s| s.serialized_size()) + .unwrap_or_default(), + } + }; + + // here we are the tree that will contain the voting tree + let inserted = self.batch_insert_empty_tree_if_not_exists( + votes_path_key_info, + true, + storage_flags, + apply_type, + transaction, + &mut None, + batch_operations, + drive_version, + )?; + + if !inserted { + return Err(Error::Drive(DriveError::CorruptedContractIndexes( + "contested votes tree already exists", + ))); + } - let path_key_element_info = PathKeyElementInfo::from_path_info_and_key_element( - index_path_info, - key_element_info, - )?; + // Now we need to add a reference to this votes, so we can keep track of it more easily - let apply_type = if estimated_costs_only_with_layer_info.is_none() { - BatchInsertApplyType::StatefulBatchInsert - } else { - BatchInsertApplyType::StatelessBatchInsert { - in_tree_using_sums: false, - target: QueryTargetValue( - document_reference_size(document_and_contract_info.document_type) - + storage_flags - .map(|s| s.serialized_size()) - .unwrap_or_default(), - ), - } - }; + // self.add_new_masternode_vote_type() - // here we should return an error if the element already exists - let inserted = self.batch_insert_if_not_exists( - path_key_element_info, - apply_type, - transaction, - batch_operations, - drive_version, - )?; - if !inserted { - return Err(Error::Drive(DriveError::CorruptedContractIndexes( - "reference already exists", - ))); - } - } Ok(()) } } diff --git a/packages/rs-drive/src/drive/document/insert_contested/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/mod.rs index d133b66cbb..bc0801d3c3 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/mod.rs @@ -33,7 +33,7 @@ mod add_contested_indices_for_contract_operations; // Module: add_contested_reference_for_index_level_for_contract_operations // This module contains functionality for adding a reference for an index level for contract operations -// mod add_contested_reference_for_index_level_for_contract_operations; +mod add_contested_reference_for_index_level_for_contract_operations; #[cfg(all( feature = "fixtures-and-mocks", diff --git a/packages/rs-drive/src/drive/document/mod.rs b/packages/rs-drive/src/drive/document/mod.rs index 08d0f2d101..27c0c91c88 100644 --- a/packages/rs-drive/src/drive/document/mod.rs +++ b/packages/rs-drive/src/drive/document/mod.rs @@ -72,6 +72,36 @@ fn make_document_reference( ) } +#[cfg(feature = "server")] +/// Creates a reference to a contested document. +fn make_document_contested_reference( + document: &Document, + storage_flags: Option<&StorageFlags>, +) -> Element { + // we need to construct the reference from the split height of the contract document + // type which is at 5 for the contested tree + // 0 represents document storage + // Then we add document id + // Then we add 0 if the document type keys history + let reference_path = vec![vec![0], document.id().to_vec()]; + let max_reference_hops = 1; + // 2 because the contract could allow for history + // 5 because + // -VotesTree + // -ContestedResourceTree + // -ActivePolls + // -DataContract ID + // - DocumentType + // We add 2 + // - 0 Storage + // - Document id + Element::Reference( + UpstreamRootHeightReference(5, reference_path), + Some(max_reference_hops), + StorageFlags::map_to_some_element_flags(storage_flags), + ) +} + #[cfg(feature = "server")] /// size of a document reference. fn document_reference_size(document_type: DocumentTypeRef) -> u32 { diff --git a/packages/rs-drive/src/drive/object_size_info/path_key_info.rs b/packages/rs-drive/src/drive/object_size_info/path_key_info.rs index d423aaaa57..fbbb25400e 100644 --- a/packages/rs-drive/src/drive/object_size_info/path_key_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/path_key_info.rs @@ -1,14 +1,14 @@ use crate::drive::object_size_info::path_key_info::PathKeyInfo::{ PathFixedSizeKey, PathFixedSizeKeyRef, PathKey, PathKeyRef, PathKeySize, }; +use crate::drive::object_size_info::PathInfo; +use crate::error::drive::DriveError; use crate::error::Error; use grovedb::batch::key_info::KeyInfo; use grovedb::batch::key_info::KeyInfo::KnownKey; use grovedb::batch::KeyInfoPath; use grovedb_storage::worst_case_costs::WorstKeyLength; use std::collections::HashSet; -use crate::drive::object_size_info::PathInfo; -use crate::error::drive::DriveError; /// Path key info #[derive(Clone)] @@ -31,7 +31,9 @@ impl<'a> TryFrom>> for PathKeyInfo<'a, 0> { fn try_from(mut value: Vec>) -> Result { if value.is_empty() { - Err(Error::Drive(DriveError::InvalidPath("path must not be none to convert into a path key info"))) + Err(Error::Drive(DriveError::InvalidPath( + "path must not be none to convert into a path key info", + ))) } else { let last = value.remove(value.len() - 1); Ok(PathKey((value, last))) diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs index 72705a085c..61f678a375 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs @@ -5,10 +5,12 @@ use grovedb::EstimatedLayerCount::{ApproximateElements, EstimatedLevel, Potentia use grovedb::EstimatedLayerInformation; use grovedb::EstimatedLayerSizes::{AllItems, AllSubtrees}; -use crate::drive::prefunded_specialized_balances::{prefunded_specialized_balances_for_voting_path_vec, prefunded_specialized_balances_path}; +use crate::drive::defaults::{AVERAGE_BALANCE_SIZE, DEFAULT_HASH_SIZE_U8, U64_SIZE_U8}; +use crate::drive::prefunded_specialized_balances::{ + prefunded_specialized_balances_for_voting_path_vec, prefunded_specialized_balances_path, +}; use grovedb::EstimatedSumTrees::{AllSumTrees, SomeSumTrees}; use std::collections::HashMap; -use crate::drive::defaults::{AVERAGE_BALANCE_SIZE, DEFAULT_HASH_SIZE_U8, U64_SIZE_U8}; impl Drive { /// Adds estimation costs for total system credits update. @@ -47,7 +49,7 @@ impl Drive { estimated_layer_sizes: AllSubtrees(1, AllSumTrees, None), }, ); - + estimated_costs_only_with_layer_info.insert( KeyInfoPath::from_known_owned_path(prefunded_specialized_balances_for_voting_path_vec()), EstimatedLayerInformation { diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs index 2bd6585f3a..a1bf76dac4 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs @@ -14,9 +14,9 @@ pub const PREFUNDED_BALANCES_FOR_VOTING: u8 = 128; /// prefunded specialized balances for voting pub(crate) fn prefunded_specialized_balances_path() -> [&'static [u8]; 1] { - [ - Into::<&[u8; 1]>::into(RootTree::PreFundedSpecializedBalances), - ] + [Into::<&[u8; 1]>::into( + RootTree::PreFundedSpecializedBalances, + )] } /// prefunded specialized balances for voting diff --git a/packages/rs-drive/src/drive/shared_estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/mod.rs b/packages/rs-drive/src/drive/shared_estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/mod.rs index 0451dc5009..fe1d0d7b94 100644 --- a/packages/rs-drive/src/drive/shared_estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/mod.rs +++ b/packages/rs-drive/src/drive/shared_estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/mod.rs @@ -8,9 +8,9 @@ use grovedb::batch::KeyInfoPath; use grovedb::EstimatedLayerInformation; -use std::collections::HashMap; -use dpp::data_contract::DataContract; use dpp::data_contract::document_type::DocumentTypeRef; +use dpp::data_contract::DataContract; +use std::collections::HashMap; impl Drive { /// This function calls the versioned `add_estimation_costs_for_contested_document_tree_levels_up_to_contract_v0` @@ -20,7 +20,9 @@ impl Drive { /// # Parameters /// - `estimated_costs_only_with_layer_info`: A mutable reference to a `HashMap` that holds the estimated layer information. /// - `drive_version`: A reference to the `DriveVersion` object that specifies the version of the function to call. - pub(in crate::drive) fn add_estimation_costs_for_contested_document_tree_levels_up_to_contract<'a>( + pub(in crate::drive) fn add_estimation_costs_for_contested_document_tree_levels_up_to_contract< + 'a, + >( contract: &'a DataContract, document_type: Option>, estimated_costs_only_with_layer_info: &mut HashMap, @@ -40,7 +42,8 @@ impl Drive { Ok(()) } version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "add_estimation_costs_for_contested_document_tree_levels_up_to_contract".to_string(), + method: "add_estimation_costs_for_contested_document_tree_levels_up_to_contract" + .to_string(), known_versions: vec![0], received: version, })), diff --git a/packages/rs-drive/src/drive/shared_estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/v0/mod.rs b/packages/rs-drive/src/drive/shared_estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/v0/mod.rs index 7e64d9778b..4d22eb9e46 100644 --- a/packages/rs-drive/src/drive/shared_estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/v0/mod.rs +++ b/packages/rs-drive/src/drive/shared_estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/v0/mod.rs @@ -1,4 +1,7 @@ -use crate::drive::defaults::{DEFAULT_HASH_SIZE_U8, ESTIMATED_AVERAGE_DOCUMENT_TYPE_NAME_SIZE, ESTIMATED_AVERAGE_INDEX_NAME_SIZE}; +use crate::drive::defaults::{ + DEFAULT_HASH_SIZE_U8, ESTIMATED_AVERAGE_DOCUMENT_TYPE_NAME_SIZE, + ESTIMATED_AVERAGE_INDEX_NAME_SIZE, +}; use crate::drive::flags::StorageFlags; use crate::drive::{contract_documents_path, Drive}; @@ -8,14 +11,19 @@ use grovedb::EstimatedLayerCount::{ApproximateElements, EstimatedLevel, Potentia use grovedb::EstimatedLayerInformation; use grovedb::EstimatedLayerSizes::AllSubtrees; -use grovedb::EstimatedSumTrees::{NoSumTrees, SomeSumTrees}; -use std::collections::HashMap; +use crate::drive::object_size_info::DocumentAndContractInfo; +use crate::drive::votes::paths::{ + vote_contested_resource_active_polls_contract_document_tree_path, + vote_contested_resource_active_polls_contract_tree_path, + vote_contested_resource_active_polls_tree_path, vote_contested_resource_tree_path, + vote_root_path, +}; use dpp::data_contract::accessors::v0::DataContractV0Getters; -use dpp::data_contract::DataContract; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::document_type::DocumentTypeRef; -use crate::drive::object_size_info::DocumentAndContractInfo; -use crate::drive::votes::paths::{vote_contested_resource_active_polls_contract_document_tree_path, vote_contested_resource_active_polls_contract_tree_path, vote_contested_resource_active_polls_tree_path, vote_contested_resource_tree_path, vote_root_path}; +use dpp::data_contract::DataContract; +use grovedb::EstimatedSumTrees::{NoSumTrees, SomeSumTrees}; +use std::collections::HashMap; impl Drive { /// Adds estimated costs for layers up to the contract level. @@ -40,7 +48,9 @@ impl Drive { /// /// This function is intended to be used internally within the Drive implementation. /// - pub(in crate::drive) fn add_estimation_costs_for_contested_document_tree_levels_up_to_contract_v0<'a>( + pub(in crate::drive) fn add_estimation_costs_for_contested_document_tree_levels_up_to_contract_v0< + 'a, + >( contract: &'a DataContract, document_type: Option>, estimated_costs_only_with_layer_info: &mut HashMap, @@ -52,7 +62,14 @@ impl Drive { is_sum_tree: false, estimated_layer_count: EstimatedLevel(2, false), //voting is on level 2 // We have balances in the middle which is a sum tree - estimated_layer_sizes: AllSubtrees(1, SomeSumTrees { sum_trees_weight: 1, non_sum_trees_weight: 2 }, None), + estimated_layer_sizes: AllSubtrees( + 1, + SomeSumTrees { + sum_trees_weight: 1, + non_sum_trees_weight: 2, + }, + None, + ), }, ); @@ -63,11 +80,7 @@ impl Drive { is_sum_tree: false, // contested resource tree is a key of "c" so it should be on the top layer of the merk estimated_layer_count: EstimatedLevel(0, false), - estimated_layer_sizes: AllSubtrees( - 1, - NoSumTrees, - None, - ), + estimated_layer_sizes: AllSubtrees(1, NoSumTrees, None), }, ); @@ -78,11 +91,7 @@ impl Drive { is_sum_tree: false, // active poll "p", with "e" and "i" first so it should be on the second layer of the merk estimated_layer_count: EstimatedLevel(1, false), - estimated_layer_sizes: AllSubtrees( - 1, - NoSumTrees, - None, - ), + estimated_layer_sizes: AllSubtrees(1, NoSumTrees, None), }, ); @@ -92,18 +101,16 @@ impl Drive { EstimatedLayerInformation { is_sum_tree: false, estimated_layer_count: PotentiallyAtMaxElements, - estimated_layer_sizes: AllSubtrees( - DEFAULT_HASH_SIZE_U8, - NoSumTrees, - None, - ), + estimated_layer_sizes: AllSubtrees(DEFAULT_HASH_SIZE_U8, NoSumTrees, None), }, ); let document_type_count = contract.document_types().len() as u32; estimated_costs_only_with_layer_info.insert( - KeyInfoPath::from_known_path(vote_contested_resource_active_polls_contract_tree_path(contract.id_ref().as_bytes())), + KeyInfoPath::from_known_path(vote_contested_resource_active_polls_contract_tree_path( + contract.id_ref().as_bytes(), + )), EstimatedLayerInformation { is_sum_tree: false, estimated_layer_count: ApproximateElements(document_type_count), @@ -114,10 +121,15 @@ impl Drive { ), }, ); - + if let Some(document_type) = document_type { estimated_costs_only_with_layer_info.insert( - KeyInfoPath::from_known_path(vote_contested_resource_active_polls_contract_document_tree_path(contract.id_ref().as_bytes(), document_type.name().as_str())), + KeyInfoPath::from_known_path( + vote_contested_resource_active_polls_contract_document_tree_path( + contract.id_ref().as_bytes(), + document_type.name().as_str(), + ), + ), EstimatedLayerInformation { is_sum_tree: false, estimated_layer_count: ApproximateElements(document_type_count), diff --git a/packages/rs-drive/src/drive/shared_estimation_costs/mod.rs b/packages/rs-drive/src/drive/shared_estimation_costs/mod.rs index 67c97a619a..c2d99dfcc2 100644 --- a/packages/rs-drive/src/drive/shared_estimation_costs/mod.rs +++ b/packages/rs-drive/src/drive/shared_estimation_costs/mod.rs @@ -1,3 +1,3 @@ +mod add_estimation_costs_for_contested_document_tree_levels_up_to_contract; mod add_estimation_costs_for_levels_up_to_contract; mod add_estimation_costs_for_levels_up_to_contract_document_type_excluded; -mod add_estimation_costs_for_contested_document_tree_levels_up_to_contract; diff --git a/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs b/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs index a7fcdacd6c..a401f2ebe7 100644 --- a/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs @@ -120,17 +120,18 @@ impl Drive { transition.data_contract_id() ))) })?; - - let contested_status = if let DocumentTransition::Create(create_transition) = transition { - if create_transition.prefunded_voting_balance().is_some() { - SingleDocumentDriveQueryContestedStatus::Contested + + let contested_status = + if let DocumentTransition::Create(create_transition) = transition { + if create_transition.prefunded_voting_balance().is_some() { + SingleDocumentDriveQueryContestedStatus::Contested + } else { + SingleDocumentDriveQueryContestedStatus::NotContested + } } else { SingleDocumentDriveQueryContestedStatus::NotContested - } - } else { - SingleDocumentDriveQueryContestedStatus::NotContested - }; - + }; + match transition { DocumentTransition::Create(_) => {} DocumentTransition::Replace(_) => {} @@ -139,7 +140,6 @@ impl Drive { DocumentTransition::UpdatePrice(_) => {} DocumentTransition::Purchase(_) => {} } - let query = SingleDocumentDriveQuery { contract_id: transition.data_contract_id().into_buffer(), diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs index 3199a214b0..a1e8faecda 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs @@ -1,9 +1,18 @@ +use crate::drive::defaults::{ + AVERAGE_CONTESTED_RESOURCE_ITEM_REFERENCE_SIZE, DEFAULT_HASH_SIZE_U8, + ESTIMATED_AVERAGE_DOCUMENT_TYPE_NAME_SIZE, U64_SIZE_U8, +}; use crate::drive::flags::StorageFlags; use crate::drive::grove_operations::QueryTarget::QueryTargetValue; use crate::drive::grove_operations::{BatchInsertApplyType, BatchInsertTreeApplyType}; use crate::drive::object_size_info::PathKeyElementInfo::{PathKeyElementSize, PathKeyRefElement}; use crate::drive::object_size_info::{DriveKeyInfo, PathInfo, PathKeyElementInfo}; -use crate::drive::votes::paths::{vote_contested_resource_active_polls_contract_tree_path, vote_contested_resource_end_date_queries_at_time_tree_path_vec, vote_contested_resource_end_date_queries_tree_path, vote_contested_resource_end_date_queries_tree_path_vec}; +use crate::drive::votes::paths::{ + vote_contested_resource_active_polls_contract_tree_path, + vote_contested_resource_end_date_queries_at_time_tree_path_vec, + vote_contested_resource_end_date_queries_tree_path, + vote_contested_resource_end_date_queries_tree_path_vec, +}; use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; @@ -14,13 +23,12 @@ use dpp::serialization::PlatformSerializable; use dpp::voting::vote_polls::VotePoll; use grovedb::batch::key_info::KeyInfo; use grovedb::batch::KeyInfoPath; -use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; -use platform_version::version::PlatformVersion; -use std::collections::HashMap; use grovedb::EstimatedLayerCount::ApproximateElements; use grovedb::EstimatedLayerSizes::{AllItems, AllSubtrees}; use grovedb::EstimatedSumTrees::NoSumTrees; -use crate::drive::defaults::{AVERAGE_CONTESTED_RESOURCE_ITEM_REFERENCE_SIZE, DEFAULT_HASH_SIZE_U8, ESTIMATED_AVERAGE_DOCUMENT_TYPE_NAME_SIZE, U64_SIZE_U8}; +use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; +use platform_version::version::PlatformVersion; +use std::collections::HashMap; impl Drive { /// We add votes poll references by end date in order to be able to check on every new block if @@ -43,8 +51,7 @@ impl Drive { StorageFlags::new_single_epoch(block_info.epoch.index, Some(creator_identity_id)) }); - if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info - { + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { estimated_costs_only_with_layer_info.insert( KeyInfoPath::from_known_path(vote_contested_resource_end_date_queries_tree_path()), EstimatedLayerInformation { @@ -56,10 +63,13 @@ impl Drive { NoSumTrees, Some(StorageFlags::approximate_size(true, None)), ), - }); - + }, + ); + estimated_costs_only_with_layer_info.insert( - KeyInfoPath::from_known_owned_path(vote_contested_resource_end_date_queries_at_time_tree_path_vec(end_date)), + KeyInfoPath::from_known_owned_path( + vote_contested_resource_end_date_queries_at_time_tree_path_vec(end_date), + ), EstimatedLayerInformation { is_sum_tree: false, // We can estimate that there is 2 votes ending per block. @@ -151,6 +161,5 @@ impl Drive { )?; Ok(()) - } } diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index dac2aa491e..48edcc37d4 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -108,9 +108,7 @@ pub fn vote_contested_resource_active_polls_tree_path_vec() -> Vec> { #[cfg(feature = "server")] /// Returns the path to the primary keys of a contract document type. -pub fn vote_contested_resource_active_polls_contract_tree_path( - contract_id: &[u8], -) -> [&[u8]; 4] { +pub fn vote_contested_resource_active_polls_contract_tree_path(contract_id: &[u8]) -> [&[u8]; 4] { [ Into::<&[u8; 1]>::into(RootTree::Votes), // 1 &[CONTESTED_RESOURCE_TREE_KEY as u8], // 1 diff --git a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs index 084809d2d4..d50c5ac0d9 100644 --- a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs @@ -1,6 +1,10 @@ use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; use crate::drive::batch::GroveDbOpBatch; -use crate::drive::votes::paths::{vote_contested_resource_tree_path_vec, vote_root_path_vec, CONTESTED_RESOURCE_TREE_KEY, END_DATE_QUERIES_TREE_KEY, IDENTITY_VOTES_TREE_KEY, VOTE_DECISIONS_TREE_KEY, ACTIVE_POLLS_TREE_KEY}; +use crate::drive::votes::paths::{ + vote_contested_resource_tree_path_vec, vote_root_path_vec, ACTIVE_POLLS_TREE_KEY, + CONTESTED_RESOURCE_TREE_KEY, END_DATE_QUERIES_TREE_KEY, IDENTITY_VOTES_TREE_KEY, + VOTE_DECISIONS_TREE_KEY, +}; use crate::drive::Drive; use crate::error::Error; diff --git a/packages/rs-drive/src/error/drive.rs b/packages/rs-drive/src/error/drive.rs index ac7b7e1eae..3c3f7ba508 100644 --- a/packages/rs-drive/src/error/drive.rs +++ b/packages/rs-drive/src/error/drive.rs @@ -101,7 +101,7 @@ pub enum DriveError { /// Error #[error("invalid path error: {0}")] InvalidPath(&'static str), - + /// Error #[error("corrupted contract path error: {0}")] CorruptedContractPath(&'static str), diff --git a/packages/rs-drive/src/query/single_document_drive_query.rs b/packages/rs-drive/src/query/single_document_drive_query.rs index 8080263312..f5fe4fa5d3 100644 --- a/packages/rs-drive/src/query/single_document_drive_query.rs +++ b/packages/rs-drive/src/query/single_document_drive_query.rs @@ -1,11 +1,11 @@ use crate::common::encode::encode_u64; use crate::drive::document::paths::contract_document_type_path_vec; -use crate::query::Query; -use grovedb::{PathQuery, SizedQuery}; use crate::drive::votes; -use crate::error::Error; use crate::error::query::QuerySyntaxError; +use crate::error::Error; +use crate::query::Query; +use grovedb::{PathQuery, SizedQuery}; /// The expected contested status of a document /// Drives stores the document in either the not contested location (most of the time) @@ -26,11 +26,14 @@ impl TryFrom for SingleDocumentDriveQueryContestedStatus { type Error = Error; fn try_from(value: i32) -> Result { - match value { + match value { 0 => Ok(SingleDocumentDriveQueryContestedStatus::NotContested), 1 => Ok(SingleDocumentDriveQueryContestedStatus::MaybeContested), 2 => Ok(SingleDocumentDriveQueryContestedStatus::Contested), - n => Err(Error::Query(QuerySyntaxError::Unsupported(format!("unsupported contested status {}, only 0, 1 and 2 are supported", n)))), + n => Err(Error::Query(QuerySyntaxError::Unsupported(format!( + "unsupported contested status {}, only 0, 1 and 2 are supported", + n + )))), } } } @@ -92,8 +95,8 @@ impl SingleDocumentDriveQuery { query.set_subquery_key(vec![0]); } } - - let limit = if with_limit_1 { Some(1) } else { None } ; + + let limit = if with_limit_1 { Some(1) } else { None }; PathQuery::new(path, SizedQuery::new(query, limit, None)) } @@ -107,7 +110,7 @@ impl SingleDocumentDriveQuery { let mut query = Query::new(); query.insert_key(self.document_id.to_vec()); - let limit = if with_limit_1 { Some(1) } else { None } ; + let limit = if with_limit_1 { Some(1) } else { None }; PathQuery::new(path, SizedQuery::new(query, limit, None)) } diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 319b130d4e..c36ba1b743 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -329,6 +329,7 @@ pub struct DriveDocumentInsertContestedMethodVersions { pub add_contested_document_for_contract_operations: FeatureVersion, pub add_contested_document_to_primary_storage: FeatureVersion, pub add_contested_indices_for_contract_operations: FeatureVersion, + pub add_contested_reference_to_document_operations: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 8b8ff8cc52..d7eedd6a41 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -196,6 +196,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { add_contested_document_for_contract_operations: 0, add_contested_document_to_primary_storage: 0, add_contested_indices_for_contract_operations: 0, + add_contested_reference_to_document_operations: 0, }, update: DriveDocumentUpdateMethodVersions { add_update_multiple_documents_operations: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index c425b1a925..a5a4438b2d 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -204,6 +204,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { add_contested_document_for_contract_operations: 0, add_contested_document_to_primary_storage: 0, add_contested_indices_for_contract_operations: 0, + add_contested_reference_to_document_operations: 0, }, update: DriveDocumentUpdateMethodVersions { add_update_multiple_documents_operations: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index ccf3c3bde7..c2f8553bd3 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -195,6 +195,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { add_contested_document_for_contract_operations: 0, add_contested_document_to_primary_storage: 0, add_contested_indices_for_contract_operations: 0, + add_contested_reference_to_document_operations: 0, }, update: DriveDocumentUpdateMethodVersions { add_update_multiple_documents_operations: 0, From 0ea13202d6c767c31c8251223fa8d72c54f8c736 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Thu, 16 May 2024 19:25:55 +0200 Subject: [PATCH 060/135] more work --- .../protos/platform/v0/platform.proto | 78 +++- .../proto/org.dash.platform.dapi.v0.rs | 343 +++++++++++++++--- packages/rs-drive-abci/src/query/service.rs | 46 ++- .../mod.rs | 55 +++ .../v0/mod.rs | 0 .../contested_resource_vote_state/mod.rs | 55 +++ .../contested_resource_vote_state/v0/mod.rs | 106 ++++++ .../contested_resource_vote_status/mod.rs | 1 - .../mod.rs | 55 +++ .../v0/mod.rs | 0 .../query/voting/contested_resources/mod.rs | 54 +++ .../voting/contested_resources/v0/mod.rs | 0 .../rs-drive-abci/src/query/voting/mod.rs | 3 +- .../tests/strategy_tests/voting_tests.rs | 4 +- packages/rs-drive/src/drive/defaults.rs | 25 ++ .../v0/mod.rs | 36 +- .../mod.rs | 8 +- .../v0/mod.rs | 153 +++----- .../src/drive/object_size_info/path_info.rs | 2 +- .../drive/object_size_info/path_key_info.rs | 2 +- packages/rs-drive/src/query/mod.rs | 1 + .../src/version/drive_abci_versions.rs | 9 + .../src/version/drive_versions.rs | 2 +- .../src/version/mocks/v2_test.rs | 43 ++- .../src/version/mocks/v3_test.rs | 43 ++- .../rs-platform-version/src/version/v1.rs | 43 ++- 26 files changed, 906 insertions(+), 261 deletions(-) create mode 100644 packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/mod.rs create mode 100644 packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/v0/mod.rs create mode 100644 packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs delete mode 100644 packages/rs-drive-abci/src/query/voting/contested_resource_vote_status/mod.rs create mode 100644 packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/mod.rs create mode 100644 packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/v0/mod.rs create mode 100644 packages/rs-drive-abci/src/query/voting/contested_resources/v0/mod.rs diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index 212bbd9e7f..98f31f9e77 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -35,8 +35,12 @@ service Platform { rpc getProtocolVersionUpgradeVoteStatus(GetProtocolVersionUpgradeVoteStatusRequest) returns (GetProtocolVersionUpgradeVoteStatusResponse); rpc getEpochsInfo(GetEpochsInfoRequest) returns (GetEpochsInfoResponse); rpc getContestedResources(GetContestedResourcesRequest) returns (GetContestedResourcesResponse); + // What's the state of a contested resource vote? (ie who is winning?) rpc getContestedResourceVoteState(GetContestedResourceVoteStateRequest) returns (GetContestedResourceVoteStateResponse); - rpc getContestedResourceVoteStatus(GetContestedResourceVoteStatusRequest) returns (GetContestedResourceVoteStatusResponse); + // Who voted for a contested resource to go to a specific identity? + rpc getContestedResourceVotersForIdentity(GetContestedResourceVotersForIdentityRequest) returns (GetContestedResourceVotersForIdentityResponse); + // How did an identity vote? + rpc getContestedResourceIdentityVoteStatus(GetContestedResourceIdentityVoteStatusRequest) returns (GetContestedResourceIdentityVoteStatusResponse); rpc getPrefundedSpecializedBalance(GetPrefundedSpecializedBalanceRequest) returns (GetPrefundedSpecializedBalanceResponse); rpc getPathElements(GetPathElementsRequest) returns (GetPathElementsResponse); } @@ -667,14 +671,21 @@ message GetContestedResourcesResponse { } } +// What's the state of a contested resource vote? (ie who is winning?) message GetContestedResourceVoteStateRequest { message GetContestedResourceVoteStateRequestV0 { - bool prove = 1; - repeated bytes resource_path = 2; - bytes contested_resource = 3; - optional bytes start_identifier = 4; - optional uint32 count = 5; - optional bool ascending = 6; + message StartAtIdentifierInfo { + bytes start_identifier = 1; + uint32 count = 2; + bool ascending = 3; + } + bytes contract_id = 1; + string document_type_name = 2; + string index_name = 3; + repeated bytes index_values = 4; + bool include_documents = 5; + optional StartAtIdentifierInfo start_at_identifier_info = 6; + bool prove = 7; } oneof version { @@ -686,12 +697,12 @@ message GetContestedResourceVoteStateResponse { message GetContestedResourceVoteStateResponseV0 { message ContestedResourceContenders { repeated Contender contenders = 1; - bool finished_results = 2; } message Contender { bytes identifier = 1; uint32 vote_count = 2; + optional bytes document = 3; } oneof result { @@ -706,9 +717,48 @@ message GetContestedResourceVoteStateResponse { } } +// Who voted for a contested resource to go to a specific identity? +message GetContestedResourceVotersForIdentityRequest { + message GetContestedResourceVotersForIdentityRequestV0 { + bool prove = 1; + repeated bytes resource_path = 2; + bytes resource_identifier = 3; + optional bytes voter_identifier = 4; + optional uint32 count = 5; + optional bool ascending = 6; + } + + oneof version { + GetContestedResourceVotersForIdentityRequestV0 v0 = 1; + } +} + +message GetContestedResourceVotersForIdentityResponse { + message GetContestedResourceVotersForIdentityResponseV0 { + message ContestedResourceVoters { + repeated Voter voters = 1; + bool finished_results = 2; + } + + message Voter { + bytes identifier = 1; + } + + oneof result { + ContestedResourceVoters contested_resource_voters = 1; + Proof proof = 2; + } + ResponseMetadata metadata = 3; + } + + oneof version { + GetContestedResourceVotersForIdentityResponseV0 v0 = 1; + } +} -message GetContestedResourceVoteStatusRequest { - message GetContestedResourceVoteStatusRequestV0 { +// How did an identity vote? +message GetContestedResourceIdentityVoteStatusRequest { + message GetContestedResourceIdentityVoteStatusRequestV0 { bool prove = 1; repeated bytes resource_path = 2; bytes resource_identifier = 3; @@ -718,12 +768,12 @@ message GetContestedResourceVoteStatusRequest { } oneof version { - GetContestedResourceVoteStatusRequestV0 v0 = 1; + GetContestedResourceIdentityVoteStatusRequestV0 v0 = 1; } } -message GetContestedResourceVoteStatusResponse { - message GetContestedResourceVoteStatusResponseV0 { +message GetContestedResourceIdentityVoteStatusResponse { + message GetContestedResourceIdentityVoteStatusResponseV0 { message ContestedResourceVoters { repeated Voter voters = 1; bool finished_results = 2; @@ -741,7 +791,7 @@ message GetContestedResourceVoteStatusResponse { } oneof version { - GetContestedResourceVoteStatusResponseV0 v0 = 1; + GetContestedResourceIdentityVoteStatusResponseV0 v0 = 1; } } diff --git a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs index 3880bd3e78..6e74f4b998 100644 --- a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs +++ b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs @@ -2225,6 +2225,7 @@ pub mod get_contested_resources_response { V0(GetContestedResourcesResponseV0), } } +/// What's the state of a contested resource vote? (ie who is winning?) #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] @@ -2244,18 +2245,38 @@ pub mod get_contested_resource_vote_state_request { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetContestedResourceVoteStateRequestV0 { - #[prost(bool, tag = "1")] + #[prost(bytes = "vec", tag = "1")] + pub contract_id: ::prost::alloc::vec::Vec, + #[prost(string, tag = "2")] + pub document_type_name: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub index_name: ::prost::alloc::string::String, + #[prost(bytes = "vec", repeated, tag = "4")] + pub index_values: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, + #[prost(bool, tag = "5")] + pub include_documents: bool, + #[prost(message, optional, tag = "6")] + pub start_at_identifier_info: ::core::option::Option< + get_contested_resource_vote_state_request_v0::StartAtIdentifierInfo, + >, + #[prost(bool, tag = "7")] pub prove: bool, - #[prost(bytes = "vec", repeated, tag = "2")] - pub resource_path: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, - #[prost(bytes = "vec", tag = "3")] - pub contested_resource: ::prost::alloc::vec::Vec, - #[prost(bytes = "vec", optional, tag = "4")] - pub start_identifier: ::core::option::Option<::prost::alloc::vec::Vec>, - #[prost(uint32, optional, tag = "5")] - pub count: ::core::option::Option, - #[prost(bool, optional, tag = "6")] - pub ascending: ::core::option::Option, + } + /// Nested message and enum types in `GetContestedResourceVoteStateRequestV0`. + pub mod get_contested_resource_vote_state_request_v0 { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct StartAtIdentifierInfo { + #[prost(bytes = "vec", tag = "1")] + pub start_identifier: ::prost::alloc::vec::Vec, + #[prost(uint32, tag = "2")] + pub count: u32, + #[prost(bool, tag = "3")] + pub ascending: bool, + } } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] @@ -2305,8 +2326,6 @@ pub mod get_contested_resource_vote_state_response { pub struct ContestedResourceContenders { #[prost(message, repeated, tag = "1")] pub contenders: ::prost::alloc::vec::Vec, - #[prost(bool, tag = "2")] - pub finished_results: bool, } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] @@ -2318,6 +2337,8 @@ pub mod get_contested_resource_vote_state_response { pub identifier: ::prost::alloc::vec::Vec, #[prost(uint32, tag = "2")] pub vote_count: u32, + #[prost(bytes = "vec", optional, tag = "3")] + pub document: ::core::option::Option<::prost::alloc::vec::Vec>, } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] @@ -2339,25 +2360,29 @@ pub mod get_contested_resource_vote_state_response { V0(GetContestedResourceVoteStateResponseV0), } } +/// Who voted for a contested resource to go to a specific identity? #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] -pub struct GetContestedResourceVoteStatusRequest { - #[prost(oneof = "get_contested_resource_vote_status_request::Version", tags = "1")] +pub struct GetContestedResourceVotersForIdentityRequest { + #[prost( + oneof = "get_contested_resource_voters_for_identity_request::Version", + tags = "1" + )] pub version: ::core::option::Option< - get_contested_resource_vote_status_request::Version, + get_contested_resource_voters_for_identity_request::Version, >, } -/// Nested message and enum types in `GetContestedResourceVoteStatusRequest`. -pub mod get_contested_resource_vote_status_request { +/// Nested message and enum types in `GetContestedResourceVotersForIdentityRequest`. +pub mod get_contested_resource_voters_for_identity_request { #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] - pub struct GetContestedResourceVoteStatusRequestV0 { + pub struct GetContestedResourceVotersForIdentityRequestV0 { #[prost(bool, tag = "1")] pub prove: bool, #[prost(bytes = "vec", repeated, tag = "2")] @@ -2377,7 +2402,7 @@ pub mod get_contested_resource_vote_status_request { #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { #[prost(message, tag = "1")] - V0(GetContestedResourceVoteStatusRequestV0), + V0(GetContestedResourceVotersForIdentityRequestV0), } } #[derive(::serde::Serialize, ::serde::Deserialize)] @@ -2385,32 +2410,35 @@ pub mod get_contested_resource_vote_status_request { #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] -pub struct GetContestedResourceVoteStatusResponse { - #[prost(oneof = "get_contested_resource_vote_status_response::Version", tags = "1")] +pub struct GetContestedResourceVotersForIdentityResponse { + #[prost( + oneof = "get_contested_resource_voters_for_identity_response::Version", + tags = "1" + )] pub version: ::core::option::Option< - get_contested_resource_vote_status_response::Version, + get_contested_resource_voters_for_identity_response::Version, >, } -/// Nested message and enum types in `GetContestedResourceVoteStatusResponse`. -pub mod get_contested_resource_vote_status_response { +/// Nested message and enum types in `GetContestedResourceVotersForIdentityResponse`. +pub mod get_contested_resource_voters_for_identity_response { #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] - pub struct GetContestedResourceVoteStatusResponseV0 { + pub struct GetContestedResourceVotersForIdentityResponseV0 { #[prost(message, optional, tag = "3")] pub metadata: ::core::option::Option, #[prost( - oneof = "get_contested_resource_vote_status_response_v0::Result", + oneof = "get_contested_resource_voters_for_identity_response_v0::Result", tags = "1, 2" )] pub result: ::core::option::Option< - get_contested_resource_vote_status_response_v0::Result, + get_contested_resource_voters_for_identity_response_v0::Result, >, } - /// Nested message and enum types in `GetContestedResourceVoteStatusResponseV0`. - pub mod get_contested_resource_vote_status_response_v0 { + /// Nested message and enum types in `GetContestedResourceVotersForIdentityResponseV0`. + pub mod get_contested_resource_voters_for_identity_response_v0 { #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] @@ -2448,7 +2476,126 @@ pub mod get_contested_resource_vote_status_response { #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Version { #[prost(message, tag = "1")] - V0(GetContestedResourceVoteStatusResponseV0), + V0(GetContestedResourceVotersForIdentityResponseV0), + } +} +/// How did an identity vote? +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(rename_all = "snake_case")] +#[derive(::dapi_grpc_macros::Mockable)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetContestedResourceIdentityVoteStatusRequest { + #[prost( + oneof = "get_contested_resource_identity_vote_status_request::Version", + tags = "1" + )] + pub version: ::core::option::Option< + get_contested_resource_identity_vote_status_request::Version, + >, +} +/// Nested message and enum types in `GetContestedResourceIdentityVoteStatusRequest`. +pub mod get_contested_resource_identity_vote_status_request { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct GetContestedResourceIdentityVoteStatusRequestV0 { + #[prost(bool, tag = "1")] + pub prove: bool, + #[prost(bytes = "vec", repeated, tag = "2")] + pub resource_path: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, + #[prost(bytes = "vec", tag = "3")] + pub resource_identifier: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", optional, tag = "4")] + pub voter_identifier: ::core::option::Option<::prost::alloc::vec::Vec>, + #[prost(uint32, optional, tag = "5")] + pub count: ::core::option::Option, + #[prost(bool, optional, tag = "6")] + pub ascending: ::core::option::Option, + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Version { + #[prost(message, tag = "1")] + V0(GetContestedResourceIdentityVoteStatusRequestV0), + } +} +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(rename_all = "snake_case")] +#[derive(::dapi_grpc_macros::Mockable)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetContestedResourceIdentityVoteStatusResponse { + #[prost( + oneof = "get_contested_resource_identity_vote_status_response::Version", + tags = "1" + )] + pub version: ::core::option::Option< + get_contested_resource_identity_vote_status_response::Version, + >, +} +/// Nested message and enum types in `GetContestedResourceIdentityVoteStatusResponse`. +pub mod get_contested_resource_identity_vote_status_response { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct GetContestedResourceIdentityVoteStatusResponseV0 { + #[prost(message, optional, tag = "3")] + pub metadata: ::core::option::Option, + #[prost( + oneof = "get_contested_resource_identity_vote_status_response_v0::Result", + tags = "1, 2" + )] + pub result: ::core::option::Option< + get_contested_resource_identity_vote_status_response_v0::Result, + >, + } + /// Nested message and enum types in `GetContestedResourceIdentityVoteStatusResponseV0`. + pub mod get_contested_resource_identity_vote_status_response_v0 { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ContestedResourceVoters { + #[prost(message, repeated, tag = "1")] + pub voters: ::prost::alloc::vec::Vec, + #[prost(bool, tag = "2")] + pub finished_results: bool, + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Voter { + #[prost(bytes = "vec", tag = "1")] + pub identifier: ::prost::alloc::vec::Vec, + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Result { + #[prost(message, tag = "1")] + ContestedResourceVoters(ContestedResourceVoters), + #[prost(message, tag = "2")] + Proof(super::super::Proof), + } + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Version { + #[prost(message, tag = "1")] + V0(GetContestedResourceIdentityVoteStatusResponseV0), } } #[derive(::serde::Serialize, ::serde::Deserialize)] @@ -3346,6 +3493,7 @@ pub mod platform_client { ); self.inner.unary(req, path, codec).await } + /// What's the state of a contested resource vote? (ie who is winning?) pub async fn get_contested_resource_vote_state( &mut self, request: impl tonic::IntoRequest, @@ -3376,13 +3524,47 @@ pub mod platform_client { ); self.inner.unary(req, path, codec).await } - pub async fn get_contested_resource_vote_status( + /// Who voted for a contested resource to go to a specific identity? + pub async fn get_contested_resource_voters_for_identity( + &mut self, + request: impl tonic::IntoRequest< + super::GetContestedResourceVotersForIdentityRequest, + >, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/org.dash.platform.dapi.v0.Platform/getContestedResourceVotersForIdentity", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "org.dash.platform.dapi.v0.Platform", + "getContestedResourceVotersForIdentity", + ), + ); + self.inner.unary(req, path, codec).await + } + /// How did an identity vote? + pub async fn get_contested_resource_identity_vote_status( &mut self, request: impl tonic::IntoRequest< - super::GetContestedResourceVoteStatusRequest, + super::GetContestedResourceIdentityVoteStatusRequest, >, ) -> std::result::Result< - tonic::Response, + tonic::Response, tonic::Status, > { self.inner @@ -3396,14 +3578,14 @@ pub mod platform_client { })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getContestedResourceVoteStatus", + "/org.dash.platform.dapi.v0.Platform/getContestedResourceIdentityVoteStatus", ); let mut req = request.into_request(); req.extensions_mut() .insert( GrpcMethod::new( "org.dash.platform.dapi.v0.Platform", - "getContestedResourceVoteStatus", + "getContestedResourceIdentityVoteStatus", ), ); self.inner.unary(req, path, codec).await @@ -3619,6 +3801,7 @@ pub mod platform_server { tonic::Response, tonic::Status, >; + /// What's the state of a contested resource vote? (ie who is winning?) async fn get_contested_resource_vote_state( &self, request: tonic::Request, @@ -3626,11 +3809,20 @@ pub mod platform_server { tonic::Response, tonic::Status, >; - async fn get_contested_resource_vote_status( + /// Who voted for a contested resource to go to a specific identity? + async fn get_contested_resource_voters_for_identity( &self, - request: tonic::Request, + request: tonic::Request, ) -> std::result::Result< - tonic::Response, + tonic::Response, + tonic::Status, + >; + /// How did an identity vote? + async fn get_contested_resource_identity_vote_status( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, tonic::Status, >; async fn get_prefunded_specialized_balance( @@ -4720,15 +4912,17 @@ pub mod platform_server { }; Box::pin(fut) } - "/org.dash.platform.dapi.v0.Platform/getContestedResourceVoteStatus" => { + "/org.dash.platform.dapi.v0.Platform/getContestedResourceVotersForIdentity" => { #[allow(non_camel_case_types)] - struct getContestedResourceVoteStatusSvc(pub Arc); + struct getContestedResourceVotersForIdentitySvc( + pub Arc, + ); impl< T: Platform, > tonic::server::UnaryService< - super::GetContestedResourceVoteStatusRequest, - > for getContestedResourceVoteStatusSvc { - type Response = super::GetContestedResourceVoteStatusResponse; + super::GetContestedResourceVotersForIdentityRequest, + > for getContestedResourceVotersForIdentitySvc { + type Response = super::GetContestedResourceVotersForIdentityResponse; type Future = BoxFuture< tonic::Response, tonic::Status, @@ -4736,12 +4930,67 @@ pub mod platform_server { fn call( &mut self, request: tonic::Request< - super::GetContestedResourceVoteStatusRequest, + super::GetContestedResourceVotersForIdentityRequest, >, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - (*inner).get_contested_resource_vote_status(request).await + (*inner) + .get_contested_resource_voters_for_identity(request) + .await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = getContestedResourceVotersForIdentitySvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/org.dash.platform.dapi.v0.Platform/getContestedResourceIdentityVoteStatus" => { + #[allow(non_camel_case_types)] + struct getContestedResourceIdentityVoteStatusSvc( + pub Arc, + ); + impl< + T: Platform, + > tonic::server::UnaryService< + super::GetContestedResourceIdentityVoteStatusRequest, + > for getContestedResourceIdentityVoteStatusSvc { + type Response = super::GetContestedResourceIdentityVoteStatusResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + super::GetContestedResourceIdentityVoteStatusRequest, + >, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + (*inner) + .get_contested_resource_identity_vote_status(request) + .await }; Box::pin(fut) } @@ -4753,7 +5002,7 @@ pub mod platform_server { let inner = self.inner.clone(); let fut = async move { let inner = inner.0; - let method = getContestedResourceVoteStatusSvc(inner); + let method = getContestedResourceIdentityVoteStatusSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) .apply_compression_config( diff --git a/packages/rs-drive-abci/src/query/service.rs b/packages/rs-drive-abci/src/query/service.rs index 7efaaf15d1..7f0f471cc3 100644 --- a/packages/rs-drive-abci/src/query/service.rs +++ b/packages/rs-drive-abci/src/query/service.rs @@ -8,26 +8,7 @@ use crate::rpc::core::DefaultCoreRPC; use crate::utils::spawn_blocking_task_with_name_if_supported; use async_trait::async_trait; use dapi_grpc::platform::v0::platform_server::Platform as PlatformService; -use dapi_grpc::platform::v0::{ - BroadcastStateTransitionRequest, BroadcastStateTransitionResponse, GetConsensusParamsRequest, - GetConsensusParamsResponse, GetContestedResourceVoteStateRequest, - GetContestedResourceVoteStateResponse, GetContestedResourceVoteStatusRequest, - GetContestedResourceVoteStatusResponse, GetContestedResourcesRequest, - GetContestedResourcesResponse, GetDataContractHistoryRequest, GetDataContractHistoryResponse, - GetDataContractRequest, GetDataContractResponse, GetDataContractsRequest, - GetDataContractsResponse, GetDocumentsRequest, GetDocumentsResponse, GetEpochsInfoRequest, - GetEpochsInfoResponse, GetIdentitiesContractKeysRequest, GetIdentitiesContractKeysResponse, - GetIdentityBalanceAndRevisionRequest, GetIdentityBalanceAndRevisionResponse, - GetIdentityBalanceRequest, GetIdentityBalanceResponse, GetIdentityByPublicKeyHashRequest, - GetIdentityByPublicKeyHashResponse, GetIdentityContractNonceRequest, - GetIdentityContractNonceResponse, GetIdentityKeysRequest, GetIdentityKeysResponse, - GetIdentityNonceRequest, GetIdentityNonceResponse, GetIdentityRequest, GetIdentityResponse, - GetPathElementsRequest, GetPathElementsResponse, GetPrefundedSpecializedBalanceRequest, - GetPrefundedSpecializedBalanceResponse, GetProofsRequest, GetProofsResponse, - GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, - GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, - WaitForStateTransitionResultRequest, WaitForStateTransitionResultResponse, -}; +use dapi_grpc::platform::v0::{BroadcastStateTransitionRequest, BroadcastStateTransitionResponse, GetConsensusParamsRequest, GetConsensusParamsResponse, GetContestedResourceIdentityVoteStateRequest, GetContestedResourceIdentityVoteStateResponse, GetContestedResourceVoteStatusRequest, GetContestedResourceVoteStatusResponse, GetContestedResourcesRequest, GetContestedResourcesResponse, GetDataContractHistoryRequest, GetDataContractHistoryResponse, GetDataContractRequest, GetDataContractResponse, GetDataContractsRequest, GetDataContractsResponse, GetDocumentsRequest, GetDocumentsResponse, GetEpochsInfoRequest, GetEpochsInfoResponse, GetIdentitiesContractKeysRequest, GetIdentitiesContractKeysResponse, GetIdentityBalanceAndRevisionRequest, GetIdentityBalanceAndRevisionResponse, GetIdentityBalanceRequest, GetIdentityBalanceResponse, GetIdentityByPublicKeyHashRequest, GetIdentityByPublicKeyHashResponse, GetIdentityContractNonceRequest, GetIdentityContractNonceResponse, GetIdentityKeysRequest, GetIdentityKeysResponse, GetIdentityNonceRequest, GetIdentityNonceResponse, GetIdentityRequest, GetIdentityResponse, GetPathElementsRequest, GetPathElementsResponse, GetPrefundedSpecializedBalanceRequest, GetPrefundedSpecializedBalanceResponse, GetProofsRequest, GetProofsResponse, GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, WaitForStateTransitionResultRequest, WaitForStateTransitionResultResponse, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse, GetContestedResourceIdentityVoteStatusRequest, GetContestedResourceIdentityVoteStatusResponse}; use dapi_grpc::tonic::{Request, Response, Status}; use dpp::version::PlatformVersion; use std::sync::atomic::Ordering; @@ -399,10 +380,10 @@ impl PlatformService for QueryService { todo!() } - async fn get_contested_resource_vote_state( + async fn get_contested_resource_identity_vote_state( &self, - request: Request, - ) -> Result, Status> { + request: Request, + ) -> Result, Status> { todo!() } @@ -410,6 +391,23 @@ impl PlatformService for QueryService { &self, request: Request, ) -> Result, Status> { + self.handle_blocking_query( + request, + Platform::::query_prefunded_specialized_balance, + "get_contested_resource_vote_status", + ) + .await + } + + async fn get_contested_resource_vote_state(&self, request: Request) -> Result, Status> { + todo!() + } + + async fn get_contested_resource_voters_for_identity(&self, request: Request) -> Result, Status> { + todo!() + } + + async fn get_contested_resource_identity_vote_status(&self, request: Request) -> Result, Status> { todo!() } @@ -422,7 +420,7 @@ impl PlatformService for QueryService { Platform::::query_prefunded_specialized_balance, "get_prefunded_specialized_balance", ) - .await + .await } } diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/mod.rs new file mode 100644 index 0000000000..ee6a44ce7d --- /dev/null +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/mod.rs @@ -0,0 +1,55 @@ +use crate::error::query::QueryError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::PlatformState; +use crate::query::QueryValidationResult; +use dapi_grpc::platform::v0::get_contested_resource_identity_vote_status_request::Version as RequestVersion; +use dapi_grpc::platform::v0::get_contested_resource_identity_vote_status_response::Version as ResponseVersion; +use dapi_grpc::platform::v0::{GetContestedResourceIdentityVoteStatusRequest, GetContestedResourceIdentityVoteStatusResponse}; +use dpp::version::PlatformVersion; + +mod v0; + +impl Platform { + /// Querying of a how an identity voted for a specific contested resource + pub fn query_contested_resource_identity_vote_status( + &self, + GetContestedResourceIdentityVoteStatusRequest { version }: GetContestedResourceIdentityVoteStatusRequest, + platform_state: &PlatformState, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let Some(version) = version else { + return Ok(QueryValidationResult::new_with_error( + QueryError::DecodingError("could not decode contested resource vote state query".to_string()), + )); + }; + + let feature_version_bounds = &platform_version.drive_abci.query.voting_based_queries.contested_resource_identity_vote_status; + + let feature_version = match &version { + RequestVersion::V0(_) => 0, + }; + if !feature_version_bounds.check_version(feature_version) { + return Ok(QueryValidationResult::new_with_error( + QueryError::UnsupportedQueryVersion( + "query_contested_resource_identity_vote_status".to_string(), + feature_version_bounds.min_version, + feature_version_bounds.max_version, + platform_version.protocol_version, + feature_version, + ), + )); + } + match version { + RequestVersion::V0(request_v0) => { + let result = + self.query_contested_resource_identity_vote_status_v0(request_v0, platform_state, platform_version)?; + + Ok(result.map(|response_v0| GetContestedResourceIdentityVoteStatusResponse { + version: Some(ResponseVersion::V0(response_v0)), + })) + } + } + } +} + diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/v0/mod.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/mod.rs index 8b13789179..0d15fad0e9 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/mod.rs @@ -1 +1,56 @@ +use crate::error::query::QueryError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::PlatformState; +use crate::query::QueryValidationResult; +use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::Version as RequestVersion; +use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::Version as ResponseVersion; +use dapi_grpc::platform::v0::{GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse}; +use dpp::version::PlatformVersion; + +mod v0; + +impl Platform { + /// Querying of a contested resource's vote status + /// This basically gives who is winning the vote + pub fn query_contested_resource_vote_state( + &self, + GetContestedResourceVoteStateRequest { version }: GetContestedResourceVoteStateRequest, + platform_state: &PlatformState, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let Some(version) = version else { + return Ok(QueryValidationResult::new_with_error( + QueryError::DecodingError("could not decode contested resource vote state query".to_string()), + )); + }; + + let feature_version_bounds = &platform_version.drive_abci.query.voting_based_queries.contested_resource_vote_state; + + let feature_version = match &version { + RequestVersion::V0(_) => 0, + }; + if !feature_version_bounds.check_version(feature_version) { + return Ok(QueryValidationResult::new_with_error( + QueryError::UnsupportedQueryVersion( + "contested_resource_vote_state".to_string(), + feature_version_bounds.min_version, + feature_version_bounds.max_version, + platform_version.protocol_version, + feature_version, + ), + )); + } + match version { + RequestVersion::V0(request_v0) => { + let result = + self.query_contested_resource_vote_state_v0(request_v0, platform_state, platform_version)?; + + Ok(result.map(|response_v0| GetContestedResourceVoteStateResponse { + version: Some(ResponseVersion::V0(response_v0)), + })) + } + } + } +} diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs new file mode 100644 index 0000000000..8aa9a65b02 --- /dev/null +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs @@ -0,0 +1,106 @@ +use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::GetContestedResourceVoteStateRequestV0; +use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::GetContestedResourceVoteStateResponseV0; +use crate::error::query::QueryError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::PlatformState; +use crate::query::QueryValidationResult; +use dpp::check_validation_result_with_data; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::identifier::Identifier; +use dpp::validation::ValidationResult; +use dpp::version::PlatformVersion; +use drive::error::query::QuerySyntaxError; + +impl Platform { + pub(super) fn query_contested_resource_vote_status_v0( + &self, + GetContestedResourceVoteStateRequestV0 { contract_id, document_type_name, index_name, index_values, include_documents, start_at_identifier_info, prove }: GetContestedResourceVoteStateRequestV0, + platform_state: &PlatformState, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let contract_id: Identifier = + check_validation_result_with_data!(contract_id.try_into().map_err(|_| { + QueryError::InvalidArgument( + "contract_id must be a valid identifier (32 bytes long)".to_string(), + ) + })); + + let (_, contract) = self.drive.get_contract_with_fetch_info_and_fee( + contract_id.to_buffer(), + None, + true, + None, + platform_version, + )?; + + let contract = check_validation_result_with_data!(contract.ok_or(QueryError::Query( + QuerySyntaxError::DataContractNotFound( + "contract not found when querying from value with contract info", + ) + ))); + + let contract_ref = &contract.contract; + + let document_type = check_validation_result_with_data!(contract_ref + .document_type_for_name(document_type_name.as_str()) + .map_err(|_| QueryError::InvalidArgument(format!( + "document type {} not found for contract {}", + document_type_name, contract_id + )))); + + let index = check_validation_result_with_data!(document_type.find_contested_index().ok_or(QueryError::InvalidArgument(format!( + "document type {} does not have a contested index", + document_type_name + )))); + + if index.name != &index_name { + return Ok(QueryValidationResult::new_with_error(QueryError::InvalidArgument(format!( + "index with name {} is not the contested index on the document type {}, {} is the name of the only contested index", + index_name, document_type_name, index.name + )))); + } + + let index = check_validation_result_with_data!(document_type + .inc (document_type_name.as_str()) + .map_err(|_| QueryError::InvalidArgument(format!( + "document type {} not found for contract {}", + document_type_name, contract_id + )))); + + let response = if prove { + let proof = check_validation_result_with_data!(self.drive.prove_identity_balance( + identity_id.into_buffer(), + None, + &platform_version.drive + )); + + GetContestedResourceVoteStateResponseV0 { + result: Some(get_identity_balance_response_v0::Result::Proof( + self.response_proof_v0(platform_state, proof), + )), + metadata: Some(self.response_metadata_v0(platform_state)), + } + } else { + let maybe_balance = self.drive.fetch_identity_balance( + identity_id.into_buffer(), + None, + platform_version, + )?; + + let Some(balance) = maybe_balance else { + return Ok(ValidationResult::new_with_error(QueryError::NotFound( + "No Identity found".to_string(), + ))); + }; + + GetContestedResourceVoteStateResponseV0 { + result: Some(get_contested_resource_vote_status_response_v0::Result::ContestedResourceVoters(balance)), + metadata: Some(self.response_metadata_v0(platform_state)), + } + }; + + Ok(QueryValidationResult::new_with_data(response)) + } +} \ No newline at end of file diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_status/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_status/mod.rs deleted file mode 100644 index 8b13789179..0000000000 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_status/mod.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/mod.rs new file mode 100644 index 0000000000..e2a47f888e --- /dev/null +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/mod.rs @@ -0,0 +1,55 @@ +use crate::error::query::QueryError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::PlatformState; +use crate::query::QueryValidationResult; +use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_request::Version as RequestVersion; +use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_response::Version as ResponseVersion; +use dapi_grpc::platform::v0::{GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse}; +use dpp::version::PlatformVersion; + +mod v0; + +impl Platform { + /// Querying of a how an identity voted for a specific contested resource + pub fn query_contested_resource_voters_for_identity( + &self, + GetContestedResourceVotersForIdentityRequest { version }: GetContestedResourceVotersForIdentityRequest, + platform_state: &PlatformState, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let Some(version) = version else { + return Ok(QueryValidationResult::new_with_error( + QueryError::DecodingError("could not decode contested resource vote state query".to_string()), + )); + }; + + let feature_version_bounds = &platform_version.drive_abci.query.voting_based_queries.contested_resource_voters_for_identity; + + let feature_version = match &version { + RequestVersion::V0(_) => 0, + }; + if !feature_version_bounds.check_version(feature_version) { + return Ok(QueryValidationResult::new_with_error( + QueryError::UnsupportedQueryVersion( + "query_contested_resource_voters_for_identity".to_string(), + feature_version_bounds.min_version, + feature_version_bounds.max_version, + platform_version.protocol_version, + feature_version, + ), + )); + } + match version { + RequestVersion::V0(request_v0) => { + let result = + self.query_contested_resource_voters_for_identity_v0(request_v0, platform_state, platform_version)?; + + Ok(result.map(|response_v0| GetContestedResourceVotersForIdentityResponse { + version: Some(ResponseVersion::V0(response_v0)), + })) + } + } + } +} + diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/v0/mod.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs index 8b13789179..d351cabc3f 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs @@ -1 +1,55 @@ +use crate::error::query::QueryError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::PlatformState; +use crate::query::QueryValidationResult; +use dapi_grpc::platform::v0::get_contested_resources_request::Version as RequestVersion; +use dapi_grpc::platform::v0::get_contested_resources_response::Version as ResponseVersion; +use dapi_grpc::platform::v0::{GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse}; +use dpp::version::PlatformVersion; + +mod v0; + +impl Platform { + /// Querying of the contested resources + pub fn query_contested_resources( + &self, + GetContestedResourceVotersForIdentityRequest { version }: GetContestedResourceVotersForIdentityRequest, + platform_state: &PlatformState, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let Some(version) = version else { + return Ok(QueryValidationResult::new_with_error( + QueryError::DecodingError("could not decode contested resource vote state query".to_string()), + )); + }; + + let feature_version_bounds = &platform_version.drive_abci.query.voting_based_queries.contested_resources; + + let feature_version = match &version { + RequestVersion::V0(_) => 0, + }; + if !feature_version_bounds.check_version(feature_version) { + return Ok(QueryValidationResult::new_with_error( + QueryError::UnsupportedQueryVersion( + "query_contested_resources".to_string(), + feature_version_bounds.min_version, + feature_version_bounds.max_version, + platform_version.protocol_version, + feature_version, + ), + )); + } + match version { + RequestVersion::V0(request_v0) => { + let result = + self.query_contested_resources_v0(request_v0, platform_state, platform_version)?; + + Ok(result.map(|response_v0| GetContestedResourceVotersForIdentityResponse { + version: Some(ResponseVersion::V0(response_v0)), + })) + } + } + } +} diff --git a/packages/rs-drive-abci/src/query/voting/contested_resources/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resources/v0/mod.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/rs-drive-abci/src/query/voting/mod.rs b/packages/rs-drive-abci/src/query/voting/mod.rs index 4781aac591..5065a5daa8 100644 --- a/packages/rs-drive-abci/src/query/voting/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/mod.rs @@ -1,3 +1,4 @@ +mod contested_resource_identity_vote_status; mod contested_resource_vote_state; -mod contested_resource_vote_status; mod contested_resources; +mod contested_resource_voters_for_identity; diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index 1d3d8cf14e..c4756d52cf 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -23,7 +23,7 @@ mod tests { use strategy_tests::{IdentityInsertInfo, StartIdentities, Strategy}; #[test] - fn run_chain_block_two_state_transitions_conflicting_unique_index() { + fn run_chain_block_two_state_transitions_conflicting_unique_index_inserted_same_block() { // In this test we try to insert two state transitions with the same unique index // We use the dpns contract and we insert two documents both with the same "name" // This is a common scenario we should see quite often @@ -199,6 +199,6 @@ mod tests { .expect("expected a document insert") .1; - assert_eq!(second_document_insert_result.code, 4009); // we expect an error + assert_eq!(second_document_insert_result.code, 0); // we expect the second to also be insertable as they are both contested } } diff --git a/packages/rs-drive/src/drive/defaults.rs b/packages/rs-drive/src/drive/defaults.rs index 5cdd4968da..0e2e35992e 100644 --- a/packages/rs-drive/src/drive/defaults.rs +++ b/packages/rs-drive/src/drive/defaults.rs @@ -75,6 +75,12 @@ pub const U32_SIZE: u32 = 4; /// u32 size pub const U32_SIZE_U16: u16 = 4; +/// u8 size +pub const U8_SIZE_U8: u8 = 1; + +/// u32 size +pub const U8_SIZE_U32: u32 = 1; + /// u32 size pub const U32_SIZE_U8: u8 = 4; /// Default float size as u16 @@ -119,3 +125,22 @@ pub const ESTIMATED_NON_UNIQUE_KEY_DUPLICATES: u32 = 2; /// The average size of an item that is acting as a tree reference towards the contested item vote pub const AVERAGE_CONTESTED_RESOURCE_ITEM_REFERENCE_SIZE: u32 = 150; + +/// Contested document reference size +// we need to construct the reference from the split height of the contract document +// type which is at 4 +// 0 represents document storage +// Then we add document id +// Then we add 0 if the document type keys history +// vec![vec![0], Vec::from(document.id)]; +// 1 (vec size) + 1 (subvec size) + 32 (document id size) = 34 +// + 6 = 40 +// 6 because of: +// 1 for type reference +// 1 for reference type +// 1 for root height offset +// reference path size +// 1 reference_hops options +// 1 reference_hops count +// 1 element flags option +pub const CONTESTED_DOCUMENT_REFERENCE_SIZE: u32 = 40; diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs index c274265522..a8255cbe1c 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs @@ -11,17 +11,18 @@ use crate::fee::op::LowLevelDriveOperation; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; -use crate::drive::defaults::DEFAULT_HASH_SIZE_U8; +use crate::drive::defaults::{CONTESTED_DOCUMENT_REFERENCE_SIZE, DEFAULT_HASH_SIZE_U8, U8_SIZE_U8}; use crate::drive::votes::paths::vote_contested_resource_active_polls_contract_document_tree_path_vec; use crate::error::drive::DriveError; use dpp::data_contract::document_type::IndexProperty; use dpp::version::PlatformVersion; use grovedb::batch::KeyInfoPath; -use grovedb::EstimatedLayerCount::PotentiallyAtMaxElements; -use grovedb::EstimatedLayerSizes::AllSubtrees; -use grovedb::EstimatedSumTrees::NoSumTrees; +use grovedb::EstimatedLayerCount::{ApproximateElements, PotentiallyAtMaxElements}; +use grovedb::EstimatedLayerSizes::{AllSubtrees, Mix}; +use grovedb::EstimatedSumTrees::{AllSumTrees, NoSumTrees}; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; +use crate::drive::document::document_reference_size; impl Drive { /// Adds indices for the top index level and calls for lower levels. @@ -159,7 +160,17 @@ impl Drive { index_path_info.push(document_top_field)?; } - // at the end of all of this we put the identity tree that will hold the votes + // Under each tree we have all identifiers of identities that want the contested resource + // Contrary to normal secondary indexes there are no property names and there is no termination key "0" + // We get something like + // Inter-wizard championship (event type) + // | + // Goblet of Fire (event name) <---- We just inserted this + // / \ + // Sam's ID Ivan's ID <---- We now need to insert at this level + // / \ / \ + // 0 (ref) 1 (sum tree) 0 (ref) 1 (sum tree) + // if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { // On this level we will have all the identities @@ -167,7 +178,7 @@ impl Drive { index_path_info.clone().convert_to_key_info_path(), EstimatedLayerInformation { is_sum_tree: false, - estimated_layer_count: PotentiallyAtMaxElements, + estimated_layer_count: ApproximateElements(16), // very seldom would more than 16 people want the resource estimated_layer_sizes: AllSubtrees( DEFAULT_HASH_SIZE_U8, NoSumTrees, @@ -188,7 +199,18 @@ impl Drive { drive_version, )?; - self.add_contested_reference_to_document_operations(document_and_contract_info, index_path_info, previous_batch_operations, storage_flags, estimated_costs_only_with_layer_info, transaction, batch_operations, drive_version) + index_path_info.push(DriveKeyInfo::Key(owner_id.to_vec()))?; + + // Inter-wizard championship (event type) + // | + // Goblet of Fire (event name) + // / \ + // Sam's ID Ivan's ID <---- We just inserted this + // / \ / \ + // 0 (ref) 1 (sum tree) 0 (ref) 1 (sum tree) <---- We now need to insert at this level + // + + self.add_contested_reference_and_vote_subtree_to_document_operations(document_and_contract_info, index_path_info, storage_flags, estimated_costs_only_with_layer_info, transaction, batch_operations, drive_version) } } diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs index 885d4ad3da..85bb92bbb6 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs @@ -17,11 +17,10 @@ use std::collections::HashMap; impl Drive { /// Adds the terminal reference. - pub fn add_contested_reference_to_document_operations( + pub fn add_contested_reference_and_vote_subtree_to_document_operations( &self, document_and_contract_info: &DocumentAndContractInfo, index_path_info: PathInfo<0>, - previous_batch_operations: &mut Option<&mut Vec>, storage_flags: Option<&StorageFlags>, estimated_costs_only_with_layer_info: &mut Option< HashMap, @@ -34,12 +33,11 @@ impl Drive { .methods .document .insert_contested - .add_contested_reference_to_document_operations + .add_contested_reference_and_vote_subtree_to_document_operations { - 0 => self.add_contested_reference_to_document_operations_v0( + 0 => self.add_contested_reference_and_vote_subtree_to_document_operations_v0( document_and_contract_info, index_path_info, - previous_batch_operations, storage_flags, estimated_costs_only_with_layer_info, transaction, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs index d18043cbeb..470d21118a 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -1,4 +1,4 @@ -use crate::drive::defaults::{DEFAULT_HASH_SIZE_U8, STORAGE_FLAGS_SIZE}; +use crate::drive::defaults::{CONTESTED_DOCUMENT_REFERENCE_SIZE, DEFAULT_HASH_SIZE_U8, STORAGE_FLAGS_SIZE, U8_SIZE_U32, U8_SIZE_U8}; use crate::drive::document::{ document_reference_size, make_document_contested_reference, make_document_reference, }; @@ -21,20 +21,19 @@ use dpp::document::DocumentV0Getters; use dpp::version::drive_versions::DriveVersion; use grovedb::batch::key_info::KeyInfo; use grovedb::batch::KeyInfoPath; -use grovedb::EstimatedLayerCount::PotentiallyAtMaxElements; -use grovedb::EstimatedLayerSizes::{AllReference, AllSubtrees}; -use grovedb::EstimatedSumTrees::NoSumTrees; +use grovedb::EstimatedLayerCount::{ApproximateElements, PotentiallyAtMaxElements}; +use grovedb::EstimatedLayerSizes::{AllItems, AllReference, AllSubtrees, Mix}; +use grovedb::EstimatedSumTrees::{AllSumTrees, NoSumTrees}; use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; impl Drive { /// Adds the terminal reference. #[inline(always)] - pub(super) fn add_contested_reference_to_document_operations_v0( + pub(super) fn add_contested_reference_and_vote_subtree_to_document_operations_v0( &self, document_and_contract_info: &DocumentAndContractInfo, mut index_path_info: PathInfo<0>, - previous_batch_operations: &mut Option<&mut Vec>, storage_flags: Option<&StorageFlags>, estimated_costs_only_with_layer_info: &mut Option< HashMap, @@ -43,33 +42,44 @@ impl Drive { batch_operations: &mut Vec, drive_version: &DriveVersion, ) -> Result<(), Error> { - // Contested Resource Index - // Under each tree we have all identifiers of identities that want the contested resource - // Contrary to normal secondary indexes there are no property names and there is no termination key "0" - // We get something like // Inter-wizard championship (event type) // | - // Goblet of Fire (event name) + // Goblet of Fire (event name) // / \ - // Sam's Document ID Ivan's Document ID + // Sam's ID Ivan's ID // / \ / \ - // 0 (ref) 1 (sum tree) 0 (ref) 1 (sum tree) + // 0 (ref) 1 (sum tree) 0 (ref) 1 (sum tree) <---- We now need to insert at this level // - let apply_type = if estimated_costs_only_with_layer_info.is_none() { - BatchInsertTreeApplyType::StatefulBatchInsertTree - } else { - BatchInsertTreeApplyType::StatelessBatchInsertTree { - in_tree_using_sums: false, - is_sum_tree: false, - flags_len: storage_flags - .map(|s| s.serialized_size()) - .unwrap_or_default(), - } - }; + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { + // On this level we will have all the identities + estimated_costs_only_with_layer_info.insert( + index_path_info.clone().convert_to_key_info_path(), + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: ApproximateElements(2), + estimated_layer_sizes: Mix { + // The votes don't have storage flags + subtrees_size: Some((U8_SIZE_U8, + AllSumTrees, // There is 1 tree that is a sum tree, so all are sum trees + None, 1)), + items_size: None, + // The references do have storage flags + // We keep storage flags because when the item is moved after being won, + // a transformation needs to take place on the storage flags to be able to + // allow the refund of credits on delete later. + references_size: Some((U8_SIZE_U8, + CONTESTED_DOCUMENT_REFERENCE_SIZE, + storage_flags.map(|s| s.serialized_size()), 1)), + }, + }, + ); + } + + // We create the reference // Here we are getting the document id and the reference - let (document_id, ref_key_element_info) = + let ref_key_element_info = match &document_and_contract_info.owned_document_info.document_info { DocumentRefAndSerialization((document, _, storage_flags)) | DocumentRefInfo((document, storage_flags)) => { @@ -77,7 +87,7 @@ impl Drive { document, storage_flags.as_ref().map(|flags| flags.as_ref()), ); - (document.id(), KeyElement((&[0], document_reference))) + KeyElement((&[0], document_reference)) } DocumentOwnedInfo((document, storage_flags)) | DocumentAndSerialization((document, _, storage_flags)) => { @@ -85,106 +95,59 @@ impl Drive { document, storage_flags.as_ref().map(|flags| flags.as_ref()), ); - (document.id(), KeyElement((&[0], document_reference))) + KeyElement((&[0], document_reference)) } DocumentEstimatedAverageSize(max_size) => { let unique_id = document_and_contract_info .document_type - .unique_id_for_storage(); - let unique_id_vec = unique_id.to_vec(); - ( - unique_id.into(), + .unique_id_for_storage().to_vec(); KeyUnknownElementSize(( KeyInfo::MaxKeySize { - unique_id: unique_id_vec, + unique_id, max_size: DEFAULT_HASH_SIZE_U8, }, Element::required_item_space(*max_size, STORAGE_FLAGS_SIZE), - )), - ) + )) + } }; + + // Now let's insert the reference, the reference is a key element that already has the 0 - // Let's start by inserting the document id tree - - // here we are the tree that will contain the ref - // We are inserting this at item name contested / Goblet of Fire / 0 with the key of - // document_key_path_info - - let document_id_key_path_info = KeyRef(document_id.as_slice()); - - let path_key_info = document_id_key_path_info.add_path_info(index_path_info.clone()); - - index_path_info.push(Key(document_id.to_vec()))?; + let reference_path_key_element_info = PathKeyElementInfo::from_path_info_and_key_element( + index_path_info.clone(), + ref_key_element_info, + )?; - // We check to make sure we are not overriding the tree - let inserted = self.batch_insert_empty_tree_if_not_exists( - path_key_info, - false, - storage_flags, - apply_type, - transaction, - previous_batch_operations, + // here we are inserting the ref + self.batch_insert( + reference_path_key_element_info, batch_operations, drive_version, )?; - if !inserted { - return Err(Error::Drive(DriveError::CorruptedContractIndexes( - "contested votes sub tree document already exists", - ))); - } - - let mut document_path_info = index_path_info.clone(); - - document_path_info.push(KeyRef(document_id.as_slice()))?; + // Let's insert the voting tree let votes_key_path_info = KeyRef(&[1]); - let votes_path_key_info = votes_key_path_info.add_path_info(document_path_info.clone()); + let votes_path_key_info = votes_key_path_info.add_path_info(index_path_info.clone()); if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { - // On this level we will have a 0 and all the top index paths - estimated_costs_only_with_layer_info.insert( - index_path_info.clone().convert_to_key_info_path(), - EstimatedLayerInformation { - is_sum_tree: false, - estimated_layer_count: PotentiallyAtMaxElements, - estimated_layer_sizes: AllSubtrees( - DEFAULT_HASH_SIZE_U8, - NoSumTrees, - storage_flags.map(|s| s.serialized_size()), - ), - }, - ); - // On this level we will have a 0 and all the top index paths estimated_costs_only_with_layer_info.insert( votes_path_key_info.clone().convert_to_key_info_path()?, EstimatedLayerInformation { - is_sum_tree: false, + is_sum_tree: true, estimated_layer_count: PotentiallyAtMaxElements, - estimated_layer_sizes: AllSubtrees( + estimated_layer_sizes: AllItems( DEFAULT_HASH_SIZE_U8, - NoSumTrees, - storage_flags.map(|s| s.serialized_size()), + U8_SIZE_U32, + None, ), }, ); } - let reference_path_key_element_info = PathKeyElementInfo::from_path_info_and_key_element( - document_path_info.clone(), - ref_key_element_info, - )?; - - // here we are inserting the ref - self.batch_insert( - reference_path_key_element_info, - batch_operations, - drive_version, - )?; - let apply_type = if estimated_costs_only_with_layer_info.is_none() { BatchInsertTreeApplyType::StatefulBatchInsertTree } else { @@ -215,10 +178,6 @@ impl Drive { ))); } - // Now we need to add a reference to this votes, so we can keep track of it more easily - - // self.add_new_masternode_vote_type() - Ok(()) } } diff --git a/packages/rs-drive/src/drive/object_size_info/path_info.rs b/packages/rs-drive/src/drive/object_size_info/path_info.rs index c458ead68f..6df0a89a73 100644 --- a/packages/rs-drive/src/drive/object_size_info/path_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/path_info.rs @@ -11,7 +11,7 @@ use crate::error::drive::DriveError; use crate::error::Error; /// Info about a path. -#[derive(Clone)] +#[derive(Clone, Debug)] pub enum PathInfo<'a, const N: usize> { /// An into iter Path PathFixedSizeArray([&'a [u8]; N]), diff --git a/packages/rs-drive/src/drive/object_size_info/path_key_info.rs b/packages/rs-drive/src/drive/object_size_info/path_key_info.rs index fbbb25400e..e19a493290 100644 --- a/packages/rs-drive/src/drive/object_size_info/path_key_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/path_key_info.rs @@ -11,7 +11,7 @@ use grovedb_storage::worst_case_costs::WorstKeyLength; use std::collections::HashSet; /// Path key info -#[derive(Clone)] +#[derive(Clone, Debug)] pub enum PathKeyInfo<'a, const N: usize> { /// An into iter Path with a Key PathFixedSizeKey(([&'a [u8]; N], Vec)), diff --git a/packages/rs-drive/src/query/mod.rs b/packages/rs-drive/src/query/mod.rs index f2f49ac149..974766975c 100644 --- a/packages/rs-drive/src/query/mod.rs +++ b/packages/rs-drive/src/query/mod.rs @@ -255,6 +255,7 @@ impl QueryResultEncoding { #[cfg(any(feature = "server", feature = "verify"))] /// Drive query struct +// todo: rename to DriveDocumentQuery #[derive(Debug, PartialEq, Clone)] pub struct DriveQuery<'a> { ///DataContract diff --git a/packages/rs-platform-version/src/version/drive_abci_versions.rs b/packages/rs-platform-version/src/version/drive_abci_versions.rs index fbe2005a67..6c7f3fb381 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions.rs @@ -17,6 +17,7 @@ pub struct DriveAbciQueryVersions { pub prefunded_specialized_balances: DriveAbciQueryPrefundedSpecializedBalancesVersions, pub identity_based_queries: DriveAbciQueryIdentityVersions, pub data_contract_based_queries: DriveAbciQueryDataContractVersions, + pub voting_based_queries: DriveAbciQueryVotingVersions, pub system: DriveAbciQuerySystemVersions, } @@ -37,6 +38,14 @@ pub struct DriveAbciQueryIdentityVersions { pub identity_by_public_key_hash: FeatureVersionBounds, } +#[derive(Clone, Debug, Default)] +pub struct DriveAbciQueryVotingVersions { + pub contested_resource_vote_state: FeatureVersionBounds, + pub contested_resource_voters_for_identity: FeatureVersionBounds, + pub contested_resource_identity_vote_status: FeatureVersionBounds, + pub contested_resources: FeatureVersionBounds, +} + #[derive(Clone, Debug, Default)] pub struct DriveAbciQueryDataContractVersions { pub data_contract: FeatureVersionBounds, diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index c36ba1b743..f43158195a 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -329,7 +329,7 @@ pub struct DriveDocumentInsertContestedMethodVersions { pub add_contested_document_for_contract_operations: FeatureVersion, pub add_contested_document_to_primary_storage: FeatureVersion, pub add_contested_indices_for_contract_operations: FeatureVersion, - pub add_contested_reference_to_document_operations: FeatureVersion, + pub add_contested_reference_and_vote_subtree_to_document_operations: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index d7eedd6a41..02532ead4a 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -12,25 +12,7 @@ use crate::version::dpp_versions::{ StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, VotingVersions, }; -use crate::version::drive_abci_versions::{ - DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, - DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, - DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, - DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, - DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, - DriveAbciFeePoolInwardsDistributionMethodVersions, - DriveAbciFeePoolOutwardsDistributionMethodVersions, - DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, - DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, - DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, - DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, - DriveAbciQueryPrefundedSpecializedBalancesVersions, DriveAbciQuerySystemVersions, - DriveAbciQueryVersions, DriveAbciStateTransitionCommonValidationVersions, - DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, - DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, - DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, - DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts, -}; +use crate::version::drive_abci_versions::{DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, DriveAbciFeePoolInwardsDistributionMethodVersions, DriveAbciFeePoolOutwardsDistributionMethodVersions, DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, DriveAbciQueryPrefundedSpecializedBalancesVersions, DriveAbciQuerySystemVersions, DriveAbciQueryVersions, DriveAbciQueryVotingVersions, DriveAbciStateTransitionCommonValidationVersions, DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts}; use crate::version::drive_versions::{ DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, @@ -196,7 +178,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { add_contested_document_for_contract_operations: 0, add_contested_document_to_primary_storage: 0, add_contested_indices_for_contract_operations: 0, - add_contested_reference_to_document_operations: 0, + add_contested_reference_and_vote_subtree_to_document_operations: 0, }, update: DriveDocumentUpdateMethodVersions { add_update_multiple_documents_operations: 0, @@ -854,6 +836,27 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { default_current_version: 0, }, }, + voting_based_queries: DriveAbciQueryVotingVersions { contested_resource_vote_state: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, + contested_resource_voters_for_identity: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, + contested_resource_identity_vote_status: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, + contested_resources: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, + }, system: DriveAbciQuerySystemVersions { version_upgrade_state: FeatureVersionBounds { min_version: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index a5a4438b2d..4b73d32d41 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -12,25 +12,7 @@ use crate::version::dpp_versions::{ StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, VotingVersions, }; -use crate::version::drive_abci_versions::{ - DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, - DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, - DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, - DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, - DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, - DriveAbciFeePoolInwardsDistributionMethodVersions, - DriveAbciFeePoolOutwardsDistributionMethodVersions, - DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, - DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, - DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, - DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, - DriveAbciQueryPrefundedSpecializedBalancesVersions, DriveAbciQuerySystemVersions, - DriveAbciQueryVersions, DriveAbciStateTransitionCommonValidationVersions, - DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, - DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, - DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, - DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts, -}; +use crate::version::drive_abci_versions::{DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, DriveAbciFeePoolInwardsDistributionMethodVersions, DriveAbciFeePoolOutwardsDistributionMethodVersions, DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, DriveAbciQueryPrefundedSpecializedBalancesVersions, DriveAbciQuerySystemVersions, DriveAbciQueryVersions, DriveAbciQueryVotingVersions, DriveAbciStateTransitionCommonValidationVersions, DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts}; use crate::version::drive_versions::{ DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, @@ -204,7 +186,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { add_contested_document_for_contract_operations: 0, add_contested_document_to_primary_storage: 0, add_contested_indices_for_contract_operations: 0, - add_contested_reference_to_document_operations: 0, + add_contested_reference_and_vote_subtree_to_document_operations: 0, }, update: DriveDocumentUpdateMethodVersions { add_update_multiple_documents_operations: 0, @@ -854,6 +836,27 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { default_current_version: 0, }, }, + voting_based_queries: DriveAbciQueryVotingVersions { contested_resource_vote_state: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, + contested_resource_voters_for_identity: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, + contested_resource_identity_vote_status: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, + contested_resources: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, + }, system: DriveAbciQuerySystemVersions { version_upgrade_state: FeatureVersionBounds { min_version: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index c2f8553bd3..a9ec1f94d8 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -12,25 +12,7 @@ use crate::version::dpp_versions::{ StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, VotingVersions, }; -use crate::version::drive_abci_versions::{ - DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, - DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, - DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, - DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, - DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, - DriveAbciFeePoolInwardsDistributionMethodVersions, - DriveAbciFeePoolOutwardsDistributionMethodVersions, - DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, - DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, - DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, - DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, - DriveAbciQueryPrefundedSpecializedBalancesVersions, DriveAbciQuerySystemVersions, - DriveAbciQueryVersions, DriveAbciStateTransitionCommonValidationVersions, - DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, - DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, - DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, - DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts, -}; +use crate::version::drive_abci_versions::{DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, DriveAbciFeePoolInwardsDistributionMethodVersions, DriveAbciFeePoolOutwardsDistributionMethodVersions, DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, DriveAbciQueryPrefundedSpecializedBalancesVersions, DriveAbciQuerySystemVersions, DriveAbciQueryVersions, DriveAbciQueryVotingVersions, DriveAbciStateTransitionCommonValidationVersions, DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts}; use crate::version::drive_versions::{ DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, @@ -195,7 +177,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { add_contested_document_for_contract_operations: 0, add_contested_document_to_primary_storage: 0, add_contested_indices_for_contract_operations: 0, - add_contested_reference_to_document_operations: 0, + add_contested_reference_and_vote_subtree_to_document_operations: 0, }, update: DriveDocumentUpdateMethodVersions { add_update_multiple_documents_operations: 0, @@ -853,6 +835,27 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { default_current_version: 0, }, }, + voting_based_queries: DriveAbciQueryVotingVersions { contested_resource_vote_state: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, + contested_resource_voters_for_identity: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, + contested_resource_identity_vote_status: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, + contested_resources: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, + }, system: DriveAbciQuerySystemVersions { version_upgrade_state: FeatureVersionBounds { min_version: 0, From cd443e58222db71a4bd33e52898f331fa3b4c56a Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sat, 18 May 2024 00:03:08 +0200 Subject: [PATCH 061/135] a lot of work on queries --- packages/rs-drive-abci/src/query/service.rs | 43 +- .../mod.rs | 30 +- .../v0/mod.rs | 1 + .../contested_resource_vote_state/mod.rs | 30 +- .../contested_resource_vote_state/v0/mod.rs | 74 ++- .../mod.rs | 30 +- .../v0/mod.rs | 1 + .../query/voting/contested_resources/mod.rs | 30 +- .../voting/contested_resources/v0/mod.rs | 1 + .../rs-drive-abci/src/query/voting/mod.rs | 2 +- .../v0/mod.rs | 1 - .../add_contested_document/mod.rs | 1 - .../v0/mod.rs | 10 +- .../mod.rs | 2 - .../v0/mod.rs | 17 +- .../v0/mod.rs | 26 +- .../mod.rs | 1 - .../v0/mod.rs | 67 +-- packages/rs-drive/src/drive/document/mod.rs | 1 - .../rs-drive/src/drive/document/query/mod.rs | 31 +- .../mod.rs | 93 +++ .../v0/mod.rs | 104 ++++ .../document/query/query_documents/mod.rs | 2 + .../document/query/query_documents/v0/mod.rs | 7 - .../drive/object_size_info/path_key_info.rs | 1 - .../v0/mod.rs | 4 +- .../v0/mod.rs | 4 +- .../mod.rs | 1 - .../v0/mod.rs | 5 +- packages/rs-drive/src/drive/votes/mod.rs | 3 + packages/rs-drive/src/drive/votes/paths.rs | 144 ++++- .../mod.rs | 75 +++ packages/rs-drive/src/query/mod.rs | 6 +- .../src/query/single_document_drive_query.rs | 6 +- .../src/query/vote_poll_vote_state_query.rs | 547 ++++++++++++++++++ .../document_create_transition_action/mod.rs | 1 - .../v0/transformer.rs | 1 - .../src/version/mocks/v2_test.rs | 32 +- .../src/version/mocks/v3_test.rs | 32 +- .../rs-platform-version/src/version/v1.rs | 32 +- packages/simple-signer/src/signer.rs | 6 +- 41 files changed, 1291 insertions(+), 214 deletions(-) create mode 100644 packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs create mode 100644 packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/resolve_contested_document_resource_vote_poll/mod.rs create mode 100644 packages/rs-drive/src/query/vote_poll_vote_state_query.rs diff --git a/packages/rs-drive-abci/src/query/service.rs b/packages/rs-drive-abci/src/query/service.rs index 7f0f471cc3..fca58367b4 100644 --- a/packages/rs-drive-abci/src/query/service.rs +++ b/packages/rs-drive-abci/src/query/service.rs @@ -8,7 +8,29 @@ use crate::rpc::core::DefaultCoreRPC; use crate::utils::spawn_blocking_task_with_name_if_supported; use async_trait::async_trait; use dapi_grpc::platform::v0::platform_server::Platform as PlatformService; -use dapi_grpc::platform::v0::{BroadcastStateTransitionRequest, BroadcastStateTransitionResponse, GetConsensusParamsRequest, GetConsensusParamsResponse, GetContestedResourceIdentityVoteStateRequest, GetContestedResourceIdentityVoteStateResponse, GetContestedResourceVoteStatusRequest, GetContestedResourceVoteStatusResponse, GetContestedResourcesRequest, GetContestedResourcesResponse, GetDataContractHistoryRequest, GetDataContractHistoryResponse, GetDataContractRequest, GetDataContractResponse, GetDataContractsRequest, GetDataContractsResponse, GetDocumentsRequest, GetDocumentsResponse, GetEpochsInfoRequest, GetEpochsInfoResponse, GetIdentitiesContractKeysRequest, GetIdentitiesContractKeysResponse, GetIdentityBalanceAndRevisionRequest, GetIdentityBalanceAndRevisionResponse, GetIdentityBalanceRequest, GetIdentityBalanceResponse, GetIdentityByPublicKeyHashRequest, GetIdentityByPublicKeyHashResponse, GetIdentityContractNonceRequest, GetIdentityContractNonceResponse, GetIdentityKeysRequest, GetIdentityKeysResponse, GetIdentityNonceRequest, GetIdentityNonceResponse, GetIdentityRequest, GetIdentityResponse, GetPathElementsRequest, GetPathElementsResponse, GetPrefundedSpecializedBalanceRequest, GetPrefundedSpecializedBalanceResponse, GetProofsRequest, GetProofsResponse, GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, WaitForStateTransitionResultRequest, WaitForStateTransitionResultResponse, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse, GetContestedResourceIdentityVoteStatusRequest, GetContestedResourceIdentityVoteStatusResponse}; +use dapi_grpc::platform::v0::{ + BroadcastStateTransitionRequest, BroadcastStateTransitionResponse, GetConsensusParamsRequest, + GetConsensusParamsResponse, GetContestedResourceIdentityVoteStateRequest, + GetContestedResourceIdentityVoteStateResponse, GetContestedResourceIdentityVoteStatusRequest, + GetContestedResourceIdentityVoteStatusResponse, GetContestedResourceVoteStateRequest, + GetContestedResourceVoteStateResponse, GetContestedResourceVoteStatusRequest, + GetContestedResourceVoteStatusResponse, GetContestedResourceVotersForIdentityRequest, + GetContestedResourceVotersForIdentityResponse, GetContestedResourcesRequest, + GetContestedResourcesResponse, GetDataContractHistoryRequest, GetDataContractHistoryResponse, + GetDataContractRequest, GetDataContractResponse, GetDataContractsRequest, + GetDataContractsResponse, GetDocumentsRequest, GetDocumentsResponse, GetEpochsInfoRequest, + GetEpochsInfoResponse, GetIdentitiesContractKeysRequest, GetIdentitiesContractKeysResponse, + GetIdentityBalanceAndRevisionRequest, GetIdentityBalanceAndRevisionResponse, + GetIdentityBalanceRequest, GetIdentityBalanceResponse, GetIdentityByPublicKeyHashRequest, + GetIdentityByPublicKeyHashResponse, GetIdentityContractNonceRequest, + GetIdentityContractNonceResponse, GetIdentityKeysRequest, GetIdentityKeysResponse, + GetIdentityNonceRequest, GetIdentityNonceResponse, GetIdentityRequest, GetIdentityResponse, + GetPathElementsRequest, GetPathElementsResponse, GetPrefundedSpecializedBalanceRequest, + GetPrefundedSpecializedBalanceResponse, GetProofsRequest, GetProofsResponse, + GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, + GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, + WaitForStateTransitionResultRequest, WaitForStateTransitionResultResponse, +}; use dapi_grpc::tonic::{Request, Response, Status}; use dpp::version::PlatformVersion; use std::sync::atomic::Ordering; @@ -396,18 +418,27 @@ impl PlatformService for QueryService { Platform::::query_prefunded_specialized_balance, "get_contested_resource_vote_status", ) - .await + .await } - async fn get_contested_resource_vote_state(&self, request: Request) -> Result, Status> { + async fn get_contested_resource_vote_state( + &self, + request: Request, + ) -> Result, Status> { todo!() } - async fn get_contested_resource_voters_for_identity(&self, request: Request) -> Result, Status> { + async fn get_contested_resource_voters_for_identity( + &self, + request: Request, + ) -> Result, Status> { todo!() } - async fn get_contested_resource_identity_vote_status(&self, request: Request) -> Result, Status> { + async fn get_contested_resource_identity_vote_status( + &self, + request: Request, + ) -> Result, Status> { todo!() } @@ -420,7 +451,7 @@ impl PlatformService for QueryService { Platform::::query_prefunded_specialized_balance, "get_prefunded_specialized_balance", ) - .await + .await } } diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/mod.rs index ee6a44ce7d..21ae44f78d 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/mod.rs @@ -5,7 +5,9 @@ use crate::platform_types::platform_state::PlatformState; use crate::query::QueryValidationResult; use dapi_grpc::platform::v0::get_contested_resource_identity_vote_status_request::Version as RequestVersion; use dapi_grpc::platform::v0::get_contested_resource_identity_vote_status_response::Version as ResponseVersion; -use dapi_grpc::platform::v0::{GetContestedResourceIdentityVoteStatusRequest, GetContestedResourceIdentityVoteStatusResponse}; +use dapi_grpc::platform::v0::{ + GetContestedResourceIdentityVoteStatusRequest, GetContestedResourceIdentityVoteStatusResponse, +}; use dpp::version::PlatformVersion; mod v0; @@ -20,11 +22,17 @@ impl Platform { ) -> Result, Error> { let Some(version) = version else { return Ok(QueryValidationResult::new_with_error( - QueryError::DecodingError("could not decode contested resource vote state query".to_string()), + QueryError::DecodingError( + "could not decode contested resource vote state query".to_string(), + ), )); }; - let feature_version_bounds = &platform_version.drive_abci.query.voting_based_queries.contested_resource_identity_vote_status; + let feature_version_bounds = &platform_version + .drive_abci + .query + .voting_based_queries + .contested_resource_identity_vote_status; let feature_version = match &version { RequestVersion::V0(_) => 0, @@ -42,14 +50,18 @@ impl Platform { } match version { RequestVersion::V0(request_v0) => { - let result = - self.query_contested_resource_identity_vote_status_v0(request_v0, platform_state, platform_version)?; + let result = self.query_contested_resource_identity_vote_status_v0( + request_v0, + platform_state, + platform_version, + )?; - Ok(result.map(|response_v0| GetContestedResourceIdentityVoteStatusResponse { - version: Some(ResponseVersion::V0(response_v0)), - })) + Ok(result.map( + |response_v0| GetContestedResourceIdentityVoteStatusResponse { + version: Some(ResponseVersion::V0(response_v0)), + }, + )) } } } } - diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/v0/mod.rs index e69de29bb2..8b13789179 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/v0/mod.rs @@ -0,0 +1 @@ + diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/mod.rs index 0d15fad0e9..f72d1c3b8b 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/mod.rs @@ -5,7 +5,9 @@ use crate::platform_types::platform_state::PlatformState; use crate::query::QueryValidationResult; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::Version as RequestVersion; use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::Version as ResponseVersion; -use dapi_grpc::platform::v0::{GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse}; +use dapi_grpc::platform::v0::{ + GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, +}; use dpp::version::PlatformVersion; mod v0; @@ -21,11 +23,17 @@ impl Platform { ) -> Result, Error> { let Some(version) = version else { return Ok(QueryValidationResult::new_with_error( - QueryError::DecodingError("could not decode contested resource vote state query".to_string()), + QueryError::DecodingError( + "could not decode contested resource vote state query".to_string(), + ), )); }; - let feature_version_bounds = &platform_version.drive_abci.query.voting_based_queries.contested_resource_vote_state; + let feature_version_bounds = &platform_version + .drive_abci + .query + .voting_based_queries + .contested_resource_vote_state; let feature_version = match &version { RequestVersion::V0(_) => 0, @@ -43,14 +51,18 @@ impl Platform { } match version { RequestVersion::V0(request_v0) => { - let result = - self.query_contested_resource_vote_state_v0(request_v0, platform_state, platform_version)?; + let result = self.query_contested_resource_vote_state_v0( + request_v0, + platform_state, + platform_version, + )?; - Ok(result.map(|response_v0| GetContestedResourceVoteStateResponse { - version: Some(ResponseVersion::V0(response_v0)), - })) + Ok( + result.map(|response_v0| GetContestedResourceVoteStateResponse { + version: Some(ResponseVersion::V0(response_v0)), + }), + ) } } } } - diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs index 8aa9a65b02..bcc924203f 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs @@ -1,22 +1,31 @@ -use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::GetContestedResourceVoteStateRequestV0; -use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::GetContestedResourceVoteStateResponseV0; use crate::error::query::QueryError; use crate::error::Error; use crate::platform_types::platform::Platform; use crate::platform_types::platform_state::PlatformState; use crate::query::QueryValidationResult; +use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::GetContestedResourceVoteStateRequestV0; +use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::GetContestedResourceVoteStateResponseV0; use dpp::check_validation_result_with_data; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::identifier::Identifier; use dpp::validation::ValidationResult; use dpp::version::PlatformVersion; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use drive::error::query::QuerySyntaxError; impl Platform { pub(super) fn query_contested_resource_vote_status_v0( &self, - GetContestedResourceVoteStateRequestV0 { contract_id, document_type_name, index_name, index_values, include_documents, start_at_identifier_info, prove }: GetContestedResourceVoteStateRequestV0, + GetContestedResourceVoteStateRequestV0 { + contract_id, + document_type_name, + index_name, + index_values, + include_documents, + start_at_identifier_info, + prove, + }: GetContestedResourceVoteStateRequestV0, platform_state: &PlatformState, platform_version: &PlatformVersion, ) -> Result, Error> { @@ -50,24 +59,51 @@ impl Platform { document_type_name, contract_id )))); - let index = check_validation_result_with_data!(document_type.find_contested_index().ok_or(QueryError::InvalidArgument(format!( - "document type {} does not have a contested index", - document_type_name - )))); - + let index = check_validation_result_with_data!(document_type.find_contested_index().ok_or( + QueryError::InvalidArgument(format!( + "document type {} does not have a contested index", + document_type_name + )) + )); + if index.name != &index_name { return Ok(QueryValidationResult::new_with_error(QueryError::InvalidArgument(format!( "index with name {} is not the contested index on the document type {}, {} is the name of the only contested index", index_name, document_type_name, index.name )))); } - - let index = check_validation_result_with_data!(document_type - .inc (document_type_name.as_str()) - .map_err(|_| QueryError::InvalidArgument(format!( - "document type {} not found for contract {}", - document_type_name, contract_id - )))); + + let index_values = match index_values + .into_iter() + .enumerate() + .map(|(pos, serialized_value)| { + Ok(bincode::decode_from_slice( + serialized_value.as_slice(), + bincode::config::standard() + .with_big_endian() + .with_no_limit(), + ) + .map_err(|_| { + QueryError::InvalidArgument(format!( + "could not convert {:?} to a value in the index values at position {}", + serialized_value, pos + )) + })? + .0) + }) + .collect::, QueryError>>() + { + Ok(index_values) => index_values, + Err(e) => return Ok(QueryValidationResult::new_with_error(e)), + }; + + let vote_poll = ContestedDocumentResourceVotePoll { + contract_id, + document_type_name, + index_name, + index_values, + } + .into(); let response = if prove { let proof = check_validation_result_with_data!(self.drive.prove_identity_balance( @@ -96,11 +132,15 @@ impl Platform { }; GetContestedResourceVoteStateResponseV0 { - result: Some(get_contested_resource_vote_status_response_v0::Result::ContestedResourceVoters(balance)), + result: Some( + get_contested_resource_vote_status_response_v0::Result::ContestedResourceVoters( + balance, + ), + ), metadata: Some(self.response_metadata_v0(platform_state)), } }; Ok(QueryValidationResult::new_with_data(response)) } -} \ No newline at end of file +} diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/mod.rs index e2a47f888e..98039a5d3d 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/mod.rs @@ -5,7 +5,9 @@ use crate::platform_types::platform_state::PlatformState; use crate::query::QueryValidationResult; use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_request::Version as RequestVersion; use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_response::Version as ResponseVersion; -use dapi_grpc::platform::v0::{GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse}; +use dapi_grpc::platform::v0::{ + GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse, +}; use dpp::version::PlatformVersion; mod v0; @@ -20,11 +22,17 @@ impl Platform { ) -> Result, Error> { let Some(version) = version else { return Ok(QueryValidationResult::new_with_error( - QueryError::DecodingError("could not decode contested resource vote state query".to_string()), + QueryError::DecodingError( + "could not decode contested resource vote state query".to_string(), + ), )); }; - let feature_version_bounds = &platform_version.drive_abci.query.voting_based_queries.contested_resource_voters_for_identity; + let feature_version_bounds = &platform_version + .drive_abci + .query + .voting_based_queries + .contested_resource_voters_for_identity; let feature_version = match &version { RequestVersion::V0(_) => 0, @@ -42,14 +50,18 @@ impl Platform { } match version { RequestVersion::V0(request_v0) => { - let result = - self.query_contested_resource_voters_for_identity_v0(request_v0, platform_state, platform_version)?; + let result = self.query_contested_resource_voters_for_identity_v0( + request_v0, + platform_state, + platform_version, + )?; - Ok(result.map(|response_v0| GetContestedResourceVotersForIdentityResponse { - version: Some(ResponseVersion::V0(response_v0)), - })) + Ok(result.map( + |response_v0| GetContestedResourceVotersForIdentityResponse { + version: Some(ResponseVersion::V0(response_v0)), + }, + )) } } } } - diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/v0/mod.rs index e69de29bb2..8b13789179 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/v0/mod.rs @@ -0,0 +1 @@ + diff --git a/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs index d351cabc3f..07872885fe 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs @@ -5,7 +5,9 @@ use crate::platform_types::platform_state::PlatformState; use crate::query::QueryValidationResult; use dapi_grpc::platform::v0::get_contested_resources_request::Version as RequestVersion; use dapi_grpc::platform::v0::get_contested_resources_response::Version as ResponseVersion; -use dapi_grpc::platform::v0::{GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse}; +use dapi_grpc::platform::v0::{ + GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse, +}; use dpp::version::PlatformVersion; mod v0; @@ -20,11 +22,17 @@ impl Platform { ) -> Result, Error> { let Some(version) = version else { return Ok(QueryValidationResult::new_with_error( - QueryError::DecodingError("could not decode contested resource vote state query".to_string()), + QueryError::DecodingError( + "could not decode contested resource vote state query".to_string(), + ), )); }; - let feature_version_bounds = &platform_version.drive_abci.query.voting_based_queries.contested_resources; + let feature_version_bounds = &platform_version + .drive_abci + .query + .voting_based_queries + .contested_resources; let feature_version = match &version { RequestVersion::V0(_) => 0, @@ -42,14 +50,18 @@ impl Platform { } match version { RequestVersion::V0(request_v0) => { - let result = - self.query_contested_resources_v0(request_v0, platform_state, platform_version)?; + let result = self.query_contested_resources_v0( + request_v0, + platform_state, + platform_version, + )?; - Ok(result.map(|response_v0| GetContestedResourceVotersForIdentityResponse { - version: Some(ResponseVersion::V0(response_v0)), - })) + Ok(result.map( + |response_v0| GetContestedResourceVotersForIdentityResponse { + version: Some(ResponseVersion::V0(response_v0)), + }, + )) } } } } - diff --git a/packages/rs-drive-abci/src/query/voting/contested_resources/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resources/v0/mod.rs index e69de29bb2..8b13789179 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resources/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resources/v0/mod.rs @@ -0,0 +1 @@ + diff --git a/packages/rs-drive-abci/src/query/voting/mod.rs b/packages/rs-drive-abci/src/query/voting/mod.rs index 5065a5daa8..e9aa1a2376 100644 --- a/packages/rs-drive-abci/src/query/voting/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/mod.rs @@ -1,4 +1,4 @@ mod contested_resource_identity_vote_status; mod contested_resource_vote_state; -mod contested_resources; mod contested_resource_voters_for_identity; +mod contested_resources; diff --git a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/v0/mod.rs b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/v0/mod.rs index 4dcb5e79cb..c4a249766b 100644 --- a/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/estimation_costs/add_estimation_costs_for_add_contested_document_to_primary_storage/v0/mod.rs @@ -8,7 +8,6 @@ use crate::drive::Drive; use crate::error::Error; -use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; use dpp::version::PlatformVersion; diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs index 0d17e2ed69..52fb52f48d 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs @@ -8,7 +8,6 @@ use crate::error::Error; use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; -use dpp::identifier::Identifier; use dpp::version::PlatformVersion; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs index 687064bfca..f32b71345e 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs @@ -1,16 +1,8 @@ -use crate::drive::document::paths::contract_documents_primary_key_path; -use crate::drive::grove_operations::DirectQueryType::{StatefulDirectQuery, StatelessDirectQuery}; -use crate::drive::grove_operations::QueryTarget::QueryTargetValue; -use crate::drive::object_size_info::{DocumentAndContractInfo, DocumentInfoV0Methods}; +use crate::drive::object_size_info::DocumentAndContractInfo; use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; -use dpp::data_contract::accessors::v0::DataContractV0Getters; -use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; -use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; - -use crate::drive::votes::paths::vote_contested_resource_contract_documents_primary_key_path; use dpp::version::PlatformVersion; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::voting::vote_polls::VotePoll; diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/mod.rs index 64ed61ce32..2d56c3b211 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/mod.rs @@ -1,7 +1,5 @@ mod v0; -use dpp::block::block_info::BlockInfo; - use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/v0/mod.rs index 7476724981..a3e76b226f 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/v0/mod.rs @@ -12,34 +12,25 @@ use crate::drive::object_size_info::DocumentInfo::{ DocumentRefAndSerialization, DocumentRefInfo, }; +use crate::drive::object_size_info::DocumentAndContractInfo; use crate::drive::object_size_info::PathKeyElementInfo::{ PathFixedSizeKeyRefElement, PathKeyUnknownElementSize, }; -use crate::drive::object_size_info::PathKeyInfo::{PathFixedSizeKeyRef, PathKeySize}; -use crate::drive::object_size_info::{DocumentAndContractInfo, DocumentInfoV0Methods}; use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; +use crate::drive::grove_operations::BatchInsertApplyType; use crate::drive::grove_operations::QueryTarget::QueryTargetValue; -use crate::drive::grove_operations::{BatchInsertApplyType, BatchInsertTreeApplyType}; -use dpp::block::block_info::BlockInfo; use dpp::data_contract::accessors::v0::DataContractV0Getters; -use dpp::data_contract::config::v0::DataContractConfigGettersV0; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use dpp::document::DocumentV0Getters; -use crate::drive::document::paths::{ - contract_documents_keeping_history_primary_key_path_for_document_id, - contract_documents_keeping_history_primary_key_path_for_unknown_document_id, - contract_documents_keeping_history_storage_time_reference_path_size, - contract_documents_primary_key_path, -}; -use crate::drive::votes::paths::vote_contested_resource_contract_documents_primary_key_path; +use crate::drive::votes::paths::vote_contested_resource_contract_documents_storage_path; use dpp::version::PlatformVersion; impl Drive { @@ -60,7 +51,7 @@ impl Drive { let drive_version = &platform_version.drive; let contract = document_and_contract_info.contract; let document_type = document_and_contract_info.document_type; - let primary_key_path = vote_contested_resource_contract_documents_primary_key_path( + let primary_key_path = vote_contested_resource_contract_documents_storage_path( contract.id_ref().as_bytes(), document_type.name().as_str(), ); diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs index a8255cbe1c..6700e4d2c3 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs @@ -11,18 +11,17 @@ use crate::fee::op::LowLevelDriveOperation; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; -use crate::drive::defaults::{CONTESTED_DOCUMENT_REFERENCE_SIZE, DEFAULT_HASH_SIZE_U8, U8_SIZE_U8}; +use crate::drive::defaults::DEFAULT_HASH_SIZE_U8; use crate::drive::votes::paths::vote_contested_resource_active_polls_contract_document_tree_path_vec; use crate::error::drive::DriveError; use dpp::data_contract::document_type::IndexProperty; use dpp::version::PlatformVersion; use grovedb::batch::KeyInfoPath; use grovedb::EstimatedLayerCount::{ApproximateElements, PotentiallyAtMaxElements}; -use grovedb::EstimatedLayerSizes::{AllSubtrees, Mix}; -use grovedb::EstimatedSumTrees::{AllSumTrees, NoSumTrees}; +use grovedb::EstimatedLayerSizes::AllSubtrees; +use grovedb::EstimatedSumTrees::NoSumTrees; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; -use crate::drive::document::document_reference_size; impl Drive { /// Adds indices for the top index level and calls for lower levels. @@ -198,19 +197,26 @@ impl Drive { batch_operations, drive_version, )?; - + index_path_info.push(DriveKeyInfo::Key(owner_id.to_vec()))?; // Inter-wizard championship (event type) // | - // Goblet of Fire (event name) + // Goblet of Fire (event name) // / \ - // Sam's ID Ivan's ID <---- We just inserted this + // Sam's ID Ivan's ID <---- We just inserted this // / \ / \ // 0 (ref) 1 (sum tree) 0 (ref) 1 (sum tree) <---- We now need to insert at this level // - - self.add_contested_reference_and_vote_subtree_to_document_operations(document_and_contract_info, index_path_info, storage_flags, estimated_costs_only_with_layer_info, transaction, batch_operations, drive_version) - + + self.add_contested_reference_and_vote_subtree_to_document_operations( + document_and_contract_info, + index_path_info, + storage_flags, + estimated_costs_only_with_layer_info, + transaction, + batch_operations, + drive_version, + ) } } diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs index 85bb92bbb6..daa30b673c 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs @@ -11,7 +11,6 @@ use dpp::version::drive_versions::DriveVersion; use grovedb::batch::KeyInfoPath; -use dpp::data_contract::document_type::IndexType; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs index 470d21118a..885d338e3a 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -1,15 +1,15 @@ -use crate::drive::defaults::{CONTESTED_DOCUMENT_REFERENCE_SIZE, DEFAULT_HASH_SIZE_U8, STORAGE_FLAGS_SIZE, U8_SIZE_U32, U8_SIZE_U8}; -use crate::drive::document::{ - document_reference_size, make_document_contested_reference, make_document_reference, +use crate::drive::defaults::{ + CONTESTED_DOCUMENT_REFERENCE_SIZE, DEFAULT_HASH_SIZE_U8, STORAGE_FLAGS_SIZE, U8_SIZE_U32, + U8_SIZE_U8, }; +use crate::drive::document::make_document_contested_reference; use crate::drive::flags::StorageFlags; -use crate::drive::grove_operations::QueryTarget::QueryTargetValue; -use crate::drive::grove_operations::{BatchInsertApplyType, BatchInsertTreeApplyType}; +use crate::drive::grove_operations::BatchInsertTreeApplyType; use crate::drive::object_size_info::DocumentInfo::{ DocumentAndSerialization, DocumentEstimatedAverageSize, DocumentOwnedInfo, DocumentRefAndSerialization, DocumentRefInfo, }; -use crate::drive::object_size_info::DriveKeyInfo::{Key, KeyRef}; +use crate::drive::object_size_info::DriveKeyInfo::KeyRef; use crate::drive::object_size_info::KeyElementInfo::{KeyElement, KeyUnknownElementSize}; use crate::drive::object_size_info::{DocumentAndContractInfo, PathInfo, PathKeyElementInfo}; use crate::drive::Drive; @@ -17,13 +17,12 @@ use crate::error::drive::DriveError; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; -use dpp::document::DocumentV0Getters; use dpp::version::drive_versions::DriveVersion; use grovedb::batch::key_info::KeyInfo; use grovedb::batch::KeyInfoPath; use grovedb::EstimatedLayerCount::{ApproximateElements, PotentiallyAtMaxElements}; -use grovedb::EstimatedLayerSizes::{AllItems, AllReference, AllSubtrees, Mix}; -use grovedb::EstimatedSumTrees::{AllSumTrees, NoSumTrees}; +use grovedb::EstimatedLayerSizes::{AllItems, Mix}; +use grovedb::EstimatedSumTrees::AllSumTrees; use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; @@ -44,7 +43,7 @@ impl Drive { ) -> Result<(), Error> { // Inter-wizard championship (event type) // | - // Goblet of Fire (event name) + // Goblet of Fire (event name) // / \ // Sam's ID Ivan's ID // / \ / \ @@ -60,22 +59,28 @@ impl Drive { estimated_layer_count: ApproximateElements(2), estimated_layer_sizes: Mix { // The votes don't have storage flags - subtrees_size: Some((U8_SIZE_U8, - AllSumTrees, // There is 1 tree that is a sum tree, so all are sum trees - None, 1)), + subtrees_size: Some(( + U8_SIZE_U8, + AllSumTrees, // There is 1 tree that is a sum tree, so all are sum trees + None, + 1, + )), items_size: None, // The references do have storage flags // We keep storage flags because when the item is moved after being won, - // a transformation needs to take place on the storage flags to be able to + // a transformation needs to take place on the storage flags to be able to // allow the refund of credits on delete later. - references_size: Some((U8_SIZE_U8, - CONTESTED_DOCUMENT_REFERENCE_SIZE, - storage_flags.map(|s| s.serialized_size()), 1)), + references_size: Some(( + U8_SIZE_U8, + CONTESTED_DOCUMENT_REFERENCE_SIZE, + storage_flags.map(|s| s.serialized_size()), + 1, + )), }, }, ); } - + // We create the reference // Here we are getting the document id and the reference @@ -100,18 +105,18 @@ impl Drive { DocumentEstimatedAverageSize(max_size) => { let unique_id = document_and_contract_info .document_type - .unique_id_for_storage().to_vec(); - KeyUnknownElementSize(( - KeyInfo::MaxKeySize { - unique_id, - max_size: DEFAULT_HASH_SIZE_U8, - }, - Element::required_item_space(*max_size, STORAGE_FLAGS_SIZE), - )) - + .unique_id_for_storage() + .to_vec(); + KeyUnknownElementSize(( + KeyInfo::MaxKeySize { + unique_id, + max_size: DEFAULT_HASH_SIZE_U8, + }, + Element::required_item_space(*max_size, STORAGE_FLAGS_SIZE), + )) } }; - + // Now let's insert the reference, the reference is a key element that already has the 0 let reference_path_key_element_info = PathKeyElementInfo::from_path_info_and_key_element( @@ -139,11 +144,7 @@ impl Drive { EstimatedLayerInformation { is_sum_tree: true, estimated_layer_count: PotentiallyAtMaxElements, - estimated_layer_sizes: AllItems( - DEFAULT_HASH_SIZE_U8, - U8_SIZE_U32, - None, - ), + estimated_layer_sizes: AllItems(DEFAULT_HASH_SIZE_U8, U8_SIZE_U32, None), }, ); } diff --git a/packages/rs-drive/src/drive/document/mod.rs b/packages/rs-drive/src/drive/document/mod.rs index 27c0c91c88..aee30c8a9c 100644 --- a/packages/rs-drive/src/drive/document/mod.rs +++ b/packages/rs-drive/src/drive/document/mod.rs @@ -7,7 +7,6 @@ #[cfg(feature = "server")] use crate::drive::flags::StorageFlags; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; -use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; #[cfg(any(feature = "server", feature = "verify"))] use dpp::data_contract::document_type::DocumentTypeRef; #[cfg(feature = "server")] diff --git a/packages/rs-drive/src/drive/document/query/mod.rs b/packages/rs-drive/src/drive/document/query/mod.rs index 136092c5d6..60c0b0353a 100644 --- a/packages/rs-drive/src/drive/document/query/mod.rs +++ b/packages/rs-drive/src/drive/document/query/mod.rs @@ -1,38 +1,11 @@ -// MIT LICENSE -// -// Copyright (c) 2021 Dash Core Group -// -// Permission is hereby granted, free of charge, to any -// person obtaining a copy of this software and associated -// documentation files (the "Software"), to deal in the -// Software without restriction, including without -// limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software -// is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice -// shall be included in all copies or substantial portions -// of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// - //! Drive Queries //! //! Defines and implements in Drive functions relevant to querying. //! +mod query_contested_documents_vote_state; mod query_documents; + pub use query_documents::*; #[cfg(all(feature = "fixtures-and-mocks", feature = "cbor_query"))] diff --git a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs new file mode 100644 index 0000000000..13c130ed91 --- /dev/null +++ b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs @@ -0,0 +1,93 @@ +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use derive_more::From; +use dpp::block::epoch::Epoch; +use dpp::document::Document; +use dpp::version::{PlatformVersion, PlatformVersionCurrentVersion}; +use grovedb::TransactionArg; + +mod v0; + +use crate::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQuery; +pub use v0::*; + +/// Represents the outcome of a query to retrieve documents. +/// +/// This enum provides versioning for the outcomes of querying documents. +/// As the system evolves, new versions of the outcome structure can be +/// added to this enum without breaking existing implementations. +#[derive(From, Debug)] +pub enum QueryContestedDocumentsVoteStateOutcome { + /// Version 0 of the `QueryDocumentsOutcome`. + /// + /// This version contains a list of documents retrieved, the number of + /// skipped documents, and the cost associated with the query. + V0(QueryContestedDocumentsVoteStateOutcomeV0), +} + +impl QueryContestedDocumentsVoteStateOutcomeV0Methods for QueryContestedDocumentsVoteStateOutcome { + fn documents(&self) -> &Vec { + match self { + QueryContestedDocumentsVoteStateOutcome::V0(outcome) => outcome.documents(), + } + } + + fn documents_owned(self) -> Vec { + match self { + QueryContestedDocumentsVoteStateOutcome::V0(outcome) => outcome.documents_owned(), + } + } + + fn cost(&self) -> u64 { + match self { + QueryContestedDocumentsVoteStateOutcome::V0(outcome) => outcome.cost(), + } + } +} + +impl Drive { + /// Performs a specified drive query and returns the result, along with any skipped items and the cost. + /// + /// This function is used to execute a given [DriveQuery]. It has options to operate in a dry-run mode + /// and supports different protocol versions. In case an epoch is specified, it calculates the fee. + /// + /// # Arguments + /// + /// * `query` - The [DriveQuery] being executed. + /// * `epoch` - An `Option<&Epoch>`. If provided, it will be used to calculate the processing fee. + /// * `dry_run` - If true, the function will not perform any actual operation and return a default `QueryDocumentsOutcome`. + /// * `transaction` - The `TransactionArg` holding the transaction data. + /// * `protocol_version` - An `Option` representing the protocol version. If not provided, the function falls back + /// to current or latest version. + /// + /// # Returns + /// + /// * `Result` - Returns `QueryDocumentsOutcome` on success with the list of documents, + /// number of skipped items, and cost. If the operation fails, it returns an `Error`. + pub fn query_contested_documents_vote_state( + &self, + query: ContestedDocumentVotePollDriveQuery, + epoch: Option<&Epoch>, + transaction: TransactionArg, + protocol_version: Option, + ) -> Result { + let platform_version = PlatformVersion::get_version_or_current_or_latest(protocol_version)?; + + match platform_version + .drive + .methods + .document + .query + .query_documents + { + 0 => self.query_contested_documents_v0(query, epoch, transaction, platform_version), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "query_documents".to_string(), + known_versions: vec![0], + received: version, + })), + } + .map(|outcome| outcome.into()) + } +} diff --git a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs new file mode 100644 index 0000000000..dff9e47f8f --- /dev/null +++ b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs @@ -0,0 +1,104 @@ +use crate::drive::Drive; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use crate::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQuery; +use dpp::block::epoch::Epoch; +use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; +use dpp::document::Document; +use dpp::version::PlatformVersion; +use dpp::ProtocolError; +use grovedb::TransactionArg; + +/// The outcome of a query +#[derive(Debug, Default)] +pub struct QueryContestedDocumentsVoteStateOutcomeV0 { + documents: Vec, + cost: u64, +} + +/// Trait defining methods associated with `QueryDocumentsOutcomeV0`. +/// +/// This trait provides a set of methods to interact with and retrieve +/// details from an instance of `QueryDocumentsOutcomeV0`. These methods +/// include retrieving the documents, skipped count, and the associated cost +/// of the query. +pub trait QueryContestedDocumentsVoteStateOutcomeV0Methods { + /// Returns a reference to the documents found from the query. + fn documents(&self) -> &Vec; + /// Consumes the instance to return the owned documents. + fn documents_owned(self) -> Vec; + /// Returns the processing cost associated with the query. + fn cost(&self) -> u64; +} + +impl QueryContestedDocumentsVoteStateOutcomeV0Methods + for QueryContestedDocumentsVoteStateOutcomeV0 +{ + fn documents(&self) -> &Vec { + &self.documents + } + + fn documents_owned(self) -> Vec { + self.documents + } + + fn cost(&self) -> u64 { + self.cost + } +} + +impl Drive { + /// Performs a specified drive query and returns the result, along with any skipped items and the cost. + /// + /// This function is used to execute a given [DriveQuery]. It has options to operate in a dry-run mode + /// and supports different protocol versions. In case an epoch is specified, it calculates the fee. + /// + /// # Arguments + /// + /// * `query` - The [DriveQuery] being executed. + /// * `epoch` - An `Option<&Epoch>`. If provided, it will be used to calculate the processing fee. + /// * `dry_run` - If true, the function will not perform any actual operation and return a default `QueryDocumentsOutcome`. + /// * `transaction` - The `TransactionArg` holding the transaction data. + /// * `platform_version` - A reference to the `PlatformVersion` object specifying the version of functions to call. + /// + /// # Returns + /// + /// * `Result` - Returns `QueryDocumentsOutcome` on success with the list of documents, + /// number of skipped items, and cost. If the operation fails, it returns an `Error`. + #[inline(always)] + pub(super) fn query_contested_documents_v0( + &self, + query: ContestedDocumentVotePollDriveQuery, + epoch: Option<&Epoch>, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + let mut drive_operations: Vec = vec![]; + let (items, skipped) = query.execute_raw_results_no_proof_internal( + self, + transaction, + &mut drive_operations, + platform_version, + )?; + let documents = items + .into_iter() + .map(|serialized| { + Document::from_bytes(serialized.as_slice(), query.document_type, platform_version) + }) + .collect::, ProtocolError>>()?; + let cost = if let Some(epoch) = epoch { + let fee_result = Drive::calculate_fee( + None, + Some(drive_operations), + epoch, + self.config.epochs_per_era, + platform_version, + )?; + fee_result.processing_fee + } else { + 0 + }; + + Ok(QueryContestedDocumentsVoteStateOutcomeV0 { documents, cost }) + } +} diff --git a/packages/rs-drive/src/drive/document/query/query_documents/mod.rs b/packages/rs-drive/src/drive/document/query/query_documents/mod.rs index ca35f3a5e4..7c9b72f0a4 100644 --- a/packages/rs-drive/src/drive/document/query/query_documents/mod.rs +++ b/packages/rs-drive/src/drive/document/query/query_documents/mod.rs @@ -2,6 +2,7 @@ use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; use crate::query::DriveQuery; +use derive_more::From; use dpp::block::epoch::Epoch; use dpp::document::Document; use dpp::version::{PlatformVersion, PlatformVersionCurrentVersion}; @@ -16,6 +17,7 @@ pub use v0::*; /// This enum provides versioning for the outcomes of querying documents. /// As the system evolves, new versions of the outcome structure can be /// added to this enum without breaking existing implementations. +#[derive(From, Debug)] pub enum QueryDocumentsOutcome { /// Version 0 of the `QueryDocumentsOutcome`. /// diff --git a/packages/rs-drive/src/drive/document/query/query_documents/v0/mod.rs b/packages/rs-drive/src/drive/document/query/query_documents/v0/mod.rs index 03494ae8c4..0dcd0d79f0 100644 --- a/packages/rs-drive/src/drive/document/query/query_documents/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/query/query_documents/v0/mod.rs @@ -1,4 +1,3 @@ -use crate::drive::document::query::query_documents::QueryDocumentsOutcome; use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; @@ -53,12 +52,6 @@ impl QueryDocumentsOutcomeV0Methods for QueryDocumentsOutcomeV0 { } } -impl From for QueryDocumentsOutcome { - fn from(val: QueryDocumentsOutcomeV0) -> Self { - QueryDocumentsOutcome::V0(val) - } -} - impl Drive { /// Performs a specified drive query and returns the result, along with any skipped items and the cost. /// diff --git a/packages/rs-drive/src/drive/object_size_info/path_key_info.rs b/packages/rs-drive/src/drive/object_size_info/path_key_info.rs index e19a493290..508d57dd24 100644 --- a/packages/rs-drive/src/drive/object_size_info/path_key_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/path_key_info.rs @@ -1,7 +1,6 @@ use crate::drive::object_size_info::path_key_info::PathKeyInfo::{ PathFixedSizeKey, PathFixedSizeKeyRef, PathKey, PathKeyRef, PathKeySize, }; -use crate::drive::object_size_info::PathInfo; use crate::error::drive::DriveError; use crate::error::Error; use grovedb::batch::key_info::KeyInfo; diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs index 61f678a375..2fedbc538a 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/estimation_costs/for_prefunded_specialized_balance_update/v0/mod.rs @@ -1,11 +1,11 @@ use crate::drive::Drive; use grovedb::batch::KeyInfoPath; -use grovedb::EstimatedLayerCount::{ApproximateElements, EstimatedLevel, PotentiallyAtMaxElements}; +use grovedb::EstimatedLayerCount::{EstimatedLevel, PotentiallyAtMaxElements}; use grovedb::EstimatedLayerInformation; use grovedb::EstimatedLayerSizes::{AllItems, AllSubtrees}; -use crate::drive::defaults::{AVERAGE_BALANCE_SIZE, DEFAULT_HASH_SIZE_U8, U64_SIZE_U8}; +use crate::drive::defaults::{AVERAGE_BALANCE_SIZE, DEFAULT_HASH_SIZE_U8}; use crate::drive::prefunded_specialized_balances::{ prefunded_specialized_balances_for_voting_path_vec, prefunded_specialized_balances_path, }; diff --git a/packages/rs-drive/src/drive/shared_estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/v0/mod.rs b/packages/rs-drive/src/drive/shared_estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/v0/mod.rs index 4d22eb9e46..f5fd811e43 100644 --- a/packages/rs-drive/src/drive/shared_estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/v0/mod.rs +++ b/packages/rs-drive/src/drive/shared_estimation_costs/add_estimation_costs_for_contested_document_tree_levels_up_to_contract/v0/mod.rs @@ -3,15 +3,13 @@ use crate::drive::defaults::{ ESTIMATED_AVERAGE_INDEX_NAME_SIZE, }; -use crate::drive::flags::StorageFlags; -use crate::drive::{contract_documents_path, Drive}; +use crate::drive::Drive; use grovedb::batch::KeyInfoPath; use grovedb::EstimatedLayerCount::{ApproximateElements, EstimatedLevel, PotentiallyAtMaxElements}; use grovedb::EstimatedLayerInformation; use grovedb::EstimatedLayerSizes::AllSubtrees; -use crate::drive::object_size_info::DocumentAndContractInfo; use crate::drive::votes::paths::{ vote_contested_resource_active_polls_contract_document_tree_path, vote_contested_resource_active_polls_contract_tree_path, diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs index b4a4b2a946..d7fab10e7e 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs @@ -9,7 +9,6 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; -use dpp::identifier::Identifier; use dpp::prelude::TimestampMillis; use dpp::version::PlatformVersion; use dpp::voting::vote_polls::VotePoll; diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs index a1e8faecda..04a09d5c76 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs @@ -1,6 +1,5 @@ use crate::drive::defaults::{ - AVERAGE_CONTESTED_RESOURCE_ITEM_REFERENCE_SIZE, DEFAULT_HASH_SIZE_U8, - ESTIMATED_AVERAGE_DOCUMENT_TYPE_NAME_SIZE, U64_SIZE_U8, + AVERAGE_CONTESTED_RESOURCE_ITEM_REFERENCE_SIZE, DEFAULT_HASH_SIZE_U8, U64_SIZE_U8, }; use crate::drive::flags::StorageFlags; use crate::drive::grove_operations::QueryTarget::QueryTargetValue; @@ -8,7 +7,6 @@ use crate::drive::grove_operations::{BatchInsertApplyType, BatchInsertTreeApplyT use crate::drive::object_size_info::PathKeyElementInfo::{PathKeyElementSize, PathKeyRefElement}; use crate::drive::object_size_info::{DriveKeyInfo, PathInfo, PathKeyElementInfo}; use crate::drive::votes::paths::{ - vote_contested_resource_active_polls_contract_tree_path, vote_contested_resource_end_date_queries_at_time_tree_path_vec, vote_contested_resource_end_date_queries_tree_path, vote_contested_resource_end_date_queries_tree_path_vec, @@ -17,7 +15,6 @@ use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; -use dpp::identifier::Identifier; use dpp::identity::TimestampMillis; use dpp::serialization::PlatformSerializable; use dpp::voting::vote_polls::VotePoll; diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index a4a48235d6..16e02c2fcb 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -21,6 +21,9 @@ pub mod paths; #[cfg(feature = "server")] mod setup; +#[cfg(any(feature = "server", feature = "verify"))] +pub mod resolve_contested_document_resource_vote_poll; + /// A trait to convert the vote to a tree path usable in grovedb pub trait TreePath { /// The tree path function diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index 48edcc37d4..5134a6eab9 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -1,5 +1,12 @@ +use crate::drive::votes::resolve_contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use crate::drive::RootTree; +use crate::error::Error; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; +use dpp::data_contract::document_type::IndexProperty; +use dpp::identifier::Identifier; use dpp::identity::TimestampMillis; +use platform_version::version::PlatformVersion; /// The votes tree structure looks like this /// @@ -28,6 +35,120 @@ pub const ACTIVE_POLLS_TREE_KEY: char = 'p'; /// A subtree made for being able to query votes that an identity has made pub const IDENTITY_VOTES_TREE_KEY: char = 'i'; +/// Convenience methods to be easily able to get a path when we know the vote poll +pub trait VotePollPaths { + /// The root path, under this there should be the documents area and the contract itself + fn contract_path(&self) -> [&[u8]; 4]; + + /// The root path, under this there should be the documents area and the contract itself as a vec + fn contract_path_vec(&self) -> Vec>; + + /// The documents path, under this you should have the various document types + fn document_type_path(&self) -> [&[u8]; 5]; + + /// The documents path, under this you should have the various document types as a vec + fn document_type_path_vec(&self) -> Vec>; + + /// The documents storage path + fn documents_storage_path(&self) -> [&[u8]; 6]; + + /// The documents storage path as a vec + fn documents_storage_path_vec(&self) -> Vec>; + + /// The contenders path as a vec + fn contenders_path(&self, platform_version: &PlatformVersion) -> Result>, Error>; + + /// The path that would store the contender information for a single contender + fn contender_path( + &self, + identity_id: Identifier, + platform_version: &PlatformVersion, + ) -> Result>, Error>; + + /// The path that would store the votes for a single contender + fn contender_voting_path( + &self, + identity_id: Identifier, + platform_version: &PlatformVersion, + ) -> Result>, Error>; +} + +impl VotePollPaths for ContestedDocumentResourceVotePollWithContractInfo { + fn contract_path(&self) -> [&[u8]; 4] { + vote_contested_resource_active_polls_contract_tree_path( + self.contract.contract.id_ref().as_slice(), + ) + } + + fn contract_path_vec(&self) -> Vec> { + vote_contested_resource_active_polls_contract_tree_path_vec( + self.contract.contract.id_ref().as_slice(), + ) + } + + fn document_type_path(&self) -> [&[u8]; 5] { + vote_contested_resource_active_polls_contract_document_tree_path( + self.contract.contract.id_ref().as_slice(), + self.document_type_name.as_str(), + ) + } + + fn document_type_path_vec(&self) -> Vec> { + vote_contested_resource_active_polls_contract_document_tree_path_vec( + self.contract.contract.id_ref().as_slice(), + self.document_type_name.as_str(), + ) + } + + fn documents_storage_path(&self) -> [&[u8]; 6] { + vote_contested_resource_contract_documents_storage_path( + self.contract.contract.id_ref().as_slice(), + self.document_type_name.as_str(), + ) + } + + fn documents_storage_path_vec(&self) -> Vec> { + vote_contested_resource_contract_documents_storage_path_vec( + self.contract.contract.id_ref().as_slice(), + self.document_type_name.as_str(), + ) + } + + fn contenders_path(&self, platform_version: &PlatformVersion) -> Result>, Error> { + let document_type = self.document_type()?; + self.index()? + .properties + .iter() + .zip(self.index_values.iter()) + .map(|(IndexProperty { name, .. }, value)| { + document_type + .serialize_value_for_key(name, value, platform_version) + .map_err(Error::Protocol) + }) + .collect::>, Error>>() + } + + fn contender_path( + &self, + identity_id: Identifier, + platform_version: &PlatformVersion, + ) -> Result>, Error> { + let mut contenders_path = self.contenders_path(platform_version)?; + contenders_path.push(identity_id.to_vec()); + Ok(contenders_path) + } + + fn contender_voting_path( + &self, + identity_id: Identifier, + platform_version: &PlatformVersion, + ) -> Result>, Error> { + let mut contender_path = self.contender_path(identity_id, platform_version)?; + contender_path.push(vec![1]); + Ok(contender_path) + } +} + /// the root path of the voting branch pub fn vote_root_path<'a>() -> [&'a [u8]; 1] { [Into::<&[u8; 1]>::into(RootTree::Votes)] @@ -106,8 +227,7 @@ pub fn vote_contested_resource_active_polls_tree_path_vec() -> Vec> { ] } -#[cfg(feature = "server")] -/// Returns the path to the primary keys of a contract document type. +/// Returns the path to root of a contract in the contested resource active polls. pub fn vote_contested_resource_active_polls_contract_tree_path(contract_id: &[u8]) -> [&[u8]; 4] { [ Into::<&[u8; 1]>::into(RootTree::Votes), // 1 @@ -117,7 +237,18 @@ pub fn vote_contested_resource_active_polls_contract_tree_path(contract_id: &[u8 ] } -#[cfg(feature = "server")] +/// Returns the path to root of a contract in the contested resource active polls. +pub fn vote_contested_resource_active_polls_contract_tree_path_vec( + contract_id: &[u8], +) -> Vec> { + vec![ + vec![RootTree::Votes as u8], + vec![CONTESTED_RESOURCE_TREE_KEY as u8], + vec![ACTIVE_POLLS_TREE_KEY as u8], + contract_id.to_vec(), + ] +} + /// Returns the path to the primary keys of a contract document type. pub fn vote_contested_resource_active_polls_contract_document_tree_path<'a>( contract_id: &'a [u8], @@ -132,7 +263,6 @@ pub fn vote_contested_resource_active_polls_contract_document_tree_path<'a>( ] } -#[cfg(feature = "server")] /// Returns the path to the root of document type in the contested tree pub fn vote_contested_resource_active_polls_contract_document_tree_path_vec( contract_id: &[u8], @@ -147,9 +277,8 @@ pub fn vote_contested_resource_active_polls_contract_document_tree_path_vec( ] } -#[cfg(feature = "server")] /// Returns the path to the primary keys of a contract document type. -pub fn vote_contested_resource_contract_documents_primary_key_path<'a>( +pub fn vote_contested_resource_contract_documents_storage_path<'a>( contract_id: &'a [u8], document_type_name: &'a str, ) -> [&'a [u8]; 6] { @@ -163,9 +292,8 @@ pub fn vote_contested_resource_contract_documents_primary_key_path<'a>( ] } -#[cfg(feature = "server")] /// Returns the path to the primary keys of a contract document type as a vec. -pub fn vote_contested_resource_active_polls_contract_documents_primary_key_path_vec( +pub fn vote_contested_resource_contract_documents_storage_path_vec( contract_id: &[u8], document_type_name: &str, ) -> Vec> { diff --git a/packages/rs-drive/src/drive/votes/resolve_contested_document_resource_vote_poll/mod.rs b/packages/rs-drive/src/drive/votes/resolve_contested_document_resource_vote_poll/mod.rs new file mode 100644 index 0000000000..cb06dd5124 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/resolve_contested_document_resource_vote_poll/mod.rs @@ -0,0 +1,75 @@ +use crate::drive::contract::DataContractFetchInfo; +use crate::drive::Drive; +use crate::error::contract::DataContractError; +use crate::error::drive::DriveError; +use crate::error::Error; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::data_contract::document_type::{DocumentType, DocumentTypeRef, Index}; +use dpp::platform_value::Value; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::ProtocolError; +use grovedb::TransactionArg; +use platform_version::version::PlatformVersion; +use std::sync::Arc; + +#[derive(Debug, PartialEq)] +pub struct ContestedDocumentResourceVotePollWithContractInfo { + pub contract: Arc, + pub document_type_name: String, + pub index_name: String, + pub index_values: Vec, +} + +impl ContestedDocumentResourceVotePollWithContractInfo { + pub fn index(&self) -> Result<&Index, Error> { + self.contract.contract.document_type_borrowed_for_name(self.document_type_name.as_str())?.indexes().get(&self.index_name).ok_or(Error::Drive(DriveError::ContestedIndexNotFound("contested index not found when try to get it from the contested document resource vote poll with contract info"))) + } + + pub fn document_type(&self) -> Result { + self.contract + .contract + .document_type_for_name(self.document_type_name.as_str()) + .map_err(|e| Error::Protocol(ProtocolError::DataContractError(e))) + } + + pub fn document_type_borrowed(&self) -> Result<&DocumentType, Error> { + self.contract + .contract + .document_type_borrowed_for_name(self.document_type_name.as_str()) + .map_err(|e| Error::Protocol(ProtocolError::DataContractError(e))) + } +} + +pub trait ContestedDocumentResourceVotePollResolver { + fn resolve( + &self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result; +} + +impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVotePoll { + fn resolve( + &self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + let ContestedDocumentResourceVotePoll { + contract_id, + document_type_name, + index_name, + index_values, + } = self; + + let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll".to_string())))?; + Ok(ContestedDocumentResourceVotePollWithContractInfo { + contract, + document_type_name: document_type_name.clone(), + index_name: index_name.clone(), + index_values: index_values.clone(), + }) + } +} diff --git a/packages/rs-drive/src/query/mod.rs b/packages/rs-drive/src/query/mod.rs index 974766975c..cde6d32fc6 100644 --- a/packages/rs-drive/src/query/mod.rs +++ b/packages/rs-drive/src/query/mod.rs @@ -75,7 +75,9 @@ mod single_document_drive_query; mod test_index; #[cfg(any(feature = "server", feature = "verify"))] -mod vote_query; +pub mod vote_poll_vote_state_query; +#[cfg(any(feature = "server", feature = "verify"))] +pub mod vote_query; #[cfg(any(feature = "server", feature = "verify"))] /// Internal clauses struct @@ -270,7 +272,7 @@ pub struct DriveQuery<'a> { pub limit: Option, /// Order by pub order_by: IndexMap, - /// Start at + /// Start at document id pub start_at: Option<[u8; 32]>, /// Start at included pub start_at_included: bool, diff --git a/packages/rs-drive/src/query/single_document_drive_query.rs b/packages/rs-drive/src/query/single_document_drive_query.rs index f5fe4fa5d3..c4b56adeb1 100644 --- a/packages/rs-drive/src/query/single_document_drive_query.rs +++ b/packages/rs-drive/src/query/single_document_drive_query.rs @@ -104,8 +104,10 @@ impl SingleDocumentDriveQuery { /// Operations to construct the contested path query. fn construct_contested_path_query(&self, with_limit_1: bool) -> PathQuery { // First we should get the overall document_type_path - let path = - votes::paths::vote_contested_resource_active_polls_contract_documents_primary_key_path_vec(&self.contract_id, self.document_type_name.as_str()); + let path = votes::paths::vote_contested_resource_contract_documents_storage_path_vec( + &self.contract_id, + self.document_type_name.as_str(), + ); let mut query = Query::new(); query.insert_key(self.document_id.to_vec()); diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs new file mode 100644 index 0000000000..2b6e5e8698 --- /dev/null +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -0,0 +1,547 @@ +use crate::drive::verify::RootHash; +use crate::drive::votes::paths::VotePollPaths; +use crate::drive::votes::resolve_contested_document_resource_vote_poll::{ + ContestedDocumentResourceVotePollResolver, ContestedDocumentResourceVotePollWithContractInfo, +}; +use crate::drive::Drive; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use crate::query::{GroveError, Query}; +use dpp::block::block_info::BlockInfo; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use grovedb::query_result_type::{QueryResultElements, QueryResultType}; +use grovedb::{PathQuery, SizedQuery, TransactionArg}; +use platform_version::version::PlatformVersion; + +/// Vote Poll Drive Query result type +#[derive(Debug, PartialEq, Clone, Copy)] +pub enum ContestedDocumentVotePollDriveQueryResultType { + Documents, + VoteTally, +} + +/// Vote Poll Drive Query struct +#[derive(Debug, PartialEq, Clone)] +pub struct ContestedDocumentVotePollDriveQuery { + /// What vote poll are we asking for? + pub vote_poll: ContestedDocumentResourceVotePoll, + /// What result type are we interested in + pub result_type: ContestedDocumentVotePollDriveQueryResultType, + /// Offset + pub offset: Option, + /// Limit + pub limit: Option, + /// Start at identity id + pub start_at: Option<[u8; 32]>, + /// Start at included + pub start_at_included: bool, + /// Ascending + pub order_ascending: bool, +} + +impl ContestedDocumentVotePollDriveQuery { + pub fn resolve( + &self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + let ContestedDocumentVotePollDriveQuery { + vote_poll, + result_type, + offset, + limit, + start_at, + start_at_included, + order_ascending, + } = self; + Ok(ResolvedContestedDocumentVotePollDriveQuery { + vote_poll: vote_poll.resolve(drive, transaction, platform_version)?, + result_type: *result_type, + offset: *offset, + limit: *limit, + start_at: *start_at, + start_at_included: *start_at_included, + order_ascending: *order_ascending, + }) + } + + #[cfg(feature = "server")] + /// Executes a query with proof and returns the items and fee. + pub fn execute_with_proof( + self, + drive: &Drive, + block_info: Option, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(Vec, u64), Error> { + let mut drive_operations = vec![]; + let items = self.execute_with_proof_internal( + drive, + transaction, + &mut drive_operations, + platform_version, + )?; + let cost = if let Some(block_info) = block_info { + let fee_result = Drive::calculate_fee( + None, + Some(drive_operations), + &block_info.epoch, + drive.config.epochs_per_era, + platform_version, + )?; + fee_result.processing_fee + } else { + 0 + }; + Ok((items, cost)) + } + + #[cfg(feature = "server")] + /// Executes an internal query with proof and returns the items. + pub(crate) fn execute_with_proof_internal( + self, + drive: &Drive, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let resolved = self.resolve(drive, transaction, platform_version)?; + let path_query = resolved.construct_path_query(platform_version)?; + drive.grove_get_proved_path_query( + &path_query, + false, + transaction, + drive_operations, + &platform_version.drive, + ) + } + + #[cfg(all(feature = "server", feature = "verify"))] + /// Executes a query with proof and returns the root hash, items, and fee. + pub fn execute_with_proof_only_get_elements( + self, + drive: &Drive, + block_info: Option, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Vec>, u64), Error> { + let mut drive_operations = vec![]; + let (root_hash, items) = self.execute_with_proof_only_get_elements_internal( + drive, + transaction, + &mut drive_operations, + platform_version, + )?; + let cost = if let Some(block_info) = block_info { + let fee_result = Drive::calculate_fee( + None, + Some(drive_operations), + &block_info.epoch, + drive.config.epochs_per_era, + platform_version, + )?; + fee_result.processing_fee + } else { + 0 + }; + Ok((root_hash, items, cost)) + } + + #[cfg(all(feature = "server", feature = "verify"))] + /// Executes an internal query with proof and returns the root hash and values. + pub(crate) fn execute_with_proof_only_get_elements_internal( + self, + drive: &Drive, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Vec>), Error> { + let resolved = self.resolve(drive, transaction, platform_version)?; + let path_query = resolved.construct_path_query(platform_version)?; + let proof = drive.grove_get_proved_path_query( + &path_query, + self.start_at.is_some(), + transaction, + drive_operations, + &platform_version.drive, + )?; + self.verify_proof_keep_serialized(proof.as_slice(), platform_version) + } + + #[cfg(feature = "server")] + /// Executes a query with no proof and returns the items, skipped items, and fee. + pub fn execute_raw_results_no_proof( + &self, + drive: &Drive, + block_info: Option, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(Vec>, u16, u64), Error> { + let mut drive_operations = vec![]; + let (items, skipped) = self.execute_raw_results_no_proof_internal( + drive, + transaction, + &mut drive_operations, + platform_version, + )?; + let cost = if let Some(block_info) = block_info { + let fee_result = Drive::calculate_fee( + None, + Some(drive_operations), + &block_info.epoch, + drive.config.epochs_per_era, + platform_version, + )?; + fee_result.processing_fee + } else { + 0 + }; + Ok((items, skipped, cost)) + } + + #[cfg(feature = "server")] + /// Executes an internal query with no proof and returns the values and skipped items. + pub(crate) fn execute_raw_results_no_proof_internal( + &self, + drive: &Drive, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result<(Vec>, u16), Error> { + let resolved = self.resolve(drive, transaction, platform_version)?; + let path_query = resolved.construct_path_query(platform_version)?; + let query_result = drive.grove_get_path_query_serialized_results( + &path_query, + transaction, + drive_operations, + &platform_version.drive, + ); + match query_result { + Err(Error::GroveDB(GroveError::PathKeyNotFound(_))) + | Err(Error::GroveDB(GroveError::PathNotFound(_))) + | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok((Vec::new(), 0)), + _ => { + let (data, skipped) = query_result?; + { + Ok((data, skipped)) + } + } + } + } + + #[cfg(feature = "server")] + #[allow(unused)] + /// Executes an internal query with no proof and returns the values and skipped items. + pub(crate) fn execute_no_proof_internal( + &self, + drive: &Drive, + result_type: QueryResultType, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result<(QueryResultElements, u16), Error> { + let resolved = self.resolve(drive, transaction, platform_version)?; + let path_query = resolved.construct_path_query(platform_version)?; + let query_result = drive.grove_get_path_query( + &path_query, + transaction, + result_type, + drive_operations, + &platform_version.drive, + ); + match query_result { + Err(Error::GroveDB(GroveError::PathKeyNotFound(_))) + | Err(Error::GroveDB(GroveError::PathNotFound(_))) + | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => { + Ok((QueryResultElements::new(), 0)) + } + _ => { + let (data, skipped) = query_result?; + { + Ok((data, skipped)) + } + } + } + } +} + +/// Vote Poll Drive Query struct +#[derive(Debug, PartialEq, Clone)] +pub struct ResolvedContestedDocumentVotePollDriveQuery { + /// What vote poll are we asking for? + pub vote_poll: ContestedDocumentResourceVotePollWithContractInfo, + /// What result type are we interested in + pub result_type: ContestedDocumentVotePollDriveQueryResultType, + /// Offset + pub offset: Option, + /// Limit + pub limit: Option, + /// Start at identity id + pub start_at: Option<[u8; 32]>, + /// Start at included + pub start_at_included: bool, + /// Ascending + pub order_ascending: bool, +} + +impl ResolvedContestedDocumentVotePollDriveQuery { + /// Operations to construct a path query. + pub fn construct_path_query( + &self, + platform_version: &PlatformVersion, + ) -> Result { + let path = self.vote_poll.contenders_path(platform_version)?; + + let mut query = Query::new_with_direction(self.order_ascending); + + // this is a range on all elements + match &self.start_at { + None => { + query.insert_all(); + } + Some(starts_at_key_bytes) => { + let starts_at_key = starts_at_key_bytes.to_vec(); + match self.order_ascending { + true => match self.start_at_included { + true => query.insert_range_from(starts_at_key..), + false => query.insert_range_after(starts_at_key..), + }, + false => match self.start_at_included { + true => query.insert_range_to_inclusive(..=starts_at_key), + false => query.insert_range_to(..starts_at_key), + }, + } + } + } + + Ok(PathQuery { + path, + query: SizedQuery { + query, + limit: self.limit, + offset: self.offset, + }, + }) + } + + #[cfg(feature = "server")] + /// Executes a query with proof and returns the items and fee. + pub fn execute_with_proof( + self, + drive: &Drive, + block_info: Option, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(Vec, u64), Error> { + let mut drive_operations = vec![]; + let items = self.execute_with_proof_internal( + drive, + transaction, + &mut drive_operations, + platform_version, + )?; + let cost = if let Some(block_info) = block_info { + let fee_result = Drive::calculate_fee( + None, + Some(drive_operations), + &block_info.epoch, + drive.config.epochs_per_era, + platform_version, + )?; + fee_result.processing_fee + } else { + 0 + }; + Ok((items, cost)) + } + + #[cfg(feature = "server")] + /// Executes an internal query with proof and returns the items. + pub(crate) fn execute_with_proof_internal( + self, + drive: &Drive, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let path_query = self.construct_path_query_operations( + drive, + true, + transaction, + drive_operations, + platform_version, + )?; + drive.grove_get_proved_path_query( + &path_query, + false, + transaction, + drive_operations, + &platform_version.drive, + ) + } + + #[cfg(all(feature = "server", feature = "verify"))] + /// Executes a query with proof and returns the root hash, items, and fee. + pub fn execute_with_proof_only_get_elements( + self, + drive: &Drive, + block_info: Option, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Vec>, u64), Error> { + let mut drive_operations = vec![]; + let (root_hash, items) = self.execute_with_proof_only_get_elements_internal( + drive, + transaction, + &mut drive_operations, + platform_version, + )?; + let cost = if let Some(block_info) = block_info { + let fee_result = Drive::calculate_fee( + None, + Some(drive_operations), + &block_info.epoch, + drive.config.epochs_per_era, + platform_version, + )?; + fee_result.processing_fee + } else { + 0 + }; + Ok((root_hash, items, cost)) + } + + #[cfg(all(feature = "server", feature = "verify"))] + /// Executes an internal query with proof and returns the root hash and values. + pub(crate) fn execute_with_proof_only_get_elements_internal( + self, + drive: &Drive, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Vec>), Error> { + let path_query = self.construct_path_query_operations( + drive, + true, + transaction, + drive_operations, + platform_version, + )?; + + let proof = drive.grove_get_proved_path_query( + &path_query, + self.start_at.is_some(), + transaction, + drive_operations, + &platform_version.drive, + )?; + self.verify_proof_keep_serialized(proof.as_slice(), platform_version) + } + + #[cfg(feature = "server")] + /// Executes a query with no proof and returns the items, skipped items, and fee. + pub fn execute_raw_results_no_proof( + &self, + drive: &Drive, + block_info: Option, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(Vec>, u16, u64), Error> { + let mut drive_operations = vec![]; + let (items, skipped) = self.execute_raw_results_no_proof_internal( + drive, + transaction, + &mut drive_operations, + platform_version, + )?; + let cost = if let Some(block_info) = block_info { + let fee_result = Drive::calculate_fee( + None, + Some(drive_operations), + &block_info.epoch, + drive.config.epochs_per_era, + platform_version, + )?; + fee_result.processing_fee + } else { + 0 + }; + Ok((items, skipped, cost)) + } + + #[cfg(feature = "server")] + /// Executes an internal query with no proof and returns the values and skipped items. + pub(crate) fn execute_raw_results_no_proof_internal( + &self, + drive: &Drive, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result<(Vec>, u16), Error> { + let path_query = self.construct_path_query_operations( + drive, + false, + transaction, + drive_operations, + platform_version, + )?; + let query_result = drive.grove_get_path_query_serialized_results( + &path_query, + transaction, + drive_operations, + &platform_version.drive, + ); + match query_result { + Err(Error::GroveDB(GroveError::PathKeyNotFound(_))) + | Err(Error::GroveDB(GroveError::PathNotFound(_))) + | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok((Vec::new(), 0)), + _ => { + let (data, skipped) = query_result?; + { + Ok((data, skipped)) + } + } + } + } + + #[cfg(feature = "server")] + #[allow(unused)] + /// Executes an internal query with no proof and returns the values and skipped items. + pub(crate) fn execute_no_proof_internal( + &self, + drive: &Drive, + result_type: QueryResultType, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result<(QueryResultElements, u16), Error> { + let path_query = self.construct_path_query_operations( + drive, + false, + transaction, + drive_operations, + platform_version, + )?; + let query_result = drive.grove_get_path_query( + &path_query, + transaction, + result_type, + drive_operations, + &platform_version.drive, + ); + match query_result { + Err(Error::GroveDB(GroveError::PathKeyNotFound(_))) + | Err(Error::GroveDB(GroveError::PathNotFound(_))) + | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => { + Ok((QueryResultElements::new(), 0)) + } + _ => { + let (data, skipped) = query_result?; + { + Ok((data, skipped)) + } + } + } + } +} diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs index 6a8b7a48b5..373002c101 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs @@ -7,7 +7,6 @@ use derive_more::From; use dpp::block::block_info::BlockInfo; use dpp::platform_value::{Identifier, Value}; use std::collections::BTreeMap; -use std::mem; use dpp::document::Document; use dpp::fee::Credits; diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs index ef3791593f..ead12549d3 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs @@ -1,6 +1,5 @@ use dpp::block::block_info::BlockInfo; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; -use dpp::fee::Credits; use dpp::platform_value::Identifier; use std::sync::Arc; diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 02532ead4a..48f6672cc4 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -12,7 +12,26 @@ use crate::version::dpp_versions::{ StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, VotingVersions, }; -use crate::version::drive_abci_versions::{DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, DriveAbciFeePoolInwardsDistributionMethodVersions, DriveAbciFeePoolOutwardsDistributionMethodVersions, DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, DriveAbciQueryPrefundedSpecializedBalancesVersions, DriveAbciQuerySystemVersions, DriveAbciQueryVersions, DriveAbciQueryVotingVersions, DriveAbciStateTransitionCommonValidationVersions, DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts}; +use crate::version::drive_abci_versions::{ + DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, + DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, + DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, + DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, + DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, + DriveAbciFeePoolInwardsDistributionMethodVersions, + DriveAbciFeePoolOutwardsDistributionMethodVersions, + DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, + DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, + DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, + DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, + DriveAbciQueryPrefundedSpecializedBalancesVersions, DriveAbciQuerySystemVersions, + DriveAbciQueryVersions, DriveAbciQueryVotingVersions, + DriveAbciStateTransitionCommonValidationVersions, + DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, + DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, + DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, + DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts, +}; use crate::version::drive_versions::{ DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, @@ -836,11 +855,12 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { default_current_version: 0, }, }, - voting_based_queries: DriveAbciQueryVotingVersions { contested_resource_vote_state: FeatureVersionBounds { - min_version: 0, - max_version: 0, - default_current_version: 0, - }, + voting_based_queries: DriveAbciQueryVotingVersions { + contested_resource_vote_state: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, contested_resource_voters_for_identity: FeatureVersionBounds { min_version: 0, max_version: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 4b73d32d41..e4d5103888 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -12,7 +12,26 @@ use crate::version::dpp_versions::{ StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, VotingVersions, }; -use crate::version::drive_abci_versions::{DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, DriveAbciFeePoolInwardsDistributionMethodVersions, DriveAbciFeePoolOutwardsDistributionMethodVersions, DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, DriveAbciQueryPrefundedSpecializedBalancesVersions, DriveAbciQuerySystemVersions, DriveAbciQueryVersions, DriveAbciQueryVotingVersions, DriveAbciStateTransitionCommonValidationVersions, DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts}; +use crate::version::drive_abci_versions::{ + DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, + DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, + DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, + DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, + DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, + DriveAbciFeePoolInwardsDistributionMethodVersions, + DriveAbciFeePoolOutwardsDistributionMethodVersions, + DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, + DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, + DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, + DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, + DriveAbciQueryPrefundedSpecializedBalancesVersions, DriveAbciQuerySystemVersions, + DriveAbciQueryVersions, DriveAbciQueryVotingVersions, + DriveAbciStateTransitionCommonValidationVersions, + DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, + DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, + DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, + DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts, +}; use crate::version::drive_versions::{ DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, @@ -836,11 +855,12 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { default_current_version: 0, }, }, - voting_based_queries: DriveAbciQueryVotingVersions { contested_resource_vote_state: FeatureVersionBounds { - min_version: 0, - max_version: 0, - default_current_version: 0, - }, + voting_based_queries: DriveAbciQueryVotingVersions { + contested_resource_vote_state: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, contested_resource_voters_for_identity: FeatureVersionBounds { min_version: 0, max_version: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index a9ec1f94d8..7c9d26854e 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -12,7 +12,26 @@ use crate::version::dpp_versions::{ StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, VotingVersions, }; -use crate::version::drive_abci_versions::{DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, DriveAbciFeePoolInwardsDistributionMethodVersions, DriveAbciFeePoolOutwardsDistributionMethodVersions, DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, DriveAbciQueryPrefundedSpecializedBalancesVersions, DriveAbciQuerySystemVersions, DriveAbciQueryVersions, DriveAbciQueryVotingVersions, DriveAbciStateTransitionCommonValidationVersions, DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts}; +use crate::version::drive_abci_versions::{ + DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, + DriveAbciBlockFeeProcessingMethodVersions, DriveAbciBlockStartMethodVersions, + DriveAbciCoreBasedUpdatesMethodVersions, DriveAbciCoreChainLockMethodVersionsAndConstants, + DriveAbciCoreSubsidyMethodVersions, DriveAbciDocumentsStateTransitionValidationVersions, + DriveAbciEngineMethodVersions, DriveAbciEpochMethodVersions, + DriveAbciFeePoolInwardsDistributionMethodVersions, + DriveAbciFeePoolOutwardsDistributionMethodVersions, + DriveAbciIdentityCreditWithdrawalMethodVersions, DriveAbciInitializationMethodVersions, + DriveAbciMasternodeIdentitiesUpdatesMethodVersions, DriveAbciMethodVersions, + DriveAbciPlatformStateStorageMethodVersions, DriveAbciProtocolUpgradeMethodVersions, + DriveAbciQueryDataContractVersions, DriveAbciQueryIdentityVersions, + DriveAbciQueryPrefundedSpecializedBalancesVersions, DriveAbciQuerySystemVersions, + DriveAbciQueryVersions, DriveAbciQueryVotingVersions, + DriveAbciStateTransitionCommonValidationVersions, + DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, + DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, + DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, + DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts, +}; use crate::version::drive_versions::{ DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, DriveContractApplyMethodVersions, DriveContractCostsMethodVersions, @@ -835,11 +854,12 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { default_current_version: 0, }, }, - voting_based_queries: DriveAbciQueryVotingVersions { contested_resource_vote_state: FeatureVersionBounds { - min_version: 0, - max_version: 0, - default_current_version: 0, - }, + voting_based_queries: DriveAbciQueryVotingVersions { + contested_resource_vote_state: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, contested_resource_voters_for_identity: FeatureVersionBounds { min_version: 0, max_version: 0, diff --git a/packages/simple-signer/src/signer.rs b/packages/simple-signer/src/signer.rs index b894a9a565..f8f8f92f3b 100644 --- a/packages/simple-signer/src/signer.rs +++ b/packages/simple-signer/src/signer.rs @@ -7,11 +7,9 @@ use dpp::identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV use dpp::identity::signer::Signer; use dpp::identity::{IdentityPublicKey, KeyType}; use dpp::platform_value::BinaryData; -use dpp::state_transition::errors::{ - InvalidIdentityPublicKeyTypeError, InvalidSignaturePublicKeyError, -}; +use dpp::state_transition::errors::InvalidIdentityPublicKeyTypeError; use dpp::{bls_signatures, ed25519_dalek, ProtocolError}; -use std::collections::{BTreeMap, HashMap}; +use std::collections::BTreeMap; use std::fmt::{Debug, Formatter}; /// This simple signer is only to be used in tests From 622eb1823a63cdde206f8fd50766b4a3c2f7fd00 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 19 May 2024 02:42:56 +0200 Subject: [PATCH 062/135] a lot more work --- Cargo.lock | 470 ++++++++------- .../protos/platform/v0/platform.proto | 29 +- .../proto/org.dash.platform.dapi.v0.rs | 90 ++- .../masternode_vote/state/v0/mod.rs | 5 - packages/rs-drive-abci/src/query/service.rs | 45 +- .../contested_resource_vote_state/v0/mod.rs | 115 +++- .../query/voting/contested_resources/mod.rs | 13 +- packages/rs-drive/Cargo.toml | 8 +- .../mod.rs | 10 +- .../v0/mod.rs | 39 +- .../mod.rs | 49 ++ .../v0/mod.rs | 28 + .../src/drive/grove_operations/mod.rs | 1 + .../v0/mod.rs | 1 - packages/rs-drive/src/drive/votes/mod.rs | 1 + .../mod.rs | 77 ++- packages/rs-drive/src/query/mod.rs | 2 + .../src/query/vote_poll_vote_state_query.rs | 533 ++++++++---------- .../src/version/drive_versions.rs | 1 + .../src/version/mocks/v2_test.rs | 1 + .../src/version/mocks/v3_test.rs | 1 + .../rs-platform-version/src/version/v1.rs | 1 + 22 files changed, 849 insertions(+), 671 deletions(-) create mode 100644 packages/rs-drive/src/drive/grove_operations/grove_get_path_query_serialized_or_sum_results/mod.rs create mode 100644 packages/rs-drive/src/drive/grove_operations/grove_get_path_query_serialized_or_sum_results/v0/mod.rs diff --git a/Cargo.lock b/Cargo.lock index be1efd3648..81e2c77cdf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,47 +74,48 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.13" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" [[package]] name = "anstyle-parse" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -122,9 +123,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.82" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "arc-swap" @@ -192,7 +193,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -203,7 +204,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -219,9 +220,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "axum" @@ -274,7 +275,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d67782c3f868daa71d3533538e98a8e13713231969def7536e8039606fc46bf0" dependencies = [ - "fastrand 2.0.2", + "fastrand 2.1.0", "futures-core", "pin-project", "tokio", @@ -357,13 +358,13 @@ dependencies = [ "lazycell", "log", "peeking_take_while", - "prettyplease 0.2.19", + "prettyplease 0.2.20", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", - "syn 2.0.60", + "syn 2.0.64", "which", ] @@ -384,7 +385,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -496,9 +497,9 @@ dependencies = [ [[package]] name = "borsh" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0901fc8eb0aca4c83be0106d6f2db17d86a08dfc2c25f0e84464bf381158add6" +checksum = "dbe5b10e214954177fb1dc9fbd20a1a2608fe99e6c832033bdc7cea287a20d77" dependencies = [ "borsh-derive", "cfg_aliases", @@ -506,15 +507,15 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51670c3aa053938b0ee3bd67c3817e471e626151131b934038e83c5bf8de48f5" +checksum = "d7a8646f94ab393e43e8b35a2558b1624bed28b97ee09c5d15456e3c9463f46d" dependencies = [ "once_cell", "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", "syn_derive", ] @@ -595,9 +596,9 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +checksum = "e0ec6b951b160caa93cc0c7b209e5a3bff7aae9062213451ac99493cd844c239" dependencies = [ "serde", ] @@ -632,9 +633,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.95" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b" +checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" dependencies = [ "jobserver", "libc", @@ -749,7 +750,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.1", + "strsim", ] [[package]] @@ -761,7 +762,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -772,9 +773,9 @@ checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" [[package]] name = "colored" @@ -788,9 +789,9 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" dependencies = [ "crossbeam-utils", ] @@ -802,8 +803,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd326812b3fd01da5bb1af7d340d0d555fd3d4b641e7f1dfcf5962a902952787" dependencies = [ "futures-core", - "prost 0.12.4", - "prost-types 0.12.4", + "prost 0.12.6", + "prost-types 0.12.6", "tonic 0.10.2", "tracing-core", ] @@ -820,7 +821,7 @@ dependencies = [ "futures-task", "hdrhistogram", "humantime", - "prost-types 0.12.4", + "prost-types 0.12.6", "serde", "serde_json", "thread_local", @@ -1010,7 +1011,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -1020,7 +1021,7 @@ dependencies = [ "dapi-grpc-macros", "futures-core", "platform-version", - "prost 0.12.4", + "prost 0.12.6", "serde", "serde_bytes", "serde_json", @@ -1036,14 +1037,14 @@ dependencies = [ "dapi-grpc", "heck 0.5.0", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] name = "darling" -version = "0.20.8" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391" +checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" dependencies = [ "darling_core", "darling_macro", @@ -1051,27 +1052,27 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.8" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f" +checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", - "strsim 0.10.0", - "syn 2.0.60", + "strsim", + "syn 2.0.64", ] [[package]] name = "darling_macro" -version = "0.20.8" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" +checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -1401,7 +1402,7 @@ dependencies = [ "metrics-exporter-prometheus", "mockall", "platform-version", - "prost 0.12.4", + "prost 0.12.6", "rand", "regex", "reopen", @@ -1410,7 +1411,7 @@ dependencies = [ "rust_decimal_macros", "serde", "serde_json", - "serde_with 3.8.0", + "serde_with 3.8.1", "sha2", "simple-signer", "strategy-tests", @@ -1488,9 +1489,9 @@ dependencies = [ [[package]] name = "either" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "enum-map" @@ -1509,7 +1510,7 @@ checksum = "f282cfdfe92516eb26c2af8589c274c7c17681f5ecc03c18255fe741c6aa64eb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -1555,9 +1556,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", @@ -1622,9 +1623,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "feature-flags-contract" @@ -1638,15 +1639,15 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38793c55593b33412e3ae40c2c9781ffaa6f438f6f8c10f24e71846fbd7ae01e" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "file-rotate" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddf221ceec4517f3cb764dae3541b2bd87666fc8832e51322fbb97250b468c71" +checksum = "7a3ed82142801f5b1363f7d463963d114db80f467e860b1cd82228eaebc627a0" dependencies = [ "chrono", "flate2", @@ -1660,9 +1661,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.28" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" dependencies = [ "crc32fast", "miniz_oxide", @@ -1703,9 +1704,9 @@ dependencies = [ [[package]] name = "fraction" -version = "0.15.1" +version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b486ab61634f05b11b591c38c71fb25139cb55e22be4fb6ecf649cc3736c074a" +checksum = "0f158e3ff0a1b334408dc9fb811cd99b446986f4d8b741bb08f9df1604085ae7" dependencies = [ "lazy_static", "num", @@ -1800,7 +1801,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -1845,9 +1846,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "js-sys", @@ -1871,9 +1872,11 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "grovedb" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?rev=d9292aa20bd8f3bda7c5d25d62db06ac341b0677#d9292aa20bd8f3bda7c5d25d62db06ac341b0677" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#a62699d8a32f72f76bb2b3a5fffbf2687fbccb92" dependencies = [ "bincode", + "bitvec", + "blake3", "grovedb-costs", "grovedb-merk", "grovedb-path", @@ -1892,7 +1895,7 @@ dependencies = [ [[package]] name = "grovedb-costs" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?rev=d9292aa20bd8f3bda7c5d25d62db06ac341b0677#d9292aa20bd8f3bda7c5d25d62db06ac341b0677" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#a62699d8a32f72f76bb2b3a5fffbf2687fbccb92" dependencies = [ "integer-encoding", "intmap", @@ -1902,7 +1905,7 @@ dependencies = [ [[package]] name = "grovedb-merk" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?rev=d9292aa20bd8f3bda7c5d25d62db06ac341b0677#d9292aa20bd8f3bda7c5d25d62db06ac341b0677" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#a62699d8a32f72f76bb2b3a5fffbf2687fbccb92" dependencies = [ "blake3", "byteorder", @@ -1925,12 +1928,12 @@ dependencies = [ [[package]] name = "grovedb-path" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?rev=d9292aa20bd8f3bda7c5d25d62db06ac341b0677#d9292aa20bd8f3bda7c5d25d62db06ac341b0677" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#a62699d8a32f72f76bb2b3a5fffbf2687fbccb92" [[package]] name = "grovedb-storage" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?rev=d9292aa20bd8f3bda7c5d25d62db06ac341b0677#d9292aa20bd8f3bda7c5d25d62db06ac341b0677" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#a62699d8a32f72f76bb2b3a5fffbf2687fbccb92" dependencies = [ "blake3", "grovedb-costs", @@ -1949,7 +1952,7 @@ dependencies = [ [[package]] name = "grovedb-visualize" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?rev=d9292aa20bd8f3bda7c5d25d62db06ac341b0677#d9292aa20bd8f3bda7c5d25d62db06ac341b0677" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#a62699d8a32f72f76bb2b3a5fffbf2687fbccb92" dependencies = [ "hex", "itertools 0.12.1", @@ -2000,9 +2003,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash 0.8.11", "allocator-api2", @@ -2129,7 +2132,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.6", + "socket2 0.5.7", "tokio", "tower-service", "tracing", @@ -2205,15 +2208,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "serde", ] [[package]] name = "instant" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" dependencies = [ "cfg-if", ] @@ -2261,6 +2264,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + [[package]] name = "iso8601" version = "0.6.1" @@ -2323,14 +2332,13 @@ dependencies = [ [[package]] name = "json-patch" -version = "1.2.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55ff1e1486799e3f64129f8ccad108b38290df9cd7015cd31bed17239f0789d6" +checksum = "ec9ad60d674508f3ca8f380a928cfe7b096bc729c4e2dbfe3852bc45da3ab30b" dependencies = [ "serde", "serde_json", "thiserror", - "treediff 4.0.3", ] [[package]] @@ -2362,7 +2370,7 @@ source = "git+https://github.com/fominok/jsonschema-rs?branch=feat-unevaluated-p dependencies = [ "ahash 0.8.11", "anyhow", - "base64 0.21.7", + "base64 0.22.1", "bytecount", "fancy-regex", "fraction", @@ -2401,9 +2409,9 @@ checksum = "744a4c881f502e98c2241d2e5f50040ac73b30194d64452bb6260393b53f0dc9" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libloading" @@ -2450,9 +2458,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "lock_api" @@ -2476,7 +2484,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" dependencies = [ - "hashbrown 0.14.3", + "hashbrown 0.14.5", ] [[package]] @@ -2566,7 +2574,7 @@ checksum = "38b4faf00617defe497754acde3024865bc143d44a86799b24e191ecff91354f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -2598,9 +2606,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" dependencies = [ "adler", ] @@ -2720,9 +2728,9 @@ dependencies = [ [[package]] name = "num" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3135b08af27d103b0a51f2ae0f8632117b7b185ccf931445affa8df530576a41" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ "num-bigint", "num-complex", @@ -2734,11 +2742,10 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" dependencies = [ - "autocfg", "num-integer", "num-traits", ] @@ -2751,9 +2758,9 @@ checksum = "63335b2e2c34fae2fb0aa2cecfd9f0832a1e24b3b32ecec612c3426d46dc8aaa" [[package]] name = "num-complex" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" dependencies = [ "num-traits", ] @@ -2772,7 +2779,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -2786,9 +2793,9 @@ dependencies = [ [[package]] name = "num-iter" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" dependencies = [ "autocfg", "num-integer", @@ -2797,11 +2804,10 @@ dependencies = [ [[package]] name = "num-rational" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "autocfg", "num-bigint", "num-integer", "num-traits", @@ -2809,9 +2815,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] @@ -2911,9 +2917,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "peeking_take_while" @@ -2929,9 +2935,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "petgraph" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", "indexmap 2.2.6", @@ -2954,7 +2960,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -2999,7 +3005,7 @@ version = "1.0.0-dev.12" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", "virtue 0.0.14", ] @@ -3021,7 +3027,7 @@ dependencies = [ "serde", "serde_json", "thiserror", - "treediff 5.0.0", + "treediff", ] [[package]] @@ -3029,7 +3035,7 @@ name = "platform-value-convertible" version = "1.0.0-dev.12" dependencies = [ "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -3045,7 +3051,7 @@ version = "1.0.0-dev.12" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -3168,12 +3174,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.19" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ac2cf0f2e4f42b49f5ffd07dae8d746508ef7526c13940e5f524012ae6c6550" +checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -3221,9 +3227,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" dependencies = [ "unicode-ident", ] @@ -3240,12 +3246,12 @@ dependencies = [ [[package]] name = "prost" -version = "0.12.4" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f5d036824e4761737860779c906171497f6d55681139d8312388f8fe398922" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" dependencies = [ "bytes", - "prost-derive 0.12.4", + "prost-derive 0.12.6", ] [[package]] @@ -3272,9 +3278,9 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.12.4" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80b776a1b2dc779f5ee0641f8ade0125bc1298dd41a9a0c16d8bd57b42d222b1" +checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" dependencies = [ "bytes", "heck 0.5.0", @@ -3283,11 +3289,11 @@ dependencies = [ "multimap 0.10.0", "once_cell", "petgraph", - "prettyplease 0.2.19", - "prost 0.12.4", - "prost-types 0.12.4", + "prettyplease 0.2.20", + "prost 0.12.6", + "prost-types 0.12.6", "regex", - "syn 2.0.60", + "syn 2.0.64", "tempfile", ] @@ -3306,15 +3312,15 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.12.4" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19de2de2a00075bf566bee3bd4db014b11587e84184d3f7a791bc17f1a8e9e48" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -3328,11 +3334,11 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.12.4" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3235c33eb02c1f1e212abdbe34c78b264b038fb58ca612664343271e36e55ffe" +checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" dependencies = [ - "prost 0.12.4", + "prost 0.12.6", ] [[package]] @@ -3638,9 +3644,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" @@ -3680,7 +3686,7 @@ dependencies = [ "bitflags 2.5.0", "errno", "libc", - "linux-raw-sys 0.4.13", + "linux-raw-sys 0.4.14", "windows-sys 0.52.0", ] @@ -3723,15 +3729,15 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.5.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beb461507cee2c2ff151784c52762cf4d9ff6a61f3e80968600ed24fa837fa54" +checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" [[package]] name = "rustls-webpki" -version = "0.102.3" +version = "0.102.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3bce581c0dd41bce533ce695a1437fa16a7ab5ac3ccfa99fe1a620a7885eabf" +checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" dependencies = [ "ring", "rustls-pki-types", @@ -3740,15 +3746,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.15" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "ryu" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "same-file" @@ -3822,11 +3828,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", "core-foundation", "core-foundation-sys", "libc", @@ -3835,9 +3841,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" dependencies = [ "core-foundation-sys", "libc", @@ -3845,18 +3851,18 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" dependencies = [ "serde", ] [[package]] name = "serde" -version = "1.0.198" +version = "1.0.202" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" +checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" dependencies = [ "serde_derive", ] @@ -3892,20 +3898,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.198" +version = "1.0.202" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" +checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] name = "serde_json" -version = "1.0.116" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "indexmap 2.2.6", "itoa", @@ -3921,14 +3927,14 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] name = "serde_spanned" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" dependencies = [ "serde", ] @@ -3951,9 +3957,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c85f8e96d1d6857f13768fcbd895fcb06225510022a2774ed8b5150581847b0" +checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20" dependencies = [ "base64 0.22.1", "chrono", @@ -3961,7 +3967,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "serde_with_macros 3.8.0", + "serde_with_macros 3.8.1", "time", ] @@ -3974,19 +3980,19 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] name = "serde_with_macros" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8b3a576c4eb2924262d5951a3b737ccaf16c931e39a2810c36f9a7e25575557" +checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -4097,9 +4103,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", "windows-sys 0.52.0", @@ -4147,12 +4153,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - [[package]] name = "strsim" version = "0.11.1" @@ -4187,7 +4187,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -4200,7 +4200,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -4231,9 +4231,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.60" +version = "2.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +checksum = "7ad3dee41f36859875573074334c200d1add8e4a87bb37113ebd31d926b7b11f" dependencies = [ "proc-macro2", "quote", @@ -4249,7 +4249,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -4289,7 +4289,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", - "fastrand 2.0.2", + "fastrand 2.1.0", "rustix 0.38.34", "windows-sys 0.52.0", ] @@ -4297,13 +4297,13 @@ dependencies = [ [[package]] name = "tenderdash-abci" version = "0.14.0-dev.12" -source = "git+https://github.com/dashpay/rs-tenderdash-abci#a848ad6d67b1c1d8f053c9ca97b89e5e4c929d96" +source = "git+https://github.com/dashpay/rs-tenderdash-abci#3048c2ecdf7a2bd023634082a85635c76db22bf0" dependencies = [ "bytes", "futures", "hex", "lhash", - "prost 0.12.4", + "prost 0.12.6", "semver", "serde_json", "tenderdash-proto", @@ -4319,7 +4319,7 @@ dependencies = [ [[package]] name = "tenderdash-proto" version = "0.14.0-dev.12" -source = "git+https://github.com/dashpay/rs-tenderdash-abci#a848ad6d67b1c1d8f053c9ca97b89e5e4c929d96" +source = "git+https://github.com/dashpay/rs-tenderdash-abci#3048c2ecdf7a2bd023634082a85635c76db22bf0" dependencies = [ "bytes", "chrono", @@ -4327,8 +4327,8 @@ dependencies = [ "flex-error", "num-derive", "num-traits", - "prost 0.12.4", - "prost-types 0.12.4", + "prost 0.12.6", + "prost-types 0.12.6", "serde", "subtle-encoding", "tenderdash-proto-compiler", @@ -4339,10 +4339,10 @@ dependencies = [ [[package]] name = "tenderdash-proto-compiler" version = "0.14.0-dev.12" -source = "git+https://github.com/dashpay/rs-tenderdash-abci#a848ad6d67b1c1d8f053c9ca97b89e5e4c929d96" +source = "git+https://github.com/dashpay/rs-tenderdash-abci#3048c2ecdf7a2bd023634082a85635c76db22bf0" dependencies = [ "fs_extra", - "prost-build 0.12.4", + "prost-build 0.12.6", "regex", "tempfile", "tonic-build 0.11.0", @@ -4399,22 +4399,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.59" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.59" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -4497,7 +4497,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.6", + "socket2 0.5.7", "tokio-macros", "tracing", "windows-sys 0.48.0", @@ -4521,7 +4521,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -4561,35 +4561,34 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] name = "toml" -version = "0.8.12" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" +checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.12", + "toml_edit 0.22.13", ] [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" dependencies = [ "serde", ] @@ -4618,15 +4617,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.12" +version = "0.22.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" +checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" dependencies = [ "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.6", + "winnow 0.6.8", ] [[package]] @@ -4647,7 +4646,7 @@ dependencies = [ "hyper-timeout", "percent-encoding", "pin-project", - "prost 0.12.4", + "prost 0.12.6", "tokio", "tokio-stream", "tower", @@ -4674,7 +4673,7 @@ dependencies = [ "hyper-timeout", "percent-encoding", "pin-project", - "prost 0.12.4", + "prost 0.12.6", "rustls-native-certs", "rustls-pemfile", "rustls-pki-types", @@ -4707,11 +4706,11 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be4ef6dd70a610078cb4e338a0f79d06bc759ff1b22d2120c2ff02ae264ba9c2" dependencies = [ - "prettyplease 0.2.19", + "prettyplease 0.2.20", "proc-macro2", - "prost-build 0.12.4", + "prost-build 0.12.6", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -4762,7 +4761,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -4817,15 +4816,6 @@ dependencies = [ "tracing-serde", ] -[[package]] -name = "treediff" -version = "4.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d127780145176e2b5d16611cc25a900150e86e9fd79d3bde6ff3a37359c9cb5" -dependencies = [ - "serde_json", -] - [[package]] name = "treediff" version = "5.0.0" @@ -4882,9 +4872,9 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" [[package]] name = "unicode-xid" @@ -4974,9 +4964,9 @@ checksum = "b522f715ead3537dc57c9907899a08e461a8f1e87fc8414a4a89bbd9854289ff" [[package]] name = "waker-fn" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" +checksum = "317211a0dc0ceedd78fb2ca9a44aed3d7b9b26f81870d485c07122b4350673b7" [[package]] name = "walkdir" @@ -5024,7 +5014,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", "wasm-bindgen-shared", ] @@ -5058,7 +5048,7 @@ checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5324,9 +5314,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.6" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352" +checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" dependencies = [ "memchr", ] @@ -5361,22 +5351,22 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index 98f31f9e77..f57d82d38f 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -34,6 +34,7 @@ service Platform { rpc getProtocolVersionUpgradeState(GetProtocolVersionUpgradeStateRequest) returns (GetProtocolVersionUpgradeStateResponse); rpc getProtocolVersionUpgradeVoteStatus(GetProtocolVersionUpgradeVoteStatusRequest) returns (GetProtocolVersionUpgradeVoteStatusResponse); rpc getEpochsInfo(GetEpochsInfoRequest) returns (GetEpochsInfoResponse); + // What votes are currently happening for a specific contested index rpc getContestedResources(GetContestedResourcesRequest) returns (GetContestedResourcesResponse); // What's the state of a contested resource vote? (ie who is winning?) rpc getContestedResourceVoteState(GetContestedResourceVoteStateRequest) returns (GetContestedResourceVoteStateResponse); @@ -636,11 +637,12 @@ message GetEpochsInfoResponse { message GetContestedResourcesRequest { message GetContestedResourcesRequestV0 { - bool prove = 1; - repeated bytes resource_path = 2; - optional bytes start_contested_resource_identifier = 3; + bytes contract_id = 1; + string document_type_name = 2; + string index_name = 3; optional uint32 count = 4; - optional bool ascending = 5; + bool ascending = 5; + bool prove = 6; } oneof version { @@ -656,7 +658,7 @@ message GetContestedResourcesResponse { } message ContestedResource { - bytes identifier = 1; + repeated bytes index_values = 1; } oneof result { @@ -676,16 +678,23 @@ message GetContestedResourceVoteStateRequest { message GetContestedResourceVoteStateRequestV0 { message StartAtIdentifierInfo { bytes start_identifier = 1; - uint32 count = 2; - bool ascending = 3; + bool start_identifier_included = 2; + } + enum ResultType { + DOCUMENTS = 0; + VOTE_TALLY = 1; + DOCUMENTS_AND_VOTE_TALLY = 2; } + bytes contract_id = 1; string document_type_name = 2; string index_name = 3; repeated bytes index_values = 4; - bool include_documents = 5; + ResultType result_type = 5; optional StartAtIdentifierInfo start_at_identifier_info = 6; - bool prove = 7; + optional uint32 count = 7; + bool order_ascending = 8; + bool prove = 9; } oneof version { @@ -701,7 +710,7 @@ message GetContestedResourceVoteStateResponse { message Contender { bytes identifier = 1; - uint32 vote_count = 2; + optional uint32 vote_count = 2; optional bytes document = 3; } diff --git a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs index 6e74f4b998..0ecb9f9438 100644 --- a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs +++ b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs @@ -2139,18 +2139,18 @@ pub mod get_contested_resources_request { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetContestedResourcesRequestV0 { - #[prost(bool, tag = "1")] - pub prove: bool, - #[prost(bytes = "vec", repeated, tag = "2")] - pub resource_path: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, - #[prost(bytes = "vec", optional, tag = "3")] - pub start_contested_resource_identifier: ::core::option::Option< - ::prost::alloc::vec::Vec, - >, + #[prost(bytes = "vec", tag = "1")] + pub contract_id: ::prost::alloc::vec::Vec, + #[prost(string, tag = "2")] + pub document_type_name: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub index_name: ::prost::alloc::string::String, #[prost(uint32, optional, tag = "4")] pub count: ::core::option::Option, - #[prost(bool, optional, tag = "5")] - pub ascending: ::core::option::Option, + #[prost(bool, tag = "5")] + pub ascending: bool, + #[prost(bool, tag = "6")] + pub prove: bool, } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] @@ -2202,8 +2202,8 @@ pub mod get_contested_resources_response { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ContestedResource { - #[prost(bytes = "vec", tag = "1")] - pub identifier: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", repeated, tag = "1")] + pub index_values: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] @@ -2253,13 +2253,20 @@ pub mod get_contested_resource_vote_state_request { pub index_name: ::prost::alloc::string::String, #[prost(bytes = "vec", repeated, tag = "4")] pub index_values: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, - #[prost(bool, tag = "5")] - pub include_documents: bool, + #[prost( + enumeration = "get_contested_resource_vote_state_request_v0::ResultType", + tag = "5" + )] + pub result_type: i32, #[prost(message, optional, tag = "6")] pub start_at_identifier_info: ::core::option::Option< get_contested_resource_vote_state_request_v0::StartAtIdentifierInfo, >, - #[prost(bool, tag = "7")] + #[prost(uint32, optional, tag = "7")] + pub count: ::core::option::Option, + #[prost(bool, tag = "8")] + pub order_ascending: bool, + #[prost(bool, tag = "9")] pub prove: bool, } /// Nested message and enum types in `GetContestedResourceVoteStateRequestV0`. @@ -2272,10 +2279,49 @@ pub mod get_contested_resource_vote_state_request { pub struct StartAtIdentifierInfo { #[prost(bytes = "vec", tag = "1")] pub start_identifier: ::prost::alloc::vec::Vec, - #[prost(uint32, tag = "2")] - pub count: u32, - #[prost(bool, tag = "3")] - pub ascending: bool, + #[prost(bool, tag = "2")] + pub start_identifier_included: bool, + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum ResultType { + Documents = 0, + VoteTally = 1, + DocumentsAndVoteTally = 2, + } + impl ResultType { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + ResultType::Documents => "DOCUMENTS", + ResultType::VoteTally => "VOTE_TALLY", + ResultType::DocumentsAndVoteTally => "DOCUMENTS_AND_VOTE_TALLY", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "DOCUMENTS" => Some(Self::Documents), + "VOTE_TALLY" => Some(Self::VoteTally), + "DOCUMENTS_AND_VOTE_TALLY" => Some(Self::DocumentsAndVoteTally), + _ => None, + } + } } } #[derive(::serde::Serialize, ::serde::Deserialize)] @@ -2335,8 +2381,8 @@ pub mod get_contested_resource_vote_state_response { pub struct Contender { #[prost(bytes = "vec", tag = "1")] pub identifier: ::prost::alloc::vec::Vec, - #[prost(uint32, tag = "2")] - pub vote_count: u32, + #[prost(uint32, optional, tag = "2")] + pub vote_count: ::core::option::Option, #[prost(bytes = "vec", optional, tag = "3")] pub document: ::core::option::Option<::prost::alloc::vec::Vec>, } @@ -3463,6 +3509,7 @@ pub mod platform_client { ); self.inner.unary(req, path, codec).await } + /// What votes are currently happening for a specific contested index pub async fn get_contested_resources( &mut self, request: impl tonic::IntoRequest, @@ -3794,6 +3841,7 @@ pub mod platform_server { tonic::Response, tonic::Status, >; + /// What votes are currently happening for a specific contested index async fn get_contested_resources( &self, request: tonic::Request, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs index 4b7bb4afe7..67c7218f18 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs @@ -2,12 +2,7 @@ use crate::error::Error; use crate::platform_types::platform::PlatformRef; use crate::rpc::core::CoreRPCLike; -use dpp::consensus::signature::IdentityNotFoundError; - -use dpp::consensus::state::identity::IdentityInsufficientBalanceError; - use dpp::prelude::ConsensusValidationResult; -use dpp::state_transition::masternode_vote_transition::accessors::MasternodeVoteTransitionAccessorsV0; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; use drive::state_transition_action::identity::masternode_vote::MasternodeVoteTransitionAction; diff --git a/packages/rs-drive-abci/src/query/service.rs b/packages/rs-drive-abci/src/query/service.rs index fca58367b4..fbf4c8cf52 100644 --- a/packages/rs-drive-abci/src/query/service.rs +++ b/packages/rs-drive-abci/src/query/service.rs @@ -10,11 +10,9 @@ use async_trait::async_trait; use dapi_grpc::platform::v0::platform_server::Platform as PlatformService; use dapi_grpc::platform::v0::{ BroadcastStateTransitionRequest, BroadcastStateTransitionResponse, GetConsensusParamsRequest, - GetConsensusParamsResponse, GetContestedResourceIdentityVoteStateRequest, - GetContestedResourceIdentityVoteStateResponse, GetContestedResourceIdentityVoteStatusRequest, + GetConsensusParamsResponse, GetContestedResourceIdentityVoteStatusRequest, GetContestedResourceIdentityVoteStatusResponse, GetContestedResourceVoteStateRequest, - GetContestedResourceVoteStateResponse, GetContestedResourceVoteStatusRequest, - GetContestedResourceVoteStatusResponse, GetContestedResourceVotersForIdentityRequest, + GetContestedResourceVoteStateResponse, GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse, GetContestedResourcesRequest, GetContestedResourcesResponse, GetDataContractHistoryRequest, GetDataContractHistoryResponse, GetDataContractRequest, GetDataContractResponse, GetDataContractsRequest, @@ -399,24 +397,10 @@ impl PlatformService for QueryService { &self, request: Request, ) -> Result, Status> { - todo!() - } - - async fn get_contested_resource_identity_vote_state( - &self, - request: Request, - ) -> Result, Status> { - todo!() - } - - async fn get_contested_resource_vote_status( - &self, - request: Request, - ) -> Result, Status> { self.handle_blocking_query( request, - Platform::::query_prefunded_specialized_balance, - "get_contested_resource_vote_status", + Platform::::query_contested_resources, + "get_contested_resources", ) .await } @@ -425,21 +409,36 @@ impl PlatformService for QueryService { &self, request: Request, ) -> Result, Status> { - todo!() + self.handle_blocking_query( + request, + Platform::::query_contested_resource_vote_state, + "get_contested_resource_vote_state", + ) + .await } async fn get_contested_resource_voters_for_identity( &self, request: Request, ) -> Result, Status> { - todo!() + self.handle_blocking_query( + request, + Platform::::query_contested_resource_voters_for_identity, + "get_contested_resource_voters_for_identity", + ) + .await } async fn get_contested_resource_identity_vote_status( &self, request: Request, ) -> Result, Status> { - todo!() + self.handle_blocking_query( + request, + Platform::::query_contested_resource_identity_vote_status, + "get_contested_resource_identity_vote_status", + ) + .await } async fn get_prefunded_specialized_balance( diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs index bcc924203f..3f0281d56d 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs @@ -4,15 +4,20 @@ use crate::platform_types::platform::Platform; use crate::platform_types::platform_state::PlatformState; use crate::query::QueryValidationResult; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::GetContestedResourceVoteStateRequestV0; -use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::GetContestedResourceVoteStateResponseV0; -use dpp::check_validation_result_with_data; +use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{ + get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0, +}; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::identifier::Identifier; use dpp::validation::ValidationResult; use dpp::version::PlatformVersion; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::{check_validation_result_with_data, platform_value}; use drive::error::query::QuerySyntaxError; +use drive::query::vote_poll_vote_state_query::{ + Contender, ContestedDocumentVotePollDriveQuery, ContestedDocumentVotePollDriveQueryResultType, +}; impl Platform { pub(super) fn query_contested_resource_vote_status_v0( @@ -22,13 +27,16 @@ impl Platform { document_type_name, index_name, index_values, - include_documents, + result_type, start_at_identifier_info, + count, + order_ascending, prove, }: GetContestedResourceVoteStateRequestV0, platform_state: &PlatformState, platform_version: &PlatformVersion, ) -> Result, Error> { + let config = &self.config.drive; let contract_id: Identifier = check_validation_result_with_data!(contract_id.try_into().map_err(|_| { QueryError::InvalidArgument( @@ -66,7 +74,7 @@ impl Platform { )) )); - if index.name != &index_name { + if &index.name != &index_name { return Ok(QueryValidationResult::new_with_error(QueryError::InvalidArgument(format!( "index with name {} is not the contested index on the document type {}, {} is the name of the only contested index", index_name, document_type_name, index.name @@ -105,36 +113,93 @@ impl Platform { } .into(); + let limit = count + .map_or(Some(config.default_query_limit), |limit_value| { + if limit_value == 0 + || limit_value > u16::MAX as u32 + || limit_value as u16 > config.default_query_limit + { + None + } else { + Some(limit_value as u16) + } + }) + .ok_or(drive::error::Error::Query(QuerySyntaxError::InvalidLimit( + format!("limit greater than max limit {}", config.max_query_limit), + )))?; + + let query = ContestedDocumentVotePollDriveQuery { + vote_poll, + result_type: result_type.try_into()?, + offset: None, + limit: Some(limit), + start_at: start_at_identifier_info + .map(|start_at_identifier_info| { + Ok::<([u8; 32], bool), platform_value::Error>(( + Identifier::from_vec(start_at_identifier_info.start_identifier)? + .to_buffer(), + start_at_identifier_info.start_identifier_included, + )) + }) + .transpose()?, + order_ascending, + }; + let response = if prove { - let proof = check_validation_result_with_data!(self.drive.prove_identity_balance( - identity_id.into_buffer(), - None, - &platform_version.drive - )); + let proof = match query.execute_with_proof(&self.drive, None, None, platform_version) { + Ok(result) => result.0, + Err(drive::error::Error::Query(query_error)) => { + return Ok(QueryValidationResult::new_with_error(QueryError::Query( + query_error, + ))); + } + Err(e) => return Err(e.into()), + }; GetContestedResourceVoteStateResponseV0 { - result: Some(get_identity_balance_response_v0::Result::Proof( - self.response_proof_v0(platform_state, proof), - )), + result: Some( + get_contested_resource_vote_state_response_v0::Result::Proof( + self.response_proof_v0(platform_state, proof), + ), + ), metadata: Some(self.response_metadata_v0(platform_state)), } } else { - let maybe_balance = self.drive.fetch_identity_balance( - identity_id.into_buffer(), - None, - platform_version, - )?; - - let Some(balance) = maybe_balance else { - return Ok(ValidationResult::new_with_error(QueryError::NotFound( - "No Identity found".to_string(), - ))); - }; + let results = + match query.execute_no_proof(&self.drive, None, &mut vec![], platform_version) { + Ok(result) => result, + Err(drive::error::Error::Query(query_error)) => { + return Ok(QueryValidationResult::new_with_error(QueryError::Query( + query_error, + ))); + } + Err(e) => return Err(e.into()), + }; + + let contenders = results + .contenders + .into_iter() + .map( + |Contender { + identity_id, + serialized_document, + vote_tally, + }| { + get_contested_resource_vote_state_response_v0::Contender { + identifier: identity_id.to_vec(), + vote_count: vote_tally, + document: serialized_document, + } + }, + ) + .collect(); GetContestedResourceVoteStateResponseV0 { result: Some( - get_contested_resource_vote_status_response_v0::Result::ContestedResourceVoters( - balance, + get_contested_resource_vote_state_response_v0::Result::ContestedResourceContenders( + get_contested_resource_vote_state_response_v0::ContestedResourceContenders { + contenders + }, ), ), metadata: Some(self.response_metadata_v0(platform_state)), diff --git a/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs index 07872885fe..3c511dc504 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs @@ -7,6 +7,7 @@ use dapi_grpc::platform::v0::get_contested_resources_request::Version as Request use dapi_grpc::platform::v0::get_contested_resources_response::Version as ResponseVersion; use dapi_grpc::platform::v0::{ GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse, + GetContestedResourcesRequest, GetContestedResourcesResponse, }; use dpp::version::PlatformVersion; @@ -16,10 +17,10 @@ impl Platform { /// Querying of the contested resources pub fn query_contested_resources( &self, - GetContestedResourceVotersForIdentityRequest { version }: GetContestedResourceVotersForIdentityRequest, + GetContestedResourcesRequest { version }: GetContestedResourcesRequest, platform_state: &PlatformState, platform_version: &PlatformVersion, - ) -> Result, Error> { + ) -> Result, Error> { let Some(version) = version else { return Ok(QueryValidationResult::new_with_error( QueryError::DecodingError( @@ -56,11 +57,9 @@ impl Platform { platform_version, )?; - Ok(result.map( - |response_v0| GetContestedResourceVotersForIdentityResponse { - version: Some(ResponseVersion::V0(response_v0)), - }, - )) + Ok(result.map(|response_v0| GetContestedResourcesResponse { + version: Some(ResponseVersion::V0(response_v0)), + })) } } } diff --git a/packages/rs-drive/Cargo.toml b/packages/rs-drive/Cargo.toml index 3bac23ad69..483c6ddd55 100644 --- a/packages/rs-drive/Cargo.toml +++ b/packages/rs-drive/Cargo.toml @@ -45,10 +45,10 @@ enum-map = { version = "2.0.3", optional = true } intmap = { version = "2.0.0", features = ["serde"], optional = true } chrono = { version = "0.4.35", optional = true } itertools = { version = "0.11.0", optional = true } -grovedb = { git = "https://github.com/dashpay/grovedb", rev = "d9292aa20bd8f3bda7c5d25d62db06ac341b0677", optional = true, default-features = false } -grovedb-costs = { git = "https://github.com/dashpay/grovedb", rev = "d9292aa20bd8f3bda7c5d25d62db06ac341b0677", optional = true } -grovedb-path = { git = "https://github.com/dashpay/grovedb", rev = "d9292aa20bd8f3bda7c5d25d62db06ac341b0677" } -grovedb-storage = { git = "https://github.com/dashpay/grovedb", rev = "d9292aa20bd8f3bda7c5d25d62db06ac341b0677", optional = true } +grovedb = { git = "https://github.com/dashpay/grovedb", branch = "feat/QuerySumTree", optional = true, default-features = false } +grovedb-costs = { git = "https://github.com/dashpay/grovedb", branch = "feat/QuerySumTree", optional = true } +grovedb-path = { git = "https://github.com/dashpay/grovedb", branch = "feat/QuerySumTree" } +grovedb-storage = { git = "https://github.com/dashpay/grovedb", branch = "feat/QuerySumTree", optional = true } [dev-dependencies] criterion = "0.3.5" diff --git a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs index 13c130ed91..47e3f4b5f9 100644 --- a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs +++ b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs @@ -9,7 +9,7 @@ use grovedb::TransactionArg; mod v0; -use crate::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQuery; +use crate::query::vote_poll_vote_state_query::{Contender, ContestedDocumentVotePollDriveQuery}; pub use v0::*; /// Represents the outcome of a query to retrieve documents. @@ -27,15 +27,15 @@ pub enum QueryContestedDocumentsVoteStateOutcome { } impl QueryContestedDocumentsVoteStateOutcomeV0Methods for QueryContestedDocumentsVoteStateOutcome { - fn documents(&self) -> &Vec { + fn contenders(&self) -> &Vec { match self { - QueryContestedDocumentsVoteStateOutcome::V0(outcome) => outcome.documents(), + QueryContestedDocumentsVoteStateOutcome::V0(outcome) => outcome.contenders(), } } - fn documents_owned(self) -> Vec { + fn contenders_owned(self) -> Vec { match self { - QueryContestedDocumentsVoteStateOutcome::V0(outcome) => outcome.documents_owned(), + QueryContestedDocumentsVoteStateOutcome::V0(outcome) => outcome.contenders_owned(), } } diff --git a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs index dff9e47f8f..b87f7c7c57 100644 --- a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs @@ -1,7 +1,7 @@ use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; -use crate::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQuery; +use crate::query::vote_poll_vote_state_query::{Contender, ContestedDocumentVotePollDriveQuery}; use dpp::block::epoch::Epoch; use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use dpp::document::Document; @@ -12,7 +12,7 @@ use grovedb::TransactionArg; /// The outcome of a query #[derive(Debug, Default)] pub struct QueryContestedDocumentsVoteStateOutcomeV0 { - documents: Vec, + contenders: Vec, cost: u64, } @@ -23,10 +23,10 @@ pub struct QueryContestedDocumentsVoteStateOutcomeV0 { /// include retrieving the documents, skipped count, and the associated cost /// of the query. pub trait QueryContestedDocumentsVoteStateOutcomeV0Methods { - /// Returns a reference to the documents found from the query. - fn documents(&self) -> &Vec; - /// Consumes the instance to return the owned documents. - fn documents_owned(self) -> Vec; + /// Returns a reference to the contenders found from the query. + fn contenders(&self) -> &Vec; + /// Consumes the instance to return the owned contenders. + fn contenders_owned(self) -> Vec; /// Returns the processing cost associated with the query. fn cost(&self) -> u64; } @@ -34,12 +34,12 @@ pub trait QueryContestedDocumentsVoteStateOutcomeV0Methods { impl QueryContestedDocumentsVoteStateOutcomeV0Methods for QueryContestedDocumentsVoteStateOutcomeV0 { - fn documents(&self) -> &Vec { - &self.documents + fn contenders(&self) -> &Vec { + &self.contenders } - fn documents_owned(self) -> Vec { - self.documents + fn contenders_owned(self) -> Vec { + self.contenders } fn cost(&self) -> u64 { @@ -74,18 +74,8 @@ impl Drive { platform_version: &PlatformVersion, ) -> Result { let mut drive_operations: Vec = vec![]; - let (items, skipped) = query.execute_raw_results_no_proof_internal( - self, - transaction, - &mut drive_operations, - platform_version, - )?; - let documents = items - .into_iter() - .map(|serialized| { - Document::from_bytes(serialized.as_slice(), query.document_type, platform_version) - }) - .collect::, ProtocolError>>()?; + let contested_document_vote_poll_drive_query_execution_result = + query.execute_no_proof(self, transaction, &mut drive_operations, platform_version)?; let cost = if let Some(epoch) = epoch { let fee_result = Drive::calculate_fee( None, @@ -99,6 +89,9 @@ impl Drive { 0 }; - Ok(QueryContestedDocumentsVoteStateOutcomeV0 { documents, cost }) + Ok(QueryContestedDocumentsVoteStateOutcomeV0 { + contenders: contested_document_vote_poll_drive_query_execution_result.contenders, + cost, + }) } } diff --git a/packages/rs-drive/src/drive/grove_operations/grove_get_path_query_serialized_or_sum_results/mod.rs b/packages/rs-drive/src/drive/grove_operations/grove_get_path_query_serialized_or_sum_results/mod.rs new file mode 100644 index 0000000000..e71110563e --- /dev/null +++ b/packages/rs-drive/src/drive/grove_operations/grove_get_path_query_serialized_or_sum_results/mod.rs @@ -0,0 +1,49 @@ +mod v0; + +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use dpp::version::drive_versions::DriveVersion; +use grovedb::operations::QueryItemOrSumReturnType; +use grovedb::PathQuery; +use grovedb::TransactionArg; + +impl Drive { + /// Retrieves the serialized or sum results of a path query from GroveDB. + /// + /// # Parameters + /// * `path_query`: The path query to execute. + /// * `transaction`: The groveDB transaction associated with this operation. + /// * `drive_operations`: A vector to collect the costs of operations for later computation. + /// * `platform_version`: The platform version to select the correct function version to run. + /// + /// # Returns + /// * `Ok((Vec>, u16))` if the operation was successful. + /// * `Err(DriveError::UnknownVersionMismatch)` if the platform version does not match known versions. + /// * `Err(DriveError::GroveDB)` if the GroveDB operation returned an error. + pub fn grove_get_path_query_serialized_or_sum_results( + &self, + path_query: &PathQuery, + transaction: TransactionArg, + drive_operations: &mut Vec, + drive_version: &DriveVersion, + ) -> Result<(Vec, u16), Error> { + match drive_version + .grove_methods + .basic + .grove_get_path_query_serialized_or_sum_results + { + 0 => self.grove_get_path_query_serialized_or_sum_results_v0( + path_query, + transaction, + drive_operations, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "grove_get_path_query_serialized_or_sum_results".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/grove_operations/grove_get_path_query_serialized_or_sum_results/v0/mod.rs b/packages/rs-drive/src/drive/grove_operations/grove_get_path_query_serialized_or_sum_results/v0/mod.rs new file mode 100644 index 0000000000..4b048cf997 --- /dev/null +++ b/packages/rs-drive/src/drive/grove_operations/grove_get_path_query_serialized_or_sum_results/v0/mod.rs @@ -0,0 +1,28 @@ +use crate::drive::Drive; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use crate::fee::op::LowLevelDriveOperation::CalculatedCostOperation; +use grovedb::operations::QueryItemOrSumReturnType; +use grovedb::{PathQuery, TransactionArg}; +use grovedb_costs::CostContext; + +impl Drive { + /// Gets the return value and the cost of a groveDB path query. + /// Pushes the cost to `drive_operations` and returns the return value. + pub(super) fn grove_get_path_query_serialized_or_sum_results_v0( + &self, + path_query: &PathQuery, + transaction: TransactionArg, + drive_operations: &mut Vec, + ) -> Result<(Vec, u16), Error> { + let CostContext { value, cost } = self.grove.query_item_value_or_sum( + path_query, + transaction.is_some(), + true, + true, + transaction, + ); + drive_operations.push(CalculatedCostOperation(cost)); + value.map_err(Error::GroveDB) + } +} diff --git a/packages/rs-drive/src/drive/grove_operations/mod.rs b/packages/rs-drive/src/drive/grove_operations/mod.rs index 4991b9bc67..12207cd0a5 100644 --- a/packages/rs-drive/src/drive/grove_operations/mod.rs +++ b/packages/rs-drive/src/drive/grove_operations/mod.rs @@ -134,6 +134,7 @@ pub mod grove_batch_operations_costs; /// Clear a subtree in grovedb pub mod grove_clear; +mod grove_get_path_query_serialized_or_sum_results; /// Proved path query in grovedb with a conditional query pub mod grove_get_proved_path_query_with_conditional; diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index 9968828f07..617be2c23d 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -5,7 +5,6 @@ use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; -use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use platform_version::version::PlatformVersion; diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 16e02c2fcb..4238fc2503 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -22,6 +22,7 @@ pub mod paths; mod setup; #[cfg(any(feature = "server", feature = "verify"))] +/// Resolve contested document resource vote poll module pub mod resolve_contested_document_resource_vote_poll; /// A trait to convert the vote to a tree path usable in grovedb diff --git a/packages/rs-drive/src/drive/votes/resolve_contested_document_resource_vote_poll/mod.rs b/packages/rs-drive/src/drive/votes/resolve_contested_document_resource_vote_poll/mod.rs index cb06dd5124..b8a78aa18b 100644 --- a/packages/rs-drive/src/drive/votes/resolve_contested_document_resource_vote_poll/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolve_contested_document_resource_vote_poll/mod.rs @@ -13,19 +13,57 @@ use grovedb::TransactionArg; use platform_version::version::PlatformVersion; use std::sync::Arc; -#[derive(Debug, PartialEq)] +/// Represents information related to a contested document resource vote poll, along with +/// associated contract details. +/// +/// This structure holds a reference to the contract, the document type name, +/// the index name, and the index values used for the poll. +#[derive(Debug, PartialEq, Clone)] pub struct ContestedDocumentResourceVotePollWithContractInfo { + /// The contract information associated with the document. pub contract: Arc, + /// The name of the document type. pub document_type_name: String, + /// The name of the index. pub index_name: String, + /// The values used in the index for the poll. pub index_values: Vec, } impl ContestedDocumentResourceVotePollWithContractInfo { + /// Retrieves the index associated with the document type and index name. + /// + /// # Returns + /// + /// * `Ok(&Index)` - A reference to the index if found. + /// * `Err(Error)` - An error if the index is not found or if there is an issue retrieving it. + /// + /// # Errors + /// + /// This method returns an `Error::Drive` variant with `DriveError::ContestedIndexNotFound` + /// if the index cannot be found within the document type. pub fn index(&self) -> Result<&Index, Error> { - self.contract.contract.document_type_borrowed_for_name(self.document_type_name.as_str())?.indexes().get(&self.index_name).ok_or(Error::Drive(DriveError::ContestedIndexNotFound("contested index not found when try to get it from the contested document resource vote poll with contract info"))) + self.contract + .contract + .document_type_borrowed_for_name(self.document_type_name.as_str())? + .indexes() + .get(&self.index_name) + .ok_or(Error::Drive(DriveError::ContestedIndexNotFound( + "contested index not found when trying to get it from the contested document resource vote poll with contract info" + ))) } + /// Retrieves the document type reference associated with the document type name. + /// + /// # Returns + /// + /// * `Ok(DocumentTypeRef)` - A reference to the document type if found. + /// * `Err(Error)` - An error if the document type cannot be found or if there is an issue retrieving it. + /// + /// # Errors + /// + /// This method returns an `Error::Protocol` variant with `ProtocolError::DataContractError` + /// if there is an issue retrieving the document type. pub fn document_type(&self) -> Result { self.contract .contract @@ -33,6 +71,17 @@ impl ContestedDocumentResourceVotePollWithContractInfo { .map_err(|e| Error::Protocol(ProtocolError::DataContractError(e))) } + /// Borrows a reference to the document type associated with the document type name. + /// + /// # Returns + /// + /// * `Ok(&DocumentType)` - A borrowed reference to the document type if found. + /// * `Err(Error)` - An error if the document type cannot be found or if there is an issue retrieving it. + /// + /// # Errors + /// + /// This method returns an `Error::Protocol` variant with `ProtocolError::DataContractError` + /// if there is an issue retrieving the document type. pub fn document_type_borrowed(&self) -> Result<&DocumentType, Error> { self.contract .contract @@ -41,7 +90,31 @@ impl ContestedDocumentResourceVotePollWithContractInfo { } } +/// A trait for resolving information related to a contested document resource vote poll. +/// +/// This trait defines a method to resolve and retrieve the necessary contract and index +/// information associated with a contested document resource vote poll. pub trait ContestedDocumentResourceVotePollResolver { + /// Resolves the contested document resource vote poll information. + /// + /// This method fetches the contract, document type name, index name, and index values + /// required to process a contested document resource vote poll. + /// + /// # Parameters + /// + /// * `drive`: A reference to the `Drive` object used for database interactions. + /// * `transaction`: The transaction argument used to ensure consistency during the resolve operation. + /// * `platform_version`: The platform version to ensure compatibility. + /// + /// # Returns + /// + /// * `Ok(ContestedDocumentResourceVotePollWithContractInfo)` - The resolved information needed for the vote poll. + /// * `Err(Error)` - An error if the resolution process fails. + /// + /// # Errors + /// + /// This method returns an `Error` variant if there is an issue resolving the contested document resource vote poll + /// information. The specific error depends on the underlying problem encountered during resolution. fn resolve( &self, drive: &Drive, diff --git a/packages/rs-drive/src/query/mod.rs b/packages/rs-drive/src/query/mod.rs index cde6d32fc6..2585512c28 100644 --- a/packages/rs-drive/src/query/mod.rs +++ b/packages/rs-drive/src/query/mod.rs @@ -75,8 +75,10 @@ mod single_document_drive_query; mod test_index; #[cfg(any(feature = "server", feature = "verify"))] +/// Vote poll vote state query module pub mod vote_poll_vote_state_query; #[cfg(any(feature = "server", feature = "verify"))] +/// Vote Query module pub mod vote_query; #[cfg(any(feature = "server", feature = "verify"))] diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index 2b6e5e8698..5fb8a8a4f9 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -4,20 +4,49 @@ use crate::drive::votes::resolve_contested_document_resource_vote_poll::{ ContestedDocumentResourceVotePollResolver, ContestedDocumentResourceVotePollWithContractInfo, }; use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::query::QuerySyntaxError; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; -use crate::query::{GroveError, Query}; +use crate::query::{GroveError, Query, SingleDocumentDriveQueryContestedStatus}; use dpp::block::block_info::BlockInfo; +use dpp::identifier::Identifier; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use grovedb::query_result_type::{QueryResultElements, QueryResultType}; -use grovedb::{PathQuery, SizedQuery, TransactionArg}; +use grovedb::{Element, PathQuery, SizedQuery, TransactionArg}; use platform_version::version::PlatformVersion; -/// Vote Poll Drive Query result type +/// Represents the types of results that can be obtained from a contested document vote poll query. +/// +/// This enum defines the various types of results that can be returned when querying the drive +/// for contested document vote poll information. #[derive(Debug, PartialEq, Clone, Copy)] pub enum ContestedDocumentVotePollDriveQueryResultType { + /// Only the identity IDs are returned in the query result. + IdentityIdsOnly, + /// The documents associated with the vote poll are returned in the query result. Documents, + /// The vote tally results are returned in the query result. VoteTally, + /// Both the documents and the vote tally results are returned in the query result. + DocumentsAndVoteTally, +} + +impl TryFrom for ContestedDocumentVotePollDriveQueryResultType { + type Error = Error; + + fn try_from(value: i32) -> Result { + match value { + 0 => Ok(ContestedDocumentVotePollDriveQueryResultType::IdentityIdsOnly), + 1 => Ok(ContestedDocumentVotePollDriveQueryResultType::Documents), + 2 => Ok(ContestedDocumentVotePollDriveQueryResultType::VoteTally), + 3 => Ok(ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally), + n => Err(Error::Query(QuerySyntaxError::Unsupported(format!( + "unsupported contested document vote poll drive query result type {}, only 0, 1 and 2 are supported", + n + )))), + } + } } /// Vote Poll Drive Query struct @@ -32,14 +61,58 @@ pub struct ContestedDocumentVotePollDriveQuery { /// Limit pub limit: Option, /// Start at identity id - pub start_at: Option<[u8; 32]>, - /// Start at included - pub start_at_included: bool, + pub start_at: Option<([u8; 32], bool)>, /// Ascending pub order_ascending: bool, } +/// Represents a contender in the contested document vote poll. +/// +/// This struct holds the identity ID of the contender, the serialized document, +/// and the vote tally. +#[derive(Debug, PartialEq, Eq, Clone, Default)] +pub struct Contender { + /// The identity ID of the contender. + identity_id: Identifier, + /// The serialized document associated with the contender. + serialized_document: Option>, + /// The vote tally for the contender. + vote_tally: Option, +} + +/// Represents the result of executing a contested document vote poll drive query. +/// +/// This struct holds the list of contenders and the number of skipped items +/// when an offset is given. +#[derive(Debug, PartialEq, Eq, Clone, Default)] +pub struct ContestedDocumentVotePollDriveQueryExecutionResult { + /// The list of contenders returned by the query. + pub contenders: Vec, + /// The number of skipped items when an offset is given. + pub skipped: u16, +} + impl ContestedDocumentVotePollDriveQuery { + /// Resolves the contested document vote poll drive query. + /// + /// This method processes the query by interacting with the drive, using the provided + /// transaction and platform version to ensure consistency and compatibility. + /// + /// # Parameters + /// + /// * `drive`: A reference to the `Drive` object used for database interactions. + /// * `transaction`: The transaction argument used to ensure consistency during the resolve operation. + /// * `platform_version`: The platform version to ensure compatibility. + /// + /// # Returns + /// + /// * `Ok(ResolvedContestedDocumentVotePollDriveQuery)` - The resolved query information. + /// * `Err(Error)` - An error if the resolution process fails. + /// + /// # Errors + /// + /// This method returns an `Error` variant if there is an issue resolving the query. + /// The specific error depends on the underlying problem encountered during resolution. pub fn resolve( &self, drive: &Drive, @@ -52,7 +125,6 @@ impl ContestedDocumentVotePollDriveQuery { offset, limit, start_at, - start_at_included, order_ascending, } = self; Ok(ResolvedContestedDocumentVotePollDriveQuery { @@ -61,7 +133,6 @@ impl ContestedDocumentVotePollDriveQuery { offset: *offset, limit: *limit, start_at: *start_at, - start_at_included: *start_at_included, order_ascending: *order_ascending, }) } @@ -116,75 +187,71 @@ impl ContestedDocumentVotePollDriveQuery { &platform_version.drive, ) } - - #[cfg(all(feature = "server", feature = "verify"))] - /// Executes a query with proof and returns the root hash, items, and fee. - pub fn execute_with_proof_only_get_elements( - self, - drive: &Drive, - block_info: Option, - transaction: TransactionArg, - platform_version: &PlatformVersion, - ) -> Result<(RootHash, Vec>, u64), Error> { - let mut drive_operations = vec![]; - let (root_hash, items) = self.execute_with_proof_only_get_elements_internal( - drive, - transaction, - &mut drive_operations, - platform_version, - )?; - let cost = if let Some(block_info) = block_info { - let fee_result = Drive::calculate_fee( - None, - Some(drive_operations), - &block_info.epoch, - drive.config.epochs_per_era, - platform_version, - )?; - fee_result.processing_fee - } else { - 0 - }; - Ok((root_hash, items, cost)) - } - - #[cfg(all(feature = "server", feature = "verify"))] - /// Executes an internal query with proof and returns the root hash and values. - pub(crate) fn execute_with_proof_only_get_elements_internal( - self, - drive: &Drive, - transaction: TransactionArg, - drive_operations: &mut Vec, - platform_version: &PlatformVersion, - ) -> Result<(RootHash, Vec>), Error> { - let resolved = self.resolve(drive, transaction, platform_version)?; - let path_query = resolved.construct_path_query(platform_version)?; - let proof = drive.grove_get_proved_path_query( - &path_query, - self.start_at.is_some(), - transaction, - drive_operations, - &platform_version.drive, - )?; - self.verify_proof_keep_serialized(proof.as_slice(), platform_version) - } + // + // #[cfg(all(feature = "server", feature = "verify"))] + // /// Executes a query with proof and returns the root hash, items, and fee. + // pub fn execute_with_proof_only_get_elements( + // self, + // drive: &Drive, + // block_info: Option, + // transaction: TransactionArg, + // platform_version: &PlatformVersion, + // ) -> Result<(RootHash, Vec>, u64), Error> { + // let mut drive_operations = vec![]; + // let (root_hash, items) = self.execute_with_proof_only_get_elements_internal( + // drive, + // transaction, + // &mut drive_operations, + // platform_version, + // )?; + // let cost = if let Some(block_info) = block_info { + // let fee_result = Drive::calculate_fee( + // None, + // Some(drive_operations), + // &block_info.epoch, + // drive.config.epochs_per_era, + // platform_version, + // )?; + // fee_result.processing_fee + // } else { + // 0 + // }; + // Ok((root_hash, items, cost)) + // } + // + // #[cfg(all(feature = "server", feature = "verify"))] + // /// Executes an internal query with proof and returns the root hash and values. + // pub(crate) fn execute_with_proof_only_get_elements_internal( + // self, + // drive: &Drive, + // transaction: TransactionArg, + // drive_operations: &mut Vec, + // platform_version: &PlatformVersion, + // ) -> Result<(RootHash, Vec>), Error> { + // let resolved = self.resolve(drive, transaction, platform_version)?; + // let path_query = resolved.construct_path_query(platform_version)?; + // let proof = drive.grove_get_proved_path_query( + // &path_query, + // self.start_at.is_some(), + // transaction, + // drive_operations, + // &platform_version.drive, + // )?; + // self.verify_proof_keep_serialized(proof.as_slice(), platform_version) + // } #[cfg(feature = "server")] /// Executes a query with no proof and returns the items, skipped items, and fee. - pub fn execute_raw_results_no_proof( + pub fn execute_no_proof_with_cost( &self, drive: &Drive, block_info: Option, transaction: TransactionArg, platform_version: &PlatformVersion, - ) -> Result<(Vec>, u16, u64), Error> { + ) -> Result<(ContestedDocumentVotePollDriveQueryExecutionResult, u64), Error> { let mut drive_operations = vec![]; - let (items, skipped) = self.execute_raw_results_no_proof_internal( - drive, - transaction, - &mut drive_operations, - platform_version, - )?; + let result = + self.execute_no_proof(drive, transaction, &mut drive_operations, platform_version)?; let cost = if let Some(block_info) = block_info { let fee_result = Drive::calculate_fee( None, @@ -197,35 +264,99 @@ impl ContestedDocumentVotePollDriveQuery { } else { 0 }; - Ok((items, skipped, cost)) + Ok((result, cost)) } #[cfg(feature = "server")] /// Executes an internal query with no proof and returns the values and skipped items. - pub(crate) fn execute_raw_results_no_proof_internal( + pub fn execute_no_proof( &self, drive: &Drive, transaction: TransactionArg, drive_operations: &mut Vec, platform_version: &PlatformVersion, - ) -> Result<(Vec>, u16), Error> { + ) -> Result { let resolved = self.resolve(drive, transaction, platform_version)?; let path_query = resolved.construct_path_query(platform_version)?; - let query_result = drive.grove_get_path_query_serialized_results( + let query_result = drive.grove_get_path_query( &path_query, transaction, + QueryResultType::QueryPathKeyElementTrioResultType, drive_operations, &platform_version.drive, ); match query_result { Err(Error::GroveDB(GroveError::PathKeyNotFound(_))) | Err(Error::GroveDB(GroveError::PathNotFound(_))) - | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok((Vec::new(), 0)), - _ => { - let (data, skipped) = query_result?; - { - Ok((data, skipped)) - } + | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => { + Ok(ContestedDocumentVotePollDriveQueryExecutionResult::default()) + } + Err(e) => Err(e), + Ok((query_result_elements, skipped)) => { + let contenders = match self.result_type { + ContestedDocumentVotePollDriveQueryResultType::IdentityIdsOnly => { + query_result_elements.to_keys().into_iter().map(|identity_id| Ok(Contender { + identity_id: Identifier::try_from(identity_id)?, + serialized_document: None, + vote_tally: None, + })).collect::, Error>>() + } + ContestedDocumentVotePollDriveQueryResultType::Documents => { + query_result_elements.to_key_elements().into_iter().map(|(identity_id, document)| { + Ok(Contender { + identity_id: Identifier::try_from(identity_id)?, + serialized_document: Some(document.into_item_bytes()?), + vote_tally: None, + }) + }).collect::, Error>>() + } + ContestedDocumentVotePollDriveQueryResultType::VoteTally => { + query_result_elements.to_key_elements().into_iter().map(|(identity_id, vote_tally)| { + let sum_tree_value = vote_tally.into_sum_tree_value()?; + if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!("sum tree value for vote tally must be between 0 and u32::Max, received {} from state", sum_tree_value)))); + } + Ok(Contender { + identity_id: Identifier::try_from(identity_id)?, + serialized_document: None, + vote_tally: Some(sum_tree_value as u32), + }) + }).collect::, Error>>() + } + ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally => { + let mut elements_iter = query_result_elements.to_path_key_elements().into_iter(); + + let mut contenders = vec![]; + while let (Some((path_doc, _, Element::Item(serialized_document, _))), Some((path_tally, _, Element::SumTree(_, sum_tree_value, _)))) = (elements_iter.next(), elements_iter.next()) { + if path_doc != path_tally { + return Err(Error::Drive(DriveError::CorruptedDriveState("the two results in a chunk when requesting documents and vote tally should both have the same path".to_string()))); + } + let Some(identity_bytes) = path_doc.last() else { + return Err(Error::Drive(DriveError::CorruptedDriveState("the path must have a last element".to_string()))); + }; + + let identity_id = Identifier::from_bytes(identity_bytes)?; + + if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!("sum tree value for vote tally must be between 0 and u32::Max, received {} from state", sum_tree_value)))); + } + + let contender = Contender { + identity_id, + serialized_document: Some(serialized_document), + vote_tally: Some(sum_tree_value as u32), + }; + + contenders.push(contender) + } + Ok(contenders) + } + }?; + + Ok(ContestedDocumentVotePollDriveQueryExecutionResult { + contenders, + skipped, + }) } } } @@ -277,10 +408,8 @@ pub struct ResolvedContestedDocumentVotePollDriveQuery { pub offset: Option, /// Limit pub limit: Option, - /// Start at identity id - pub start_at: Option<[u8; 32]>, - /// Start at included - pub start_at_included: bool, + /// Start at identity id, the bool is if it is also included + pub start_at: Option<([u8; 32], bool)>, /// Ascending pub order_ascending: bool, } @@ -300,14 +429,14 @@ impl ResolvedContestedDocumentVotePollDriveQuery { None => { query.insert_all(); } - Some(starts_at_key_bytes) => { + Some((starts_at_key_bytes, start_at_included)) => { let starts_at_key = starts_at_key_bytes.to_vec(); match self.order_ascending { - true => match self.start_at_included { + true => match start_at_included { true => query.insert_range_from(starts_at_key..), false => query.insert_range_after(starts_at_key..), }, - false => match self.start_at_included { + false => match start_at_included { true => query.insert_range_to_inclusive(..=starts_at_key), false => query.insert_range_to(..starts_at_key), }, @@ -315,6 +444,20 @@ impl ResolvedContestedDocumentVotePollDriveQuery { } } + let (subquery_path, subquery) = match self.result_type { + ContestedDocumentVotePollDriveQueryResultType::Documents => (Some(vec![vec![0]]), None), + ContestedDocumentVotePollDriveQueryResultType::VoteTally => (Some(vec![vec![1]]), None), + ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally => { + let mut query = Query::new(); + query.insert_keys(vec![vec![0], vec![1]]); + (None, Some(query.into())) + } + ContestedDocumentVotePollDriveQueryResultType::IdentityIdsOnly => (None, None), + }; + + query.default_subquery_branch.subquery_path = subquery_path; + query.default_subquery_branch.subquery = subquery; + Ok(PathQuery { path, query: SizedQuery { @@ -324,224 +467,4 @@ impl ResolvedContestedDocumentVotePollDriveQuery { }, }) } - - #[cfg(feature = "server")] - /// Executes a query with proof and returns the items and fee. - pub fn execute_with_proof( - self, - drive: &Drive, - block_info: Option, - transaction: TransactionArg, - platform_version: &PlatformVersion, - ) -> Result<(Vec, u64), Error> { - let mut drive_operations = vec![]; - let items = self.execute_with_proof_internal( - drive, - transaction, - &mut drive_operations, - platform_version, - )?; - let cost = if let Some(block_info) = block_info { - let fee_result = Drive::calculate_fee( - None, - Some(drive_operations), - &block_info.epoch, - drive.config.epochs_per_era, - platform_version, - )?; - fee_result.processing_fee - } else { - 0 - }; - Ok((items, cost)) - } - - #[cfg(feature = "server")] - /// Executes an internal query with proof and returns the items. - pub(crate) fn execute_with_proof_internal( - self, - drive: &Drive, - transaction: TransactionArg, - drive_operations: &mut Vec, - platform_version: &PlatformVersion, - ) -> Result, Error> { - let path_query = self.construct_path_query_operations( - drive, - true, - transaction, - drive_operations, - platform_version, - )?; - drive.grove_get_proved_path_query( - &path_query, - false, - transaction, - drive_operations, - &platform_version.drive, - ) - } - - #[cfg(all(feature = "server", feature = "verify"))] - /// Executes a query with proof and returns the root hash, items, and fee. - pub fn execute_with_proof_only_get_elements( - self, - drive: &Drive, - block_info: Option, - transaction: TransactionArg, - platform_version: &PlatformVersion, - ) -> Result<(RootHash, Vec>, u64), Error> { - let mut drive_operations = vec![]; - let (root_hash, items) = self.execute_with_proof_only_get_elements_internal( - drive, - transaction, - &mut drive_operations, - platform_version, - )?; - let cost = if let Some(block_info) = block_info { - let fee_result = Drive::calculate_fee( - None, - Some(drive_operations), - &block_info.epoch, - drive.config.epochs_per_era, - platform_version, - )?; - fee_result.processing_fee - } else { - 0 - }; - Ok((root_hash, items, cost)) - } - - #[cfg(all(feature = "server", feature = "verify"))] - /// Executes an internal query with proof and returns the root hash and values. - pub(crate) fn execute_with_proof_only_get_elements_internal( - self, - drive: &Drive, - transaction: TransactionArg, - drive_operations: &mut Vec, - platform_version: &PlatformVersion, - ) -> Result<(RootHash, Vec>), Error> { - let path_query = self.construct_path_query_operations( - drive, - true, - transaction, - drive_operations, - platform_version, - )?; - - let proof = drive.grove_get_proved_path_query( - &path_query, - self.start_at.is_some(), - transaction, - drive_operations, - &platform_version.drive, - )?; - self.verify_proof_keep_serialized(proof.as_slice(), platform_version) - } - - #[cfg(feature = "server")] - /// Executes a query with no proof and returns the items, skipped items, and fee. - pub fn execute_raw_results_no_proof( - &self, - drive: &Drive, - block_info: Option, - transaction: TransactionArg, - platform_version: &PlatformVersion, - ) -> Result<(Vec>, u16, u64), Error> { - let mut drive_operations = vec![]; - let (items, skipped) = self.execute_raw_results_no_proof_internal( - drive, - transaction, - &mut drive_operations, - platform_version, - )?; - let cost = if let Some(block_info) = block_info { - let fee_result = Drive::calculate_fee( - None, - Some(drive_operations), - &block_info.epoch, - drive.config.epochs_per_era, - platform_version, - )?; - fee_result.processing_fee - } else { - 0 - }; - Ok((items, skipped, cost)) - } - - #[cfg(feature = "server")] - /// Executes an internal query with no proof and returns the values and skipped items. - pub(crate) fn execute_raw_results_no_proof_internal( - &self, - drive: &Drive, - transaction: TransactionArg, - drive_operations: &mut Vec, - platform_version: &PlatformVersion, - ) -> Result<(Vec>, u16), Error> { - let path_query = self.construct_path_query_operations( - drive, - false, - transaction, - drive_operations, - platform_version, - )?; - let query_result = drive.grove_get_path_query_serialized_results( - &path_query, - transaction, - drive_operations, - &platform_version.drive, - ); - match query_result { - Err(Error::GroveDB(GroveError::PathKeyNotFound(_))) - | Err(Error::GroveDB(GroveError::PathNotFound(_))) - | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok((Vec::new(), 0)), - _ => { - let (data, skipped) = query_result?; - { - Ok((data, skipped)) - } - } - } - } - - #[cfg(feature = "server")] - #[allow(unused)] - /// Executes an internal query with no proof and returns the values and skipped items. - pub(crate) fn execute_no_proof_internal( - &self, - drive: &Drive, - result_type: QueryResultType, - transaction: TransactionArg, - drive_operations: &mut Vec, - platform_version: &PlatformVersion, - ) -> Result<(QueryResultElements, u16), Error> { - let path_query = self.construct_path_query_operations( - drive, - false, - transaction, - drive_operations, - platform_version, - )?; - let query_result = drive.grove_get_path_query( - &path_query, - transaction, - result_type, - drive_operations, - &platform_version.drive, - ); - match query_result { - Err(Error::GroveDB(GroveError::PathKeyNotFound(_))) - | Err(Error::GroveDB(GroveError::PathNotFound(_))) - | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => { - Ok((QueryResultElements::new(), 0)) - } - _ => { - let (data, skipped) = query_result?; - { - Ok((data, skipped)) - } - } - } - } } diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index f43158195a..b415138f37 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -382,6 +382,7 @@ pub struct DriveGroveBasicMethodVersions { pub grove_get_raw_value_u64_from_encoded_var_vec: FeatureVersion, pub grove_get: FeatureVersion, pub grove_get_path_query_serialized_results: FeatureVersion, + pub grove_get_path_query_serialized_or_sum_results: FeatureVersion, pub grove_get_path_query: FeatureVersion, pub grove_get_path_query_with_optional: FeatureVersion, pub grove_get_raw_path_query_with_optional: FeatureVersion, diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 48f6672cc4..5efde6b625 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -500,6 +500,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { grove_get_raw_value_u64_from_encoded_var_vec: 0, grove_get: 0, grove_get_path_query_serialized_results: 0, + grove_get_path_query_serialized_or_sum_results: 0, grove_get_path_query: 0, grove_get_path_query_with_optional: 0, grove_get_raw_path_query_with_optional: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index e4d5103888..d2b7b251ad 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -500,6 +500,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { grove_get_raw_value_u64_from_encoded_var_vec: 0, grove_get: 0, grove_get_path_query_serialized_results: 0, + grove_get_path_query_serialized_or_sum_results: 0, grove_get_path_query: 0, grove_get_path_query_with_optional: 0, grove_get_raw_path_query_with_optional: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 7c9d26854e..63bd35649d 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -499,6 +499,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { grove_get_raw_value_u64_from_encoded_var_vec: 0, grove_get: 0, grove_get_path_query_serialized_results: 0, + grove_get_path_query_serialized_or_sum_results: 0, grove_get_path_query: 0, grove_get_path_query_with_optional: 0, grove_get_raw_path_query_with_optional: 0, From b54e7658d8f0058f9518624b422247c287f7378a Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 19 May 2024 04:40:37 +0200 Subject: [PATCH 063/135] another query --- .../protos/platform/v0/platform.proto | 25 +- .../proto/org.dash.platform.dapi.v0.rs | 57 ++-- .../v0/mod.rs | 201 +++++++++++++ .../contested_resource_vote_state/v0/mod.rs | 4 +- .../v0/mod.rs | 233 +++++++++++++++ .../query/voting/contested_resources/mod.rs | 1 - packages/rs-drive/src/query/mod.rs | 4 + .../query/vote_poll_contestant_votes_query.rs | 282 ++++++++++++++++++ .../src/query/vote_poll_vote_state_query.rs | 9 +- 9 files changed, 775 insertions(+), 41 deletions(-) create mode 100644 packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index f57d82d38f..529097ad40 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -729,12 +729,19 @@ message GetContestedResourceVoteStateResponse { // Who voted for a contested resource to go to a specific identity? message GetContestedResourceVotersForIdentityRequest { message GetContestedResourceVotersForIdentityRequestV0 { - bool prove = 1; - repeated bytes resource_path = 2; - bytes resource_identifier = 3; - optional bytes voter_identifier = 4; - optional uint32 count = 5; - optional bool ascending = 6; + message StartAtIdentifierInfo { + bytes start_identifier = 1; + bool start_identifier_included = 2; + } + bytes contract_id = 1; + string document_type_name = 2; + string index_name = 3; + repeated bytes index_values = 4; + bytes contestant_id = 5; + optional StartAtIdentifierInfo start_at_identifier_info = 6; + optional uint32 count = 7; + bool order_ascending = 8; + bool prove = 9; } oneof version { @@ -745,14 +752,10 @@ message GetContestedResourceVotersForIdentityRequest { message GetContestedResourceVotersForIdentityResponse { message GetContestedResourceVotersForIdentityResponseV0 { message ContestedResourceVoters { - repeated Voter voters = 1; + repeated bytes voters = 1; bool finished_results = 2; } - message Voter { - bytes identifier = 1; - } - oneof result { ContestedResourceVoters contested_resource_voters = 1; Proof proof = 2; diff --git a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs index 0ecb9f9438..ac6c7ab92d 100644 --- a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs +++ b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs @@ -2429,18 +2429,40 @@ pub mod get_contested_resource_voters_for_identity_request { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetContestedResourceVotersForIdentityRequestV0 { - #[prost(bool, tag = "1")] - pub prove: bool, - #[prost(bytes = "vec", repeated, tag = "2")] - pub resource_path: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, - #[prost(bytes = "vec", tag = "3")] - pub resource_identifier: ::prost::alloc::vec::Vec, - #[prost(bytes = "vec", optional, tag = "4")] - pub voter_identifier: ::core::option::Option<::prost::alloc::vec::Vec>, - #[prost(uint32, optional, tag = "5")] + #[prost(bytes = "vec", tag = "1")] + pub contract_id: ::prost::alloc::vec::Vec, + #[prost(string, tag = "2")] + pub document_type_name: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub index_name: ::prost::alloc::string::String, + #[prost(bytes = "vec", repeated, tag = "4")] + pub index_values: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, + #[prost(bytes = "vec", tag = "5")] + pub contestant_id: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "6")] + pub start_at_identifier_info: ::core::option::Option< + get_contested_resource_voters_for_identity_request_v0::StartAtIdentifierInfo, + >, + #[prost(uint32, optional, tag = "7")] pub count: ::core::option::Option, - #[prost(bool, optional, tag = "6")] - pub ascending: ::core::option::Option, + #[prost(bool, tag = "8")] + pub order_ascending: bool, + #[prost(bool, tag = "9")] + pub prove: bool, + } + /// Nested message and enum types in `GetContestedResourceVotersForIdentityRequestV0`. + pub mod get_contested_resource_voters_for_identity_request_v0 { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct StartAtIdentifierInfo { + #[prost(bytes = "vec", tag = "1")] + pub start_identifier: ::prost::alloc::vec::Vec, + #[prost(bool, tag = "2")] + pub start_identifier_included: bool, + } } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] @@ -2491,22 +2513,13 @@ pub mod get_contested_resource_voters_for_identity_response { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ContestedResourceVoters { - #[prost(message, repeated, tag = "1")] - pub voters: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", repeated, tag = "1")] + pub voters: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, #[prost(bool, tag = "2")] pub finished_results: bool, } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] - #[derive(::dapi_grpc_macros::Mockable)] - #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Voter { - #[prost(bytes = "vec", tag = "1")] - pub identifier: ::prost::alloc::vec::Vec, - } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/v0/mod.rs index 8b13789179..5b77587958 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/v0/mod.rs @@ -1 +1,202 @@ +use crate::error::query::QueryError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::PlatformState; +use crate::query::QueryValidationResult; +use dapi_grpc::platform::v0::get_contested_resource_identity_vote_status_request::GetContestedResourceIdentityVoteStatusRequestV0; +use dapi_grpc::platform::v0::get_contested_resource_identity_vote_status_response::{ + get_contested_resource_identity_vote_status_response_v0, GetContestedResourceIdentityVoteStatusResponseV0, +}; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::identifier::Identifier; +use dpp::validation::ValidationResult; +use dpp::version::PlatformVersion; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::{check_validation_result_with_data, platform_value}; +use drive::error::query::QuerySyntaxError; + +impl Platform { + pub(super) fn query_contested_resource_identity_vote_status_v0( + &self, + GetContestedResourceIdentityVoteStatusRequestV0 { + prove, resource_path, resource_identifier, voter_identifier, count, ascending + }: GetContestedResourceIdentityVoteStatusRequestV0, + platform_state: &PlatformState, + platform_version: &PlatformVersion, + ) -> Result, Error> { + todo!() + // let config = &self.config.drive; + // let contract_id: Identifier = + // check_validation_result_with_data!(contract_id.try_into().map_err(|_| { + // QueryError::InvalidArgument( + // "contract_id must be a valid identifier (32 bytes long)".to_string(), + // ) + // })); + // + // let (_, contract) = self.drive.get_contract_with_fetch_info_and_fee( + // contract_id.to_buffer(), + // None, + // true, + // None, + // platform_version, + // )?; + // + // let contract = check_validation_result_with_data!(contract.ok_or(QueryError::Query( + // QuerySyntaxError::DataContractNotFound( + // "contract not found when querying from value with contract info", + // ) + // ))); + // + // let contract_ref = &contract.contract; + // + // let document_type = check_validation_result_with_data!(contract_ref + // .document_type_for_name(document_type_name.as_str()) + // .map_err(|_| QueryError::InvalidArgument(format!( + // "document type {} not found for contract {}", + // document_type_name, contract_id + // )))); + // + // let index = check_validation_result_with_data!(document_type.find_contested_index().ok_or( + // QueryError::InvalidArgument(format!( + // "document type {} does not have a contested index", + // document_type_name + // )) + // )); + // + // if &index.name != &index_name { + // return Ok(QueryValidationResult::new_with_error(QueryError::InvalidArgument(format!( + // "index with name {} is not the contested index on the document type {}, {} is the name of the only contested index", + // index_name, document_type_name, index.name + // )))); + // } + // + // let index_values = match index_values + // .into_iter() + // .enumerate() + // .map(|(pos, serialized_value)| { + // Ok(bincode::decode_from_slice( + // serialized_value.as_slice(), + // bincode::config::standard() + // .with_big_endian() + // .with_no_limit(), + // ) + // .map_err(|_| { + // QueryError::InvalidArgument(format!( + // "could not convert {:?} to a value in the index values at position {}", + // serialized_value, pos + // )) + // })? + // .0) + // }) + // .collect::, QueryError>>() + // { + // Ok(index_values) => index_values, + // Err(e) => return Ok(QueryValidationResult::new_with_error(e)), + // }; + // + // let vote_poll = ContestedDocumentResourceVotePoll { + // contract_id, + // document_type_name, + // index_name, + // index_values, + // } + // .into(); + // + // let limit = count + // .map_or(Some(config.default_query_limit), |limit_value| { + // if limit_value == 0 + // || limit_value > u16::MAX as u32 + // || limit_value as u16 > config.default_query_limit + // { + // None + // } else { + // Some(limit_value as u16) + // } + // }) + // .ok_or(drive::error::Error::Query(QuerySyntaxError::InvalidLimit( + // format!("limit greater than max limit {}", config.max_query_limit), + // )))?; + // + // let query = ContestedDocumentVotePollDriveQuery { + // vote_poll, + // result_type: result_type.try_into()?, + // offset: None, + // limit: Some(limit), + // start_at: start_at_identifier_info + // .map(|start_at_identifier_info| { + // Ok::<([u8; 32], bool), platform_value::Error>(( + // Identifier::from_vec(start_at_identifier_info.start_identifier)? + // .to_buffer(), + // start_at_identifier_info.start_identifier_included, + // )) + // }) + // .transpose()?, + // order_ascending, + // }; + // + // let response = if prove { + // let proof = match query.execute_with_proof(&self.drive, None, None, platform_version) { + // Ok(result) => result.0, + // Err(drive::error::Error::Query(query_error)) => { + // return Ok(QueryValidationResult::new_with_error(QueryError::Query( + // query_error, + // ))); + // } + // Err(e) => return Err(e.into()), + // }; + // + // GetContestedResourceIdentityVoteStatusResponseV0 { + // result: Some( + // get_contested_resource_identity_vote_status_response_v0::Result::Proof( + // self.response_proof_v0(platform_state, proof), + // ), + // ), + // metadata: Some(self.response_metadata_v0(platform_state)), + // } + // } else { + // let results = + // match query.execute_no_proof(&self.drive, None, &mut vec![], platform_version) { + // Ok(result) => result, + // Err(drive::error::Error::Query(query_error)) => { + // return Ok(QueryValidationResult::new_with_error(QueryError::Query( + // query_error, + // ))); + // } + // Err(e) => return Err(e.into()), + // }; + // + // let contenders = results + // .contenders + // .into_iter() + // .map( + // |Contender { + // identity_id, + // serialized_document, + // vote_tally, + // }| { + // get_contested_resource_identity_vote_status_response_v0::Contender { + // identifier: identity_id.to_vec(), + // vote_count: vote_tally, + // document: serialized_document, + // } + // }, + // ) + // .collect(); + // + // GetContestedResourceIdentityVoteStatusResponseV0 { + // result: Some( + // get_contested_resource_identity_vote_status_response_v0::Result::ContestedResourceContenders( + // get_contested_resource_identity_vote_status_response_v0::ContestedResourceContenders { + // contenders + // }, + // ), + // ), + // metadata: Some(self.response_metadata_v0(platform_state)), + // } + // }; + // + // Ok(QueryValidationResult::new_with_data(response)) + } +} diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs index 3f0281d56d..99c68a6d7f 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs @@ -16,11 +16,11 @@ use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDoc use dpp::{check_validation_result_with_data, platform_value}; use drive::error::query::QuerySyntaxError; use drive::query::vote_poll_vote_state_query::{ - Contender, ContestedDocumentVotePollDriveQuery, ContestedDocumentVotePollDriveQueryResultType, + Contender, ContestedDocumentVotePollDriveQuery, }; impl Platform { - pub(super) fn query_contested_resource_vote_status_v0( + pub(super) fn query_contested_resource_vote_state_v0( &self, GetContestedResourceVoteStateRequestV0 { contract_id, diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/v0/mod.rs index 8b13789179..1858c02be8 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/v0/mod.rs @@ -1 +1,234 @@ +use crate::error::query::QueryError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::PlatformState; +use crate::query::QueryValidationResult; +use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_request::GetContestedResourceVotersForIdentityRequestV0; +use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_response::{ + get_contested_resource_voters_for_identity_response_v0, GetContestedResourceVotersForIdentityResponseV0, +}; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::identifier::Identifier; +use dpp::validation::ValidationResult; +use dpp::version::PlatformVersion; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::{check_validation_result_with_data, platform_value}; +use drive::error::query::QuerySyntaxError; +use drive::query::vote_poll_contestant_votes_query::ContestedDocumentVotePollVotesDriveQuery; + +impl Platform { + pub(super) fn query_contested_resource_voters_for_identity_v0( + &self, + GetContestedResourceVotersForIdentityRequestV0 { + contract_id, document_type_name, index_name, index_values, contestant_id, start_at_identifier_info, count, order_ascending, prove + }: GetContestedResourceVotersForIdentityRequestV0, + platform_state: &PlatformState, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let config = &self.config.drive; + let contract_id: Identifier = + check_validation_result_with_data!(contract_id.try_into().map_err(|_| { + QueryError::InvalidArgument( + "contract_id must be a valid identifier (32 bytes long)".to_string(), + ) + })); + + let contestant_id: Identifier = + check_validation_result_with_data!(contestant_id.try_into().map_err(|_| { + QueryError::InvalidArgument( + "voter_id must be a valid identifier (32 bytes long)".to_string(), + ) + })); + + let (_, contract) = self.drive.get_contract_with_fetch_info_and_fee( + contract_id.to_buffer(), + None, + true, + None, + platform_version, + )?; + + let contract = check_validation_result_with_data!(contract.ok_or(QueryError::Query( + QuerySyntaxError::DataContractNotFound( + "contract not found when querying from value with contract info", + ) + ))); + + let contract_ref = &contract.contract; + + let document_type = check_validation_result_with_data!(contract_ref + .document_type_for_name(document_type_name.as_str()) + .map_err(|_| QueryError::InvalidArgument(format!( + "document type {} not found for contract {}", + document_type_name, contract_id + )))); + + let index = check_validation_result_with_data!(document_type.find_contested_index().ok_or( + QueryError::InvalidArgument(format!( + "document type {} does not have a contested index", + document_type_name + )) + )); + + if &index.name != &index_name { + return Ok(QueryValidationResult::new_with_error(QueryError::InvalidArgument(format!( + "index with name {} is not the contested index on the document type {}, {} is the name of the only contested index", + index_name, document_type_name, index.name + )))); + } + + let index_values = match index_values + .into_iter() + .enumerate() + .map(|(pos, serialized_value)| { + Ok(bincode::decode_from_slice( + serialized_value.as_slice(), + bincode::config::standard() + .with_big_endian() + .with_no_limit(), + ) + .map_err(|_| { + QueryError::InvalidArgument(format!( + "could not convert {:?} to a value in the index values at position {}", + serialized_value, pos + )) + })? + .0) + }) + .collect::, QueryError>>() + { + Ok(index_values) => index_values, + Err(e) => return Ok(QueryValidationResult::new_with_error(e)), + }; + + let vote_poll = ContestedDocumentResourceVotePoll { + contract_id, + document_type_name, + index_name, + index_values, + } + .into(); + + let limit = count + .map_or(Some(config.default_query_limit), |limit_value| { + if limit_value == 0 + || limit_value > u16::MAX as u32 + || limit_value as u16 > config.default_query_limit + { + None + } else { + Some(limit_value as u16) + } + }) + .ok_or(drive::error::Error::Query(QuerySyntaxError::InvalidLimit( + format!("limit greater than max limit {}", config.max_query_limit), + )))?; + + let response = if prove { + let query = ContestedDocumentVotePollVotesDriveQuery { + vote_poll, + contestant_id, + offset: None, + limit: Some(limit), + start_at: start_at_identifier_info + .map(|start_at_identifier_info| { + Ok::<([u8; 32], bool), platform_value::Error>(( + Identifier::from_vec(start_at_identifier_info.start_identifier)? + .to_buffer(), + start_at_identifier_info.start_identifier_included, + )) + }) + .transpose()?, + order_ascending, + }; + + let proof = match query.execute_with_proof(&self.drive, None, None, platform_version) { + Ok(result) => result.0, + Err(drive::error::Error::Query(query_error)) => { + return Ok(QueryValidationResult::new_with_error(QueryError::Query( + query_error, + ))); + } + Err(e) => return Err(e.into()), + }; + + GetContestedResourceVotersForIdentityResponseV0 { + result: Some( + get_contested_resource_voters_for_identity_response_v0::Result::Proof( + self.response_proof_v0(platform_state, proof), + ), + ), + metadata: Some(self.response_metadata_v0(platform_state)), + } + } else { + let query = ContestedDocumentVotePollVotesDriveQuery { + vote_poll: vote_poll.clone(), + contestant_id, + offset: None, + limit: Some(limit), + start_at: start_at_identifier_info.clone() + .map(|start_at_identifier_info| { + Ok::<([u8; 32], bool), platform_value::Error>(( + Identifier::from_vec(start_at_identifier_info.start_identifier)? + .to_buffer(), + start_at_identifier_info.start_identifier_included, + )) + }) + .transpose()?, + order_ascending, + }; + + let voters = + match query.execute_no_proof(&self.drive, None, &mut vec![], platform_version) { + Ok(result) => result, + Err(drive::error::Error::Query(query_error)) => { + return Ok(QueryValidationResult::new_with_error(QueryError::Query( + query_error, + ))); + } + Err(e) => return Err(e.into()), + }; + + let finished_results = if voters.len() == limit as usize && limit > 0 { + let extra_query = ContestedDocumentVotePollVotesDriveQuery { + vote_poll, + contestant_id, + offset: None, + limit: Some(1), + start_at: Some((voters.last().unwrap().to_buffer(), false)), + order_ascending, + }; + let another_result = match extra_query.execute_no_proof(&self.drive, None, &mut vec![], platform_version) { + Ok(result) => result, + Err(drive::error::Error::Query(query_error)) => { + return Ok(QueryValidationResult::new_with_error(QueryError::Query( + query_error, + ))); + } + Err(e) => return Err(e.into()), + }; + another_result.is_empty() + } else { + true + }; + + let voters= voters.into_iter().map(|voter| voter.to_vec()).collect(); + + GetContestedResourceVotersForIdentityResponseV0 { + result: Some( + get_contested_resource_voters_for_identity_response_v0::Result::ContestedResourceVoters( + get_contested_resource_voters_for_identity_response_v0::ContestedResourceVoters { + voters, + finished_results, + }, + ), + ), + metadata: Some(self.response_metadata_v0(platform_state)), + } + }; + + Ok(QueryValidationResult::new_with_data(response)) + } +} diff --git a/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs index 3c511dc504..2011dc2769 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs @@ -6,7 +6,6 @@ use crate::query::QueryValidationResult; use dapi_grpc::platform::v0::get_contested_resources_request::Version as RequestVersion; use dapi_grpc::platform::v0::get_contested_resources_response::Version as ResponseVersion; use dapi_grpc::platform::v0::{ - GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse, GetContestedResourcesRequest, GetContestedResourcesResponse, }; use dpp::version::PlatformVersion; diff --git a/packages/rs-drive/src/query/mod.rs b/packages/rs-drive/src/query/mod.rs index 2585512c28..ba8f87c251 100644 --- a/packages/rs-drive/src/query/mod.rs +++ b/packages/rs-drive/src/query/mod.rs @@ -81,6 +81,10 @@ pub mod vote_poll_vote_state_query; /// Vote Query module pub mod vote_query; +#[cfg(any(feature = "server", feature = "verify"))] +/// Vote poll contestant votes query module +pub mod vote_poll_contestant_votes_query; + #[cfg(any(feature = "server", feature = "verify"))] /// Internal clauses struct #[derive(Clone, Debug, PartialEq, Default)] diff --git a/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs b/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs new file mode 100644 index 0000000000..78f3842b1f --- /dev/null +++ b/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs @@ -0,0 +1,282 @@ +use crate::drive::votes::paths::VotePollPaths; +use crate::drive::votes::resolve_contested_document_resource_vote_poll::{ + ContestedDocumentResourceVotePollResolver, ContestedDocumentResourceVotePollWithContractInfo, +}; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use crate::query::{GroveError, Query}; +use dpp::block::block_info::BlockInfo; +use dpp::identifier::Identifier; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use grovedb::query_result_type::{QueryResultElements, QueryResultType}; +use grovedb::{Element, PathQuery, SizedQuery, TransactionArg}; +use dpp::platform_value; +use platform_version::version::PlatformVersion; + +/// Vote Poll Drive Query struct +#[derive(Debug, PartialEq, Clone)] +pub struct ContestedDocumentVotePollVotesDriveQuery { + /// What vote poll are we asking for? + pub vote_poll: ContestedDocumentResourceVotePoll, + /// Which contestant do we want to get the votes for + pub contestant_id: Identifier, + /// Offset + pub offset: Option, + /// Limit + pub limit: Option, + /// Start at identity id + pub start_at: Option<([u8; 32], bool)>, + /// Ascending + pub order_ascending: bool, +} + +impl ContestedDocumentVotePollVotesDriveQuery { + /// Resolves the contested document vote poll drive query. + /// + /// This method processes the query by interacting with the drive, using the provided + /// transaction and platform version to ensure consistency and compatibility. + /// + /// # Parameters + /// + /// * `drive`: A reference to the `Drive` object used for database interactions. + /// * `transaction`: The transaction argument used to ensure consistency during the resolve operation. + /// * `platform_version`: The platform version to ensure compatibility. + /// + /// # Returns + /// + /// * `Ok(ResolvedContestedDocumentVotePollDriveQuery)` - The resolved query information. + /// * `Err(Error)` - An error if the resolution process fails. + /// + /// # Errors + /// + /// This method returns an `Error` variant if there is an issue resolving the query. + /// The specific error depends on the underlying problem encountered during resolution. + pub fn resolve( + &self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + let ContestedDocumentVotePollVotesDriveQuery { + vote_poll, + contestant_id, offset, + limit, + start_at, + order_ascending, + } = self; + Ok(ResolvedContestedDocumentVotePollVotesDriveQuery { + vote_poll: vote_poll.resolve(drive, transaction, platform_version)?, + contestant_id: *contestant_id, + offset: *offset, + limit: *limit, + start_at: *start_at, + order_ascending: *order_ascending, + }) + } + + #[cfg(feature = "server")] + /// Executes a query with proof and returns the items and fee. + pub fn execute_with_proof( + self, + drive: &Drive, + block_info: Option, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(Vec, u64), Error> { + let mut drive_operations = vec![]; + let items = self.execute_with_proof_internal( + drive, + transaction, + &mut drive_operations, + platform_version, + )?; + let cost = if let Some(block_info) = block_info { + let fee_result = Drive::calculate_fee( + None, + Some(drive_operations), + &block_info.epoch, + drive.config.epochs_per_era, + platform_version, + )?; + fee_result.processing_fee + } else { + 0 + }; + Ok((items, cost)) + } + + #[cfg(feature = "server")] + /// Executes an internal query with proof and returns the items. + pub(crate) fn execute_with_proof_internal( + self, + drive: &Drive, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let resolved = self.resolve(drive, transaction, platform_version)?; + let path_query = resolved.construct_path_query(platform_version)?; + drive.grove_get_proved_path_query( + &path_query, + false, + transaction, + drive_operations, + &platform_version.drive, + ) + } + + #[cfg(feature = "server")] + /// Executes a query with no proof and returns the items, skipped items, and fee. + pub fn execute_no_proof_with_cost( + &self, + drive: &Drive, + block_info: Option, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(Vec, u64), Error> { + let mut drive_operations = vec![]; + let result = + self.execute_no_proof(drive, transaction, &mut drive_operations, platform_version)?; + let cost = if let Some(block_info) = block_info { + let fee_result = Drive::calculate_fee( + None, + Some(drive_operations), + &block_info.epoch, + drive.config.epochs_per_era, + platform_version, + )?; + fee_result.processing_fee + } else { + 0 + }; + Ok((result, cost)) + } + + #[cfg(feature = "server")] + /// Executes an internal query with no proof and returns the values and skipped items. + pub fn execute_no_proof( + &self, + drive: &Drive, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let resolved = self.resolve(drive, transaction, platform_version)?; + let path_query = resolved.construct_path_query(platform_version)?; + let query_result = drive.grove_get_path_query( + &path_query, + transaction, + QueryResultType::QueryPathKeyElementTrioResultType, + drive_operations, + &platform_version.drive, + ); + match query_result { + Err(Error::GroveDB(GroveError::PathKeyNotFound(_))) + | Err(Error::GroveDB(GroveError::PathNotFound(_))) + | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => { + Ok(vec![]) + } + Err(e) => Err(e), + Ok((query_result_elements, skipped)) => { + let voters = query_result_elements.to_keys().into_iter().map(|voter_id| Identifier::try_from(voter_id)).collect::, platform_value::Error>>()?; + + Ok(voters) + } + } + } + + #[cfg(feature = "server")] + #[allow(unused)] + /// Executes an internal query with no proof and returns the values and skipped items. + pub(crate) fn execute_no_proof_internal( + &self, + drive: &Drive, + result_type: QueryResultType, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result<(QueryResultElements, u16), Error> { + let resolved = self.resolve(drive, transaction, platform_version)?; + let path_query = resolved.construct_path_query(platform_version)?; + let query_result = drive.grove_get_path_query( + &path_query, + transaction, + result_type, + drive_operations, + &platform_version.drive, + ); + match query_result { + Err(Error::GroveDB(GroveError::PathKeyNotFound(_))) + | Err(Error::GroveDB(GroveError::PathNotFound(_))) + | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => { + Ok((QueryResultElements::new(), 0)) + } + _ => { + let (data, skipped) = query_result?; + { + Ok((data, skipped)) + } + } + } + } +} + +/// Vote Poll Drive Query struct +#[derive(Debug, PartialEq, Clone)] +pub struct ResolvedContestedDocumentVotePollVotesDriveQuery { + /// What vote poll are we asking for? + pub vote_poll: ContestedDocumentResourceVotePollWithContractInfo, + /// Who's votes are we looking for + pub contestant_id: Identifier, + /// Offset + pub offset: Option, + /// Limit + pub limit: Option, + /// Start at identity id, the bool is if it is also included + pub start_at: Option<([u8; 32], bool)>, + /// Ascending + pub order_ascending: bool, +} + +impl ResolvedContestedDocumentVotePollVotesDriveQuery { + /// Operations to construct a path query. + pub fn construct_path_query( + &self, + platform_version: &PlatformVersion, + ) -> Result { + let mut path = self.vote_poll.contender_voting_path(self.contestant_id, platform_version)?; + + let mut query = Query::new_with_direction(self.order_ascending); + + // this is a range on all elements + match &self.start_at { + None => { + query.insert_all(); + } + Some((starts_at_key_bytes, start_at_included)) => { + let starts_at_key = starts_at_key_bytes.to_vec(); + match self.order_ascending { + true => match start_at_included { + true => query.insert_range_from(starts_at_key..), + false => query.insert_range_after(starts_at_key..), + }, + false => match start_at_included { + true => query.insert_range_to_inclusive(..=starts_at_key), + false => query.insert_range_to(..starts_at_key), + }, + } + } + } + + Ok(PathQuery { + path, + query: SizedQuery { + query, + limit: self.limit, + offset: self.offset, + }, + }) + } +} diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index 5fb8a8a4f9..eb980bbc97 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -1,4 +1,3 @@ -use crate::drive::verify::RootHash; use crate::drive::votes::paths::VotePollPaths; use crate::drive::votes::resolve_contested_document_resource_vote_poll::{ ContestedDocumentResourceVotePollResolver, ContestedDocumentResourceVotePollWithContractInfo, @@ -8,7 +7,7 @@ use crate::error::drive::DriveError; use crate::error::query::QuerySyntaxError; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; -use crate::query::{GroveError, Query, SingleDocumentDriveQueryContestedStatus}; +use crate::query::{GroveError, Query}; use dpp::block::block_info::BlockInfo; use dpp::identifier::Identifier; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; @@ -40,7 +39,7 @@ impl TryFrom for ContestedDocumentVotePollDriveQueryResultType { 0 => Ok(ContestedDocumentVotePollDriveQueryResultType::IdentityIdsOnly), 1 => Ok(ContestedDocumentVotePollDriveQueryResultType::Documents), 2 => Ok(ContestedDocumentVotePollDriveQueryResultType::VoteTally), - 3 => Ok(ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally), + 4 => Err(Error::Drive(DriveError::CorruptedCodeExecution("voters for identity must be set manually"))), n => Err(Error::Query(QuerySyntaxError::Unsupported(format!( "unsupported contested document vote poll drive query result type {}, only 0, 1 and 2 are supported", n @@ -242,7 +241,7 @@ impl ContestedDocumentVotePollDriveQuery { #[cfg(feature = "server")] /// Executes a query with no proof and returns the items, skipped items, and fee. - pub fn execute_no_proof_with_cost( + pub fn execute_no_proof_with_cost( &self, drive: &Drive, block_info: Option, @@ -420,7 +419,7 @@ impl ResolvedContestedDocumentVotePollDriveQuery { &self, platform_version: &PlatformVersion, ) -> Result { - let path = self.vote_poll.contenders_path(platform_version)?; + let mut path = self.vote_poll.contenders_path(platform_version)?; let mut query = Query::new_with_direction(self.order_ascending); From 095e8450b6f2a017c4fe2fdf1dfbb7662b31277f Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 19 May 2024 05:59:45 +0200 Subject: [PATCH 064/135] more work --- .../v0/mod.rs | 44 ++++++------ .../contested_resource_vote_state/v0/mod.rs | 7 +- .../v0/mod.rs | 50 +++++++++----- .../query/voting/contested_resources/mod.rs | 4 +- .../voting/contested_resources/v0/mod.rs | 24 +++++++ .../tests/strategy_tests/voting_tests.rs | 67 ++++++++++++++++++- .../query/vote_poll_contestant_votes_query.rs | 19 ++++-- .../src/query/vote_poll_vote_state_query.rs | 6 +- 8 files changed, 164 insertions(+), 57 deletions(-) diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/v0/mod.rs index 5b77587958..22b867fc6e 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/v0/mod.rs @@ -1,4 +1,3 @@ - use crate::error::query::QueryError; use crate::error::Error; use crate::platform_types::platform::Platform; @@ -6,7 +5,8 @@ use crate::platform_types::platform_state::PlatformState; use crate::query::QueryValidationResult; use dapi_grpc::platform::v0::get_contested_resource_identity_vote_status_request::GetContestedResourceIdentityVoteStatusRequestV0; use dapi_grpc::platform::v0::get_contested_resource_identity_vote_status_response::{ - get_contested_resource_identity_vote_status_response_v0, GetContestedResourceIdentityVoteStatusResponseV0, + get_contested_resource_identity_vote_status_response_v0, + GetContestedResourceIdentityVoteStatusResponseV0, }; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; @@ -21,11 +21,17 @@ impl Platform { pub(super) fn query_contested_resource_identity_vote_status_v0( &self, GetContestedResourceIdentityVoteStatusRequestV0 { - prove, resource_path, resource_identifier, voter_identifier, count, ascending + prove, + resource_path, + resource_identifier, + voter_identifier, + count, + ascending, }: GetContestedResourceIdentityVoteStatusRequestV0, platform_state: &PlatformState, platform_version: &PlatformVersion, - ) -> Result, Error> { + ) -> Result, Error> + { todo!() // let config = &self.config.drive; // let contract_id: Identifier = @@ -34,7 +40,7 @@ impl Platform { // "contract_id must be a valid identifier (32 bytes long)".to_string(), // ) // })); - // + // // let (_, contract) = self.drive.get_contract_with_fetch_info_and_fee( // contract_id.to_buffer(), // None, @@ -42,36 +48,36 @@ impl Platform { // None, // platform_version, // )?; - // + // // let contract = check_validation_result_with_data!(contract.ok_or(QueryError::Query( // QuerySyntaxError::DataContractNotFound( // "contract not found when querying from value with contract info", // ) // ))); - // + // // let contract_ref = &contract.contract; - // + // // let document_type = check_validation_result_with_data!(contract_ref // .document_type_for_name(document_type_name.as_str()) // .map_err(|_| QueryError::InvalidArgument(format!( // "document type {} not found for contract {}", // document_type_name, contract_id // )))); - // + // // let index = check_validation_result_with_data!(document_type.find_contested_index().ok_or( // QueryError::InvalidArgument(format!( // "document type {} does not have a contested index", // document_type_name // )) // )); - // + // // if &index.name != &index_name { // return Ok(QueryValidationResult::new_with_error(QueryError::InvalidArgument(format!( // "index with name {} is not the contested index on the document type {}, {} is the name of the only contested index", // index_name, document_type_name, index.name // )))); // } - // + // // let index_values = match index_values // .into_iter() // .enumerate() @@ -95,7 +101,7 @@ impl Platform { // Ok(index_values) => index_values, // Err(e) => return Ok(QueryValidationResult::new_with_error(e)), // }; - // + // // let vote_poll = ContestedDocumentResourceVotePoll { // contract_id, // document_type_name, @@ -103,7 +109,7 @@ impl Platform { // index_values, // } // .into(); - // + // // let limit = count // .map_or(Some(config.default_query_limit), |limit_value| { // if limit_value == 0 @@ -118,7 +124,7 @@ impl Platform { // .ok_or(drive::error::Error::Query(QuerySyntaxError::InvalidLimit( // format!("limit greater than max limit {}", config.max_query_limit), // )))?; - // + // // let query = ContestedDocumentVotePollDriveQuery { // vote_poll, // result_type: result_type.try_into()?, @@ -135,7 +141,7 @@ impl Platform { // .transpose()?, // order_ascending, // }; - // + // // let response = if prove { // let proof = match query.execute_with_proof(&self.drive, None, None, platform_version) { // Ok(result) => result.0, @@ -146,7 +152,7 @@ impl Platform { // } // Err(e) => return Err(e.into()), // }; - // + // // GetContestedResourceIdentityVoteStatusResponseV0 { // result: Some( // get_contested_resource_identity_vote_status_response_v0::Result::Proof( @@ -166,7 +172,7 @@ impl Platform { // } // Err(e) => return Err(e.into()), // }; - // + // // let contenders = results // .contenders // .into_iter() @@ -184,7 +190,7 @@ impl Platform { // }, // ) // .collect(); - // + // // GetContestedResourceIdentityVoteStatusResponseV0 { // result: Some( // get_contested_resource_identity_vote_status_response_v0::Result::ContestedResourceContenders( @@ -196,7 +202,7 @@ impl Platform { // metadata: Some(self.response_metadata_v0(platform_state)), // } // }; - // + // // Ok(QueryValidationResult::new_with_data(response)) } } diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs index 99c68a6d7f..de15c55a69 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs @@ -15,9 +15,7 @@ use dpp::version::PlatformVersion; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::{check_validation_result_with_data, platform_value}; use drive::error::query::QuerySyntaxError; -use drive::query::vote_poll_vote_state_query::{ - Contender, ContestedDocumentVotePollDriveQuery, -}; +use drive::query::vote_poll_vote_state_query::{Contender, ContestedDocumentVotePollDriveQuery}; impl Platform { pub(super) fn query_contested_resource_vote_state_v0( @@ -110,8 +108,7 @@ impl Platform { document_type_name, index_name, index_values, - } - .into(); + }; let limit = count .map_or(Some(config.default_query_limit), |limit_value| { diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/v0/mod.rs index 1858c02be8..ef10ae68ac 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/v0/mod.rs @@ -5,7 +5,8 @@ use crate::platform_types::platform_state::PlatformState; use crate::query::QueryValidationResult; use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_request::GetContestedResourceVotersForIdentityRequestV0; use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_response::{ - get_contested_resource_voters_for_identity_response_v0, GetContestedResourceVotersForIdentityResponseV0, + get_contested_resource_voters_for_identity_response_v0, + GetContestedResourceVotersForIdentityResponseV0, }; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; @@ -21,7 +22,15 @@ impl Platform { pub(super) fn query_contested_resource_voters_for_identity_v0( &self, GetContestedResourceVotersForIdentityRequestV0 { - contract_id, document_type_name, index_name, index_values, contestant_id, start_at_identifier_info, count, order_ascending, prove + contract_id, + document_type_name, + index_name, + index_values, + contestant_id, + start_at_identifier_info, + count, + order_ascending, + prove, }: GetContestedResourceVotersForIdentityRequestV0, platform_state: &PlatformState, platform_version: &PlatformVersion, @@ -88,13 +97,13 @@ impl Platform { .with_big_endian() .with_no_limit(), ) - .map_err(|_| { - QueryError::InvalidArgument(format!( - "could not convert {:?} to a value in the index values at position {}", - serialized_value, pos - )) - })? - .0) + .map_err(|_| { + QueryError::InvalidArgument(format!( + "could not convert {:?} to a value in the index values at position {}", + serialized_value, pos + )) + })? + .0) }) .collect::, QueryError>>() { @@ -108,7 +117,7 @@ impl Platform { index_name, index_values, } - .into(); + .into(); let limit = count .map_or(Some(config.default_query_limit), |limit_value| { @@ -142,7 +151,7 @@ impl Platform { .transpose()?, order_ascending, }; - + let proof = match query.execute_with_proof(&self.drive, None, None, platform_version) { Ok(result) => result.0, Err(drive::error::Error::Query(query_error)) => { @@ -167,7 +176,8 @@ impl Platform { contestant_id, offset: None, limit: Some(limit), - start_at: start_at_identifier_info.clone() + start_at: start_at_identifier_info + .clone() .map(|start_at_identifier_info| { Ok::<([u8; 32], bool), platform_value::Error>(( Identifier::from_vec(start_at_identifier_info.start_identifier)? @@ -178,7 +188,7 @@ impl Platform { .transpose()?, order_ascending, }; - + let voters = match query.execute_no_proof(&self.drive, None, &mut vec![], platform_version) { Ok(result) => result, @@ -189,7 +199,7 @@ impl Platform { } Err(e) => return Err(e.into()), }; - + let finished_results = if voters.len() == limit as usize && limit > 0 { let extra_query = ContestedDocumentVotePollVotesDriveQuery { vote_poll, @@ -199,7 +209,12 @@ impl Platform { start_at: Some((voters.last().unwrap().to_buffer(), false)), order_ascending, }; - let another_result = match extra_query.execute_no_proof(&self.drive, None, &mut vec![], platform_version) { + let another_result = match extra_query.execute_no_proof( + &self.drive, + None, + &mut vec![], + platform_version, + ) { Ok(result) => result, Err(drive::error::Error::Query(query_error)) => { return Ok(QueryValidationResult::new_with_error(QueryError::Query( @@ -212,8 +227,8 @@ impl Platform { } else { true }; - - let voters= voters.into_iter().map(|voter| voter.to_vec()).collect(); + + let voters = voters.into_iter().map(|voter| voter.to_vec()).collect(); GetContestedResourceVotersForIdentityResponseV0 { result: Some( @@ -231,4 +246,3 @@ impl Platform { Ok(QueryValidationResult::new_with_data(response)) } } - diff --git a/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs index 2011dc2769..97de6da674 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resources/mod.rs @@ -5,9 +5,7 @@ use crate::platform_types::platform_state::PlatformState; use crate::query::QueryValidationResult; use dapi_grpc::platform::v0::get_contested_resources_request::Version as RequestVersion; use dapi_grpc::platform::v0::get_contested_resources_response::Version as ResponseVersion; -use dapi_grpc::platform::v0::{ - GetContestedResourcesRequest, GetContestedResourcesResponse, -}; +use dapi_grpc::platform::v0::{GetContestedResourcesRequest, GetContestedResourcesResponse}; use dpp::version::PlatformVersion; mod v0; diff --git a/packages/rs-drive-abci/src/query/voting/contested_resources/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resources/v0/mod.rs index 8b13789179..e15c5960ec 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resources/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resources/v0/mod.rs @@ -1 +1,25 @@ +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::PlatformState; +use crate::query::QueryValidationResult; +use dapi_grpc::platform::v0::get_contested_resources_request::GetContestedResourcesRequestV0; +use dapi_grpc::platform::v0::get_contested_resources_response::GetContestedResourcesResponseV0; +use dpp::version::PlatformVersion; +impl Platform { + pub(super) fn query_contested_resources_v0( + &self, + GetContestedResourcesRequestV0 { + contract_id, + document_type_name, + index_name, + count, + ascending, + prove, + }: GetContestedResourcesRequestV0, + platform_state: &PlatformState, + platform_version: &PlatformVersion, + ) -> Result, Error> { + todo!() + } +} diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index c4756d52cf..c03e7990c6 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -17,6 +17,12 @@ mod tests { use rand::SeedableRng; use simple_signer::signer::SimpleSigner; use std::collections::BTreeMap; + use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, GetContestedResourceVoteStateRequest}; + use dapi_grpc::platform::v0::get_consensus_params_response::Version; + use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0::ResultType; + use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::GetContestedResourceVoteStateRequestV0; + use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; + use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use strategy_tests::frequency::Frequency; use strategy_tests::operations::{DocumentAction, DocumentOp, Operation, OperationType}; use strategy_tests::transitions::create_state_transitions_for_identities; @@ -25,7 +31,7 @@ mod tests { #[test] fn run_chain_block_two_state_transitions_conflicting_unique_index_inserted_same_block() { // In this test we try to insert two state transitions with the same unique index - // We use the dpns contract and we insert two documents both with the same "name" + // We use the DPNS contract, and we insert two documents both with the same "name" // This is a common scenario we should see quite often let config = PlatformConfig { validator_set_quorum_size: 100, @@ -113,7 +119,7 @@ mod tests { }; let document_op_2 = DocumentOp { - contract: dpns_contract, + contract: dpns_contract.clone(), action: DocumentAction::DocumentActionInsertSpecific( BTreeMap::from([ ("label".into(), "quantum".into()), @@ -181,6 +187,10 @@ mod tests { let outcome = run_chain_for_strategy(&mut platform, 2, strategy.clone(), config.clone(), 15); + let platform = outcome.abci_app.platform; + + let platform_state = platform.state.load(); + let state_transitions_block_2 = outcome .state_transition_results_per_block .get(&2) @@ -200,5 +210,58 @@ mod tests { .1; assert_eq!(second_document_insert_result.code, 0); // we expect the second to also be insertable as they are both contested + + // Now let's run a query for the vote totals + + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + + let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) + .expect("expected to encode the word dash"); + + let quantum_encoded = bincode::encode_to_vec(Value::Text("quantum".to_string()), config) + .expect("expected to encode the word quantum"); + + let query_validation_result = platform + .query_contested_resource_vote_state( + GetContestedResourceVoteStateRequest { + version: Some(get_contested_resource_vote_state_request::Version::V0( + GetContestedResourceVoteStateRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: document_type.name().clone(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![dash_encoded, quantum_encoded], + result_type: ResultType::DocumentsAndVoteTally as i32, + start_at_identifier_info: None, + count: None, + order_ascending: true, + prove: false, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_vote_state_response::Version::V0( + GetContestedResourceVoteStateResponseV0 { metadata, result }, + ) = query_validation_result.version.expect("expected a version"); + + let Some( + get_contested_resource_vote_state_response_v0::Result::ContestedResourceContenders( + get_contested_resource_vote_state_response_v0::ContestedResourceContenders { + contenders, + }, + ), + ) = result + else { + panic!("expected contenders") + }; + + assert_eq!(contenders.len(), 2); } } diff --git a/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs b/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs index 78f3842b1f..3777bacecb 100644 --- a/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs +++ b/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs @@ -9,10 +9,10 @@ use crate::fee::op::LowLevelDriveOperation; use crate::query::{GroveError, Query}; use dpp::block::block_info::BlockInfo; use dpp::identifier::Identifier; +use dpp::platform_value; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use grovedb::query_result_type::{QueryResultElements, QueryResultType}; use grovedb::{Element, PathQuery, SizedQuery, TransactionArg}; -use dpp::platform_value; use platform_version::version::PlatformVersion; /// Vote Poll Drive Query struct @@ -61,7 +61,8 @@ impl ContestedDocumentVotePollVotesDriveQuery { ) -> Result { let ContestedDocumentVotePollVotesDriveQuery { vote_poll, - contestant_id, offset, + contestant_id, + offset, limit, start_at, order_ascending, @@ -175,12 +176,14 @@ impl ContestedDocumentVotePollVotesDriveQuery { match query_result { Err(Error::GroveDB(GroveError::PathKeyNotFound(_))) | Err(Error::GroveDB(GroveError::PathNotFound(_))) - | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => { - Ok(vec![]) - } + | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok(vec![]), Err(e) => Err(e), Ok((query_result_elements, skipped)) => { - let voters = query_result_elements.to_keys().into_iter().map(|voter_id| Identifier::try_from(voter_id)).collect::, platform_value::Error>>()?; + let voters = query_result_elements + .to_keys() + .into_iter() + .map(|voter_id| Identifier::try_from(voter_id)) + .collect::, platform_value::Error>>()?; Ok(voters) } @@ -246,7 +249,9 @@ impl ResolvedContestedDocumentVotePollVotesDriveQuery { &self, platform_version: &PlatformVersion, ) -> Result { - let mut path = self.vote_poll.contender_voting_path(self.contestant_id, platform_version)?; + let mut path = self + .vote_poll + .contender_voting_path(self.contestant_id, platform_version)?; let mut query = Query::new_with_direction(self.order_ascending); diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index eb980bbc97..9b07353d4e 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -72,11 +72,11 @@ pub struct ContestedDocumentVotePollDriveQuery { #[derive(Debug, PartialEq, Eq, Clone, Default)] pub struct Contender { /// The identity ID of the contender. - identity_id: Identifier, + pub identity_id: Identifier, /// The serialized document associated with the contender. - serialized_document: Option>, + pub serialized_document: Option>, /// The vote tally for the contender. - vote_tally: Option, + pub vote_tally: Option, } /// Represents the result of executing a contested document vote poll drive query. From 231219bbef94e8c1bf9ecffd915bbf411ef3403d Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 19 May 2024 06:42:15 +0200 Subject: [PATCH 065/135] query now working --- Cargo.lock | 12 ++--- .../protos/platform/v0/platform.proto | 7 +-- .../proto/org.dash.platform.dapi.v0.rs | 9 ++-- .../contested_resource_vote_state/v0/mod.rs | 2 +- .../tests/strategy_tests/voting_tests.rs | 53 ++++++++++++++++--- packages/rs-drive/src/drive/votes/paths.rs | 28 ++++++---- .../src/query/vote_poll_vote_state_query.rs | 6 +-- 7 files changed, 85 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 81e2c77cdf..d7d90f0932 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1872,7 +1872,7 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "grovedb" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#a62699d8a32f72f76bb2b3a5fffbf2687fbccb92" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#2c0712b89eb9e13b70c2772f941832f061d54ac7" dependencies = [ "bincode", "bitvec", @@ -1895,7 +1895,7 @@ dependencies = [ [[package]] name = "grovedb-costs" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#a62699d8a32f72f76bb2b3a5fffbf2687fbccb92" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#2c0712b89eb9e13b70c2772f941832f061d54ac7" dependencies = [ "integer-encoding", "intmap", @@ -1905,7 +1905,7 @@ dependencies = [ [[package]] name = "grovedb-merk" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#a62699d8a32f72f76bb2b3a5fffbf2687fbccb92" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#2c0712b89eb9e13b70c2772f941832f061d54ac7" dependencies = [ "blake3", "byteorder", @@ -1928,12 +1928,12 @@ dependencies = [ [[package]] name = "grovedb-path" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#a62699d8a32f72f76bb2b3a5fffbf2687fbccb92" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#2c0712b89eb9e13b70c2772f941832f061d54ac7" [[package]] name = "grovedb-storage" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#a62699d8a32f72f76bb2b3a5fffbf2687fbccb92" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#2c0712b89eb9e13b70c2772f941832f061d54ac7" dependencies = [ "blake3", "grovedb-costs", @@ -1952,7 +1952,7 @@ dependencies = [ [[package]] name = "grovedb-visualize" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#a62699d8a32f72f76bb2b3a5fffbf2687fbccb92" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#2c0712b89eb9e13b70c2772f941832f061d54ac7" dependencies = [ "hex", "itertools 0.12.1", diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index 529097ad40..f0c6970f1b 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -681,9 +681,10 @@ message GetContestedResourceVoteStateRequest { bool start_identifier_included = 2; } enum ResultType { - DOCUMENTS = 0; - VOTE_TALLY = 1; - DOCUMENTS_AND_VOTE_TALLY = 2; + IDENTITY_IDS_ONLY = 0; + DOCUMENTS = 1; + VOTE_TALLY = 2; + DOCUMENTS_AND_VOTE_TALLY = 3; } bytes contract_id = 1; diff --git a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs index ac6c7ab92d..f1f7c3aef5 100644 --- a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs +++ b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs @@ -2297,9 +2297,10 @@ pub mod get_contested_resource_vote_state_request { )] #[repr(i32)] pub enum ResultType { - Documents = 0, - VoteTally = 1, - DocumentsAndVoteTally = 2, + IdentityIdsOnly = 0, + Documents = 1, + VoteTally = 2, + DocumentsAndVoteTally = 3, } impl ResultType { /// String value of the enum field names used in the ProtoBuf definition. @@ -2308,6 +2309,7 @@ pub mod get_contested_resource_vote_state_request { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { + ResultType::IdentityIdsOnly => "IDENTITY_IDS_ONLY", ResultType::Documents => "DOCUMENTS", ResultType::VoteTally => "VOTE_TALLY", ResultType::DocumentsAndVoteTally => "DOCUMENTS_AND_VOTE_TALLY", @@ -2316,6 +2318,7 @@ pub mod get_contested_resource_vote_state_request { /// Creates an enum from field names used in the ProtoBuf definition. pub fn from_str_name(value: &str) -> ::core::option::Option { match value { + "IDENTITY_IDS_ONLY" => Some(Self::IdentityIdsOnly), "DOCUMENTS" => Some(Self::Documents), "VOTE_TALLY" => Some(Self::VoteTally), "DOCUMENTS_AND_VOTE_TALLY" => Some(Self::DocumentsAndVoteTally), diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs index de15c55a69..0f3b09a390 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs @@ -72,7 +72,7 @@ impl Platform { )) )); - if &index.name != &index_name { + if index.name != index_name { return Ok(QueryValidationResult::new_with_error(QueryError::InvalidArgument(format!( "index with name {} is not the contested index on the document type {}, {} is the name of the only contested index", index_name, document_type_name, index.name diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index c03e7990c6..4f36b82295 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -23,6 +23,8 @@ mod tests { use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::GetContestedResourceVoteStateRequestV0; use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; + use dpp::document::{Document, DocumentV0Getters}; + use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use strategy_tests::frequency::Frequency; use strategy_tests::operations::{DocumentAction, DocumentOp, Operation, OperationType}; use strategy_tests::transitions::create_state_transitions_for_identities; @@ -95,6 +97,9 @@ mod tests { .document_type_for_name("domain") .expect("expected a profile document type") .to_owned_document_type(); + + let identity1_id = start_identities.first().unwrap().0.id(); + let identity2_id = start_identities.last().unwrap().0.id(); let document_op_1 = DocumentOp { contract: dpns_contract.clone(), action: DocumentAction::DocumentActionInsertSpecific( @@ -104,11 +109,8 @@ mod tests { ("normalizedParentDomainName".into(), "dash".into()), ( "records".into(), - BTreeMap::from([( - "dashUniqueIdentityId", - Value::from(start_identities.first().unwrap().0.id()), - )]) - .into(), + BTreeMap::from([("dashUniqueIdentityId", Value::from(identity1_id))]) + .into(), ), ]), Some(start_identities.first().unwrap().0.id()), @@ -248,7 +250,10 @@ mod tests { .expect("expected query to be valid"); let get_contested_resource_vote_state_response::Version::V0( - GetContestedResourceVoteStateResponseV0 { metadata, result }, + GetContestedResourceVoteStateResponseV0 { + metadata: _, + result, + }, ) = query_validation_result.version.expect("expected a version"); let Some( @@ -263,5 +268,41 @@ mod tests { }; assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + let first_contender_document = Document::from_bytes( + first_contender + .document + .as_ref() + .expect("expected a document") + .as_slice(), + document_type.as_ref(), + platform_version, + ) + .expect("expected to get document"); + + let second_contender_document = Document::from_bytes( + second_contender + .document + .as_ref() + .expect("expected a document") + .as_slice(), + document_type.as_ref(), + platform_version, + ) + .expect("expected to get document"); + + assert_ne!(first_contender_document, second_contender_document); + + assert_eq!(first_contender.identifier, identity2_id.to_vec()); + + assert_eq!(second_contender.identifier, identity1_id.to_vec()); + + assert_eq!(first_contender.vote_count, Some(0)); + + assert_eq!(second_contender.vote_count, Some(0)); } } diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index 5134a6eab9..06795e5ee7 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -115,17 +115,25 @@ impl VotePollPaths for ContestedDocumentResourceVotePollWithContractInfo { } fn contenders_path(&self, platform_version: &PlatformVersion) -> Result>, Error> { + let mut root = vote_contested_resource_active_polls_contract_document_tree_path_vec( + self.contract.contract.id_ref().as_slice(), + self.document_type_name.as_str(), + ); let document_type = self.document_type()?; - self.index()? - .properties - .iter() - .zip(self.index_values.iter()) - .map(|(IndexProperty { name, .. }, value)| { - document_type - .serialize_value_for_key(name, value, platform_version) - .map_err(Error::Protocol) - }) - .collect::>, Error>>() + root.append( + &mut self + .index()? + .properties + .iter() + .zip(self.index_values.iter()) + .map(|(IndexProperty { name, .. }, value)| { + document_type + .serialize_value_for_key(name, value, platform_version) + .map_err(Error::Protocol) + }) + .collect::>, Error>>()?, + ); + Ok(root) } fn contender_path( diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index 9b07353d4e..371760c1e8 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -39,9 +39,9 @@ impl TryFrom for ContestedDocumentVotePollDriveQueryResultType { 0 => Ok(ContestedDocumentVotePollDriveQueryResultType::IdentityIdsOnly), 1 => Ok(ContestedDocumentVotePollDriveQueryResultType::Documents), 2 => Ok(ContestedDocumentVotePollDriveQueryResultType::VoteTally), - 4 => Err(Error::Drive(DriveError::CorruptedCodeExecution("voters for identity must be set manually"))), + 3 => Ok(ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally), n => Err(Error::Query(QuerySyntaxError::Unsupported(format!( - "unsupported contested document vote poll drive query result type {}, only 0, 1 and 2 are supported", + "unsupported contested document vote poll drive query result type {}, only 0, 1, 2 and 3 are supported", n )))), } @@ -419,7 +419,7 @@ impl ResolvedContestedDocumentVotePollDriveQuery { &self, platform_version: &PlatformVersion, ) -> Result { - let mut path = self.vote_poll.contenders_path(platform_version)?; + let path = self.vote_poll.contenders_path(platform_version)?; let mut query = Query::new_with_direction(self.order_ascending); From 1ee74868b3582adacb266b4e49c126c2cc6260fd Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 19 May 2024 12:46:55 +0200 Subject: [PATCH 066/135] proof verification --- .../tests/strategy_tests/voting_tests.rs | 110 +++++++++++++++++- .../drive/object_size_info/contract_info.rs | 4 +- .../rs-drive/src/drive/verify/voting/mod.rs | 2 + .../verify_start_at_contender_in_proof/mod.rs | 61 ++++++++++ .../v0/mod.rs | 87 ++++++++++++++ .../verify_vote_poll_vote_state_proof/mod.rs | 47 ++++++++ .../v0/mod.rs | 104 +++++++++++++++++ packages/rs-drive/src/drive/votes/paths.rs | 16 +-- .../mod.rs | 17 ++- .../query/vote_poll_contestant_votes_query.rs | 6 +- .../src/query/vote_poll_vote_state_query.rs | 6 +- .../src/version/drive_versions.rs | 2 + .../src/version/mocks/v2_test.rs | 2 + .../src/version/mocks/v3_test.rs | 2 + .../rs-platform-version/src/version/v1.rs | 2 + 15 files changed, 440 insertions(+), 28 deletions(-) create mode 100644 packages/rs-drive/src/drive/verify/voting/verify_start_at_contender_in_proof/mod.rs create mode 100644 packages/rs-drive/src/drive/verify/voting/verify_start_at_contender_in_proof/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/mod.rs create mode 100644 packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index 4f36b82295..e91f711eff 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -17,7 +17,7 @@ mod tests { use rand::SeedableRng; use simple_signer::signer::SimpleSigner; use std::collections::BTreeMap; - use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, GetContestedResourceVoteStateRequest}; + use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse}; use dapi_grpc::platform::v0::get_consensus_params_response::Version; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0::ResultType; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::GetContestedResourceVoteStateRequestV0; @@ -25,6 +25,11 @@ mod tests { use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::document::{Document, DocumentV0Getters}; use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; + use drive::drive::object_size_info::DataContractResolvedInfo; + use drive::drive::votes::resolve_contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; + use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; + use drive::query::vote_poll_vote_state_query::ResolvedContestedDocumentVotePollDriveQuery; + use drive_abci::platform_types::platform_state::v0::PlatformStateV0Methods; use strategy_tests::frequency::Frequency; use strategy_tests::operations::{DocumentAction, DocumentOp, Operation, OperationType}; use strategy_tests::transitions::create_state_transitions_for_identities; @@ -224,6 +229,8 @@ mod tests { let quantum_encoded = bincode::encode_to_vec(Value::Text("quantum".to_string()), config) .expect("expected to encode the word quantum"); + + let index_name = "parentNameAndLabel".to_string(); let query_validation_result = platform .query_contested_resource_vote_state( @@ -232,8 +239,8 @@ mod tests { GetContestedResourceVoteStateRequestV0 { contract_id: dpns_contract.id().to_vec(), document_type_name: document_type.name().clone(), - index_name: "parentNameAndLabel".to_string(), - index_values: vec![dash_encoded, quantum_encoded], + index_name: index_name.clone(), + index_values: vec![dash_encoded.clone(), quantum_encoded.clone()], result_type: ResultType::DocumentsAndVoteTally as i32, start_at_identifier_info: None, count: None, @@ -304,5 +311,102 @@ mod tests { assert_eq!(first_contender.vote_count, Some(0)); assert_eq!(second_contender.vote_count, Some(0)); + + let GetContestedResourceVoteStateResponse { version } = platform + .query_contested_resource_vote_state( + GetContestedResourceVoteStateRequest { + version: Some(get_contested_resource_vote_state_request::Version::V0( + GetContestedResourceVoteStateRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: document_type.name().clone(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![dash_encoded, quantum_encoded], + result_type: ResultType::DocumentsAndVoteTally as i32, + start_at_identifier_info: None, + count: None, + order_ascending: true, + prove: true, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_vote_state_response::Version::V0( + GetContestedResourceVoteStateResponseV0 { + metadata: _, + result, + }, + ) = version.expect("expected a version"); + + let Some( + get_contested_resource_vote_state_response_v0::Result::Proof( + proof, + ), + ) = result + else { + panic!("expected contenders") + }; + + + let resolved_contested_document_vote_poll_drive_query = ResolvedContestedDocumentVotePollDriveQuery { + vote_poll: ContestedDocumentResourceVotePollWithContractInfo { + contract: DataContractResolvedInfo::BorrowedDataContract(&dpns_contract), + document_type_name: document_type.name().clone(), + index_name: index_name.clone(), + index_values: vec![Value::Text("dash".to_string()), Value::Text("quantum".to_string())], + }, + result_type: DocumentsAndVoteTally, + offset: None, + limit: None, + start_at: None, + order_ascending: true, + }; + + let (root_hash, contenders) = resolved_contested_document_vote_poll_drive_query.verify_vote_poll_vote_state_proof(proof.grovedb_proof.as_ref(), platform_version).expect("expected to verify proof"); + + assert_eq!(root_hash, platform_state.last_committed_block_app_hash().expect("expected an app hash")); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + let first_contender_document = Document::from_bytes( + first_contender + .serialized_document + .as_ref() + .expect("expected a document") + .as_slice(), + document_type.as_ref(), + platform_version, + ) + .expect("expected to get document"); + + let second_contender_document = Document::from_bytes( + second_contender + .serialized_document + .as_ref() + .expect("expected a document") + .as_slice(), + document_type.as_ref(), + platform_version, + ) + .expect("expected to get document"); + + assert_ne!(first_contender_document, second_contender_document); + + assert_eq!(first_contender.identity_id, identity2_id); + + assert_eq!(second_contender.identity_id, identity1_id); + + assert_eq!(first_contender.vote_tally, Some(0)); + + assert_eq!(second_contender.vote_tally, Some(0)); } } diff --git a/packages/rs-drive/src/drive/object_size_info/contract_info.rs b/packages/rs-drive/src/drive/object_size_info/contract_info.rs index 4f7691ad3f..547b1d55a6 100644 --- a/packages/rs-drive/src/drive/object_size_info/contract_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/contract_info.rs @@ -79,8 +79,8 @@ impl<'a> DataContractInfo<'a> { /// Contains resolved data contract information, typically used after initial /// fetching or retrieval steps have been completed. This enum simplifies handling /// of data contract states post-retrieval. -#[derive(Clone, Debug)] -pub(crate) enum DataContractResolvedInfo<'a> { +#[derive(Clone, Debug, PartialEq)] +pub enum DataContractResolvedInfo<'a> { /// Information necessary for fetched data contracts, encapsulated in an /// `Arc` to ensure thread-safe shared ownership and access. DataContractFetchInfo(Arc), diff --git a/packages/rs-drive/src/drive/verify/voting/mod.rs b/packages/rs-drive/src/drive/verify/voting/mod.rs index 26611b695b..ea312a70e7 100644 --- a/packages/rs-drive/src/drive/verify/voting/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/mod.rs @@ -1 +1,3 @@ mod verify_masternode_vote; +mod verify_vote_poll_vote_state_proof; +// mod verify_start_at_contender_in_proof; diff --git a/packages/rs-drive/src/drive/verify/voting/verify_start_at_contender_in_proof/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_start_at_contender_in_proof/mod.rs new file mode 100644 index 0000000000..99188f2428 --- /dev/null +++ b/packages/rs-drive/src/drive/verify/voting/verify_start_at_contender_in_proof/mod.rs @@ -0,0 +1,61 @@ +mod v0; + +use crate::drive::verify::RootHash; +use crate::error::drive::DriveError; + +use crate::error::Error; +use dpp::document::Document; +use dpp::version::PlatformVersion; +use crate::query::vote_poll_contestant_votes_query::ResolvedContestedDocumentVotePollVotesDriveQuery; +use crate::query::vote_poll_vote_state_query::Contender; + +impl<'a> ResolvedContestedDocumentVotePollVotesDriveQuery<'a> { + /// Verifies if a document exists at the beginning of a proof, + /// and returns the root hash and the optionally found document. + /// + /// # Arguments + /// + /// * `proof` - A byte slice containing the proof data. + /// * `is_proof_subset` - A boolean indicating whether the proof is a subset query or not. + /// * `document_id` - A byte_32 array, representing the ID of the document to start at. + /// * `platform_version` - The platform version against which to verify the proof. + /// + /// # Returns + /// + /// A `Result` with a tuple containing: + /// * The root hash of the verified proof. + /// * An `Option` containing the found document if available. + /// + /// # Errors + /// + /// This function returns an Error in the following cases: + /// * If the proof is corrupted (wrong path, wrong key, etc.). + /// * If the provided proof has an incorrect number of elements. + pub fn verify_start_at_contender_in_proof( + &self, + proof: &[u8], + is_proof_subset: bool, + document_id: [u8; 32], + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Option), Error> { + match platform_version + .drive + .methods + .verify + .voting + .verify_start_at_contender_in_proof + { + 0 => self.verify_start_at_contender_in_proof_v0( + proof, + is_proof_subset, + document_id, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "verify_start_at_contender_in_proof".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/verify/voting/verify_start_at_contender_in_proof/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_start_at_contender_in_proof/v0/mod.rs new file mode 100644 index 0000000000..d4d91d2fed --- /dev/null +++ b/packages/rs-drive/src/drive/verify/voting/verify_start_at_contender_in_proof/v0/mod.rs @@ -0,0 +1,87 @@ +use crate::drive::verify::RootHash; + +use crate::error::proof::ProofError; +use crate::error::Error; +use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; +use dpp::document::Document; +use dpp::version::PlatformVersion; +use grovedb::{GroveDb, PathQuery}; +use crate::query::vote_poll_contestant_votes_query::ResolvedContestedDocumentVotePollVotesDriveQuery; +use crate::query::vote_poll_vote_state_query::Contender; + +impl<'a> ResolvedContestedDocumentVotePollVotesDriveQuery<'a> { + /// Verifies if a document exists at the beginning of a proof, + /// and returns the root hash and the optionally found document. + /// + /// # Arguments + /// + /// * `proof` - A byte slice containing the proof data. + /// * `is_proof_subset` - A boolean indicating whether the proof is a subset query or not. + /// * `document_id` - A byte_32 array, representing the ID of the document to start at. + /// + /// # Returns + /// + /// A `Result` with a tuple containing: + /// * The root hash of the verified proof. + /// * An `Option` containing the found document if available. + /// + /// # Errors + /// + /// This function returns an Error in the following cases: + /// * If the proof is corrupted (wrong path, wrong key, etc.). + /// * If the provided proof has an incorrect number of elements. + #[inline(always)] + pub(super) fn verify_start_at_contender_in_proof_v0( + &self, + proof: &[u8], + is_proof_subset: bool, + contender_identity_id: [u8; 32], + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Option), Error> { + let start_at_document_path = ; + let start_at_document_key = contender_identity_id.to_vec(); + let path_query = PathQuery::new_single_key( + start_at_document_path.clone(), + start_at_document_key.clone(), + ); + let (root_hash, mut proved_key_values) = if is_proof_subset { + GroveDb::verify_subset_query(proof, &path_query)? + } else { + GroveDb::verify_query(proof, &path_query)? + }; + match proved_key_values.len() { + 1 => { + let (path, key, maybe_element) = proved_key_values.remove(0); + if path != start_at_document_path { + return Err(Error::Proof(ProofError::CorruptedProof( + "we did not get back a contender for the correct path".to_string(), + ))); + } + if key != start_at_document_key { + return Err(Error::Proof(ProofError::CorruptedProof( + "we did not get back a contender for the correct key".to_string(), + ))); + } + let document = maybe_element + .map(|element| { + let document_bytes = element.into_item_bytes().map_err(Error::GroveDB)?; + Document::from_bytes( + document_bytes.as_slice(), + self.document_type, + platform_version, + ) + .map_err(Error::Protocol) + }) + .transpose()?; + Ok((root_hash, document)) + } + 0 => Err(Error::Proof(ProofError::WrongElementCount { + expected: 1, + got: 0, + })), + _ => Err(Error::Proof(ProofError::TooManyElements( + "expected one contender for start at", + ))), + } + } +} diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/mod.rs new file mode 100644 index 0000000000..cd14f722fc --- /dev/null +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/mod.rs @@ -0,0 +1,47 @@ +mod v0; + +use crate::drive::verify::RootHash; +use crate::error::drive::DriveError; + +use crate::error::Error; + +use dpp::version::PlatformVersion; +use crate::query::vote_poll_vote_state_query::{Contender, ResolvedContestedDocumentVotePollDriveQuery}; + +impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { + /// Verifies a proof for the vote poll vote state proof. + /// + /// This function takes a byte slice representing the serialized proof, verifies it, and returns a tuple consisting of the root hash + /// and a vector of deserialized contenders. + /// + /// # Arguments + /// + /// * `proof` - A byte slice representing the proof to be verified. + /// * `platform_version` - The platform version against which to verify the proof. + /// + /// # Returns + /// + /// A `Result` containing: + /// * A tuple with the root hash and a vector of deserialized `Document`s if the proof is valid. + /// * An `Error` variant, in case the proof verification fails or a deserialization error occurs. + /// + /// # Errors + /// + /// This function will return an `Error` variant if: + /// 1. The proof verification fails. + /// 2. A deserialization error occurs when parsing the serialized document(s). + pub fn verify_vote_poll_vote_state_proof( + &self, + proof: &[u8], + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Vec), Error> { + match platform_version.drive.methods.verify.voting.verify_vote_poll_vote_state_proof { + 0 => self.verify_vote_poll_vote_state_proof_v0(proof, platform_version), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "verify_vote_poll_vote_state_proof".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs new file mode 100644 index 0000000000..962d161bfc --- /dev/null +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs @@ -0,0 +1,104 @@ +use grovedb::{Element, GroveDb}; +use dpp::identifier::Identifier; +use crate::drive::verify::RootHash; + +use crate::error::Error; + +use dpp::version::PlatformVersion; +use crate::error::drive::DriveError; +use crate::query::vote_poll_vote_state_query::{Contender, ContestedDocumentVotePollDriveQueryResultType, ResolvedContestedDocumentVotePollDriveQuery}; + +impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { + /// Verifies a proof for a collection of documents. + /// + /// This function takes a slice of bytes `proof` containing a serialized proof, + /// verifies it, and returns a tuple consisting of the root hash and a vector of deserialized documents. + /// + /// # Arguments + /// + /// * `proof` - A byte slice representing the proof to be verified. + /// * `drive_version` - The current active drive version + /// + /// # Returns + /// + /// A `Result` containing: + /// * A tuple with the root hash and a vector of deserialized `Document`s, if the proof is valid. + /// * An `Error` variant, in case the proof verification fails or deserialization error occurs. + /// + /// # Errors + /// + /// This function will return an `Error` variant if: + /// 1. The proof verification fails. + /// 2. There is a deserialization error when parsing the serialized document(s) into `Document` struct(s). + #[inline(always)] + pub(super) fn verify_vote_poll_vote_state_proof_v0( + &self, + proof: &[u8], + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Vec), Error> { + let path_query = self.construct_path_query(platform_version)?; + let (root_hash, proved_key_values) = GroveDb::verify_query(proof, &path_query)?; + + let contenders = match self.result_type { + ContestedDocumentVotePollDriveQueryResultType::IdentityIdsOnly => { + proved_key_values.into_iter().map(|(_,identity_id, _)| Ok(Contender { + identity_id: Identifier::try_from(identity_id)?, + serialized_document: None, + vote_tally: None, + })).collect::, Error>>() + } + ContestedDocumentVotePollDriveQueryResultType::Documents => { + proved_key_values.into_iter().map(|(_, identity_id, document)| { + Ok(Contender { + identity_id: Identifier::try_from(identity_id)?, + serialized_document: document.map(|document| document.into_item_bytes()).transpose()?, + vote_tally: None, + }) + }).collect::, Error>>() + } + ContestedDocumentVotePollDriveQueryResultType::VoteTally => { + proved_key_values.into_iter().map(|(_, identity_id, vote_tally)| { + let sum_tree_value = vote_tally.map(|vote_tally| vote_tally.into_sum_tree_value()).transpose()?.unwrap_or_default(); + if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!("sum tree value for vote tally must be between 0 and u32::Max, received {} from state", sum_tree_value)))); + } + Ok(Contender { + identity_id: Identifier::try_from(identity_id)?, + serialized_document: None, + vote_tally: Some(sum_tree_value as u32), + }) + }).collect::, Error>>() + } + ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally => { + let mut elements_iter = proved_key_values.into_iter(); + + let mut contenders = vec![]; + while let (Some((path_doc, _, Some(Element::Item(serialized_document, _)))), Some((path_tally, _, Some(Element::SumTree(_, sum_tree_value, _))))) = (elements_iter.next(), elements_iter.next()) { + if path_doc != path_tally { + return Err(Error::Drive(DriveError::CorruptedDriveState("the two results in a chunk when requesting documents and vote tally should both have the same path".to_string()))); + } + let Some(identity_bytes) = path_doc.last() else { + return Err(Error::Drive(DriveError::CorruptedDriveState("the path must have a last element".to_string()))); + }; + + let identity_id = Identifier::from_bytes(identity_bytes)?; + + if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!("sum tree value for vote tally must be between 0 and u32::Max, received {} from state", sum_tree_value)))); + } + + let contender = Contender { + identity_id, + serialized_document: Some(serialized_document), + vote_tally: Some(sum_tree_value as u32), + }; + + contenders.push(contender) + } + Ok(contenders) + } + }?; + + Ok((root_hash, contenders)) + } +} diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index 06795e5ee7..1ceed9f3f0 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -73,50 +73,50 @@ pub trait VotePollPaths { ) -> Result>, Error>; } -impl VotePollPaths for ContestedDocumentResourceVotePollWithContractInfo { +impl<'a> VotePollPaths for ContestedDocumentResourceVotePollWithContractInfo<'a> { fn contract_path(&self) -> [&[u8]; 4] { vote_contested_resource_active_polls_contract_tree_path( - self.contract.contract.id_ref().as_slice(), + self.contract.as_ref().id_ref().as_slice(), ) } fn contract_path_vec(&self) -> Vec> { vote_contested_resource_active_polls_contract_tree_path_vec( - self.contract.contract.id_ref().as_slice(), + self.contract.as_ref().id_ref().as_slice(), ) } fn document_type_path(&self) -> [&[u8]; 5] { vote_contested_resource_active_polls_contract_document_tree_path( - self.contract.contract.id_ref().as_slice(), + self.contract.as_ref().id_ref().as_slice(), self.document_type_name.as_str(), ) } fn document_type_path_vec(&self) -> Vec> { vote_contested_resource_active_polls_contract_document_tree_path_vec( - self.contract.contract.id_ref().as_slice(), + self.contract.as_ref().id_ref().as_slice(), self.document_type_name.as_str(), ) } fn documents_storage_path(&self) -> [&[u8]; 6] { vote_contested_resource_contract_documents_storage_path( - self.contract.contract.id_ref().as_slice(), + self.contract.as_ref().id_ref().as_slice(), self.document_type_name.as_str(), ) } fn documents_storage_path_vec(&self) -> Vec> { vote_contested_resource_contract_documents_storage_path_vec( - self.contract.contract.id_ref().as_slice(), + self.contract.as_ref().id_ref().as_slice(), self.document_type_name.as_str(), ) } fn contenders_path(&self, platform_version: &PlatformVersion) -> Result>, Error> { let mut root = vote_contested_resource_active_polls_contract_document_tree_path_vec( - self.contract.contract.id_ref().as_slice(), + self.contract.as_ref().id_ref().as_slice(), self.document_type_name.as_str(), ); let document_type = self.document_type()?; diff --git a/packages/rs-drive/src/drive/votes/resolve_contested_document_resource_vote_poll/mod.rs b/packages/rs-drive/src/drive/votes/resolve_contested_document_resource_vote_poll/mod.rs index b8a78aa18b..489b91bde1 100644 --- a/packages/rs-drive/src/drive/votes/resolve_contested_document_resource_vote_poll/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolve_contested_document_resource_vote_poll/mod.rs @@ -1,4 +1,3 @@ -use crate::drive::contract::DataContractFetchInfo; use crate::drive::Drive; use crate::error::contract::DataContractError; use crate::error::drive::DriveError; @@ -11,7 +10,7 @@ use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDoc use dpp::ProtocolError; use grovedb::TransactionArg; use platform_version::version::PlatformVersion; -use std::sync::Arc; +use crate::drive::object_size_info::DataContractResolvedInfo; /// Represents information related to a contested document resource vote poll, along with /// associated contract details. @@ -19,9 +18,9 @@ use std::sync::Arc; /// This structure holds a reference to the contract, the document type name, /// the index name, and the index values used for the poll. #[derive(Debug, PartialEq, Clone)] -pub struct ContestedDocumentResourceVotePollWithContractInfo { +pub struct ContestedDocumentResourceVotePollWithContractInfo<'a> { /// The contract information associated with the document. - pub contract: Arc, + pub contract: DataContractResolvedInfo<'a>, /// The name of the document type. pub document_type_name: String, /// The name of the index. @@ -30,7 +29,7 @@ pub struct ContestedDocumentResourceVotePollWithContractInfo { pub index_values: Vec, } -impl ContestedDocumentResourceVotePollWithContractInfo { +impl<'a> ContestedDocumentResourceVotePollWithContractInfo<'a> { /// Retrieves the index associated with the document type and index name. /// /// # Returns @@ -44,7 +43,7 @@ impl ContestedDocumentResourceVotePollWithContractInfo { /// if the index cannot be found within the document type. pub fn index(&self) -> Result<&Index, Error> { self.contract - .contract + .as_ref() .document_type_borrowed_for_name(self.document_type_name.as_str())? .indexes() .get(&self.index_name) @@ -66,7 +65,7 @@ impl ContestedDocumentResourceVotePollWithContractInfo { /// if there is an issue retrieving the document type. pub fn document_type(&self) -> Result { self.contract - .contract + .as_ref() .document_type_for_name(self.document_type_name.as_str()) .map_err(|e| Error::Protocol(ProtocolError::DataContractError(e))) } @@ -84,7 +83,7 @@ impl ContestedDocumentResourceVotePollWithContractInfo { /// if there is an issue retrieving the document type. pub fn document_type_borrowed(&self) -> Result<&DocumentType, Error> { self.contract - .contract + .as_ref() .document_type_borrowed_for_name(self.document_type_name.as_str()) .map_err(|e| Error::Protocol(ProtocolError::DataContractError(e))) } @@ -139,7 +138,7 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll".to_string())))?; Ok(ContestedDocumentResourceVotePollWithContractInfo { - contract, + contract: DataContractResolvedInfo::DataContractFetchInfo(contract), document_type_name: document_type_name.clone(), index_name: index_name.clone(), index_values: index_values.clone(), diff --git a/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs b/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs index 3777bacecb..f982a24068 100644 --- a/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs +++ b/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs @@ -228,9 +228,9 @@ impl ContestedDocumentVotePollVotesDriveQuery { /// Vote Poll Drive Query struct #[derive(Debug, PartialEq, Clone)] -pub struct ResolvedContestedDocumentVotePollVotesDriveQuery { +pub struct ResolvedContestedDocumentVotePollVotesDriveQuery<'a> { /// What vote poll are we asking for? - pub vote_poll: ContestedDocumentResourceVotePollWithContractInfo, + pub vote_poll: ContestedDocumentResourceVotePollWithContractInfo<'a>, /// Who's votes are we looking for pub contestant_id: Identifier, /// Offset @@ -243,7 +243,7 @@ pub struct ResolvedContestedDocumentVotePollVotesDriveQuery { pub order_ascending: bool, } -impl ResolvedContestedDocumentVotePollVotesDriveQuery { +impl<'a> ResolvedContestedDocumentVotePollVotesDriveQuery<'a> { /// Operations to construct a path query. pub fn construct_path_query( &self, diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index 371760c1e8..f7220d3922 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -398,9 +398,9 @@ impl ContestedDocumentVotePollDriveQuery { /// Vote Poll Drive Query struct #[derive(Debug, PartialEq, Clone)] -pub struct ResolvedContestedDocumentVotePollDriveQuery { +pub struct ResolvedContestedDocumentVotePollDriveQuery<'a> { /// What vote poll are we asking for? - pub vote_poll: ContestedDocumentResourceVotePollWithContractInfo, + pub vote_poll: ContestedDocumentResourceVotePollWithContractInfo<'a>, /// What result type are we interested in pub result_type: ContestedDocumentVotePollDriveQueryResultType, /// Offset @@ -413,7 +413,7 @@ pub struct ResolvedContestedDocumentVotePollDriveQuery { pub order_ascending: bool, } -impl ResolvedContestedDocumentVotePollDriveQuery { +impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { /// Operations to construct a path query. pub fn construct_path_query( &self, diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index b415138f37..7bba988667 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -112,6 +112,8 @@ pub struct DriveVerifyIdentityMethodVersions { #[derive(Clone, Debug, Default)] pub struct DriveVerifyVoteMethodVersions { pub verify_masternode_vote: FeatureVersion, + pub verify_start_at_contender_in_proof: FeatureVersion, + pub verify_vote_poll_vote_state_proof: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 5efde6b625..5c274e918f 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -311,6 +311,8 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { }, voting: DriveVerifyVoteMethodVersions { verify_masternode_vote: 0, + verify_start_at_contender_in_proof: 0, + verify_vote_poll_vote_state_proof: 0, }, state_transition: DriveVerifyStateTransitionMethodVersions { verify_state_transition_was_executed_with_proof: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index d2b7b251ad..78b3561b8e 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -319,6 +319,8 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { }, voting: DriveVerifyVoteMethodVersions { verify_masternode_vote: 0, + verify_start_at_contender_in_proof: 0, + verify_vote_poll_vote_state_proof: 0, }, state_transition: DriveVerifyStateTransitionMethodVersions { verify_state_transition_was_executed_with_proof: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 63bd35649d..4e713de1eb 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -310,6 +310,8 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { }, voting: DriveVerifyVoteMethodVersions { verify_masternode_vote: 0, + verify_start_at_contender_in_proof: 0, + verify_vote_poll_vote_state_proof: 0, }, state_transition: DriveVerifyStateTransitionMethodVersions { verify_state_transition_was_executed_with_proof: 0, From f6497987f15d36a356639a93d98d17e7de0a9c2c Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 20 May 2024 11:21:10 +0200 Subject: [PATCH 067/135] more work --- .../schema/v1/dpns-contract-documents.json | 2 + .../state_transitions/documents_batch/mod.rs | 123 ++++++++++++++++++ 2 files changed, 125 insertions(+) diff --git a/packages/dpns-contract/schema/v1/dpns-contract-documents.json b/packages/dpns-contract/schema/v1/dpns-contract-documents.json index 63fe579816..43e55f1a6b 100644 --- a/packages/dpns-contract/schema/v1/dpns-contract-documents.json +++ b/packages/dpns-contract/schema/v1/dpns-contract-documents.json @@ -1,6 +1,8 @@ { "domain": { "type": "object", + "documentsMutable": false, + "canBeDeleted": false, "indices": [ { "name": "parentNameAndLabel", diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs index da5d970161..b4584a96e6 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs @@ -418,6 +418,129 @@ mod tests { .expect("expected to commit transaction"); } + #[test] + fn test_document_creation_on_contested_unique_index() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let mut rng = StdRng::seed_from_u64(433); + + let platform_state = platform.state.load(); + + let (identity_1, signer_1, key_1) = setup_identity(&mut platform, 958, dash_to_credits!(0.5)); + + let (identity_2, signer_2, key_2) = setup_identity(&mut platform, 93, dash_to_credits!(0.5)); + + let dpns = platform.drive.cache.system_data_contracts.load_dpns(); + let dpns_contract = dpns.clone(); + + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); + + assert!(!domain.documents_mutable()); + assert!(!domain.documents_can_be_deleted()); + + let entropy = Bytes32::random_with_rng(&mut rng); + + let mut document_1 = domain + .random_document_with_identifier_and_entropy( + &mut rng, + identity_1.id(), + entropy, + DocumentFieldFillType::FillIfNotRequired, + DocumentFieldFillSize::AnyDocumentFillSize, + platform_version, + ) + .expect("expected a random document"); + + let mut document_2 = domain + .random_document_with_identifier_and_entropy( + &mut rng, + identity_2.id(), + entropy, + DocumentFieldFillType::FillIfNotRequired, + DocumentFieldFillSize::AnyDocumentFillSize, + platform_version, + ) + .expect("expected a random document"); + + document_1.set("parentDomainName", "dash".into()); + document_1.set("normalizedParentDomainName", "dash".into()); + document_1.set("label", "quantum".into()); + document_1.set("normalizedLabel", "quantum".into()); + document_1.set("records.dashUniqueIdentityId", document_1.owner_id().into()); + + document_2.set("parentDomainName", "dash".into()); + document_2.set("normalizedParentDomainName", "dash".into()); + document_2.set("label", "quantum".into()); + document_2.set("normalizedLabel", "quantum".into()); + + let documents_batch_create_transition_1 = + DocumentsBatchTransition::new_document_creation_transition_from_document( + document_1, + domain, + entropy.0, + &key_1, + 2, + 0, + &signer_1, + platform_version, + None, + None, + None, + ) + .expect("expect to create documents batch transition"); + + let documents_batch_create_serialized_transition_1 = documents_batch_create_transition_1 + .serialize_to_bytes() + .expect("expected documents batch serialized state transition"); + + let documents_batch_create_transition_2 = + DocumentsBatchTransition::new_document_creation_transition_from_document( + document_2, + domain, + entropy.0, + &key_2, + 2, + 0, + &signer_2, + platform_version, + None, + None, + None, + ) + .expect("expect to create documents batch transition"); + + let documents_batch_create_serialized_transition_2 = documents_batch_create_transition_2 + .serialize_to_bytes() + .expect("expected documents batch serialized state transition"); + + let transaction = platform.drive.grove.start_transaction(); + + let processing_result = platform + .platform + .process_raw_state_transitions( + &vec![documents_batch_create_serialized_transition_1.clone(), documents_batch_create_serialized_transition_2.clone()], + &platform_state, + &BlockInfo::default(), + &transaction, + platform_version, + ) + .expect("expected to process state transition"); + + assert_eq!(processing_result.valid_count(), 2); + + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit transaction"); + } + #[test] fn test_document_creation_on_restricted_document_type_that_only_allows_contract_owner_to_create( ) { From 67fcc95f8651585dd1937a2ab783d910126c052f Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 20 May 2024 18:10:22 +0200 Subject: [PATCH 068/135] more fixes --- .../schema/v1/dpns-contract-documents.json | 2 + .../state_transitions/documents_batch/mod.rs | 361 +++++++++++++++++- .../tests/strategy_tests/voting_tests.rs | 62 +-- .../verify_vote_poll_vote_state_proof/mod.rs | 12 +- .../v0/mod.rs | 13 +- .../mod.rs | 2 +- 6 files changed, 402 insertions(+), 50 deletions(-) diff --git a/packages/dpns-contract/schema/v1/dpns-contract-documents.json b/packages/dpns-contract/schema/v1/dpns-contract-documents.json index 43e55f1a6b..6ce1d5bc34 100644 --- a/packages/dpns-contract/schema/v1/dpns-contract-documents.json +++ b/packages/dpns-contract/schema/v1/dpns-contract-documents.json @@ -146,6 +146,8 @@ }, "preorder": { "type": "object", + "documentsMutable": false, + "canBeDeleted": true, "indices": [ { "name": "saltedHash", diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs index b4584a96e6..33d322160b 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs @@ -328,9 +328,22 @@ mod tests { } mod creation_tests { + use rand::Rng; + use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse}; + use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0::ResultType; + use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::GetContestedResourceVoteStateRequestV0; + use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; use super::*; use dpp::data_contract::accessors::v0::DataContractV0Setters; use dpp::data_contract::document_type::restricted_creation::CreationRestrictionMode; + use dpp::document::Document; + use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; + use dpp::util::hash::hash_double; + use drive::drive::object_size_info::DataContractResolvedInfo; + use drive::drive::votes::resolve_contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; + use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; + use drive::query::vote_poll_vote_state_query::ResolvedContestedDocumentVotePollDriveQuery; + use crate::platform_types::platform_state::v0::PlatformStateV0Methods; #[test] fn test_document_creation() { @@ -429,22 +442,55 @@ mod tests { let platform_state = platform.state.load(); - let (identity_1, signer_1, key_1) = setup_identity(&mut platform, 958, dash_to_credits!(0.5)); + let (identity_1, signer_1, key_1) = + setup_identity(&mut platform, 958, dash_to_credits!(0.5)); + + let (identity_2, signer_2, key_2) = + setup_identity(&mut platform, 93, dash_to_credits!(0.5)); - let (identity_2, signer_2, key_2) = setup_identity(&mut platform, 93, dash_to_credits!(0.5)); - let dpns = platform.drive.cache.system_data_contracts.load_dpns(); let dpns_contract = dpns.clone(); + let preorder = dpns_contract + .document_type_for_name("preorder") + .expect("expected a profile document type"); + + assert!(!preorder.documents_mutable()); + assert!(preorder.documents_can_be_deleted()); + assert!(!preorder.documents_transferable().is_transferable()); + let domain = dpns_contract .document_type_for_name("domain") .expect("expected a profile document type"); assert!(!domain.documents_mutable()); assert!(!domain.documents_can_be_deleted()); + assert!(!domain.documents_transferable().is_transferable()); let entropy = Bytes32::random_with_rng(&mut rng); + let mut preorder_document_1 = preorder + .random_document_with_identifier_and_entropy( + &mut rng, + identity_1.id(), + entropy, + DocumentFieldFillType::FillIfNotRequired, + DocumentFieldFillSize::AnyDocumentFillSize, + platform_version, + ) + .expect("expected a random document"); + + let mut preorder_document_2 = preorder + .random_document_with_identifier_and_entropy( + &mut rng, + identity_2.id(), + entropy, + DocumentFieldFillType::FillIfNotRequired, + DocumentFieldFillSize::AnyDocumentFillSize, + platform_version, + ) + .expect("expected a random document"); + let mut document_1 = domain .random_document_with_identifier_and_entropy( &mut rng, @@ -472,11 +518,77 @@ mod tests { document_1.set("label", "quantum".into()); document_1.set("normalizedLabel", "quantum".into()); document_1.set("records.dashUniqueIdentityId", document_1.owner_id().into()); + document_1.set("subdomainRules.allowSubdomains", false.into()); document_2.set("parentDomainName", "dash".into()); document_2.set("normalizedParentDomainName", "dash".into()); document_2.set("label", "quantum".into()); document_2.set("normalizedLabel", "quantum".into()); + document_2.set("records.dashUniqueIdentityId", document_2.owner_id().into()); + document_2.set("subdomainRules.allowSubdomains", false.into()); + + let salt_1: [u8; 32] = rng.gen(); + let salt_2: [u8; 32] = rng.gen(); + + let mut salted_domain_buffer_1: Vec = vec![]; + salted_domain_buffer_1.extend(salt_1); + salted_domain_buffer_1.extend("quantum.dash".as_bytes()); + + let salted_domain_hash_1 = hash_double(salted_domain_buffer_1); + + let mut salted_domain_buffer_2: Vec = vec![]; + salted_domain_buffer_2.extend(salt_2); + salted_domain_buffer_2.extend("quantum.dash".as_bytes()); + + let salted_domain_hash_2 = hash_double(salted_domain_buffer_2); + + preorder_document_1.set("saltedDomainHash", salted_domain_hash_1.into()); + preorder_document_2.set("saltedDomainHash", salted_domain_hash_2.into()); + + document_1.set("preorderSalt", salt_1.into()); + document_2.set("preorderSalt", salt_2.into()); + + let documents_batch_create_preorder_transition_1 = + DocumentsBatchTransition::new_document_creation_transition_from_document( + preorder_document_1, + preorder, + entropy.0, + &key_1, + 2, + 0, + &signer_1, + platform_version, + None, + None, + None, + ) + .expect("expect to create documents batch transition"); + + let documents_batch_create_serialized_preorder_transition_1 = + documents_batch_create_preorder_transition_1 + .serialize_to_bytes() + .expect("expected documents batch serialized state transition"); + + let documents_batch_create_preorder_transition_2 = + DocumentsBatchTransition::new_document_creation_transition_from_document( + preorder_document_2, + preorder, + entropy.0, + &key_2, + 2, + 0, + &signer_2, + platform_version, + None, + None, + None, + ) + .expect("expect to create documents batch transition"); + + let documents_batch_create_serialized_preorder_transition_2 = + documents_batch_create_preorder_transition_2 + .serialize_to_bytes() + .expect("expected documents batch serialized state transition"); let documents_batch_create_transition_1 = DocumentsBatchTransition::new_document_creation_transition_from_document( @@ -484,7 +596,7 @@ mod tests { domain, entropy.0, &key_1, - 2, + 3, 0, &signer_1, platform_version, @@ -492,11 +604,12 @@ mod tests { None, None, ) - .expect("expect to create documents batch transition"); + .expect("expect to create documents batch transition"); - let documents_batch_create_serialized_transition_1 = documents_batch_create_transition_1 - .serialize_to_bytes() - .expect("expected documents batch serialized state transition"); + let documents_batch_create_serialized_transition_1 = + documents_batch_create_transition_1 + .serialize_to_bytes() + .expect("expected documents batch serialized state transition"); let documents_batch_create_transition_2 = DocumentsBatchTransition::new_document_creation_transition_from_document( @@ -504,7 +617,7 @@ mod tests { domain, entropy.0, &key_2, - 2, + 3, 0, &signer_2, platform_version, @@ -512,18 +625,22 @@ mod tests { None, None, ) - .expect("expect to create documents batch transition"); + .expect("expect to create documents batch transition"); - let documents_batch_create_serialized_transition_2 = documents_batch_create_transition_2 - .serialize_to_bytes() - .expect("expected documents batch serialized state transition"); + let documents_batch_create_serialized_transition_2 = + documents_batch_create_transition_2 + .serialize_to_bytes() + .expect("expected documents batch serialized state transition"); let transaction = platform.drive.grove.start_transaction(); let processing_result = platform .platform .process_raw_state_transitions( - &vec![documents_batch_create_serialized_transition_1.clone(), documents_batch_create_serialized_transition_2.clone()], + &vec![ + documents_batch_create_serialized_preorder_transition_1.clone(), + documents_batch_create_serialized_preorder_transition_2.clone(), + ], &platform_state, &BlockInfo::default(), &transaction, @@ -531,14 +648,230 @@ mod tests { ) .expect("expected to process state transition"); + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit transaction"); + assert_eq!(processing_result.valid_count(), 2); + let transaction = platform.drive.grove.start_transaction(); + + let processing_result = platform + .platform + .process_raw_state_transitions( + &vec![ + documents_batch_create_serialized_transition_1.clone(), + documents_batch_create_serialized_transition_2.clone(), + ], + &platform_state, + &BlockInfo::default(), + &transaction, + platform_version, + ) + .expect("expected to process state transition"); + platform .drive .grove .commit_transaction(transaction) .unwrap() .expect("expected to commit transaction"); + + assert_eq!(processing_result.valid_count(), 2); + + // Now let's run a query for the vote totals + + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + + let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) + .expect("expected to encode the word dash"); + + let quantum_encoded = + bincode::encode_to_vec(Value::Text("quantum".to_string()), config) + .expect("expected to encode the word quantum"); + + let index_name = "parentNameAndLabel".to_string(); + + let query_validation_result = platform + .query_contested_resource_vote_state( + GetContestedResourceVoteStateRequest { + version: Some(get_contested_resource_vote_state_request::Version::V0( + GetContestedResourceVoteStateRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![dash_encoded.clone(), quantum_encoded.clone()], + result_type: ResultType::DocumentsAndVoteTally as i32, + start_at_identifier_info: None, + count: None, + order_ascending: true, + prove: false, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_vote_state_response::Version::V0( + GetContestedResourceVoteStateResponseV0 { + metadata: _, + result, + }, + ) = query_validation_result.version.expect("expected a version"); + + let Some( + get_contested_resource_vote_state_response_v0::Result::ContestedResourceContenders( + get_contested_resource_vote_state_response_v0::ContestedResourceContenders { + contenders, + }, + ), + ) = result + else { + panic!("expected contenders") + }; + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + let first_contender_document = Document::from_bytes( + first_contender + .document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); + + let second_contender_document = Document::from_bytes( + second_contender + .document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); + + assert_ne!(first_contender_document, second_contender_document); + + assert_eq!(first_contender.identifier, identity_1.id().to_vec()); + + assert_eq!(second_contender.identifier, identity_2.id().to_vec()); + + assert_eq!(first_contender.vote_count, Some(0)); + + assert_eq!(second_contender.vote_count, Some(0)); + + let GetContestedResourceVoteStateResponse { version } = platform + .query_contested_resource_vote_state( + GetContestedResourceVoteStateRequest { + version: Some(get_contested_resource_vote_state_request::Version::V0( + GetContestedResourceVoteStateRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![dash_encoded, quantum_encoded], + result_type: ResultType::DocumentsAndVoteTally as i32, + start_at_identifier_info: None, + count: None, + order_ascending: true, + prove: true, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_vote_state_response::Version::V0( + GetContestedResourceVoteStateResponseV0 { + metadata: _, + result, + }, + ) = version.expect("expected a version"); + + let Some(get_contested_resource_vote_state_response_v0::Result::Proof(proof)) = result + else { + panic!("expected contenders") + }; + + let resolved_contested_document_vote_poll_drive_query = + ResolvedContestedDocumentVotePollDriveQuery { + vote_poll: ContestedDocumentResourceVotePollWithContractInfo { + contract: DataContractResolvedInfo::BorrowedDataContract(&dpns_contract), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![ + Value::Text("dash".to_string()), + Value::Text("quantum".to_string()), + ], + }, + result_type: DocumentsAndVoteTally, + offset: None, + limit: None, + start_at: None, + order_ascending: true, + }; + + let (root_hash, contenders) = resolved_contested_document_vote_poll_drive_query + .verify_vote_poll_vote_state_proof(proof.grovedb_proof.as_ref(), platform_version) + .expect("expected to verify proof"); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + let first_contender_document = Document::from_bytes( + first_contender + .serialized_document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); + + let second_contender_document = Document::from_bytes( + second_contender + .serialized_document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); + + assert_ne!(first_contender_document, second_contender_document); + + assert_eq!(first_contender.identity_id, identity_1.id()); + + assert_eq!(second_contender.identity_id, identity_2.id()); + + assert_eq!(first_contender.vote_tally, Some(0)); + + assert_eq!(second_contender.vote_tally, Some(0)); } #[test] diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index e91f711eff..94dcc9c708 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -229,7 +229,7 @@ mod tests { let quantum_encoded = bincode::encode_to_vec(Value::Text("quantum".to_string()), config) .expect("expected to encode the word quantum"); - + let index_name = "parentNameAndLabel".to_string(); let query_validation_result = platform @@ -343,33 +343,39 @@ mod tests { }, ) = version.expect("expected a version"); - let Some( - get_contested_resource_vote_state_response_v0::Result::Proof( - proof, - ), - ) = result - else { - panic!("expected contenders") - }; - - - let resolved_contested_document_vote_poll_drive_query = ResolvedContestedDocumentVotePollDriveQuery { - vote_poll: ContestedDocumentResourceVotePollWithContractInfo { - contract: DataContractResolvedInfo::BorrowedDataContract(&dpns_contract), - document_type_name: document_type.name().clone(), - index_name: index_name.clone(), - index_values: vec![Value::Text("dash".to_string()), Value::Text("quantum".to_string())], - }, - result_type: DocumentsAndVoteTally, - offset: None, - limit: None, - start_at: None, - order_ascending: true, + let Some(get_contested_resource_vote_state_response_v0::Result::Proof(proof)) = result + else { + panic!("expected contenders") }; - let (root_hash, contenders) = resolved_contested_document_vote_poll_drive_query.verify_vote_poll_vote_state_proof(proof.grovedb_proof.as_ref(), platform_version).expect("expected to verify proof"); - - assert_eq!(root_hash, platform_state.last_committed_block_app_hash().expect("expected an app hash")); + let resolved_contested_document_vote_poll_drive_query = + ResolvedContestedDocumentVotePollDriveQuery { + vote_poll: ContestedDocumentResourceVotePollWithContractInfo { + contract: DataContractResolvedInfo::BorrowedDataContract(&dpns_contract), + document_type_name: document_type.name().clone(), + index_name: index_name.clone(), + index_values: vec![ + Value::Text("dash".to_string()), + Value::Text("quantum".to_string()), + ], + }, + result_type: DocumentsAndVoteTally, + offset: None, + limit: None, + start_at: None, + order_ascending: true, + }; + + let (root_hash, contenders) = resolved_contested_document_vote_poll_drive_query + .verify_vote_poll_vote_state_proof(proof.grovedb_proof.as_ref(), platform_version) + .expect("expected to verify proof"); + + assert_eq!( + root_hash, + platform_state + .last_committed_block_app_hash() + .expect("expected an app hash") + ); assert_eq!(contenders.len(), 2); @@ -386,7 +392,7 @@ mod tests { document_type.as_ref(), platform_version, ) - .expect("expected to get document"); + .expect("expected to get document"); let second_contender_document = Document::from_bytes( second_contender @@ -397,7 +403,7 @@ mod tests { document_type.as_ref(), platform_version, ) - .expect("expected to get document"); + .expect("expected to get document"); assert_ne!(first_contender_document, second_contender_document); diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/mod.rs index cd14f722fc..321f9063c4 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/mod.rs @@ -5,8 +5,10 @@ use crate::error::drive::DriveError; use crate::error::Error; +use crate::query::vote_poll_vote_state_query::{ + Contender, ResolvedContestedDocumentVotePollDriveQuery, +}; use dpp::version::PlatformVersion; -use crate::query::vote_poll_vote_state_query::{Contender, ResolvedContestedDocumentVotePollDriveQuery}; impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { /// Verifies a proof for the vote poll vote state proof. @@ -35,7 +37,13 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { proof: &[u8], platform_version: &PlatformVersion, ) -> Result<(RootHash, Vec), Error> { - match platform_version.drive.methods.verify.voting.verify_vote_poll_vote_state_proof { + match platform_version + .drive + .methods + .verify + .voting + .verify_vote_poll_vote_state_proof + { 0 => self.verify_vote_poll_vote_state_proof_v0(proof, platform_version), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { method: "verify_vote_poll_vote_state_proof".to_string(), diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs index 962d161bfc..c54a65edd5 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs @@ -1,12 +1,15 @@ -use grovedb::{Element, GroveDb}; -use dpp::identifier::Identifier; use crate::drive::verify::RootHash; +use dpp::identifier::Identifier; +use grovedb::{Element, GroveDb}; use crate::error::Error; -use dpp::version::PlatformVersion; use crate::error::drive::DriveError; -use crate::query::vote_poll_vote_state_query::{Contender, ContestedDocumentVotePollDriveQueryResultType, ResolvedContestedDocumentVotePollDriveQuery}; +use crate::query::vote_poll_vote_state_query::{ + Contender, ContestedDocumentVotePollDriveQueryResultType, + ResolvedContestedDocumentVotePollDriveQuery, +}; +use dpp::version::PlatformVersion; impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { /// Verifies a proof for a collection of documents. @@ -98,7 +101,7 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { Ok(contenders) } }?; - + Ok((root_hash, contenders)) } } diff --git a/packages/rs-drive/src/drive/votes/resolve_contested_document_resource_vote_poll/mod.rs b/packages/rs-drive/src/drive/votes/resolve_contested_document_resource_vote_poll/mod.rs index 489b91bde1..40ceb3f82c 100644 --- a/packages/rs-drive/src/drive/votes/resolve_contested_document_resource_vote_poll/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolve_contested_document_resource_vote_poll/mod.rs @@ -1,3 +1,4 @@ +use crate::drive::object_size_info::DataContractResolvedInfo; use crate::drive::Drive; use crate::error::contract::DataContractError; use crate::error::drive::DriveError; @@ -10,7 +11,6 @@ use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDoc use dpp::ProtocolError; use grovedb::TransactionArg; use platform_version::version::PlatformVersion; -use crate::drive::object_size_info::DataContractResolvedInfo; /// Represents information related to a contested document resource vote poll, along with /// associated contract details. From 470318bb9609943e65b7ff7b01cb8e9f49537749 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 20 May 2024 20:17:16 +0200 Subject: [PATCH 069/135] vote validation --- ...nvalid_state_transition_signature_error.rs | 12 +- .../identity/identity_public_key/random.rs | 23 + .../identity/identity_public_key/v0/random.rs | 32 +- packages/rs-dpp/src/state_transition/mod.rs | 35 +- .../identity_signed.rs | 8 +- .../masternode_vote_transition/methods/mod.rs | 42 +- .../methods/v0/mod.rs | 20 +- .../v0/v0_methods.rs | 35 +- .../vote_choices/resource_vote_choice/mod.rs | 1 + .../validate_fees_of_event/v0/mod.rs | 6 +- .../execution/types/execution_event/mod.rs | 5 + .../v0/mod.rs | 4 +- .../state_transitions/documents_batch/mod.rs | 67 +- .../state_transitions/masternode_vote/mod.rs | 618 ++++++++++++++++++ .../state_transition/state_transitions/mod.rs | 73 +++ .../v0/mod.rs | 16 +- .../src/version/mocks/v2_test.rs | 2 +- .../src/version/mocks/v3_test.rs | 2 +- .../rs-platform-version/src/version/v1.rs | 2 +- 19 files changed, 897 insertions(+), 106 deletions(-) diff --git a/packages/rs-dpp/src/errors/consensus/signature/invalid_state_transition_signature_error.rs b/packages/rs-dpp/src/errors/consensus/signature/invalid_state_transition_signature_error.rs index c464106716..4c179a63f3 100644 --- a/packages/rs-dpp/src/errors/consensus/signature/invalid_state_transition_signature_error.rs +++ b/packages/rs-dpp/src/errors/consensus/signature/invalid_state_transition_signature_error.rs @@ -19,7 +19,9 @@ use thiserror::Error; )] #[error("Invalid State Transition signature")] #[platform_serialize(unversioned)] -pub struct InvalidStateTransitionSignatureError; +pub struct InvalidStateTransitionSignatureError { + message: String, +} /* @@ -28,8 +30,12 @@ DO NOT CHANGE ORDER OF FIELDS WITHOUT INTRODUCING OF NEW VERSION */ impl InvalidStateTransitionSignatureError { - pub fn new() -> Self { - Self + pub fn new(message: String) -> Self { + Self { message } + } + + pub fn message(&self) -> &String { + &self.message } } diff --git a/packages/rs-dpp/src/identity/identity_public_key/random.rs b/packages/rs-dpp/src/identity/identity_public_key/random.rs index fd5d6d5d2c..0dea7a5dee 100644 --- a/packages/rs-dpp/src/identity/identity_public_key/random.rs +++ b/packages/rs-dpp/src/identity/identity_public_key/random.rs @@ -342,6 +342,29 @@ impl IdentityPublicKey { } } + pub fn random_voting_key_with_rng( + id: KeyID, + rng: &mut StdRng, + platform_version: &PlatformVersion, + ) -> Result<(Self, Vec), ProtocolError> { + match platform_version + .dpp + .identity_versions + .identity_key_structure_version + { + 0 => { + let (key, private_key) = + IdentityPublicKeyV0::random_voting_key_with_rng(id, rng, platform_version)?; + Ok((key.into(), private_key)) + } + version => Err(ProtocolError::UnknownVersionMismatch { + method: "IdentityPublicKey::random_voting_key_with_rng".to_string(), + known_versions: vec![0], + received: version, + }), + } + } + /// Generates a random ECDSA master-level authentication public key along with its corresponding private key. /// /// This method constructs a random ECDSA (using the secp256k1 curve) high-level authentication public key diff --git a/packages/rs-dpp/src/identity/identity_public_key/v0/random.rs b/packages/rs-dpp/src/identity/identity_public_key/v0/random.rs index 2375810df2..13afdd673f 100644 --- a/packages/rs-dpp/src/identity/identity_public_key/v0/random.rs +++ b/packages/rs-dpp/src/identity/identity_public_key/v0/random.rs @@ -1,8 +1,8 @@ use crate::identity::contract_bounds::ContractBounds; use crate::identity::identity_public_key::v0::IdentityPublicKeyV0; -use crate::identity::KeyType::ECDSA_SECP256K1; -use crate::identity::Purpose::AUTHENTICATION; -use crate::identity::SecurityLevel::{CRITICAL, HIGH, MASTER}; +use crate::identity::KeyType::{ECDSA_HASH160, ECDSA_SECP256K1}; +use crate::identity::Purpose::{AUTHENTICATION, VOTING}; +use crate::identity::SecurityLevel::{CRITICAL, HIGH, MASTER, MEDIUM}; use crate::identity::{KeyCount, KeyID, KeyType, Purpose, SecurityLevel}; use crate::version::PlatformVersion; use crate::ProtocolError; @@ -219,6 +219,32 @@ impl IdentityPublicKeyV0 { )) } + pub fn random_voting_key_with_rng( + id: KeyID, + rng: &mut StdRng, + platform_version: &PlatformVersion, + ) -> Result<(Self, Vec), ProtocolError> { + let key_type = ECDSA_HASH160; + let purpose = VOTING; + let security_level = MEDIUM; + let read_only = false; + let (data, private_data) = + key_type.random_public_and_private_key_data(rng, platform_version)?; + Ok(( + IdentityPublicKeyV0 { + id, + key_type, + purpose, + security_level, + read_only, + disabled_at: None, + data: data.into(), + contract_bounds: None, + }, + private_data, + )) + } + pub fn random_ecdsa_critical_level_authentication_key_with_rng( id: KeyID, rng: &mut StdRng, diff --git a/packages/rs-dpp/src/state_transition/mod.rs b/packages/rs-dpp/src/state_transition/mod.rs index 7619773dc0..646fcf5396 100644 --- a/packages/rs-dpp/src/state_transition/mod.rs +++ b/packages/rs-dpp/src/state_transition/mod.rs @@ -13,6 +13,7 @@ use bincode::{Decode, Encode}; feature = "state-transition-validation" ))] use dashcore::signer; +use dashcore::signer::double_sha; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize, PlatformSignable}; use platform_version::version::PlatformVersion; @@ -665,15 +666,15 @@ impl StateTransition { )); } let data = self.signable_bytes()?; - signer::verify_data_signature(&data, self.signature().as_slice(), public_key_hash).map_err( - |_| { + let data_hash = double_sha(data); + signer::verify_hash_signature(&data_hash, self.signature().as_slice(), public_key_hash) + .map_err(|e| { ProtocolError::from(ConsensusError::SignatureError( SignatureError::InvalidStateTransitionSignatureError( - InvalidStateTransitionSignatureError::new(), + InvalidStateTransitionSignatureError::new(e.to_string()), ), )) - }, - ) + }) } #[cfg(feature = "state-transition-validation")] @@ -685,17 +686,15 @@ impl StateTransition { )); } let data = self.signable_bytes()?; - signer::verify_data_signature(&data, self.signature().as_slice(), public_key).map_err( - |_| { - // TODO: it shouldn't respond with consensus error + signer::verify_data_signature(&data, self.signature().as_slice(), public_key).map_err(|e| { + // TODO: it shouldn't respond with consensus error - ProtocolError::from(ConsensusError::SignatureError( - SignatureError::InvalidStateTransitionSignatureError( - InvalidStateTransitionSignatureError::new(), - ), - )) - }, - ) + ProtocolError::from(ConsensusError::SignatureError( + SignatureError::InvalidStateTransitionSignatureError( + InvalidStateTransitionSignatureError::new(e.to_string()), + ), + )) + }) } #[cfg(feature = "state-transition-validation")] @@ -714,12 +713,12 @@ impl StateTransition { let data = self.signable_bytes()?; bls.verify_signature(self.signature().as_slice(), &data, public_key) - .map(|_| ()) - .map_err(|_| { + .map(|e| ()) + .map_err(|e| { // TODO: it shouldn't respond with consensus error ProtocolError::from(ConsensusError::SignatureError( SignatureError::InvalidStateTransitionSignatureError( - InvalidStateTransitionSignatureError::new(), + InvalidStateTransitionSignatureError::new(e.to_string()), ), )) }) diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/identity_signed.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/identity_signed.rs index 8c79f2bfb3..cfc6f9d65b 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/identity_signed.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/identity_signed.rs @@ -1,4 +1,4 @@ -use crate::identity::{KeyID, SecurityLevel}; +use crate::identity::{KeyID, Purpose, SecurityLevel}; use crate::state_transition::masternode_vote_transition::MasternodeVoteTransition; use crate::state_transition::StateTransitionIdentitySigned; @@ -22,4 +22,10 @@ impl StateTransitionIdentitySigned for MasternodeVoteTransition { MasternodeVoteTransition::V0(transition) => transition.security_level_requirement(), } } + + fn purpose_requirement(&self) -> Purpose { + match self { + MasternodeVoteTransition::V0(transition) => transition.purpose_requirement(), + } + } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/mod.rs index a2e8c936f1..ab84344af4 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/mod.rs @@ -1,7 +1,47 @@ mod v0; +use crate::identity::signer::Signer; +use crate::identity::IdentityPublicKey; +use crate::prelude::IdentityNonce; +use crate::ProtocolError; +use platform_value::Identifier; +use platform_version::version::{FeatureVersion, PlatformVersion}; pub use v0::*; +use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; use crate::state_transition::masternode_vote_transition::MasternodeVoteTransition; +use crate::state_transition::StateTransition; +use crate::voting::votes::Vote; -impl MasternodeVoteTransitionMethodsV0 for MasternodeVoteTransition {} +impl MasternodeVoteTransitionMethodsV0 for MasternodeVoteTransition { + fn try_from_vote_with_signer( + vote: Vote, + signer: &S, + pro_tx_hash: Identifier, + masternode_voting_key: &IdentityPublicKey, + nonce: IdentityNonce, + platform_version: &PlatformVersion, + feature_version: Option, + ) -> Result { + match feature_version.unwrap_or( + platform_version + .dpp + .state_transition_serialization_versions + .masternode_vote_state_transition + .default_current_version, + ) { + 0 => Ok(MasternodeVoteTransitionV0::try_from_vote_with_signer( + vote, + signer, + pro_tx_hash, + masternode_voting_key, + nonce, + )?), + version => Err(ProtocolError::UnknownVersionMismatch { + method: "MasternodeVoteTransition::try_from_vote_with_signer".to_string(), + known_versions: vec![0], + received: version, + }), + } + } +} diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/v0/mod.rs index ae9aac7ea9..f4053bb30e 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/v0/mod.rs @@ -1,6 +1,24 @@ -use crate::state_transition::StateTransitionType; +use crate::identity::signer::Signer; +use crate::identity::IdentityPublicKey; +use crate::prelude::IdentityNonce; +use crate::state_transition::{StateTransition, StateTransitionType}; +use crate::voting::votes::Vote; +use crate::ProtocolError; +use platform_value::Identifier; +use platform_version::version::{FeatureVersion, PlatformVersion}; pub trait MasternodeVoteTransitionMethodsV0 { + #[cfg(feature = "state-transition-signing")] + fn try_from_vote_with_signer( + vote: Vote, + signer: &S, + pro_tx_hash: Identifier, + masternode_voting_key: &IdentityPublicKey, + nonce: IdentityNonce, + platform_version: &PlatformVersion, + feature_version: Option, + ) -> Result; + /// Get State Transition Type fn get_type() -> StateTransitionType { StateTransitionType::MasternodeVote diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/v0_methods.rs index 1ac5dbebc0..8b7a02a9e1 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/v0_methods.rs @@ -1,4 +1,35 @@ -use crate::state_transition::masternode_vote_transition::methods::MasternodeVoteTransitionMethodsV0; +use crate::identity::signer::Signer; +use crate::identity::{IdentityPublicKey, SecurityLevel}; +use crate::prelude::IdentityNonce; use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; +use crate::state_transition::masternode_vote_transition::MasternodeVoteTransition; +use crate::state_transition::StateTransition; +use crate::voting::votes::Vote; +use crate::ProtocolError; +use platform_value::Identifier; -impl MasternodeVoteTransitionMethodsV0 for MasternodeVoteTransitionV0 {} +impl MasternodeVoteTransitionV0 { + pub fn try_from_vote_with_signer( + vote: Vote, + signer: &S, + pro_tx_hash: Identifier, + masternode_voting_key: &IdentityPublicKey, + nonce: IdentityNonce, + ) -> Result { + let masternode_vote_transition: MasternodeVoteTransition = MasternodeVoteTransitionV0 { + pro_tx_hash, + vote, + nonce, + signature_public_key_id: 0, + signature: Default::default(), + } + .into(); + let mut state_transition: StateTransition = masternode_vote_transition.into(); + state_transition.sign_external( + masternode_voting_key, + signer, + None:: Result>, + )?; + Ok(state_transition) + } +} diff --git a/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs b/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs index 6889d9ce79..b1380d66d2 100644 --- a/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs +++ b/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs @@ -21,5 +21,6 @@ pub enum ResourceVoteChoice { TowardsIdentity(Identifier), #[default] Abstain, + Defer, Lock, } diff --git a/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/validate_fees_of_event/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/validate_fees_of_event/v0/mod.rs index 86b6dd890b..27e56dd02f 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/validate_fees_of_event/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/validate_fees_of_event/v0/mod.rs @@ -51,7 +51,7 @@ where user_fee_increase, } => { let previous_balance = identity.balance.ok_or(Error::Execution( - ExecutionError::CorruptedCodeExecution("partial identity info with no balance"), + ExecutionError::CorruptedCodeExecution("partial identity info with no balance in paid from asset lock execution event"), ))?; let previous_balance_with_top_up = previous_balance + added_balance; let mut estimated_fee_result = self @@ -101,7 +101,9 @@ where user_fee_increase, } => { let balance = identity.balance.ok_or(Error::Execution( - ExecutionError::CorruptedCodeExecution("partial identity info with no balance"), + ExecutionError::CorruptedCodeExecution( + "partial identity info with no balance in paid execution event", + ), ))?; let balance_after_principal_operation = balance.saturating_sub(removed_balance.unwrap_or_default()); diff --git a/packages/rs-drive-abci/src/execution/types/execution_event/mod.rs b/packages/rs-drive-abci/src/execution/types/execution_event/mod.rs index 131bc401d2..133aafb3a5 100644 --- a/packages/rs-drive-abci/src/execution/types/execution_event/mod.rs +++ b/packages/rs-drive-abci/src/execution/types/execution_event/mod.rs @@ -174,6 +174,11 @@ impl<'a> ExecutionEvent<'a> { ))) } } + StateTransitionAction::MasternodeVoteAction(_) => { + let operations = + action.into_high_level_drive_operations(epoch, platform_version)?; + Ok(ExecutionEvent::Free { operations }) + } _ => { let user_fee_increase = action.user_fee_increase(); let operations = diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_state_transition_identity_signed/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_state_transition_identity_signed/v0/mod.rs index 09da255515..4e316a7af0 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_state_transition_identity_signed/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/common/validate_state_transition_identity_signed/v0/mod.rs @@ -241,9 +241,9 @@ pub fn convert_to_consensus_signature_error( ), ProtocolError::WrongPublicKeyPurposeError(err) => Ok(err.into()), ProtocolError::Error(_) => Err(error), - _ => Ok(ConsensusError::SignatureError( + e => Ok(ConsensusError::SignatureError( SignatureError::InvalidStateTransitionSignatureError( - InvalidStateTransitionSignatureError::new(), + InvalidStateTransitionSignatureError::new(e.to_string()), ), )), } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs index 33d322160b..e3556e5b3c 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs @@ -235,9 +235,9 @@ impl StateTransitionStateValidationV0 for DocumentsBatchTransition { #[cfg(test)] mod tests { + use crate::execution::validation::state_transition::state_transitions::tests::setup_identity; use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult; - use crate::rpc::core::MockCoreRPCLike; - use crate::test::helpers::setup::{TempPlatform, TestPlatformBuilder}; + use crate::test::helpers::setup::TestPlatformBuilder; use dpp::block::block_info::BlockInfo; use dpp::dash_to_credits; use dpp::data_contract::accessors::v0::DataContractV0Getters; @@ -251,11 +251,9 @@ mod tests { use dpp::fee::fee_result::BalanceChange; use dpp::fee::Credits; use dpp::identity::accessors::IdentityGettersV0; - use dpp::identity::{Identity, IdentityPublicKey, IdentityV0}; use dpp::nft::TradeMode; use dpp::platform_value::btreemap_extensions::BTreeValueMapHelper; use dpp::platform_value::{Bytes32, Value}; - use dpp::prelude::Identifier; use dpp::serialization::PlatformSerializable; use dpp::state_transition::documents_batch_transition::methods::v0::DocumentsBatchTransitionMethodsV0; use dpp::state_transition::documents_batch_transition::DocumentsBatchTransition; @@ -266,66 +264,6 @@ mod tests { use platform_version::version::PlatformVersion; use rand::prelude::StdRng; use rand::SeedableRng; - use simple_signer::signer::SimpleSigner; - use std::collections::BTreeMap; - - fn setup_identity( - platform: &mut TempPlatform, - seed: u64, - credits: Credits, - ) -> (Identity, SimpleSigner, IdentityPublicKey) { - let platform_version = PlatformVersion::latest(); - let mut signer = SimpleSigner::default(); - - let mut rng = StdRng::seed_from_u64(seed); - - let (master_key, master_private_key) = - IdentityPublicKey::random_ecdsa_master_authentication_key_with_rng( - 0, - &mut rng, - platform_version, - ) - .expect("expected to get key pair"); - - signer.add_key(master_key.clone(), master_private_key.clone()); - - let (critical_public_key, private_key) = - IdentityPublicKey::random_ecdsa_critical_level_authentication_key_with_rng( - 1, - &mut rng, - platform_version, - ) - .expect("expected to get key pair"); - - signer.add_key(critical_public_key.clone(), private_key.clone()); - - let identity: Identity = IdentityV0 { - id: Identifier::random_with_rng(&mut rng), - public_keys: BTreeMap::from([ - (0, master_key.clone()), - (1, critical_public_key.clone()), - ]), - balance: credits, - revision: 0, - } - .into(); - - // We just add this identity to the system first - - platform - .drive - .add_new_identity( - identity.clone(), - false, - &BlockInfo::default(), - true, - None, - platform_version, - ) - .expect("expected to add a new identity"); - - (identity, signer, critical_public_key) - } mod creation_tests { use rand::Rng; @@ -343,7 +281,6 @@ mod tests { use drive::drive::votes::resolve_contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; use drive::query::vote_poll_vote_state_query::ResolvedContestedDocumentVotePollDriveQuery; - use crate::platform_types::platform_state::v0::PlatformStateV0Methods; #[test] fn test_document_creation() { diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index ee1a9d77b7..8b38ffc86f 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -80,3 +80,621 @@ impl StateTransitionStateValidationV0 for MasternodeVoteTransition { } } } + +#[cfg(test)] +mod tests { + use crate::execution::validation::state_transition::state_transitions::tests::setup_identity; + use crate::test::helpers::setup::TestPlatformBuilder; + use dpp::block::block_info::BlockInfo; + use dpp::dash_to_credits; + use dpp::data_contract::accessors::v0::DataContractV0Getters; + use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; + use dpp::data_contract::document_type::random_document::{ + CreateRandomDocument, DocumentFieldFillSize, DocumentFieldFillType, + }; + use dpp::document::{DocumentV0Getters, DocumentV0Setters}; + use dpp::identity::accessors::IdentityGettersV0; + use dpp::platform_value::{Bytes32, Value}; + use dpp::serialization::PlatformSerializable; + use dpp::state_transition::documents_batch_transition::methods::v0::DocumentsBatchTransitionMethodsV0; + use dpp::state_transition::documents_batch_transition::DocumentsBatchTransition; + use platform_version::version::PlatformVersion; + use rand::prelude::StdRng; + use rand::SeedableRng; + + mod vote_tests { + use std::collections::BTreeMap; + use std::sync::Arc; + use arc_swap::Guard; + use rand::Rng; + use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse}; + use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0::ResultType; + use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::GetContestedResourceVoteStateRequestV0; + use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; + use super::*; + use dpp::document::Document; + use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; + use dpp::fee::Credits; + use dpp::identifier::Identifier; + use dpp::identity::{IdentityPublicKey, IdentityV0}; + use dpp::prelude::{DataContract, Identity}; + use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; + use dpp::state_transition::masternode_vote_transition::methods::MasternodeVoteTransitionMethodsV0; + use dpp::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; + use dpp::util::hash::hash_double; + use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice::TowardsIdentity; + use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; + use dpp::voting::vote_polls::VotePoll; + use dpp::voting::votes::resource_vote::ResourceVote; + use dpp::voting::votes::resource_vote::v0::ResourceVoteV0; + use dpp::voting::votes::Vote; + use drive::drive::object_size_info::DataContractResolvedInfo; + use drive::drive::votes::resolve_contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; + use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; + use drive::query::vote_poll_vote_state_query::ResolvedContestedDocumentVotePollDriveQuery; + use simple_signer::signer::SimpleSigner; + use crate::platform_types::platform_state::PlatformState; + use crate::rpc::core::MockCoreRPCLike; + use crate::test::helpers::setup::TempPlatform; + + fn setup_masternode_identity( + platform: &mut TempPlatform, + seed: u64, + platform_version: &PlatformVersion, + ) -> (Identity, SimpleSigner, IdentityPublicKey) { + let mut signer = SimpleSigner::default(); + + let mut rng = StdRng::seed_from_u64(seed); + + let (voting_key, voting_private_key) = + IdentityPublicKey::random_voting_key_with_rng(0, &mut rng, platform_version) + .expect("expected to get key pair"); + + signer.add_key(voting_key.clone(), voting_private_key.clone()); + + let identity: Identity = IdentityV0 { + id: Identifier::random_with_rng(&mut rng), + public_keys: BTreeMap::from([(0, voting_key.clone())]), + balance: 0, + revision: 0, + } + .into(); + + // We just add this identity to the system first + + platform + .drive + .add_new_identity( + identity.clone(), + true, + &BlockInfo::default(), + true, + None, + platform_version, + ) + .expect("expected to add a new identity"); + + (identity, signer, voting_key) + } + + fn create_dpns_name_contest( + platform: &mut TempPlatform, + platform_state: &Guard>, + seed: u64, + platform_version: &PlatformVersion, + ) -> (Identity, Identity, Arc) { + let mut rng = StdRng::seed_from_u64(seed); + + let (identity_1, signer_1, key_1) = + setup_identity(platform, rng.gen(), dash_to_credits!(0.5)); + + let (identity_2, signer_2, key_2) = + setup_identity(platform, rng.gen(), dash_to_credits!(0.5)); + + // Flip them if needed so identity 1 id is always smaller than identity 2 id + let (identity_1, identity_2, signer_1, signer_2, key_1, key_2) = + if identity_1.id() < identity_2.id() { + (identity_1, identity_2, signer_1, signer_2, key_1, key_2) + } else { + (identity_2, identity_1, signer_2, signer_1, key_2, key_1) + }; + + let dpns = platform.drive.cache.system_data_contracts.load_dpns(); + let dpns_contract = dpns.clone(); + + let preorder = dpns_contract + .document_type_for_name("preorder") + .expect("expected a profile document type"); + + assert!(!preorder.documents_mutable()); + assert!(preorder.documents_can_be_deleted()); + assert!(!preorder.documents_transferable().is_transferable()); + + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); + + assert!(!domain.documents_mutable()); + assert!(!domain.documents_can_be_deleted()); + assert!(!domain.documents_transferable().is_transferable()); + + let entropy = Bytes32::random_with_rng(&mut rng); + + let mut preorder_document_1 = preorder + .random_document_with_identifier_and_entropy( + &mut rng, + identity_1.id(), + entropy, + DocumentFieldFillType::FillIfNotRequired, + DocumentFieldFillSize::AnyDocumentFillSize, + platform_version, + ) + .expect("expected a random document"); + + let mut preorder_document_2 = preorder + .random_document_with_identifier_and_entropy( + &mut rng, + identity_2.id(), + entropy, + DocumentFieldFillType::FillIfNotRequired, + DocumentFieldFillSize::AnyDocumentFillSize, + platform_version, + ) + .expect("expected a random document"); + + let mut document_1 = domain + .random_document_with_identifier_and_entropy( + &mut rng, + identity_1.id(), + entropy, + DocumentFieldFillType::FillIfNotRequired, + DocumentFieldFillSize::AnyDocumentFillSize, + platform_version, + ) + .expect("expected a random document"); + + let mut document_2 = domain + .random_document_with_identifier_and_entropy( + &mut rng, + identity_2.id(), + entropy, + DocumentFieldFillType::FillIfNotRequired, + DocumentFieldFillSize::AnyDocumentFillSize, + platform_version, + ) + .expect("expected a random document"); + + document_1.set("parentDomainName", "dash".into()); + document_1.set("normalizedParentDomainName", "dash".into()); + document_1.set("label", "quantum".into()); + document_1.set("normalizedLabel", "quantum".into()); + document_1.set("records.dashUniqueIdentityId", document_1.owner_id().into()); + document_1.set("subdomainRules.allowSubdomains", false.into()); + + document_2.set("parentDomainName", "dash".into()); + document_2.set("normalizedParentDomainName", "dash".into()); + document_2.set("label", "quantum".into()); + document_2.set("normalizedLabel", "quantum".into()); + document_2.set("records.dashUniqueIdentityId", document_2.owner_id().into()); + document_2.set("subdomainRules.allowSubdomains", false.into()); + + let salt_1: [u8; 32] = rng.gen(); + let salt_2: [u8; 32] = rng.gen(); + + let mut salted_domain_buffer_1: Vec = vec![]; + salted_domain_buffer_1.extend(salt_1); + salted_domain_buffer_1.extend("quantum.dash".as_bytes()); + + let salted_domain_hash_1 = hash_double(salted_domain_buffer_1); + + let mut salted_domain_buffer_2: Vec = vec![]; + salted_domain_buffer_2.extend(salt_2); + salted_domain_buffer_2.extend("quantum.dash".as_bytes()); + + let salted_domain_hash_2 = hash_double(salted_domain_buffer_2); + + preorder_document_1.set("saltedDomainHash", salted_domain_hash_1.into()); + preorder_document_2.set("saltedDomainHash", salted_domain_hash_2.into()); + + document_1.set("preorderSalt", salt_1.into()); + document_2.set("preorderSalt", salt_2.into()); + + let documents_batch_create_preorder_transition_1 = + DocumentsBatchTransition::new_document_creation_transition_from_document( + preorder_document_1, + preorder, + entropy.0, + &key_1, + 2, + 0, + &signer_1, + platform_version, + None, + None, + None, + ) + .expect("expect to create documents batch transition"); + + let documents_batch_create_serialized_preorder_transition_1 = + documents_batch_create_preorder_transition_1 + .serialize_to_bytes() + .expect("expected documents batch serialized state transition"); + + let documents_batch_create_preorder_transition_2 = + DocumentsBatchTransition::new_document_creation_transition_from_document( + preorder_document_2, + preorder, + entropy.0, + &key_2, + 2, + 0, + &signer_2, + platform_version, + None, + None, + None, + ) + .expect("expect to create documents batch transition"); + + let documents_batch_create_serialized_preorder_transition_2 = + documents_batch_create_preorder_transition_2 + .serialize_to_bytes() + .expect("expected documents batch serialized state transition"); + + let documents_batch_create_transition_1 = + DocumentsBatchTransition::new_document_creation_transition_from_document( + document_1, + domain, + entropy.0, + &key_1, + 3, + 0, + &signer_1, + platform_version, + None, + None, + None, + ) + .expect("expect to create documents batch transition"); + + let documents_batch_create_serialized_transition_1 = + documents_batch_create_transition_1 + .serialize_to_bytes() + .expect("expected documents batch serialized state transition"); + + let documents_batch_create_transition_2 = + DocumentsBatchTransition::new_document_creation_transition_from_document( + document_2, + domain, + entropy.0, + &key_2, + 3, + 0, + &signer_2, + platform_version, + None, + None, + None, + ) + .expect("expect to create documents batch transition"); + + let documents_batch_create_serialized_transition_2 = + documents_batch_create_transition_2 + .serialize_to_bytes() + .expect("expected documents batch serialized state transition"); + + let transaction = platform.drive.grove.start_transaction(); + + 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(), + ], + platform_state, + &BlockInfo::default(), + &transaction, + platform_version, + ) + .expect("expected to process state transition"); + + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit transaction"); + + assert_eq!(processing_result.valid_count(), 2); + + let transaction = platform.drive.grove.start_transaction(); + + let processing_result = platform + .platform + .process_raw_state_transitions( + &vec![ + documents_batch_create_serialized_transition_1.clone(), + documents_batch_create_serialized_transition_2.clone(), + ], + platform_state, + &BlockInfo::default(), + &transaction, + platform_version, + ) + .expect("expected to process state transition"); + + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit transaction"); + + assert_eq!(processing_result.valid_count(), 2); + + // Now let's run a query for the vote totals + + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + + let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) + .expect("expected to encode the word dash"); + + let quantum_encoded = + bincode::encode_to_vec(Value::Text("quantum".to_string()), config) + .expect("expected to encode the word quantum"); + + let index_name = "parentNameAndLabel".to_string(); + + let query_validation_result = platform + .query_contested_resource_vote_state( + GetContestedResourceVoteStateRequest { + version: Some(get_contested_resource_vote_state_request::Version::V0( + GetContestedResourceVoteStateRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![dash_encoded.clone(), quantum_encoded.clone()], + result_type: ResultType::DocumentsAndVoteTally as i32, + start_at_identifier_info: None, + count: None, + order_ascending: true, + prove: false, + }, + )), + }, + platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_vote_state_response::Version::V0( + GetContestedResourceVoteStateResponseV0 { + metadata: _, + result, + }, + ) = query_validation_result.version.expect("expected a version"); + + let Some( + get_contested_resource_vote_state_response_v0::Result::ContestedResourceContenders( + get_contested_resource_vote_state_response_v0::ContestedResourceContenders { + contenders, + }, + ), + ) = result + else { + panic!("expected contenders") + }; + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + let first_contender_document = Document::from_bytes( + first_contender + .document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); + + let second_contender_document = Document::from_bytes( + second_contender + .document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); + + assert_ne!(first_contender_document, second_contender_document); + + assert_eq!(first_contender.identifier, identity_1.id().to_vec()); + + assert_eq!(second_contender.identifier, identity_2.id().to_vec()); + + assert_eq!(first_contender.vote_count, Some(0)); + + assert_eq!(second_contender.vote_count, Some(0)); + + let GetContestedResourceVoteStateResponse { version } = platform + .query_contested_resource_vote_state( + GetContestedResourceVoteStateRequest { + version: Some(get_contested_resource_vote_state_request::Version::V0( + GetContestedResourceVoteStateRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![dash_encoded, quantum_encoded], + result_type: ResultType::DocumentsAndVoteTally as i32, + start_at_identifier_info: None, + count: None, + order_ascending: true, + prove: true, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_vote_state_response::Version::V0( + GetContestedResourceVoteStateResponseV0 { + metadata: _, + result, + }, + ) = version.expect("expected a version"); + + let Some(get_contested_resource_vote_state_response_v0::Result::Proof(proof)) = result + else { + panic!("expected contenders") + }; + + let resolved_contested_document_vote_poll_drive_query = + ResolvedContestedDocumentVotePollDriveQuery { + vote_poll: ContestedDocumentResourceVotePollWithContractInfo { + contract: DataContractResolvedInfo::BorrowedDataContract(&dpns_contract), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![ + Value::Text("dash".to_string()), + Value::Text("quantum".to_string()), + ], + }, + result_type: DocumentsAndVoteTally, + offset: None, + limit: None, + start_at: None, + order_ascending: true, + }; + + let (root_hash, contenders) = resolved_contested_document_vote_poll_drive_query + .verify_vote_poll_vote_state_proof(proof.grovedb_proof.as_ref(), platform_version) + .expect("expected to verify proof"); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + let first_contender_document = Document::from_bytes( + first_contender + .serialized_document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); + + let second_contender_document = Document::from_bytes( + second_contender + .serialized_document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); + + assert_ne!(first_contender_document, second_contender_document); + + assert_eq!(first_contender.identity_id, identity_1.id()); + + assert_eq!(second_contender.identity_id, identity_2.id()); + + assert_eq!(first_contender.vote_tally, Some(0)); + + assert_eq!(second_contender.vote_tally, Some(0)); + + (identity_1, identity_2, dpns_contract) + } + + #[test] + fn test_masternode_voting() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = + create_dpns_name_contest(&mut platform, &platform_state, 7, platform_version); + + let (masternode_1, signer_1, voting_key_1) = + setup_masternode_identity(&mut platform, 29, platform_version); + + // Let's vote for contender 1 + + let vote = Vote::ResourceVote(ResourceVote::V0(ResourceVoteV0 { + vote_poll: VotePoll::ContestedDocumentResourceVotePoll( + ContestedDocumentResourceVotePoll { + contract_id: dpns_contract.id(), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![ + Value::Text("dash".to_string()), + Value::Text("quantum".to_string()), + ], + }, + ), + resource_vote_choice: TowardsIdentity(contender_1.id()), + })); + + let masternode_vote_transition = MasternodeVoteTransition::try_from_vote_with_signer( + vote, + &signer_1, + masternode_1.id(), + &voting_key_1, + 1, + platform_version, + None, + ) + .expect("expected to make transition vote"); + + let masternode_vote_serialized_transition = masternode_vote_transition + .serialize_to_bytes() + .expect("expected documents batch serialized state transition"); + + let transaction = platform.drive.grove.start_transaction(); + + let processing_result = platform + .platform + .process_raw_state_transitions( + &vec![masternode_vote_serialized_transition.clone()], + &platform_state, + &BlockInfo::default(), + &transaction, + platform_version, + ) + .expect("expected to process state transition"); + + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit transaction"); + + assert_eq!(processing_result.valid_count(), 2); + } + } +} 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 4f6b16223d..168b2181ad 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 @@ -49,3 +49,76 @@ impl ValidationMode { } } } + +#[cfg(test)] +mod tests { + use crate::rpc::core::MockCoreRPCLike; + use crate::test::helpers::setup::TempPlatform; + use dpp::block::block_info::BlockInfo; + use dpp::fee::Credits; + use dpp::identity::{Identity, IdentityPublicKey, IdentityV0}; + use dpp::prelude::Identifier; + use platform_version::version::PlatformVersion; + use rand::prelude::StdRng; + use rand::SeedableRng; + use simple_signer::signer::SimpleSigner; + use std::collections::BTreeMap; + + pub(in crate::execution::validation::state_transition::state_transitions) fn setup_identity( + platform: &mut TempPlatform, + seed: u64, + credits: Credits, + ) -> (Identity, SimpleSigner, IdentityPublicKey) { + let platform_version = PlatformVersion::latest(); + let mut signer = SimpleSigner::default(); + + let mut rng = StdRng::seed_from_u64(seed); + + let (master_key, master_private_key) = + IdentityPublicKey::random_ecdsa_master_authentication_key_with_rng( + 0, + &mut rng, + platform_version, + ) + .expect("expected to get key pair"); + + signer.add_key(master_key.clone(), master_private_key.clone()); + + let (critical_public_key, private_key) = + IdentityPublicKey::random_ecdsa_critical_level_authentication_key_with_rng( + 1, + &mut rng, + platform_version, + ) + .expect("expected to get key pair"); + + signer.add_key(critical_public_key.clone(), private_key.clone()); + + let identity: Identity = IdentityV0 { + id: Identifier::random_with_rng(&mut rng), + public_keys: BTreeMap::from([ + (0, master_key.clone()), + (1, critical_public_key.clone()), + ]), + balance: credits, + revision: 0, + } + .into(); + + // We just add this identity to the system first + + platform + .drive + .add_new_identity( + identity.clone(), + false, + &BlockInfo::default(), + true, + None, + platform_version, + ) + .expect("expected to add a new identity"); + + (identity, signer, critical_public_key) + } +} diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/v0/mod.rs index 2feb5fd286..0ac22b87ff 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/add_prefunded_specialized_balance_operations/v0/mod.rs @@ -9,12 +9,12 @@ use crate::drive::prefunded_specialized_balances::{ prefunded_specialized_balances_for_voting_path, prefunded_specialized_balances_for_voting_path_vec, }; +use crate::error::identity::IdentityError; +use dpp::balances::credits::MAX_CREDITS; use dpp::identifier::Identifier; use dpp::version::PlatformVersion; use grovedb::batch::{GroveDbOp, KeyInfoPath}; -use grovedb::Element::Item; -use grovedb::{EstimatedLayerInformation, TransactionArg}; -use integer_encoding::VarInt; +use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; impl Drive { @@ -54,18 +54,24 @@ impl Drive { .ok_or(Error::Drive(DriveError::CriticalCorruptedState( "trying to add an amount that would overflow credits", )))?; + // while i64::MAX could potentially work, best to avoid it. + if new_total >= MAX_CREDITS { + return Err(Error::Identity(IdentityError::CriticalBalanceOverflow( + "trying to set prefunded specialized balance to over max credits amount (i64::MAX)", + ))); + }; let path_holding_total_credits_vec = prefunded_specialized_balances_for_voting_path_vec(); let op = if had_previous_balance { GroveDbOp::replace_op( path_holding_total_credits_vec, specialized_balance_id.to_vec(), - Item(new_total.encode_var_vec(), None), + Element::new_sum_item(new_total as i64), ) } else { GroveDbOp::insert_op( path_holding_total_credits_vec, specialized_balance_id.to_vec(), - Item(new_total.encode_var_vec(), None), + Element::new_sum_item(new_total as i64), ) }; drive_operations.push(GroveOperation(op)); diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 5c274e918f..c4459948e2 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -713,7 +713,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { basic_structure: Some(0), advanced_structure: None, identity_signatures: None, - advanced_minimum_balance_pre_check: None, + advanced_minimum_balance_pre_check: Some(0), nonce: Some(0), state: 0, transform_into_action: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 78b3561b8e..e9189d67bc 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -713,7 +713,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { basic_structure: Some(0), advanced_structure: None, identity_signatures: None, - advanced_minimum_balance_pre_check: None, + advanced_minimum_balance_pre_check: Some(0), nonce: Some(0), state: 0, transform_into_action: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 4e713de1eb..19411d7ce5 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -712,7 +712,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { basic_structure: Some(0), advanced_structure: None, identity_signatures: None, - advanced_minimum_balance_pre_check: None, + advanced_minimum_balance_pre_check: Some(0), nonce: Some(0), state: 0, transform_into_action: 0, From 18094a5a899f5b28fc29726d0b67c0780eb27d28 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 21 May 2024 10:46:09 +0200 Subject: [PATCH 070/135] voting is working --- .../vote_choices/resource_vote_choice/mod.rs | 11 + .../state_transitions/documents_batch/mod.rs | 4 +- .../state_transitions/masternode_vote/mod.rs | 210 +++++++++++- .../masternode_vote/state/v0/mod.rs | 18 +- .../tests/strategy_tests/voting_tests.rs | 1 + .../drive/batch/drive_op_batch/identity.rs | 4 +- .../mod.rs | 1 - .../v0/mod.rs | 3 - .../drive/object_size_info/contract_info.rs | 47 +++ .../mod.rs | 10 +- .../v0/mod.rs | 60 ++-- .../insert/register_identity_vote/mod.rs | 6 +- .../insert/register_identity_vote/v0/mod.rs | 18 +- packages/rs-drive/src/drive/votes/mod.rs | 2 +- packages/rs-drive/src/drive/votes/paths.rs | 102 +++++- .../mod.rs | 147 --------- .../rs-drive/src/drive/votes/resolved/mod.rs | 5 + .../mod.rs | 300 ++++++++++++++++++ .../resolve.rs | 152 +++++++++ .../drive/votes/resolved/vote_polls/mod.rs | 58 ++++ .../votes/resolved/vote_polls/resolve.rs | 59 ++++ .../src/drive/votes/resolved/votes/mod.rs | 34 ++ .../src/drive/votes/resolved/votes/resolve.rs | 59 ++++ .../resolved_resource_vote/accessors/mod.rs | 27 ++ .../accessors/v0/mod.rs | 14 + .../votes/resolved_resource_vote/mod.rs | 17 + .../votes/resolved_resource_vote/resolve.rs | 60 ++++ .../votes/resolved_resource_vote/v0/mod.rs | 13 + .../resolved_resource_vote/v0/resolve.rs | 72 +++++ .../query/vote_poll_contestant_votes_query.rs | 15 +- .../src/query/vote_poll_vote_state_query.rs | 9 +- .../identity/masternode_vote/mod.rs | 6 +- .../identity/masternode_vote/transformer.rs | 42 ++- .../identity/masternode_vote/v0/mod.rs | 6 +- .../masternode_vote/v0/transformer.rs | 27 +- 35 files changed, 1370 insertions(+), 249 deletions(-) delete mode 100644 packages/rs-drive/src/drive/votes/resolve_contested_document_resource_vote_poll/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/resolved/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs create mode 100644 packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/resolved/vote_polls/resolve.rs create mode 100644 packages/rs-drive/src/drive/votes/resolved/votes/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/resolved/votes/resolve.rs create mode 100644 packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/accessors/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/accessors/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/resolve.rs create mode 100644 packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/resolve.rs diff --git a/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs b/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs index b1380d66d2..2ff2bce069 100644 --- a/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs +++ b/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs @@ -24,3 +24,14 @@ pub enum ResourceVoteChoice { Defer, Lock, } + +impl ResourceVoteChoice { + pub fn to_key(&self) -> Vec { + match self { + ResourceVoteChoice::TowardsIdentity(identity_id) => identity_id.to_vec(), + ResourceVoteChoice::Abstain => vec![128], + ResourceVoteChoice::Defer => vec![129], + ResourceVoteChoice::Lock => vec![130], + } + } +} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs index e3556e5b3c..4b16058787 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs @@ -278,7 +278,7 @@ mod tests { use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use dpp::util::hash::hash_double; use drive::drive::object_size_info::DataContractResolvedInfo; - use drive::drive::votes::resolve_contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; + use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::{ContestedDocumentResourceVotePollWithContractInfo, ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed}; use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; use drive::query::vote_poll_vote_state_query::ResolvedContestedDocumentVotePollDriveQuery; @@ -752,7 +752,7 @@ mod tests { let resolved_contested_document_vote_poll_drive_query = ResolvedContestedDocumentVotePollDriveQuery { - vote_poll: ContestedDocumentResourceVotePollWithContractInfo { + vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { contract: DataContractResolvedInfo::BorrowedDataContract(&dpns_contract), document_type_name: domain.name().clone(), index_name: index_name.clone(), diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 8b38ffc86f..4fb8b7b89a 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -31,7 +31,7 @@ impl StateTransitionActionTransformerV0 for MasternodeVoteTransition { _block_info: &BlockInfo, _validation_mode: ValidationMode, _execution_context: &mut StateTransitionExecutionContext, - _tx: TransactionArg, + tx: TransactionArg, ) -> Result, Error> { let platform_version = PlatformVersion::get(platform.state.current_protocol_version_in_consensus())?; @@ -42,7 +42,7 @@ impl StateTransitionActionTransformerV0 for MasternodeVoteTransition { .masternode_vote_state_transition .transform_into_action { - 0 => self.transform_into_action_v0(), + 0 => self.transform_into_action_v0(platform, tx, platform_version), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { method: "masternode votes state transition: transform_into_action".to_string(), known_versions: vec![0], @@ -120,7 +120,6 @@ mod tests { use dpp::prelude::{DataContract, Identity}; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; use dpp::state_transition::masternode_vote_transition::methods::MasternodeVoteTransitionMethodsV0; - use dpp::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; use dpp::util::hash::hash_double; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice::TowardsIdentity; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; @@ -129,7 +128,7 @@ mod tests { use dpp::voting::votes::resource_vote::v0::ResourceVoteV0; use dpp::voting::votes::Vote; use drive::drive::object_size_info::DataContractResolvedInfo; - use drive::drive::votes::resolve_contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; + use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::{ContestedDocumentResourceVotePollWithContractInfo, ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed}; use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; use drive::query::vote_poll_vote_state_query::ResolvedContestedDocumentVotePollDriveQuery; use simple_signer::signer::SimpleSigner; @@ -545,7 +544,7 @@ mod tests { }, )), }, - &platform_state, + platform_state, platform_version, ) .expect("expected to execute query") @@ -566,7 +565,7 @@ mod tests { let resolved_contested_document_vote_poll_drive_query = ResolvedContestedDocumentVotePollDriveQuery { - vote_poll: ContestedDocumentResourceVotePollWithContractInfo { + vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { contract: DataContractResolvedInfo::BorrowedDataContract(&dpns_contract), document_type_name: domain.name().clone(), index_name: index_name.clone(), @@ -582,7 +581,7 @@ mod tests { order_ascending: true, }; - let (root_hash, contenders) = resolved_contested_document_vote_poll_drive_query + let (_, contenders) = resolved_contested_document_vote_poll_drive_query .verify_vote_poll_vote_state_proof(proof.grovedb_proof.as_ref(), platform_version) .expect("expected to verify proof"); @@ -694,7 +693,202 @@ mod tests { .unwrap() .expect("expected to commit transaction"); - assert_eq!(processing_result.valid_count(), 2); + assert_eq!(processing_result.valid_count(), 1); + + // Now let's run a query for the vote totals + + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); + + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + + let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) + .expect("expected to encode the word dash"); + + let quantum_encoded = + bincode::encode_to_vec(Value::Text("quantum".to_string()), config) + .expect("expected to encode the word quantum"); + + let index_name = "parentNameAndLabel".to_string(); + + let query_validation_result = platform + .query_contested_resource_vote_state( + GetContestedResourceVoteStateRequest { + version: Some(get_contested_resource_vote_state_request::Version::V0( + GetContestedResourceVoteStateRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![dash_encoded.clone(), quantum_encoded.clone()], + result_type: ResultType::DocumentsAndVoteTally as i32, + start_at_identifier_info: None, + count: None, + order_ascending: true, + prove: false, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_vote_state_response::Version::V0( + GetContestedResourceVoteStateResponseV0 { + metadata: _, + result, + }, + ) = query_validation_result.version.expect("expected a version"); + + let Some( + get_contested_resource_vote_state_response_v0::Result::ContestedResourceContenders( + get_contested_resource_vote_state_response_v0::ContestedResourceContenders { + contenders, + }, + ), + ) = result + else { + panic!("expected contenders") + }; + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + let first_contender_document = Document::from_bytes( + first_contender + .document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); + + let second_contender_document = Document::from_bytes( + second_contender + .document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); + + assert_ne!(first_contender_document, second_contender_document); + + assert_eq!(first_contender.identifier, contender_1.id().to_vec()); + + assert_eq!(second_contender.identifier, contender_2.id().to_vec()); + + assert_eq!(first_contender.vote_count, Some(1)); + + assert_eq!(second_contender.vote_count, Some(0)); + + let GetContestedResourceVoteStateResponse { version } = platform + .query_contested_resource_vote_state( + GetContestedResourceVoteStateRequest { + version: Some(get_contested_resource_vote_state_request::Version::V0( + GetContestedResourceVoteStateRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![dash_encoded, quantum_encoded], + result_type: ResultType::DocumentsAndVoteTally as i32, + start_at_identifier_info: None, + count: None, + order_ascending: true, + prove: true, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_vote_state_response::Version::V0( + GetContestedResourceVoteStateResponseV0 { + metadata: _, + result, + }, + ) = version.expect("expected a version"); + + let Some(get_contested_resource_vote_state_response_v0::Result::Proof(proof)) = result + else { + panic!("expected contenders") + }; + + let resolved_contested_document_vote_poll_drive_query = + ResolvedContestedDocumentVotePollDriveQuery { + vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { + contract: DataContractResolvedInfo::BorrowedDataContract(&dpns_contract), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![ + Value::Text("dash".to_string()), + Value::Text("quantum".to_string()), + ], + }, + result_type: DocumentsAndVoteTally, + offset: None, + limit: None, + start_at: None, + order_ascending: true, + }; + + let (_, contenders) = resolved_contested_document_vote_poll_drive_query + .verify_vote_poll_vote_state_proof(proof.grovedb_proof.as_ref(), platform_version) + .expect("expected to verify proof"); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + let first_contender_document = Document::from_bytes( + first_contender + .serialized_document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); + + let second_contender_document = Document::from_bytes( + second_contender + .serialized_document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); + + assert_ne!(first_contender_document, second_contender_document); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(1)); + + assert_eq!(second_contender.vote_tally, Some(0)); } } } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs index 67c7218f18..48a87a1f84 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs @@ -12,33 +12,39 @@ use drive::state_transition_action::StateTransitionAction; pub(in crate::execution::validation::state_transition::state_transitions::masternode_vote) trait MasternodeVoteStateTransitionStateValidationV0 { - fn validate_state_v0( + fn validate_state_v0( &self, platform: &PlatformRef, tx: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error>; - fn transform_into_action_v0( + fn transform_into_action_v0( &self, + platform: &PlatformRef, + tx: TransactionArg, + platform_version: &PlatformVersion, ) -> Result, Error>; } impl MasternodeVoteStateTransitionStateValidationV0 for MasternodeVoteTransition { - fn validate_state_v0( + fn validate_state_v0( &self, platform: &PlatformRef, tx: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { - self.transform_into_action_v0() + self.transform_into_action_v0(platform, tx, platform_version) } - fn transform_into_action_v0( + fn transform_into_action_v0( &self, + platform: &PlatformRef, + tx: TransactionArg, + platform_version: &PlatformVersion, ) -> Result, Error> { Ok(ConsensusValidationResult::new_with_data( - MasternodeVoteTransitionAction::from(self).into(), + MasternodeVoteTransitionAction::transform_from_transition(self, platform.drive, tx, platform_version)?.into(), )) } } diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index 94dcc9c708..1d7081b373 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -27,6 +27,7 @@ mod tests { use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use drive::drive::object_size_info::DataContractResolvedInfo; use drive::drive::votes::resolve_contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; + use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; use drive::query::vote_poll_vote_state_query::ResolvedContestedDocumentVotePollDriveQuery; use drive_abci::platform_types::platform_state::v0::PlatformStateV0Methods; diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs index d89d7bcf01..d1b64f39c6 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs @@ -8,10 +8,10 @@ use dpp::prelude::{IdentityNonce, Revision}; use crate::drive::identity::update::methods::merge_identity_nonce::MergeIdentityContractNonceResultToResult; use dpp::version::PlatformVersion; -use dpp::voting::votes::Vote; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; +use crate::drive::votes::resolved::votes::ResolvedVote; /// Operations on Identities #[derive(Clone, Debug)] @@ -80,7 +80,7 @@ pub enum IdentityOperationType { /// The pro tx hash of the masternode doing the voting voter_pro_tx_hash: [u8; 32], /// Contested Vote type - vote: Vote, + vote: ResolvedVote, }, /// Updates an identities nonce for a specific contract. UpdateIdentityNonce { diff --git a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs index 47e3f4b5f9..0ffd932534 100644 --- a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs +++ b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs @@ -3,7 +3,6 @@ use crate::error::drive::DriveError; use crate::error::Error; use derive_more::From; use dpp::block::epoch::Epoch; -use dpp::document::Document; use dpp::version::{PlatformVersion, PlatformVersionCurrentVersion}; use grovedb::TransactionArg; diff --git a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs index b87f7c7c57..f8cb9cdea8 100644 --- a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs @@ -3,10 +3,7 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use crate::query::vote_poll_vote_state_query::{Contender, ContestedDocumentVotePollDriveQuery}; use dpp::block::epoch::Epoch; -use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; -use dpp::document::Document; use dpp::version::PlatformVersion; -use dpp::ProtocolError; use grovedb::TransactionArg; /// The outcome of a query diff --git a/packages/rs-drive/src/drive/object_size_info/contract_info.rs b/packages/rs-drive/src/drive/object_size_info/contract_info.rs index 547b1d55a6..f49e1ff27a 100644 --- a/packages/rs-drive/src/drive/object_size_info/contract_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/contract_info.rs @@ -76,6 +76,41 @@ impl<'a> DataContractInfo<'a> { } } +/// Contains resolved data contract information, typically used after initial +/// fetching or retrieval steps have been completed. This enum simplifies handling +/// of data contract states post-retrieval. +#[derive(Clone, Debug, PartialEq)] +pub enum DataContractOwnedResolvedInfo { + /// Information necessary for fetched data contracts, encapsulated in an + /// `Arc` to ensure thread-safe shared ownership and access. + DataContractFetchInfo(Arc), + + /// An owned instance of a data contract. This variant provides full control + /// and mutability over the data contract, suitable for scenarios requiring + /// modifications or extended operations on the data contract. + OwnedDataContract(DataContract), +} + + +impl DataContractOwnedResolvedInfo { + /// The id of the contract + pub fn id(&self) -> Identifier { + match self { + DataContractOwnedResolvedInfo::DataContractFetchInfo(fetch_info) => { fetch_info.contract.id() } + DataContractOwnedResolvedInfo::OwnedDataContract(data_contract) => { data_contract.id() } + } + } +} +impl AsRef for DataContractOwnedResolvedInfo { + /// The ref of the contract + fn as_ref(&self) -> &DataContract { + match self { + DataContractOwnedResolvedInfo::DataContractFetchInfo(fetch_info) => &fetch_info.contract, + DataContractOwnedResolvedInfo::OwnedDataContract(owned) => owned, + } + } +} + /// Contains resolved data contract information, typically used after initial /// fetching or retrieval steps have been completed. This enum simplifies handling /// of data contract states post-retrieval. @@ -94,7 +129,19 @@ pub enum DataContractResolvedInfo<'a> { /// modifications or extended operations on the data contract. OwnedDataContract(DataContract), } + +impl<'a> DataContractResolvedInfo<'a> { + /// The id of the contract + pub fn id(&self) -> Identifier { + match self { + DataContractResolvedInfo::DataContractFetchInfo(fetch_info) => { fetch_info.contract.id() } + DataContractResolvedInfo::BorrowedDataContract(data_contract) => { data_contract.id() } + DataContractResolvedInfo::OwnedDataContract(data_contract) => { data_contract.id() } + } + } +} impl<'a> AsRef for DataContractResolvedInfo<'a> { + /// The ref of the contract fn as_ref(&self) -> &DataContract { match self { DataContractResolvedInfo::DataContractFetchInfo(fetch_info) => &fetch_info.contract, diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs index c7ebe69030..0723070043 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs @@ -13,8 +13,8 @@ use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use grovedb::{EstimatedLayerInformation, TransactionArg}; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; impl Drive { /// Registers a vote for a contested resource based on the voter's identifier, @@ -46,7 +46,7 @@ impl Drive { pub fn register_contested_resource_identity_vote( &self, voter_pro_tx_hash: [u8; 32], - vote_poll: ContestedDocumentResourceVotePoll, + vote_poll: ContestedDocumentResourceVotePollWithContractInfo, vote_choice: ResourceVoteChoice, block_info: &BlockInfo, apply: bool, @@ -70,7 +70,7 @@ impl Drive { platform_version, ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "register_identity_vote".to_string(), + method: "register_contested_resource_identity_vote".to_string(), known_versions: vec![0], received: version, })), @@ -106,7 +106,7 @@ impl Drive { pub fn register_contested_resource_identity_vote_operations( &self, voter_pro_tx_hash: [u8; 32], - vote_poll: ContestedDocumentResourceVotePoll, + vote_poll: ContestedDocumentResourceVotePollWithContractInfo, vote_choice: ResourceVoteChoice, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< @@ -132,7 +132,7 @@ impl Drive { platform_version, ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "register_identity_vote".to_string(), + method: "register_contested_resource_identity_vote_operations".to_string(), known_versions: vec![0], received: version, })), diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index 617be2c23d..3d4d194f1d 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -4,44 +4,64 @@ use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use grovedb::batch::KeyInfoPath; -use grovedb::{EstimatedLayerInformation, TransactionArg}; +use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; use platform_version::version::PlatformVersion; use std::collections::HashMap; +use crate::drive::object_size_info::PathKeyElementInfo::PathKeyElement; +use crate::drive::votes::paths::VotePollPaths; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; impl Drive { pub(super) fn register_contested_resource_identity_vote_v0( &self, voter_pro_tx_hash: [u8; 32], - vote_poll: ContestedDocumentResourceVotePoll, + vote_poll: ContestedDocumentResourceVotePollWithContractInfo, vote_choice: ResourceVoteChoice, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { - // let's start by creating a batch of operations - let mut drive_operations: Vec = vec![]; + let mut estimated_costs_only_with_layer_info = if apply { + None::> + } else { + Some(HashMap::new()) + }; - // let contract_fetch_info = self - // .get_contract_with_fetch_info_and_add_to_operations( - // vote.vote_poll().contract_id.to_buffer(), - // Some(&block_info.epoch), - // true, - // transaction, - // &mut drive_operations, - // platform_version, - // )? - // .ok_or(Error::Document(DocumentError::DataContractNotFound))?; + let batch_operations = self.register_contested_resource_identity_vote_operations_v0( + voter_pro_tx_hash, + vote_poll, + vote_choice, + block_info, + &mut estimated_costs_only_with_layer_info, + transaction, + platform_version, + )?; + + let mut drive_operations: Vec = vec![]; + self.apply_batch_low_level_drive_operations( + estimated_costs_only_with_layer_info, + transaction, + batch_operations, + &mut drive_operations, + &platform_version.drive, + )?; - todo!() + let fees = Drive::calculate_fee( + None, + Some(drive_operations), + &block_info.epoch, + self.config.epochs_per_era, + platform_version, + )?; + Ok(fees) } pub(super) fn register_contested_resource_identity_vote_operations_v0( &self, voter_pro_tx_hash: [u8; 32], - vote_poll: ContestedDocumentResourceVotePoll, + vote_poll: ContestedDocumentResourceVotePollWithContractInfo, vote_choice: ResourceVoteChoice, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< @@ -55,6 +75,10 @@ impl Drive { // The vote at this point will have been verified as valid by rs-drive-abci - todo!() + let voting_path = vote_poll.contender_voting_path(vote_choice, platform_version)?; + + self.batch_insert::<0>(PathKeyElement((voting_path, voter_pro_tx_hash.to_vec(), Element::new_sum_item(1))), &mut drive_operations, &platform_version.drive)?; + + Ok(drive_operations) } } diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs index d63dcfa76b..b02b058bd7 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs @@ -12,8 +12,8 @@ use dpp::fee::fee_result::FeeResult; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; -use dpp::voting::votes::Vote; use grovedb::{EstimatedLayerInformation, TransactionArg}; +use crate::drive::votes::resolved::votes::ResolvedVote; impl Drive { /// Registers a vote associated with a specific identity using the given voter's ProRegTx hash. @@ -42,7 +42,7 @@ impl Drive { pub fn register_identity_vote( &self, voter_pro_tx_hash: [u8; 32], - vote: Vote, + vote: ResolvedVote, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, @@ -99,7 +99,7 @@ impl Drive { pub fn register_identity_vote_operations( &self, voter_pro_tx_hash: [u8; 32], - vote: Vote, + vote: ResolvedVote, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< HashMap, diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs index 3b91f994d7..93f34f1ddf 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs @@ -3,29 +3,29 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; -use dpp::voting::vote_polls::VotePoll; -use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; -use dpp::voting::votes::Vote; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use platform_version::version::PlatformVersion; use std::collections::HashMap; +use crate::drive::votes::resolved::vote_polls::ResolvedVotePoll; +use crate::drive::votes::resolved::votes::resolved_resource_vote::accessors::v0::ResolvedResourceVoteGettersV0; +use crate::drive::votes::resolved::votes::ResolvedVote; impl Drive { pub(super) fn register_identity_vote_v0( &self, voter_pro_tx_hash: [u8; 32], - vote: Vote, + vote: ResolvedVote, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { match vote { - Vote::ResourceVote(resource_vote) => { + ResolvedVote::ResolvedResourceVote(resource_vote) => { let vote_choice = resource_vote.resource_vote_choice(); match resource_vote.vote_poll_owned() { - VotePoll::ContestedDocumentResourceVotePoll( + ResolvedVotePoll::ContestedDocumentResourceVotePollWithContractInfo( contested_document_resource_vote_poll, ) => self.register_contested_resource_identity_vote( voter_pro_tx_hash, @@ -44,7 +44,7 @@ impl Drive { pub(super) fn register_identity_vote_operations_v0( &self, voter_pro_tx_hash: [u8; 32], - vote: Vote, + vote: ResolvedVote, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< HashMap, @@ -53,10 +53,10 @@ impl Drive { platform_version: &PlatformVersion, ) -> Result, Error> { match vote { - Vote::ResourceVote(resource_vote) => { + ResolvedVote::ResolvedResourceVote(resource_vote) => { let vote_choice = resource_vote.resource_vote_choice(); match resource_vote.vote_poll_owned() { - VotePoll::ContestedDocumentResourceVotePoll( + ResolvedVotePoll::ContestedDocumentResourceVotePollWithContractInfo( contested_document_resource_vote_poll, ) => self.register_contested_resource_identity_vote_operations( voter_pro_tx_hash, diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 4238fc2503..7b39cb62b7 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -23,7 +23,7 @@ mod setup; #[cfg(any(feature = "server", feature = "verify"))] /// Resolve contested document resource vote poll module -pub mod resolve_contested_document_resource_vote_poll; +pub mod resolved; /// A trait to convert the vote to a tree path usable in grovedb pub trait TreePath { diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index 1ceed9f3f0..4665781fec 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -1,4 +1,3 @@ -use crate::drive::votes::resolve_contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use crate::drive::RootTree; use crate::error::Error; use dpp::data_contract::accessors::v0::DataContractV0Getters; @@ -6,7 +5,9 @@ use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; use dpp::data_contract::document_type::IndexProperty; use dpp::identifier::Identifier; use dpp::identity::TimestampMillis; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use platform_version::version::PlatformVersion; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::{ContestedDocumentResourceVotePollWithContractInfo, ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed}; /// The votes tree structure looks like this /// @@ -68,12 +69,12 @@ pub trait VotePollPaths { /// The path that would store the votes for a single contender fn contender_voting_path( &self, - identity_id: Identifier, + vote_choice: ResourceVoteChoice, platform_version: &PlatformVersion, ) -> Result>, Error>; } -impl<'a> VotePollPaths for ContestedDocumentResourceVotePollWithContractInfo<'a> { +impl VotePollPaths for ContestedDocumentResourceVotePollWithContractInfo { fn contract_path(&self) -> [&[u8]; 4] { vote_contested_resource_active_polls_contract_tree_path( self.contract.as_ref().id_ref().as_slice(), @@ -147,13 +148,102 @@ impl<'a> VotePollPaths for ContestedDocumentResourceVotePollWithContractInfo<'a> } fn contender_voting_path( + &self, + vote_choice: ResourceVoteChoice, + platform_version: &PlatformVersion, + ) -> Result>, Error> { + let key = vote_choice.to_key(); + let mut contender_voting_path = self.contenders_path(platform_version)?; + contender_voting_path.push(key); + contender_voting_path.push(vec![1]); + Ok(contender_voting_path) + } +} + + +impl<'a> VotePollPaths for ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed<'a> { + fn contract_path(&self) -> [&[u8]; 4] { + vote_contested_resource_active_polls_contract_tree_path( + self.contract.as_ref().id_ref().as_slice(), + ) + } + + fn contract_path_vec(&self) -> Vec> { + vote_contested_resource_active_polls_contract_tree_path_vec( + self.contract.as_ref().id_ref().as_slice(), + ) + } + + fn document_type_path(&self) -> [&[u8]; 5] { + vote_contested_resource_active_polls_contract_document_tree_path( + self.contract.as_ref().id_ref().as_slice(), + self.document_type_name.as_str(), + ) + } + + fn document_type_path_vec(&self) -> Vec> { + vote_contested_resource_active_polls_contract_document_tree_path_vec( + self.contract.as_ref().id_ref().as_slice(), + self.document_type_name.as_str(), + ) + } + + fn documents_storage_path(&self) -> [&[u8]; 6] { + vote_contested_resource_contract_documents_storage_path( + self.contract.as_ref().id_ref().as_slice(), + self.document_type_name.as_str(), + ) + } + + fn documents_storage_path_vec(&self) -> Vec> { + vote_contested_resource_contract_documents_storage_path_vec( + self.contract.as_ref().id_ref().as_slice(), + self.document_type_name.as_str(), + ) + } + + fn contenders_path(&self, platform_version: &PlatformVersion) -> Result>, Error> { + let mut root = vote_contested_resource_active_polls_contract_document_tree_path_vec( + self.contract.as_ref().id_ref().as_slice(), + self.document_type_name.as_str(), + ); + let document_type = self.document_type()?; + root.append( + &mut self + .index()? + .properties + .iter() + .zip(self.index_values.iter()) + .map(|(IndexProperty { name, .. }, value)| { + document_type + .serialize_value_for_key(name, value, platform_version) + .map_err(Error::Protocol) + }) + .collect::>, Error>>()?, + ); + Ok(root) + } + + fn contender_path( &self, identity_id: Identifier, platform_version: &PlatformVersion, ) -> Result>, Error> { - let mut contender_path = self.contender_path(identity_id, platform_version)?; - contender_path.push(vec![1]); - Ok(contender_path) + let mut contenders_path = self.contenders_path(platform_version)?; + contenders_path.push(identity_id.to_vec()); + Ok(contenders_path) + } + + fn contender_voting_path( + &self, + vote_choice: ResourceVoteChoice, + platform_version: &PlatformVersion, + ) -> Result>, Error> { + let key = vote_choice.to_key(); + let mut contender_voting_path = self.contenders_path(platform_version)?; + contender_voting_path.push(key); + contender_voting_path.push(vec![1]); + Ok(contender_voting_path) } } diff --git a/packages/rs-drive/src/drive/votes/resolve_contested_document_resource_vote_poll/mod.rs b/packages/rs-drive/src/drive/votes/resolve_contested_document_resource_vote_poll/mod.rs deleted file mode 100644 index 40ceb3f82c..0000000000 --- a/packages/rs-drive/src/drive/votes/resolve_contested_document_resource_vote_poll/mod.rs +++ /dev/null @@ -1,147 +0,0 @@ -use crate::drive::object_size_info::DataContractResolvedInfo; -use crate::drive::Drive; -use crate::error::contract::DataContractError; -use crate::error::drive::DriveError; -use crate::error::Error; -use dpp::data_contract::accessors::v0::DataContractV0Getters; -use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; -use dpp::data_contract::document_type::{DocumentType, DocumentTypeRef, Index}; -use dpp::platform_value::Value; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; -use dpp::ProtocolError; -use grovedb::TransactionArg; -use platform_version::version::PlatformVersion; - -/// Represents information related to a contested document resource vote poll, along with -/// associated contract details. -/// -/// This structure holds a reference to the contract, the document type name, -/// the index name, and the index values used for the poll. -#[derive(Debug, PartialEq, Clone)] -pub struct ContestedDocumentResourceVotePollWithContractInfo<'a> { - /// The contract information associated with the document. - pub contract: DataContractResolvedInfo<'a>, - /// The name of the document type. - pub document_type_name: String, - /// The name of the index. - pub index_name: String, - /// The values used in the index for the poll. - pub index_values: Vec, -} - -impl<'a> ContestedDocumentResourceVotePollWithContractInfo<'a> { - /// Retrieves the index associated with the document type and index name. - /// - /// # Returns - /// - /// * `Ok(&Index)` - A reference to the index if found. - /// * `Err(Error)` - An error if the index is not found or if there is an issue retrieving it. - /// - /// # Errors - /// - /// This method returns an `Error::Drive` variant with `DriveError::ContestedIndexNotFound` - /// if the index cannot be found within the document type. - pub fn index(&self) -> Result<&Index, Error> { - self.contract - .as_ref() - .document_type_borrowed_for_name(self.document_type_name.as_str())? - .indexes() - .get(&self.index_name) - .ok_or(Error::Drive(DriveError::ContestedIndexNotFound( - "contested index not found when trying to get it from the contested document resource vote poll with contract info" - ))) - } - - /// Retrieves the document type reference associated with the document type name. - /// - /// # Returns - /// - /// * `Ok(DocumentTypeRef)` - A reference to the document type if found. - /// * `Err(Error)` - An error if the document type cannot be found or if there is an issue retrieving it. - /// - /// # Errors - /// - /// This method returns an `Error::Protocol` variant with `ProtocolError::DataContractError` - /// if there is an issue retrieving the document type. - pub fn document_type(&self) -> Result { - self.contract - .as_ref() - .document_type_for_name(self.document_type_name.as_str()) - .map_err(|e| Error::Protocol(ProtocolError::DataContractError(e))) - } - - /// Borrows a reference to the document type associated with the document type name. - /// - /// # Returns - /// - /// * `Ok(&DocumentType)` - A borrowed reference to the document type if found. - /// * `Err(Error)` - An error if the document type cannot be found or if there is an issue retrieving it. - /// - /// # Errors - /// - /// This method returns an `Error::Protocol` variant with `ProtocolError::DataContractError` - /// if there is an issue retrieving the document type. - pub fn document_type_borrowed(&self) -> Result<&DocumentType, Error> { - self.contract - .as_ref() - .document_type_borrowed_for_name(self.document_type_name.as_str()) - .map_err(|e| Error::Protocol(ProtocolError::DataContractError(e))) - } -} - -/// A trait for resolving information related to a contested document resource vote poll. -/// -/// This trait defines a method to resolve and retrieve the necessary contract and index -/// information associated with a contested document resource vote poll. -pub trait ContestedDocumentResourceVotePollResolver { - /// Resolves the contested document resource vote poll information. - /// - /// This method fetches the contract, document type name, index name, and index values - /// required to process a contested document resource vote poll. - /// - /// # Parameters - /// - /// * `drive`: A reference to the `Drive` object used for database interactions. - /// * `transaction`: The transaction argument used to ensure consistency during the resolve operation. - /// * `platform_version`: The platform version to ensure compatibility. - /// - /// # Returns - /// - /// * `Ok(ContestedDocumentResourceVotePollWithContractInfo)` - The resolved information needed for the vote poll. - /// * `Err(Error)` - An error if the resolution process fails. - /// - /// # Errors - /// - /// This method returns an `Error` variant if there is an issue resolving the contested document resource vote poll - /// information. The specific error depends on the underlying problem encountered during resolution. - fn resolve( - &self, - drive: &Drive, - transaction: TransactionArg, - platform_version: &PlatformVersion, - ) -> Result; -} - -impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVotePoll { - fn resolve( - &self, - drive: &Drive, - transaction: TransactionArg, - platform_version: &PlatformVersion, - ) -> Result { - let ContestedDocumentResourceVotePoll { - contract_id, - document_type_name, - index_name, - index_values, - } = self; - - let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll".to_string())))?; - Ok(ContestedDocumentResourceVotePollWithContractInfo { - contract: DataContractResolvedInfo::DataContractFetchInfo(contract), - document_type_name: document_type_name.clone(), - index_name: index_name.clone(), - index_values: index_values.clone(), - }) - } -} diff --git a/packages/rs-drive/src/drive/votes/resolved/mod.rs b/packages/rs-drive/src/drive/votes/resolved/mod.rs new file mode 100644 index 0000000000..015f74edec --- /dev/null +++ b/packages/rs-drive/src/drive/votes/resolved/mod.rs @@ -0,0 +1,5 @@ + +/// votes module +pub mod votes; +/// vote polls module +pub mod vote_polls; \ No newline at end of file diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/mod.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/mod.rs new file mode 100644 index 0000000000..085eb5aafb --- /dev/null +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/mod.rs @@ -0,0 +1,300 @@ +pub(crate) mod resolve; + +use crate::drive::object_size_info::{DataContractOwnedResolvedInfo, DataContractResolvedInfo}; +use crate::error::drive::DriveError; +use crate::error::Error; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::data_contract::document_type::{DocumentType, DocumentTypeRef, Index}; +use dpp::identifier::Identifier; +use dpp::platform_value::Value; +use dpp::ProtocolError; +use dpp::serialization::PlatformSerializable; +use dpp::util::hash::hash_double; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; + +/// Represents information related to a contested document resource vote poll, along with +/// associated contract details. +/// +/// This structure holds a reference to the contract, the document type name, +/// the index name, and the index values used for the poll. +#[derive(Debug, PartialEq, Clone)] +pub struct ContestedDocumentResourceVotePollWithContractInfo { + /// The contract information associated with the document. + pub contract: DataContractOwnedResolvedInfo, + /// The name of the document type. + pub document_type_name: String, + /// The name of the index. + pub index_name: String, + /// The values used in the index for the poll. + pub index_values: Vec, +} + +/// Represents information related to a contested document resource vote poll, along with +/// associated contract details. +/// +/// This structure holds a reference to the contract, the document type name, +/// the index name, and the index values used for the poll. +#[derive(Debug, PartialEq, Clone)] +pub struct ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed<'a> { + /// The contract information associated with the document. + pub contract: DataContractResolvedInfo<'a>, + /// The name of the document type. + pub document_type_name: String, + /// The name of the index. + pub index_name: String, + /// The values used in the index for the poll. + pub index_values: Vec, +} + +impl From for ContestedDocumentResourceVotePoll { + fn from(value: ContestedDocumentResourceVotePollWithContractInfo) -> Self { + let ContestedDocumentResourceVotePollWithContractInfo { contract, document_type_name, index_name, index_values } = value; + + ContestedDocumentResourceVotePoll { + contract_id: contract.id(), + document_type_name, + index_name, + index_values, + } + } +} + +impl<'a> From> for ContestedDocumentResourceVotePoll { + fn from(value: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed) -> Self { + let ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { contract, document_type_name, index_name, index_values } = value; + + ContestedDocumentResourceVotePoll { + contract_id: contract.id(), + document_type_name, + index_name, + index_values, + } + } +} + +impl From<&ContestedDocumentResourceVotePollWithContractInfo> for ContestedDocumentResourceVotePoll { + fn from(value: &ContestedDocumentResourceVotePollWithContractInfo) -> Self { + let ContestedDocumentResourceVotePollWithContractInfo { contract, document_type_name, index_name, index_values } = value; + + ContestedDocumentResourceVotePoll { + contract_id: contract.id(), + document_type_name: document_type_name.clone(), + index_name : index_name.clone(), + index_values: index_values.clone(), + } + } +} + +impl<'a> From<&ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed<'a>> for ContestedDocumentResourceVotePoll { + fn from(value: &ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed) -> Self { + let ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { contract, document_type_name, index_name, index_values } = value; + + ContestedDocumentResourceVotePoll { + contract_id: contract.id(), + document_type_name: document_type_name.clone(), + index_name : index_name.clone(), + index_values: index_values.clone(), + } + } +} + +impl ContestedDocumentResourceVotePollWithContractInfo { + /// Serializes the contested document resource vote poll with contract information to bytes. + /// + /// # Returns + /// + /// A `Result` containing a `Vec` with the serialized bytes, or a `ProtocolError` if serialization fails. + pub fn serialize_to_bytes(&self) -> Result, ProtocolError> { + let contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll = self.into(); + contested_document_resource_vote_poll.serialize_to_bytes() + } + + /// Computes the double SHA-256 hash of the serialized contested document resource vote poll. + /// + /// # Returns + /// + /// A `Result` containing a `[u8; 32]` array with the hash, or a `ProtocolError` if hashing fails. + pub fn sha256_2_hash(&self) -> Result<[u8; 32], ProtocolError> { + let encoded = self.serialize_to_bytes()?; + Ok(hash_double(encoded)) + } + + /// Retrieves the specialized balance identifier associated with the contested document resource vote poll. + /// + /// # Returns + /// + /// A `Result` containing the `Identifier`, or a `ProtocolError` if retrieving the balance ID fails. + pub fn specialized_balance_id(&self) -> Result { + self.unique_id() + } + + /// Retrieves the unique identifier associated with the contested document resource vote poll. + /// + /// # Returns + /// + /// A `Result` containing the `Identifier`, or a `ProtocolError` if retrieving the unique ID fails. + pub fn unique_id(&self) -> Result { + self.sha256_2_hash().map(Identifier::new) + } +} + +impl<'a> ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed<'a> { + /// Serializes the contested document resource vote poll with contract information (allowing borrowed data) to bytes. + /// + /// # Returns + /// + /// A `Result` containing a `Vec` with the serialized bytes, or a `ProtocolError` if serialization fails. + pub fn serialize_to_bytes(&self) -> Result, ProtocolError> { + let contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll = self.into(); + contested_document_resource_vote_poll.serialize_to_bytes() + } + + /// Computes the double SHA-256 hash of the serialized contested document resource vote poll (allowing borrowed data). + /// + /// # Returns + /// + /// A `Result` containing a `[u8; 32]` array with the hash, or a `ProtocolError` if hashing fails. + pub fn sha256_2_hash(&self) -> Result<[u8; 32], ProtocolError> { + let encoded = self.serialize_to_bytes()?; + Ok(hash_double(encoded)) + } + + /// Retrieves the specialized balance identifier associated with the contested document resource vote poll (allowing borrowed data). + /// + /// # Returns + /// + /// A `Result` containing the `Identifier`, or a `ProtocolError` if retrieving the balance ID fails. + pub fn specialized_balance_id(&self) -> Result { + self.unique_id() + } + + /// Retrieves the unique identifier associated with the contested document resource vote poll (allowing borrowed data). + /// + /// # Returns + /// + /// A `Result` containing the `Identifier`, or a `ProtocolError` if retrieving the unique ID fails. + pub fn unique_id(&self) -> Result { + self.sha256_2_hash().map(Identifier::new) + } +} + +impl ContestedDocumentResourceVotePollWithContractInfo { + /// Retrieves the index associated with the document type and index name. + /// + /// # Returns + /// + /// * `Ok(&Index)` - A reference to the index if found. + /// * `Err(Error)` - An error if the index is not found or if there is an issue retrieving it. + /// + /// # Errors + /// + /// This method returns an `Error::Drive` variant with `DriveError::ContestedIndexNotFound` + /// if the index cannot be found within the document type. + pub fn index(&self) -> Result<&Index, Error> { + self.contract + .as_ref() + .document_type_borrowed_for_name(self.document_type_name.as_str())? + .indexes() + .get(&self.index_name) + .ok_or(Error::Drive(DriveError::ContestedIndexNotFound( + "contested index not found when trying to get it from the contested document resource vote poll with contract info" + ))) + } + + /// Retrieves the document type reference associated with the document type name. + /// + /// # Returns + /// + /// * `Ok(DocumentTypeRef)` - A reference to the document type if found. + /// * `Err(Error)` - An error if the document type cannot be found or if there is an issue retrieving it. + /// + /// # Errors + /// + /// This method returns an `Error::Protocol` variant with `ProtocolError::DataContractError` + /// if there is an issue retrieving the document type. + pub fn document_type(&self) -> Result { + self.contract + .as_ref() + .document_type_for_name(self.document_type_name.as_str()) + .map_err(|e| Error::Protocol(ProtocolError::DataContractError(e))) + } + + /// Borrows a reference to the document type associated with the document type name. + /// + /// # Returns + /// + /// * `Ok(&DocumentType)` - A borrowed reference to the document type if found. + /// * `Err(Error)` - An error if the document type cannot be found or if there is an issue retrieving it. + /// + /// # Errors + /// + /// This method returns an `Error::Protocol` variant with `ProtocolError::DataContractError` + /// if there is an issue retrieving the document type. + pub fn document_type_borrowed(&self) -> Result<&DocumentType, Error> { + self.contract + .as_ref() + .document_type_borrowed_for_name(self.document_type_name.as_str()) + .map_err(|e| Error::Protocol(ProtocolError::DataContractError(e))) + } +} + +impl<'a> ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed<'a> { + /// Retrieves the index associated with the document type and index name. + /// + /// # Returns + /// + /// * `Ok(&Index)` - A reference to the index if found. + /// * `Err(Error)` - An error if the index is not found or if there is an issue retrieving it. + /// + /// # Errors + /// + /// This method returns an `Error::Drive` variant with `DriveError::ContestedIndexNotFound` + /// if the index cannot be found within the document type. + pub fn index(&self) -> Result<&Index, Error> { + self.contract + .as_ref() + .document_type_borrowed_for_name(self.document_type_name.as_str())? + .indexes() + .get(&self.index_name) + .ok_or(Error::Drive(DriveError::ContestedIndexNotFound( + "contested index not found when trying to get it from the contested document resource vote poll with contract info" + ))) + } + + /// Retrieves the document type reference associated with the document type name. + /// + /// # Returns + /// + /// * `Ok(DocumentTypeRef)` - A reference to the document type if found. + /// * `Err(Error)` - An error if the document type cannot be found or if there is an issue retrieving it. + /// + /// # Errors + /// + /// This method returns an `Error::Protocol` variant with `ProtocolError::DataContractError` + /// if there is an issue retrieving the document type. + pub fn document_type(&self) -> Result { + self.contract + .as_ref() + .document_type_for_name(self.document_type_name.as_str()) + .map_err(|e| Error::Protocol(ProtocolError::DataContractError(e))) + } + + /// Borrows a reference to the document type associated with the document type name. + /// + /// # Returns + /// + /// * `Ok(&DocumentType)` - A borrowed reference to the document type if found. + /// * `Err(Error)` - An error if the document type cannot be found or if there is an issue retrieving it. + /// + /// # Errors + /// + /// This method returns an `Error::Protocol` variant with `ProtocolError::DataContractError` + /// if there is an issue retrieving the document type. + pub fn document_type_borrowed(&self) -> Result<&DocumentType, Error> { + self.contract + .as_ref() + .document_type_borrowed_for_name(self.document_type_name.as_str()) + .map_err(|e| Error::Protocol(ProtocolError::DataContractError(e))) + } +} diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs new file mode 100644 index 0000000000..96f03c2911 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs @@ -0,0 +1,152 @@ +use grovedb::TransactionArg; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use platform_version::version::PlatformVersion; +use crate::drive::Drive; +use crate::drive::object_size_info::{DataContractOwnedResolvedInfo, DataContractResolvedInfo}; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::{ContestedDocumentResourceVotePollWithContractInfo, ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed}; +use crate::error::contract::DataContractError; +use crate::error::Error; + +/// A trait for resolving information related to a contested document resource vote poll. +/// +/// This trait defines a method to resolve and retrieve the necessary contract and index +/// information associated with a contested document resource vote poll. +pub trait ContestedDocumentResourceVotePollResolver { + /// Resolves the contested document resource vote poll information. + /// + /// This method fetches the contract, document type name, index name, and index values + /// required to process a contested document resource vote poll. + /// + /// # Parameters + /// + /// * `drive`: A reference to the `Drive` object used for database interactions. + /// * `transaction`: The transaction argument used to ensure consistency during the resolve operation. + /// * `platform_version`: The platform version to ensure compatibility. + /// + /// # Returns + /// + /// * `Ok(ContestedDocumentResourceVotePollWithContractInfo)` - The resolved information needed for the vote poll. + /// * `Err(Error)` - An error if the resolution process fails. + /// + /// # Errors + /// + /// This method returns an `Error` variant if there is an issue resolving the contested document resource vote poll + /// information. The specific error depends on the underlying problem encountered during resolution. + fn resolve( + &self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result; + + fn resolve_owned( + self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result; + + fn resolve_allow_borrowed<'a>( + &self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error>; + + fn resolve_owned_allow_borrowed<'a>( + self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error>; +} + +impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVotePoll { + fn resolve( + &self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + let ContestedDocumentResourceVotePoll { + contract_id, + document_type_name, + index_name, + index_values, + } = self; + + let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll".to_string())))?; + Ok(ContestedDocumentResourceVotePollWithContractInfo { + contract: DataContractOwnedResolvedInfo::DataContractFetchInfo(contract), + document_type_name: document_type_name.clone(), + index_name: index_name.clone(), + index_values: index_values.clone(), + }) + } + + fn resolve_owned( + self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + let ContestedDocumentResourceVotePoll { + contract_id, + document_type_name, + index_name, + index_values, + } = self; + + let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll".to_string())))?; + Ok(ContestedDocumentResourceVotePollWithContractInfo { + contract: DataContractOwnedResolvedInfo::DataContractFetchInfo(contract), + document_type_name, + index_name, + index_values, + }) + } + + fn resolve_allow_borrowed<'a>( + &self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let ContestedDocumentResourceVotePoll { + contract_id, + document_type_name, + index_name, + index_values, + } = self; + + let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll".to_string())))?; + Ok(ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { + contract: DataContractResolvedInfo::DataContractFetchInfo(contract), + document_type_name: document_type_name.clone(), + index_name: index_name.clone(), + index_values: index_values.clone(), + }) + } + + fn resolve_owned_allow_borrowed<'a>( + self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let ContestedDocumentResourceVotePoll { + contract_id, + document_type_name, + index_name, + index_values, + } = self; + + let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll".to_string())))?; + Ok(ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { + contract: DataContractResolvedInfo::DataContractFetchInfo(contract), + document_type_name, + index_name, + index_values, + }) + } +} diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs new file mode 100644 index 0000000000..0f57140e4f --- /dev/null +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs @@ -0,0 +1,58 @@ +use derive_more::From; +use dpp::identifier::Identifier; +use dpp::ProtocolError; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; + +/// Module containing logic for contested document resource vote polls. +pub mod contested_document_resource_vote_poll; + +/// Module containing logic to resolve various components. +pub(crate) mod resolve; + +/// Represents a resolved vote poll in the system. +#[derive(Debug, Clone, PartialEq, From)] +pub enum ResolvedVotePoll { + /// A resolved vote poll with contract information for a contested document resource. + ContestedDocumentResourceVotePollWithContractInfo(ContestedDocumentResourceVotePollWithContractInfo), +} + +impl ResolvedVotePoll { + /// Retrieves the specialized balance identifier associated with the resolved vote poll. + /// + /// # Returns + /// + /// * `Ok(Some(identifier))` if a specialized balance ID is available. + /// * `Ok(None)` if no specialized balance ID is associated. + /// * `Err(ProtocolError)` if there is an error retrieving the balance ID. + /// + /// # Errors + /// + /// Returns a `ProtocolError` if there is an issue retrieving the specialized balance ID. + pub fn specialized_balance_id(&self) -> Result, ProtocolError> { + match self { + ResolvedVotePoll::ContestedDocumentResourceVotePollWithContractInfo(contested_document_resource_vote_poll) => { + Ok(Some( + contested_document_resource_vote_poll.specialized_balance_id()?, + )) + } + } + } + + /// Retrieves the unique identifier associated with the resolved vote poll. + /// + /// # Returns + /// + /// * `Ok(identifier)` containing the unique identifier. + /// * `Err(ProtocolError)` if there is an error retrieving the unique ID. + /// + /// # Errors + /// + /// Returns a `ProtocolError` if there is an issue retrieving the unique ID. + pub fn unique_id(&self) -> Result { + match self { + ResolvedVotePoll::ContestedDocumentResourceVotePollWithContractInfo(contested_document_resource_vote_poll) => { + contested_document_resource_vote_poll.unique_id() + } + } + } +} diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/resolve.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/resolve.rs new file mode 100644 index 0000000000..c1980830a2 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/resolve.rs @@ -0,0 +1,59 @@ +use grovedb::TransactionArg; +use dpp::voting::vote_polls::VotePoll; +use platform_version::version::PlatformVersion; +use crate::drive::Drive; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; +use crate::drive::votes::resolved::vote_polls::ResolvedVotePoll; +use crate::error::Error; + +pub trait VotePollResolver { + /// Resolves the contested document resource vote poll information. + /// + /// This method fetches the contract, document type name, index name, and index values + /// required to process a contested document resource vote poll. + /// + /// # Parameters + /// + /// * `drive`: A reference to the `Drive` object used for database interactions. + /// * `transaction`: The transaction argument used to ensure consistency during the resolve operation. + /// * `platform_version`: The platform version to ensure compatibility. + /// + /// # Returns + /// + /// * `Ok(ContestedDocumentResourceVotePollWithContractInfo)` - The resolved information needed for the vote poll. + /// * `Err(Error)` - An error if the resolution process fails. + /// + /// # Errors + /// + /// This method returns an `Error` variant if there is an issue resolving the contested document resource vote poll + /// information. The specific error depends on the underlying problem encountered during resolution. + fn resolve( + &self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result; + + fn resolve_owned( + self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result; +} + +impl VotePollResolver for VotePoll { + fn resolve(&self, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { + match self { VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll) => { + Ok(ResolvedVotePoll::ContestedDocumentResourceVotePollWithContractInfo(contested_document_resource_vote_poll.resolve(drive, transaction, platform_version)?)) + } + } + } + + fn resolve_owned(self, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { + match self { VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll) => { + Ok(ResolvedVotePoll::ContestedDocumentResourceVotePollWithContractInfo(contested_document_resource_vote_poll.resolve(drive, transaction, platform_version)?)) + } + } + } +} \ No newline at end of file diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/mod.rs b/packages/rs-drive/src/drive/votes/resolved/votes/mod.rs new file mode 100644 index 0000000000..b66dab8ae5 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/resolved/votes/mod.rs @@ -0,0 +1,34 @@ +/// Resolved resource vote module +pub mod resolved_resource_vote; +pub(crate) mod resolve; + +use dpp::identifier::Identifier; +use dpp::ProtocolError; +use crate::drive::votes::resolved::votes::resolved_resource_vote::accessors::v0::ResolvedResourceVoteGettersV0; +use crate::drive::votes::resolved::votes::resolved_resource_vote::ResolvedResourceVote; + +/// Represents the different types of resolved votes within the system. +#[derive(Debug, Clone, PartialEq)] +pub enum ResolvedVote { + /// A resolved vote for a specific resource. + ResolvedResourceVote(ResolvedResourceVote), +} + +impl ResolvedVote { + /// Retrieves the specialized balance identifier associated with the resolved vote. + /// + /// # Returns + /// + /// * `Ok(Some(identifier))` if a specialized balance ID is available. + /// * `Ok(None)` if no specialized balance ID is associated. + /// * `Err(ProtocolError)` if there is an error retrieving the balance ID. + /// + /// # Errors + /// + /// Returns a `ProtocolError` if there is an issue retrieving the specialized balance ID. + pub fn specialized_balance_id(&self) -> Result, ProtocolError> { + match self { + ResolvedVote::ResolvedResourceVote(resource_vote) => resource_vote.vote_poll().specialized_balance_id(), + } + } +} \ No newline at end of file diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/resolve.rs b/packages/rs-drive/src/drive/votes/resolved/votes/resolve.rs new file mode 100644 index 0000000000..4d82ca5e8e --- /dev/null +++ b/packages/rs-drive/src/drive/votes/resolved/votes/resolve.rs @@ -0,0 +1,59 @@ +use grovedb::TransactionArg; +use dpp::voting::votes::Vote; +use platform_version::version::PlatformVersion; +use crate::drive::Drive; +use crate::drive::votes::resolved::votes::ResolvedVote; +use crate::error::Error; +use crate::drive::votes::resolved::votes::resolved_resource_vote::resolve::ResourceVoteResolver; + +pub trait VoteResolver { + /// Resolves the contested document resource vote poll information. + /// + /// This method fetches the contract, document type name, index name, and index values + /// required to process a contested document resource vote poll. + /// + /// # Parameters + /// + /// * `drive`: A reference to the `Drive` object used for database interactions. + /// * `transaction`: The transaction argument used to ensure consistency during the resolve operation. + /// * `platform_version`: The platform version to ensure compatibility. + /// + /// # Returns + /// + /// * `Ok(ContestedDocumentResourceVotePollWithContractInfo)` - The resolved information needed for the vote poll. + /// * `Err(Error)` - An error if the resolution process fails. + /// + /// # Errors + /// + /// This method returns an `Error` variant if there is an issue resolving the contested document resource vote poll + /// information. The specific error depends on the underlying problem encountered during resolution. + fn resolve( + &self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result; + + fn resolve_owned( + self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result; +} + +impl VoteResolver for Vote { + fn resolve(&self, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { + match self { Vote::ResourceVote(resource_vote) => { + Ok(ResolvedVote::ResolvedResourceVote(resource_vote.resolve(drive, transaction, platform_version)?)) + } + } + } + + fn resolve_owned(self, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { + match self { Vote::ResourceVote(resource_vote) => { + Ok(ResolvedVote::ResolvedResourceVote(resource_vote.resolve_owned(drive, transaction, platform_version)?)) + } + } + } +} diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/accessors/mod.rs b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/accessors/mod.rs new file mode 100644 index 0000000000..24420eea2c --- /dev/null +++ b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/accessors/mod.rs @@ -0,0 +1,27 @@ +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use crate::drive::votes::resolved::vote_polls::ResolvedVotePoll; +use crate::drive::votes::resolved::votes::resolved_resource_vote::accessors::v0::ResolvedResourceVoteGettersV0; +use crate::drive::votes::resolved::votes::resolved_resource_vote::ResolvedResourceVote; + +/// Module containing version 0 of the implementation. +pub mod v0; + +impl ResolvedResourceVoteGettersV0 for ResolvedResourceVote { + fn vote_poll(&self) -> &ResolvedVotePoll { + match self { + ResolvedResourceVote::V0(v0) => &v0.resolved_vote_poll, + } + } + + fn vote_poll_owned(self) -> ResolvedVotePoll { + match self { + ResolvedResourceVote::V0(v0) => v0.resolved_vote_poll, + } + } + + fn resource_vote_choice(&self) -> ResourceVoteChoice { + match self { + ResolvedResourceVote::V0(v0) => v0.resource_vote_choice, + } + } +} diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/accessors/v0/mod.rs b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/accessors/v0/mod.rs new file mode 100644 index 0000000000..9059ea460a --- /dev/null +++ b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/accessors/v0/mod.rs @@ -0,0 +1,14 @@ +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use crate::drive::votes::resolved::vote_polls::ResolvedVotePoll; + +/// Trait for getters in Resource Vote +pub trait ResolvedResourceVoteGettersV0 { + /// The vote poll + fn vote_poll(&self) -> &ResolvedVotePoll; + + /// The vote poll as owned + fn vote_poll_owned(self) -> ResolvedVotePoll; + + /// The choice made in the vote + fn resource_vote_choice(&self) -> ResourceVoteChoice; +} diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/mod.rs b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/mod.rs new file mode 100644 index 0000000000..8bff100321 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/mod.rs @@ -0,0 +1,17 @@ +use crate::drive::votes::resolved::votes::resolved_resource_vote::v0::ResolvedResourceVoteV0; + +/// Module containing accessors for various components. +pub mod accessors; + +/// Module containing version 0 of the implementation. +pub mod v0; + +/// Module containing logic to resolve resources. +pub(crate) mod resolve; + +/// Represents a resolved resource vote in the system. +#[derive(Debug, Clone, PartialEq)] +pub enum ResolvedResourceVote { + /// Version 0 of the resolved resource vote. + V0(ResolvedResourceVoteV0), +} \ No newline at end of file diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/resolve.rs b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/resolve.rs new file mode 100644 index 0000000000..663e1bb069 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/resolve.rs @@ -0,0 +1,60 @@ +use grovedb::TransactionArg; +use dpp::voting::votes::resource_vote::ResourceVote; +use platform_version::version::PlatformVersion; +use crate::drive::Drive; +use crate::drive::votes::resolved::votes::resolve::VoteResolver; +use crate::drive::votes::resolved::votes::resolved_resource_vote::ResolvedResourceVote; +use crate::drive::votes::resolved::votes::resolved_resource_vote::v0::resolve::ResourceVoteResolverV0; +use crate::error::Error; + +pub trait ResourceVoteResolver { + /// Resolves the contested document resource vote poll information. + /// + /// This method fetches the contract, document type name, index name, and index values + /// required to process a contested document resource vote poll. + /// + /// # Parameters + /// + /// * `drive`: A reference to the `Drive` object used for database interactions. + /// * `transaction`: The transaction argument used to ensure consistency during the resolve operation. + /// * `platform_version`: The platform version to ensure compatibility. + /// + /// # Returns + /// + /// * `Ok(ContestedDocumentResourceVotePollWithContractInfo)` - The resolved information needed for the vote poll. + /// * `Err(Error)` - An error if the resolution process fails. + /// + /// # Errors + /// + /// This method returns an `Error` variant if there is an issue resolving the contested document resource vote poll + /// information. The specific error depends on the underlying problem encountered during resolution. + fn resolve( + &self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result; + + fn resolve_owned( + self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result; +} + +impl ResourceVoteResolver for ResourceVote { + fn resolve(&self, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { + match self { ResourceVote::V0(resource_vote) => { + Ok(ResolvedResourceVote::V0(resource_vote.resolve(drive, transaction, platform_version)?)) + } + } + } + + fn resolve_owned(self, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { + match self { ResourceVote::V0(resource_vote) => { + Ok(ResolvedResourceVote::V0(resource_vote.resolve_owned(drive, transaction, platform_version)?)) + } + } + } +} diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/mod.rs new file mode 100644 index 0000000000..e2a4f3b4c8 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/mod.rs @@ -0,0 +1,13 @@ +pub(crate) mod resolve; + +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use crate::drive::votes::resolved::vote_polls::ResolvedVotePoll; + +/// Represents the version 0 of a resolved resource vote. +#[derive(Debug, Clone, PartialEq)] +pub struct ResolvedResourceVoteV0 { + /// The resolved vote poll associated with this resource vote. + pub resolved_vote_poll: ResolvedVotePoll, + /// The choice made in the resource vote. + pub resource_vote_choice: ResourceVoteChoice, +} \ No newline at end of file diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/resolve.rs b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/resolve.rs new file mode 100644 index 0000000000..d23554da46 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/resolve.rs @@ -0,0 +1,72 @@ +use grovedb::TransactionArg; +use dpp::voting::votes::resource_vote::v0::ResourceVoteV0; +use platform_version::version::PlatformVersion; +use crate::drive::Drive; +use crate::drive::votes::resolved::votes::resolve::VoteResolver; +use crate::drive::votes::resolved::votes::resolved_resource_vote::v0::ResolvedResourceVoteV0; +use crate::error::Error; +use crate::drive::votes::resolved::vote_polls::resolve::VotePollResolver; + +pub(in crate::drive::votes::resolved::votes::resolved_resource_vote) trait ResourceVoteResolverV0 { + /// Resolves the contested document resource vote poll information. + /// + /// This method fetches the contract, document type name, index name, and index values + /// required to process a contested document resource vote poll. + /// + /// # Parameters + /// + /// * `drive`: A reference to the `Drive` object used for database interactions. + /// * `transaction`: The transaction argument used to ensure consistency during the resolve operation. + /// * `platform_version`: The platform version to ensure compatibility. + /// + /// # Returns + /// + /// * `Ok(ContestedDocumentResourceVotePollWithContractInfo)` - The resolved information needed for the vote poll. + /// * `Err(Error)` - An error if the resolution process fails. + /// + /// # Errors + /// + /// This method returns an `Error` variant if there is an issue resolving the contested document resource vote poll + /// information. The specific error depends on the underlying problem encountered during resolution. + fn resolve( + &self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result; + + fn resolve_owned( + self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result; +} + +impl ResourceVoteResolverV0 for ResourceVoteV0 { + fn resolve(&self, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { + let ResourceVoteV0 { + vote_poll, resource_vote_choice + } = self; + + let resolved_vote_poll = vote_poll.resolve(drive, transaction, platform_version)?; + + Ok(ResolvedResourceVoteV0 { + resolved_vote_poll, + resource_vote_choice: *resource_vote_choice, + }) + } + + fn resolve_owned(self, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { + let ResourceVoteV0 { + vote_poll, resource_vote_choice + } = self; + + let resolved_vote_poll = vote_poll.resolve_owned(drive, transaction, platform_version)?; + + Ok(ResolvedResourceVoteV0 { + resolved_vote_poll, + resource_vote_choice, + }) + } +} diff --git a/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs b/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs index f982a24068..1c002dfb56 100644 --- a/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs +++ b/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs @@ -1,9 +1,5 @@ use crate::drive::votes::paths::VotePollPaths; -use crate::drive::votes::resolve_contested_document_resource_vote_poll::{ - ContestedDocumentResourceVotePollResolver, ContestedDocumentResourceVotePollWithContractInfo, -}; use crate::drive::Drive; -use crate::error::drive::DriveError; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use crate::query::{GroveError, Query}; @@ -12,8 +8,11 @@ use dpp::identifier::Identifier; use dpp::platform_value; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use grovedb::query_result_type::{QueryResultElements, QueryResultType}; -use grovedb::{Element, PathQuery, SizedQuery, TransactionArg}; +use grovedb::{PathQuery, SizedQuery, TransactionArg}; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice::TowardsIdentity; use platform_version::version::PlatformVersion; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; /// Vote Poll Drive Query struct #[derive(Debug, PartialEq, Clone)] @@ -68,7 +67,7 @@ impl ContestedDocumentVotePollVotesDriveQuery { order_ascending, } = self; Ok(ResolvedContestedDocumentVotePollVotesDriveQuery { - vote_poll: vote_poll.resolve(drive, transaction, platform_version)?, + vote_poll: vote_poll.resolve_allow_borrowed(drive, transaction, platform_version)?, contestant_id: *contestant_id, offset: *offset, limit: *limit, @@ -230,7 +229,7 @@ impl ContestedDocumentVotePollVotesDriveQuery { #[derive(Debug, PartialEq, Clone)] pub struct ResolvedContestedDocumentVotePollVotesDriveQuery<'a> { /// What vote poll are we asking for? - pub vote_poll: ContestedDocumentResourceVotePollWithContractInfo<'a>, + pub vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed<'a>, /// Who's votes are we looking for pub contestant_id: Identifier, /// Offset @@ -251,7 +250,7 @@ impl<'a> ResolvedContestedDocumentVotePollVotesDriveQuery<'a> { ) -> Result { let mut path = self .vote_poll - .contender_voting_path(self.contestant_id, platform_version)?; + .contender_voting_path(TowardsIdentity(self.contestant_id), platform_version)?; let mut query = Query::new_with_direction(self.order_ascending); diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index f7220d3922..65b89cd1ef 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -1,7 +1,4 @@ use crate::drive::votes::paths::VotePollPaths; -use crate::drive::votes::resolve_contested_document_resource_vote_poll::{ - ContestedDocumentResourceVotePollResolver, ContestedDocumentResourceVotePollWithContractInfo, -}; use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::query::QuerySyntaxError; @@ -14,6 +11,8 @@ use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDoc use grovedb::query_result_type::{QueryResultElements, QueryResultType}; use grovedb::{Element, PathQuery, SizedQuery, TransactionArg}; use platform_version::version::PlatformVersion; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; /// Represents the types of results that can be obtained from a contested document vote poll query. /// @@ -127,7 +126,7 @@ impl ContestedDocumentVotePollDriveQuery { order_ascending, } = self; Ok(ResolvedContestedDocumentVotePollDriveQuery { - vote_poll: vote_poll.resolve(drive, transaction, platform_version)?, + vote_poll: vote_poll.resolve_allow_borrowed(drive, transaction, platform_version)?, result_type: *result_type, offset: *offset, limit: *limit, @@ -400,7 +399,7 @@ impl ContestedDocumentVotePollDriveQuery { #[derive(Debug, PartialEq, Clone)] pub struct ResolvedContestedDocumentVotePollDriveQuery<'a> { /// What vote poll are we asking for? - pub vote_poll: ContestedDocumentResourceVotePollWithContractInfo<'a>, + pub vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed<'a>, /// What result type are we interested in pub result_type: ContestedDocumentVotePollDriveQueryResultType, /// Offset diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs index f0f27144d7..0c6d6cc058 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs @@ -7,7 +7,7 @@ use crate::state_transition_action::identity::masternode_vote::v0::MasternodeVot use derive_more::From; use dpp::platform_value::Identifier; use dpp::prelude::IdentityNonce; -use dpp::voting::votes::Vote; +use crate::drive::votes::resolved::votes::ResolvedVote; /// action #[derive(Debug, Clone, From)] @@ -25,14 +25,14 @@ impl MasternodeVoteTransitionAction { } /// Resource votes - pub fn vote_ref(&self) -> &Vote { + pub fn vote_ref(&self) -> &ResolvedVote { match self { MasternodeVoteTransitionAction::V0(transition) => &transition.vote, } } /// Resource votes as owned - pub fn vote_owned(self) -> Vote { + pub fn vote_owned(self) -> ResolvedVote { match self { MasternodeVoteTransitionAction::V0(transition) => transition.vote, } diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs index f7fd9ea9d2..e43c2f75eb 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs @@ -1,19 +1,45 @@ +use grovedb::TransactionArg; use crate::state_transition_action::identity::masternode_vote::v0::MasternodeVoteTransitionActionV0; use crate::state_transition_action::identity::masternode_vote::MasternodeVoteTransitionAction; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; +use platform_version::version::PlatformVersion; +use crate::drive::Drive; +use crate::error::Error; -impl From for MasternodeVoteTransitionAction { - fn from(value: MasternodeVoteTransition) -> Self { +impl MasternodeVoteTransitionAction { + /// Transforms an owned `MasternodeVoteTransition` into a `MasternodeVoteTransitionAction`. + /// + /// # Parameters + /// + /// - `value`: The owned `MasternodeVoteTransition` to transform. + /// - `drive`: A reference to the `Drive` instance. + /// - `transaction`: The transaction argument. + /// - `platform_version`: A reference to the platform version. + /// + /// # Returns + /// + /// A `Result` containing the transformed `MasternodeVoteTransitionAction`, or an `Error` if the transformation fails. + pub fn transform_from_owned_transition(value: MasternodeVoteTransition, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { match value { - MasternodeVoteTransition::V0(v0) => MasternodeVoteTransitionActionV0::from(v0).into(), + MasternodeVoteTransition::V0(v0) => Ok(MasternodeVoteTransitionActionV0::transform_from_owned_transition(v0, drive, transaction, platform_version)?.into()), } } -} -impl From<&MasternodeVoteTransition> for MasternodeVoteTransitionAction { - fn from(value: &MasternodeVoteTransition) -> Self { + /// Transforms a borrowed `MasternodeVoteTransition` into a `MasternodeVoteTransitionAction`. + /// + /// # Parameters + /// + /// - `value`: A reference to the `MasternodeVoteTransition` to transform. + /// - `drive`: A reference to the `Drive` instance. + /// - `transaction`: The transaction argument. + /// - `platform_version`: A reference to the platform version. + /// + /// # Returns + /// + /// A `Result` containing the transformed `MasternodeVoteTransitionAction`, or an `Error` if the transformation fails. + pub fn transform_from_transition(value: &MasternodeVoteTransition, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { match value { - MasternodeVoteTransition::V0(v0) => MasternodeVoteTransitionActionV0::from(v0).into(), + MasternodeVoteTransition::V0(v0) => Ok(MasternodeVoteTransitionActionV0::transform_from_transition(v0, drive, transaction, platform_version)?.into()), } } -} +} \ No newline at end of file diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs index 3658568838..a077bf153b 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs @@ -2,15 +2,15 @@ mod transformer; use dpp::platform_value::Identifier; use dpp::prelude::IdentityNonce; -use dpp::voting::votes::Vote; +use crate::drive::votes::resolved::votes::ResolvedVote; /// action v0 -#[derive(Default, Debug, Clone)] +#[derive(Debug, Clone)] pub struct MasternodeVoteTransitionActionV0 { /// the pro tx hash identifier of the masternode pub pro_tx_hash: Identifier, /// the resource votes - pub vote: Vote, + pub vote: ResolvedVote, /// nonce pub nonce: IdentityNonce, } diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs index 7fc1ca6774..31d3fdb9de 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs @@ -1,34 +1,39 @@ +use grovedb::TransactionArg; use crate::state_transition_action::identity::masternode_vote::v0::MasternodeVoteTransitionActionV0; use dpp::state_transition::state_transitions::identity::masternode_vote_transition::v0::MasternodeVoteTransitionV0; +use platform_version::version::PlatformVersion; +use crate::drive::Drive; +use crate::drive::votes::resolved::votes::resolve::VoteResolver; +use crate::error::Error; -impl From for MasternodeVoteTransitionActionV0 { - fn from(value: MasternodeVoteTransitionV0) -> Self { +impl MasternodeVoteTransitionActionV0 { + pub(crate) fn transform_from_owned_transition(value: MasternodeVoteTransitionV0, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { let MasternodeVoteTransitionV0 { pro_tx_hash, vote, nonce, .. } = value; - MasternodeVoteTransitionActionV0 { + let resolved_vote = vote.resolve_owned(drive, transaction, platform_version)?; + Ok(MasternodeVoteTransitionActionV0 { pro_tx_hash, - vote, + vote: resolved_vote, nonce, - } + }) } -} -impl From<&MasternodeVoteTransitionV0> for MasternodeVoteTransitionActionV0 { - fn from(value: &MasternodeVoteTransitionV0) -> Self { + pub(crate) fn transform_from_transition(value: &MasternodeVoteTransitionV0, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { let MasternodeVoteTransitionV0 { pro_tx_hash, vote, nonce, .. } = value; - MasternodeVoteTransitionActionV0 { + let resolved_vote = vote.resolve(drive, transaction, platform_version)?; + Ok(MasternodeVoteTransitionActionV0 { pro_tx_hash: *pro_tx_hash, - vote: vote.clone(), + vote: resolved_vote, nonce: *nonce, - } + }) } } From a8c9e5c7ad8a1b6d45edfcbb8dd11b2f7b92a244 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 21 May 2024 10:50:32 +0200 Subject: [PATCH 071/135] nit --- .../state_transition/state_transitions/masternode_vote/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 4fb8b7b89a..2ef819015f 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -114,7 +114,6 @@ mod tests { use super::*; use dpp::document::Document; use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; - use dpp::fee::Credits; use dpp::identifier::Identifier; use dpp::identity::{IdentityPublicKey, IdentityV0}; use dpp::prelude::{DataContract, Identity}; From afbf2f5268744af7c5db92f524cf01b24184e053 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 22 May 2024 02:27:49 +0200 Subject: [PATCH 072/135] more work --- .../protos/platform/v0/platform.proto | 52 ++++ .../proto/org.dash.platform.dapi.v0.rs | 247 ++++++++++++++++++ packages/rs-dpp/src/lib.rs | 2 + .../document_create_transition/v0/mod.rs | 23 +- .../state_transitions/masternode_vote/mod.rs | 10 + .../contested_resource_vote_state/v0/mod.rs | 4 +- .../mod.rs | 66 +++++ .../v0/mod.rs | 119 +++++++++ .../rs-drive-abci/src/query/voting/mod.rs | 1 + packages/rs-drive-proof-verifier/src/types.rs | 13 + packages/rs-drive/src/common/encode.rs | 37 ++- .../mod.rs | 6 +- .../v0/mod.rs | 12 +- .../verify_vote_poll_vote_state_proof/mod.rs | 4 +- .../v0/mod.rs | 18 +- packages/rs-drive/src/query/mod.rs | 2 + .../src/query/vote_poll_vote_state_query.rs | 34 ++- .../src/query/vote_polls_by_end_date_query.rs | 233 +++++++++++++++++ .../btreemap_removal_extensions.rs | 77 +++++- .../src/btreemap_extensions/mod.rs | 1 + .../src/version/drive_abci_versions.rs | 1 + packages/rs-sdk/src/platform/fetch.rs | 6 + packages/rs-sdk/src/platform/fetch_many.rs | 15 +- packages/rs-sdk/src/platform/query.rs | 23 +- packages/rs-sdk/src/platform/transition.rs | 1 + .../rs-sdk/src/platform/transition/vote.rs | 148 +++++++++++ 26 files changed, 1092 insertions(+), 63 deletions(-) create mode 100644 packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/mod.rs create mode 100644 packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/v0/mod.rs create mode 100644 packages/rs-drive/src/query/vote_polls_by_end_date_query.rs create mode 100644 packages/rs-sdk/src/platform/transition/vote.rs diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index f0c6970f1b..ed2a760594 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -42,6 +42,8 @@ service Platform { rpc getContestedResourceVotersForIdentity(GetContestedResourceVotersForIdentityRequest) returns (GetContestedResourceVotersForIdentityResponse); // How did an identity vote? rpc getContestedResourceIdentityVoteStatus(GetContestedResourceIdentityVoteStatusRequest) returns (GetContestedResourceIdentityVoteStatusResponse); + // What vote polls will end soon? + rpc getContestedResourcesByEndDate(GetContestedVotePollsByEndDateRequest) returns (GetContestedVotePollsByEndDateResponse); rpc getPrefundedSpecializedBalance(GetPrefundedSpecializedBalanceRequest) returns (GetPrefundedSpecializedBalanceResponse); rpc getPathElements(GetPathElementsRequest) returns (GetPathElementsResponse); } @@ -673,6 +675,56 @@ message GetContestedResourcesResponse { } } +message GetContestedVotePollsByEndDateRequest { + message GetContestedVotePollsByEndDateRequestV0 { + message StartAtTimeInfo { + uint64 start_time_ms = 1; + bool start_time_included = 2; + } + message EndAtTimeInfo { + uint64 end_time_ms = 1; + bool end_time_included = 2; + } + optional StartAtTimeInfo start_time_info = 1; + optional EndAtTimeInfo end_time_info = 2; + optional uint32 limit = 3; + bool ascending = 4; + bool prove = 5; + } + + oneof version { + GetContestedVotePollsByEndDateRequestV0 v0 = 1; + } +} + +message GetContestedVotePollsByEndDateResponse { + message GetContestedVotePollsByEndDateResponseV0 { + message ContestedVotePoll { + repeated bytes serialized_vote_polls = 1; + } + + message ContestedVotePollsByTimestamp { + uint64 timestamp = 1; + repeated ContestedVotePoll vote_polls = 2; + } + + message ContestedVotePollsByTimestamps { + repeated ContestedVotePollsByTimestamp contested_vote_polls_by_timestamps = 1; + bool finished_results = 2; + } + + oneof result { + ContestedVotePollsByTimestamps contested_vote_polls_by_timestamps = 1; + Proof proof = 2; + } + ResponseMetadata metadata = 3; + } + + oneof version { + GetContestedVotePollsByEndDateResponseV0 v0 = 1; + } +} + // What's the state of a contested resource vote? (ie who is winning?) message GetContestedResourceVoteStateRequest { message GetContestedResourceVoteStateRequestV0 { diff --git a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs index f1f7c3aef5..1b72ba0e67 100644 --- a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs +++ b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs @@ -2225,6 +2225,163 @@ pub mod get_contested_resources_response { V0(GetContestedResourcesResponseV0), } } +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(rename_all = "snake_case")] +#[derive(::dapi_grpc_macros::Mockable)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetContestedVotePollsByEndDateRequest { + #[prost(oneof = "get_contested_vote_polls_by_end_date_request::Version", tags = "1")] + pub version: ::core::option::Option< + get_contested_vote_polls_by_end_date_request::Version, + >, +} +/// Nested message and enum types in `GetContestedVotePollsByEndDateRequest`. +pub mod get_contested_vote_polls_by_end_date_request { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct GetContestedVotePollsByEndDateRequestV0 { + #[prost(message, optional, tag = "1")] + pub start_time_info: ::core::option::Option< + get_contested_vote_polls_by_end_date_request_v0::StartAtTimeInfo, + >, + #[prost(message, optional, tag = "2")] + pub end_time_info: ::core::option::Option< + get_contested_vote_polls_by_end_date_request_v0::EndAtTimeInfo, + >, + #[prost(uint32, optional, tag = "3")] + pub limit: ::core::option::Option, + #[prost(bool, tag = "4")] + pub ascending: bool, + #[prost(bool, tag = "5")] + pub prove: bool, + } + /// Nested message and enum types in `GetContestedVotePollsByEndDateRequestV0`. + pub mod get_contested_vote_polls_by_end_date_request_v0 { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct StartAtTimeInfo { + #[prost(uint64, tag = "1")] + pub start_time_ms: u64, + #[prost(bool, tag = "2")] + pub start_time_included: bool, + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct EndAtTimeInfo { + #[prost(uint64, tag = "1")] + pub end_time_ms: u64, + #[prost(bool, tag = "2")] + pub end_time_included: bool, + } + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Version { + #[prost(message, tag = "1")] + V0(GetContestedVotePollsByEndDateRequestV0), + } +} +#[derive(::serde::Serialize, ::serde::Deserialize)] +#[serde(rename_all = "snake_case")] +#[derive(::dapi_grpc_macros::Mockable)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetContestedVotePollsByEndDateResponse { + #[prost( + oneof = "get_contested_vote_polls_by_end_date_response::Version", + tags = "1" + )] + pub version: ::core::option::Option< + get_contested_vote_polls_by_end_date_response::Version, + >, +} +/// Nested message and enum types in `GetContestedVotePollsByEndDateResponse`. +pub mod get_contested_vote_polls_by_end_date_response { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct GetContestedVotePollsByEndDateResponseV0 { + #[prost(message, optional, tag = "3")] + pub metadata: ::core::option::Option, + #[prost( + oneof = "get_contested_vote_polls_by_end_date_response_v0::Result", + tags = "1, 2" + )] + pub result: ::core::option::Option< + get_contested_vote_polls_by_end_date_response_v0::Result, + >, + } + /// Nested message and enum types in `GetContestedVotePollsByEndDateResponseV0`. + pub mod get_contested_vote_polls_by_end_date_response_v0 { + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ContestedVotePoll { + #[prost(bytes = "vec", repeated, tag = "1")] + pub serialized_vote_polls: ::prost::alloc::vec::Vec< + ::prost::alloc::vec::Vec, + >, + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ContestedVotePollsByTimestamp { + #[prost(uint64, tag = "1")] + pub timestamp: u64, + #[prost(message, repeated, tag = "2")] + pub vote_polls: ::prost::alloc::vec::Vec, + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[derive(::dapi_grpc_macros::Mockable)] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ContestedVotePollsByTimestamps { + #[prost(message, repeated, tag = "1")] + pub contested_vote_polls_by_timestamps: ::prost::alloc::vec::Vec< + ContestedVotePollsByTimestamp, + >, + #[prost(bool, tag = "2")] + pub finished_results: bool, + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Result { + #[prost(message, tag = "1")] + ContestedVotePollsByTimestamps(ContestedVotePollsByTimestamps), + #[prost(message, tag = "2")] + Proof(super::super::Proof), + } + } + #[derive(::serde::Serialize, ::serde::Deserialize)] + #[serde(rename_all = "snake_case")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Version { + #[prost(message, tag = "1")] + V0(GetContestedVotePollsByEndDateResponseV0), + } +} /// What's the state of a contested resource vote? (ie who is winning?) #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] @@ -3653,6 +3810,39 @@ pub mod platform_client { ); self.inner.unary(req, path, codec).await } + /// What vote polls will end soon? + pub async fn get_contested_resources_by_end_date( + &mut self, + request: impl tonic::IntoRequest< + super::GetContestedVotePollsByEndDateRequest, + >, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/org.dash.platform.dapi.v0.Platform/getContestedResourcesByEndDate", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "org.dash.platform.dapi.v0.Platform", + "getContestedResourcesByEndDate", + ), + ); + self.inner.unary(req, path, codec).await + } pub async fn get_prefunded_specialized_balance( &mut self, request: impl tonic::IntoRequest< @@ -3889,6 +4079,14 @@ pub mod platform_server { tonic::Response, tonic::Status, >; + /// What vote polls will end soon? + async fn get_contested_resources_by_end_date( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_prefunded_specialized_balance( &self, request: tonic::Request, @@ -5082,6 +5280,55 @@ pub mod platform_server { }; Box::pin(fut) } + "/org.dash.platform.dapi.v0.Platform/getContestedResourcesByEndDate" => { + #[allow(non_camel_case_types)] + struct getContestedResourcesByEndDateSvc(pub Arc); + impl< + T: Platform, + > tonic::server::UnaryService< + super::GetContestedVotePollsByEndDateRequest, + > for getContestedResourcesByEndDateSvc { + type Response = super::GetContestedVotePollsByEndDateResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + super::GetContestedVotePollsByEndDateRequest, + >, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + (*inner).get_contested_resources_by_end_date(request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = getContestedResourcesByEndDateSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } "/org.dash.platform.dapi.v0.Platform/getPrefundedSpecializedBalance" => { #[allow(non_camel_case_types)] struct getPrefundedSpecializedBalanceSvc(pub Arc); diff --git a/packages/rs-dpp/src/lib.rs b/packages/rs-dpp/src/lib.rs index 4701daa126..2c14ea5a1e 100644 --- a/packages/rs-dpp/src/lib.rs +++ b/packages/rs-dpp/src/lib.rs @@ -72,6 +72,8 @@ pub mod prelude { pub type CoreBlockHeight = u32; pub type TimestampMillis = u64; + + pub type TimestampIncluded = bool; pub type Revision = u64; pub type IdentityNonce = u64; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs index ce84f01d27..bea69b8082 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs @@ -31,6 +31,7 @@ use crate::state_transition::documents_batch_transition::document_base_transitio use crate::state_transition::documents_batch_transition::document_base_transition::v0::DocumentTransitionObjectLike; use crate::state_transition::documents_batch_transition::document_base_transition::DocumentBaseTransition; use derive_more::Display; +use platform_value::btreemap_extensions::BTreeValueRemoveTupleFromMapHelper; use platform_version::version::PlatformVersion; #[cfg(feature = "state-transition-value-conversion")] @@ -38,7 +39,7 @@ use crate::state_transition::documents_batch_transition; mod property_names { pub const ENTROPY: &str = "$entropy"; - pub const PREFUNDED_VOTING_BALANCES: &str = "$prefundedVotingBalances"; + pub const PREFUNDED_VOTING_BALANCE: &str = "$prefundedVotingBalance"; } /// The Binary fields in [`DocumentCreateTransition`] @@ -70,7 +71,7 @@ pub struct DocumentCreateTransitionV0 { #[cfg_attr( feature = "state-transition-serde-conversion", - serde(rename = "$prefundedVotingBalances") + serde(rename = "$prefundedVotingBalance") )] /// Pre funded balance (for unique index conflict resolution voting - the identity will put money /// aside that will be used by voters to vote) @@ -98,8 +99,7 @@ impl DocumentCreateTransitionV0 { .remove_hash256_bytes(property_names::ENTROPY) .map_err(ProtocolError::ValueError)?, prefunded_voting_balance: map - .remove_optional_map_as_btree_map(property_names::PREFUNDED_VOTING_BALANCES)? - .unwrap_or_default(), + .remove_optional_tuple(property_names::PREFUNDED_VOTING_BALANCE)?, data: map, }) } @@ -112,12 +112,15 @@ impl DocumentCreateTransitionV0 { Value::Bytes(self.entropy.to_vec()), ); - transition_base_map.insert( - property_names::PREFUNDED_VOTING_BALANCES.to_string(), - Value::Map(ValueMap::from_btree_map( - self.prefunded_voting_balance.clone(), - )), - ); + if let Some((index_name, prefunded_voting_balance)) = &self.prefunded_voting_balance { + let index_name_value = Value::Text(index_name.clone()); + let prefunded_voting_balance_value = Value::U64(*prefunded_voting_balance); + transition_base_map.insert( + property_names::PREFUNDED_VOTING_BALANCE.to_string(), + Value::Array(vec![index_name_value, prefunded_voting_balance_value]), + ); + } + transition_base_map.extend(self.data.clone()); diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 2ef819015f..78c71c5af4 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -130,6 +130,7 @@ mod tests { use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::{ContestedDocumentResourceVotePollWithContractInfo, ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed}; use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; use drive::query::vote_poll_vote_state_query::ResolvedContestedDocumentVotePollDriveQuery; + use drive::query::VotePollsByEndDateDriveQuery; use simple_signer::signer::SimpleSigner; use crate::platform_types::platform_state::PlatformState; use crate::rpc::core::MockCoreRPCLike; @@ -888,6 +889,15 @@ mod tests { assert_eq!(first_contender.vote_tally, Some(1)); assert_eq!(second_contender.vote_tally, Some(0)); + + let vote_polls_by_end_date_query = VotePollsByEndDateDriveQuery { + start_time: None, + end_time: None, + limit: None, + order_ascending: true, + }; + + vote_polls_by_end_date_query.execute_no_proof() } } } diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs index 0f3b09a390..3c8a3d9272 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs @@ -15,7 +15,7 @@ use dpp::version::PlatformVersion; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::{check_validation_result_with_data, platform_value}; use drive::error::query::QuerySyntaxError; -use drive::query::vote_poll_vote_state_query::{Contender, ContestedDocumentVotePollDriveQuery}; +use drive::query::vote_poll_vote_state_query::{ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQuery}; impl Platform { pub(super) fn query_contested_resource_vote_state_v0( @@ -177,7 +177,7 @@ impl Platform { .contenders .into_iter() .map( - |Contender { + |ContenderWithSerializedDocument { identity_id, serialized_document, vote_tally, diff --git a/packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/mod.rs new file mode 100644 index 0000000000..9b6eef6837 --- /dev/null +++ b/packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/mod.rs @@ -0,0 +1,66 @@ +use crate::error::query::QueryError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::PlatformState; +use crate::query::QueryValidationResult; +use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::Version as RequestVersion; +use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::Version as ResponseVersion; +use dapi_grpc::platform::v0::{GetContestedVotePollsByEndDateRequest, GetContestedVotePollsByEndDateResponse}; +use dpp::version::PlatformVersion; + +mod v0; + +impl Platform { + /// Querying of the contested vote polls by a query targeting the end date + /// This is for querying what votes are ending soon, but can be for other time based queries + pub fn query_contested_vote_polls_by_end_date_query( + &self, + GetContestedVotePollsByEndDateRequest { version }: GetContestedVotePollsByEndDateRequest, + platform_state: &PlatformState, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let Some(version) = version else { + return Ok(QueryValidationResult::new_with_error( + QueryError::DecodingError( + "could not decode contested vote polls by end date query".to_string(), + ), + )); + }; + + let feature_version_bounds = &platform_version + .drive_abci + .query + .voting_based_queries + .contested_vote_polls_by_end_date_query; + + let feature_version = match &version { + RequestVersion::V0(_) => 0, + }; + if !feature_version_bounds.check_version(feature_version) { + return Ok(QueryValidationResult::new_with_error( + QueryError::UnsupportedQueryVersion( + "contested_vote_polls_by_end_date_query".to_string(), + feature_version_bounds.min_version, + feature_version_bounds.max_version, + platform_version.protocol_version, + feature_version, + ), + )); + } + match version { + RequestVersion::V0(request_v0) => { + let result = self.query_contested_vote_polls_by_end_date_query_v0( + request_v0, + platform_state, + platform_version, + )?; + + Ok( + result.map(|response_v0| GetContestedVotePollsByEndDateResponse { + version: Some(ResponseVersion::V0(response_v0)), + }), + ) + } + } + } +} diff --git a/packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/v0/mod.rs new file mode 100644 index 0000000000..825301299b --- /dev/null +++ b/packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/v0/mod.rs @@ -0,0 +1,119 @@ +use crate::error::query::QueryError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::PlatformState; +use crate::query::QueryValidationResult; +use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{ + get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0, +}; +use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_request::GetContestedVotePollsByEndDateRequestV0; +use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_response::{get_contested_vote_polls_by_end_date_response_v0, GetContestedVotePollsByEndDateResponseV0}; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::version::PlatformVersion; + +use drive::error::query::QuerySyntaxError; +use drive::query::vote_poll_vote_state_query::{ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQuery}; +use drive::query::VotePollsByEndDateDriveQuery; + +impl Platform { + pub(super) fn query_contested_vote_polls_by_end_date_query_v0( + &self, + GetContestedVotePollsByEndDateRequestV0 { + start_time_info, end_time_info, limit, ascending, prove + }: GetContestedVotePollsByEndDateRequestV0, + platform_state: &PlatformState, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let config = &self.config.drive; + + let start_time = start_time_info.map(|start_time_info| (start_time_info.start_time_ms, start_time_info.start_time_included)); + + let end_time = end_time_info.map(|end_time_info| (end_time_info.end_time_ms, end_time_info.end_time_included)); + + let limit = limit + .map_or(Some(config.default_query_limit), |limit_value| { + if limit_value == 0 + || limit_value > u16::MAX as u32 + || limit_value as u16 > config.default_query_limit + { + None + } else { + Some(limit_value as u16) + } + }) + .ok_or(drive::error::Error::Query(QuerySyntaxError::InvalidLimit( + format!("limit greater than max limit {}", config.max_query_limit), + )))?; + + let query = VotePollsByEndDateDriveQuery { + start_time, + limit: Some(limit), + order_ascending: ascending, + end_time, + }; + + let response = if prove { + let proof = match query.execute_with_proof(&self.drive, None, None, platform_version) { + Ok(result) => result.0, + Err(drive::error::Error::Query(query_error)) => { + return Ok(QueryValidationResult::new_with_error(QueryError::Query( + query_error, + ))); + } + Err(e) => return Err(e.into()), + }; + + GetContestedVotePollsByEndDateResponseV0 { + result: Some( + get_contested_vote_polls_by_end_date_response_v0::Result::Proof( + self.response_proof_v0(platform_state, proof), + ), + ), + metadata: Some(self.response_metadata_v0(platform_state)), + } + } else { + let results = + match query.execute_no_proof(&self.drive, None, &mut vec![], platform_version) { + Ok(result) => result, + Err(drive::error::Error::Query(query_error)) => { + return Ok(QueryValidationResult::new_with_error(QueryError::Query( + query_error, + ))); + } + Err(e) => return Err(e.into()), + }; + + let contenders = results + .contenders + .into_iter() + .map( + |ContenderWithSerializedDocument { + identity_id, + serialized_document, + vote_tally, + }| { + get_contested_resource_vote_state_response_v0::Contender { + identifier: identity_id.to_vec(), + vote_count: vote_tally, + document: serialized_document, + } + }, + ) + .collect(); + + GetContestedVotePollsByEndDateResponseV0 { + result: Some( + get_contested_vote_polls_by_end_date_response_v0::Result::ContestedVotePollsByTimestamps( + get_contested_vote_polls_by_end_date_response_v0::ContestedVotePollsByTimestamps { + contested_vote_polls_by_timestamps: vec![], + finished_results: false, + }, + ), + ), + metadata: Some(self.response_metadata_v0(platform_state)), + } + }; + + Ok(QueryValidationResult::new_with_data(response)) + } +} diff --git a/packages/rs-drive-abci/src/query/voting/mod.rs b/packages/rs-drive-abci/src/query/voting/mod.rs index e9aa1a2376..25c34322d0 100644 --- a/packages/rs-drive-abci/src/query/voting/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/mod.rs @@ -2,3 +2,4 @@ mod contested_resource_identity_vote_status; mod contested_resource_vote_state; mod contested_resource_voters_for_identity; mod contested_resources; +mod contested_vote_polls_by_end_date_query; diff --git a/packages/rs-drive-proof-verifier/src/types.rs b/packages/rs-drive-proof-verifier/src/types.rs index 592ccd7997..7798c6dd5a 100644 --- a/packages/rs-drive-proof-verifier/src/types.rs +++ b/packages/rs-drive-proof-verifier/src/types.rs @@ -17,7 +17,11 @@ use dpp::{ prelude::{DataContract, Identifier, IdentityPublicKey, Revision}, util::deserializer::ProtocolVersion, }; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::voting::votes::resource_vote::ResourceVote; use drive::grovedb::Element; +use drive::query::vote_poll_vote_state_query::Contender; /// A data structure that holds a set of objects of a generic type `O`, indexed by a key of type `K`. /// @@ -45,6 +49,12 @@ pub type DataContractHistory = BTreeMap; /// If data contract is not found, it is represented as `None`. pub type DataContracts = RetrievedObjects; +/// Multiple contenders for a vote resolution. +/// +/// Mapping between the contenders identity IDs and their info. +/// If a contender is not found, it is represented as `None`. +pub type Contenders = RetrievedObjects; + /// Multiple grovedb elements. /// /// Mapping between the key id and associated elements. @@ -56,6 +66,9 @@ pub type IdentityBalance = u64; /// Identity balance and revision of the identity. pub type IdentityBalanceAndRevision = (u64, Revision); +/// A contested vote for querying +pub type ContestedVote = (ContestedDocumentResourceVotePoll, ResourceVoteChoice); + /// An identity nonce #[derive(Debug)] pub struct IdentityNonceFetcher(pub IdentityNonce); diff --git a/packages/rs-drive/src/common/encode.rs b/packages/rs-drive/src/common/encode.rs index db5f5156f7..0a38989be2 100644 --- a/packages/rs-drive/src/common/encode.rs +++ b/packages/rs-drive/src/common/encode.rs @@ -32,7 +32,9 @@ //! This module defines encoding functions. //! -use byteorder::{BigEndian, WriteBytesExt}; +use byteorder::{BigEndian, ByteOrder, WriteBytesExt}; +use crate::error::drive::DriveError; +use crate::error::Error; /// Encodes an unsigned integer on 64 bits. pub fn encode_u64(val: u64) -> Vec { @@ -60,6 +62,39 @@ pub fn encode_u64(val: u64) -> Vec { wtr } +/// Decodes a 64-bit unsigned integer from a vector of bytes encoded with `encode_u64`. +/// +/// # Arguments +/// +/// * `bytes` - A vector of bytes representing the encoded 64-bit unsigned integer. +/// +/// # Returns +/// +/// * A 64-bit unsigned integer decoded from the input bytes. +/// +/// # Panics +/// +/// This function will panic if the input vector does not have exactly 8 bytes. +pub fn decode_u64(bytes: Vec) -> Result { + // Ensure the input vector has exactly 8 bytes + if bytes.len() != 8 { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!("Trying to decode a u64 from {} bytes {}", bytes.len(), hex::encode(bytes))))); + } + + // Clone the input vector to modify it + let mut wtr = bytes; + + // Flip the sign bit back to its original state + // This reverses the transformation done in `encode_u64` + wtr[0] ^= 0b1000_0000; + + // Read the integer from the modified bytes + // The bytes are in big endian form, which preserves the correct order + // when they were written in the encode function + Ok(BigEndian::read_u64(&wtr)) +} + + /// Encodes a signed integer on 64 bits. pub fn encode_i64(val: i64) -> Vec { // Positive integers are represented in binary with the signed bit set to 0 diff --git a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs index 0ffd932534..8d082a1cb8 100644 --- a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs +++ b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs @@ -8,7 +8,7 @@ use grovedb::TransactionArg; mod v0; -use crate::query::vote_poll_vote_state_query::{Contender, ContestedDocumentVotePollDriveQuery}; +use crate::query::vote_poll_vote_state_query::{ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQuery}; pub use v0::*; /// Represents the outcome of a query to retrieve documents. @@ -26,13 +26,13 @@ pub enum QueryContestedDocumentsVoteStateOutcome { } impl QueryContestedDocumentsVoteStateOutcomeV0Methods for QueryContestedDocumentsVoteStateOutcome { - fn contenders(&self) -> &Vec { + fn contenders(&self) -> &Vec { match self { QueryContestedDocumentsVoteStateOutcome::V0(outcome) => outcome.contenders(), } } - fn contenders_owned(self) -> Vec { + fn contenders_owned(self) -> Vec { match self { QueryContestedDocumentsVoteStateOutcome::V0(outcome) => outcome.contenders_owned(), } diff --git a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs index f8cb9cdea8..8d7134eadd 100644 --- a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs @@ -1,7 +1,7 @@ use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; -use crate::query::vote_poll_vote_state_query::{Contender, ContestedDocumentVotePollDriveQuery}; +use crate::query::vote_poll_vote_state_query::{ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQuery}; use dpp::block::epoch::Epoch; use dpp::version::PlatformVersion; use grovedb::TransactionArg; @@ -9,7 +9,7 @@ use grovedb::TransactionArg; /// The outcome of a query #[derive(Debug, Default)] pub struct QueryContestedDocumentsVoteStateOutcomeV0 { - contenders: Vec, + contenders: Vec, cost: u64, } @@ -21,9 +21,9 @@ pub struct QueryContestedDocumentsVoteStateOutcomeV0 { /// of the query. pub trait QueryContestedDocumentsVoteStateOutcomeV0Methods { /// Returns a reference to the contenders found from the query. - fn contenders(&self) -> &Vec; + fn contenders(&self) -> &Vec; /// Consumes the instance to return the owned contenders. - fn contenders_owned(self) -> Vec; + fn contenders_owned(self) -> Vec; /// Returns the processing cost associated with the query. fn cost(&self) -> u64; } @@ -31,11 +31,11 @@ pub trait QueryContestedDocumentsVoteStateOutcomeV0Methods { impl QueryContestedDocumentsVoteStateOutcomeV0Methods for QueryContestedDocumentsVoteStateOutcomeV0 { - fn contenders(&self) -> &Vec { + fn contenders(&self) -> &Vec { &self.contenders } - fn contenders_owned(self) -> Vec { + fn contenders_owned(self) -> Vec { self.contenders } diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/mod.rs index 321f9063c4..ea03d1e5be 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/mod.rs @@ -6,7 +6,7 @@ use crate::error::drive::DriveError; use crate::error::Error; use crate::query::vote_poll_vote_state_query::{ - Contender, ResolvedContestedDocumentVotePollDriveQuery, + ContenderWithSerializedDocument, ResolvedContestedDocumentVotePollDriveQuery, }; use dpp::version::PlatformVersion; @@ -36,7 +36,7 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { &self, proof: &[u8], platform_version: &PlatformVersion, - ) -> Result<(RootHash, Vec), Error> { + ) -> Result<(RootHash, Vec), Error> { match platform_version .drive .methods diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs index c54a65edd5..27483b8072 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs @@ -6,7 +6,7 @@ use crate::error::Error; use crate::error::drive::DriveError; use crate::query::vote_poll_vote_state_query::{ - Contender, ContestedDocumentVotePollDriveQueryResultType, + ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQueryResultType, ResolvedContestedDocumentVotePollDriveQuery, }; use dpp::version::PlatformVersion; @@ -38,26 +38,26 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { &self, proof: &[u8], platform_version: &PlatformVersion, - ) -> Result<(RootHash, Vec), Error> { + ) -> Result<(RootHash, Vec), Error> { let path_query = self.construct_path_query(platform_version)?; let (root_hash, proved_key_values) = GroveDb::verify_query(proof, &path_query)?; let contenders = match self.result_type { ContestedDocumentVotePollDriveQueryResultType::IdentityIdsOnly => { - proved_key_values.into_iter().map(|(_,identity_id, _)| Ok(Contender { + proved_key_values.into_iter().map(|(_,identity_id, _)| Ok(ContenderWithSerializedDocument { identity_id: Identifier::try_from(identity_id)?, serialized_document: None, vote_tally: None, - })).collect::, Error>>() + })).collect::, Error>>() } ContestedDocumentVotePollDriveQueryResultType::Documents => { proved_key_values.into_iter().map(|(_, identity_id, document)| { - Ok(Contender { + Ok(ContenderWithSerializedDocument { identity_id: Identifier::try_from(identity_id)?, serialized_document: document.map(|document| document.into_item_bytes()).transpose()?, vote_tally: None, }) - }).collect::, Error>>() + }).collect::, Error>>() } ContestedDocumentVotePollDriveQueryResultType::VoteTally => { proved_key_values.into_iter().map(|(_, identity_id, vote_tally)| { @@ -65,12 +65,12 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { return Err(Error::Drive(DriveError::CorruptedDriveState(format!("sum tree value for vote tally must be between 0 and u32::Max, received {} from state", sum_tree_value)))); } - Ok(Contender { + Ok(ContenderWithSerializedDocument { identity_id: Identifier::try_from(identity_id)?, serialized_document: None, vote_tally: Some(sum_tree_value as u32), }) - }).collect::, Error>>() + }).collect::, Error>>() } ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally => { let mut elements_iter = proved_key_values.into_iter(); @@ -90,7 +90,7 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { return Err(Error::Drive(DriveError::CorruptedDriveState(format!("sum tree value for vote tally must be between 0 and u32::Max, received {} from state", sum_tree_value)))); } - let contender = Contender { + let contender = ContenderWithSerializedDocument { identity_id, serialized_document: Some(serialized_document), vote_tally: Some(sum_tree_value as u32), diff --git a/packages/rs-drive/src/query/mod.rs b/packages/rs-drive/src/query/mod.rs index ba8f87c251..ae8207e7e7 100644 --- a/packages/rs-drive/src/query/mod.rs +++ b/packages/rs-drive/src/query/mod.rs @@ -5,6 +5,7 @@ pub use { ordering::OrderClause, single_document_drive_query::SingleDocumentDriveQuery, single_document_drive_query::SingleDocumentDriveQueryContestedStatus, + vote_polls_by_end_date_query::VotePollsByEndDateDriveQuery, vote_query::IdentityBasedVoteDriveQuery, }; // Imports available when either "server" or "verify" features are enabled @@ -84,6 +85,7 @@ pub mod vote_query; #[cfg(any(feature = "server", feature = "verify"))] /// Vote poll contestant votes query module pub mod vote_poll_contestant_votes_query; +mod vote_polls_by_end_date_query; #[cfg(any(feature = "server", feature = "verify"))] /// Internal clauses struct diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index 65b89cd1ef..82627816df 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -10,6 +10,7 @@ use dpp::identifier::Identifier; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use grovedb::query_result_type::{QueryResultElements, QueryResultType}; use grovedb::{Element, PathQuery, SizedQuery, TransactionArg}; +use dpp::document::Document; use platform_version::version::PlatformVersion; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; @@ -65,11 +66,12 @@ pub struct ContestedDocumentVotePollDriveQuery { } /// Represents a contender in the contested document vote poll. +/// This is for internal use where the document is in serialized form /// /// This struct holds the identity ID of the contender, the serialized document, /// and the vote tally. #[derive(Debug, PartialEq, Eq, Clone, Default)] -pub struct Contender { +pub struct ContenderWithSerializedDocument { /// The identity ID of the contender. pub identity_id: Identifier, /// The serialized document associated with the contender. @@ -78,6 +80,20 @@ pub struct Contender { pub vote_tally: Option, } +/// Represents a contender in the contested document vote poll. +/// +/// This struct holds the identity ID of the contender, the serialized document, +/// and the vote tally. +#[derive(Debug, PartialEq, Clone, Default)] +pub struct Contender { + /// The identity ID of the contender. + pub identity_id: Identifier, + /// The serialized document associated with the contender. + pub serialized_document: Option, + /// The vote tally for the contender. + pub vote_tally: Option, +} + /// Represents the result of executing a contested document vote poll drive query. /// /// This struct holds the list of contenders and the number of skipped items @@ -85,7 +101,7 @@ pub struct Contender { #[derive(Debug, PartialEq, Eq, Clone, Default)] pub struct ContestedDocumentVotePollDriveQueryExecutionResult { /// The list of contenders returned by the query. - pub contenders: Vec, + pub contenders: Vec, /// The number of skipped items when an offset is given. pub skipped: u16, } @@ -293,20 +309,20 @@ impl ContestedDocumentVotePollDriveQuery { Ok((query_result_elements, skipped)) => { let contenders = match self.result_type { ContestedDocumentVotePollDriveQueryResultType::IdentityIdsOnly => { - query_result_elements.to_keys().into_iter().map(|identity_id| Ok(Contender { + query_result_elements.to_keys().into_iter().map(|identity_id| Ok(ContenderWithSerializedDocument { identity_id: Identifier::try_from(identity_id)?, serialized_document: None, vote_tally: None, - })).collect::, Error>>() + })).collect::, Error>>() } ContestedDocumentVotePollDriveQueryResultType::Documents => { query_result_elements.to_key_elements().into_iter().map(|(identity_id, document)| { - Ok(Contender { + Ok(ContenderWithSerializedDocument { identity_id: Identifier::try_from(identity_id)?, serialized_document: Some(document.into_item_bytes()?), vote_tally: None, }) - }).collect::, Error>>() + }).collect::, Error>>() } ContestedDocumentVotePollDriveQueryResultType::VoteTally => { query_result_elements.to_key_elements().into_iter().map(|(identity_id, vote_tally)| { @@ -314,12 +330,12 @@ impl ContestedDocumentVotePollDriveQuery { if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { return Err(Error::Drive(DriveError::CorruptedDriveState(format!("sum tree value for vote tally must be between 0 and u32::Max, received {} from state", sum_tree_value)))); } - Ok(Contender { + Ok(ContenderWithSerializedDocument { identity_id: Identifier::try_from(identity_id)?, serialized_document: None, vote_tally: Some(sum_tree_value as u32), }) - }).collect::, Error>>() + }).collect::, Error>>() } ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally => { let mut elements_iter = query_result_elements.to_path_key_elements().into_iter(); @@ -339,7 +355,7 @@ impl ContestedDocumentVotePollDriveQuery { return Err(Error::Drive(DriveError::CorruptedDriveState(format!("sum tree value for vote tally must be between 0 and u32::Max, received {} from state", sum_tree_value)))); } - let contender = Contender { + let contender = ContenderWithSerializedDocument { identity_id, serialized_document: Some(serialized_document), vote_tally: Some(sum_tree_value as u32), diff --git a/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs b/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs new file mode 100644 index 0000000000..dc490e0609 --- /dev/null +++ b/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs @@ -0,0 +1,233 @@ +use std::collections::BTreeMap; +use grovedb::query_result_type::{QueryResultElements, QueryResultType}; +use grovedb::{PathQuery, SizedQuery, TransactionArg}; +use dpp::block::block_info::BlockInfo; +use dpp::data_contract::document_type::DocumentPropertyType; +use dpp::fee::Credits; +use dpp::prelude::{TimestampIncluded, TimestampMillis}; +use dpp::serialization::PlatformDeserializable; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use platform_version::version::PlatformVersion; +use crate::common::encode::{decode_u64, encode_u64}; +use crate::drive::Drive; +use crate::drive::votes::paths::{vote_contested_resource_end_date_queries_tree_path_vec}; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use crate::query::{GroveError, Query}; + +/// Vote Poll Drive Query struct +#[derive(Debug, PartialEq, Clone)] +pub struct VotePollsByEndDateDriveQuery { + /// What is the start time we are asking for + pub start_time: Option<(TimestampMillis, TimestampIncluded)>, + /// What vote poll are we asking for? + pub end_time: Option<(TimestampMillis, TimestampIncluded)>, + /// Limit + pub limit: Option, + /// Ascending + pub order_ascending: bool, +} + + +impl VotePollsByEndDateDriveQuery { + /// Operations to construct a path query. + pub fn construct_path_query( + &self, + ) -> PathQuery{ + let path = vote_contested_resource_end_date_queries_tree_path_vec(); + + let mut query = Query::new_with_direction(self.order_ascending); + + // this is a range on all elements + match &(self.start_time, self.end_time) { + (None, None) => { + query.insert_all(); + } + (Some((starts_at_key_bytes, start_at_included)), None) => { + let starts_at_key = DocumentPropertyType::encode_u64(*starts_at_key_bytes); + match start_at_included { + true => query.insert_range_from(starts_at_key..), + false => query.insert_range_after(starts_at_key..), + } + } + (None, Some((ends_at_key_bytes, ends_at_included))) => { + let ends_at_key = DocumentPropertyType::encode_u64(*ends_at_key_bytes); + match ends_at_included { + true => query.insert_range_to_inclusive(..=ends_at_key), + false => query.insert_range_to(..ends_at_key), + } + } + (Some((starts_at_key_bytes, start_at_included)), Some((ends_at_key_bytes, ends_at_included))) => { + let starts_at_key = encode_u64(*starts_at_key_bytes); + let ends_at_key = encode_u64(*ends_at_key_bytes); + match (start_at_included, ends_at_included) { + (true, true) => query.insert_range_inclusive(starts_at_key..=ends_at_key), + (true, false) => query.insert_range(starts_at_key..ends_at_key), + (false, true) => query.insert_range_after_to_inclusive(starts_at_key..=ends_at_key), + (false, false) => query.insert_range_after_to(starts_at_key..ends_at_key), + } + } + } + + PathQuery { + path, + query: SizedQuery { + query, + limit: self.limit, + offset: None, + }, + } + } + #[cfg(feature = "server")] + /// Executes a query with proof and returns the items and fee. + pub fn execute_with_proof( + self, + drive: &Drive, + block_info: Option, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(Vec, u64), Error> { + let mut drive_operations = vec![]; + let items = self.execute_with_proof_internal( + drive, + transaction, + &mut drive_operations, + platform_version, + )?; + let cost = if let Some(block_info) = block_info { + let fee_result = Drive::calculate_fee( + None, + Some(drive_operations), + &block_info.epoch, + drive.config.epochs_per_era, + platform_version, + )?; + fee_result.processing_fee + } else { + 0 + }; + Ok((items, cost)) + } + + #[cfg(feature = "server")] + /// Executes an internal query with proof and returns the items. + pub(crate) fn execute_with_proof_internal( + self, + drive: &Drive, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let path_query = self.construct_path_query(); + drive.grove_get_proved_path_query( + &path_query, + false, + transaction, + drive_operations, + &platform_version.drive, + ) + } + #[cfg(feature = "server")] + /// Executes a query with no proof and returns the items, skipped items, and fee. + pub fn execute_no_proof_with_cost( + &self, + drive: &Drive, + block_info: Option, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(BTreeMap>, Credits), Error> { + let mut drive_operations = vec![]; + let result = + self.execute_no_proof(drive, transaction, &mut drive_operations, platform_version)?; + let cost = if let Some(block_info) = block_info { + let fee_result = Drive::calculate_fee( + None, + Some(drive_operations), + &block_info.epoch, + drive.config.epochs_per_era, + platform_version, + )?; + fee_result.processing_fee + } else { + 0 + }; + Ok((result, cost)) + } + + #[cfg(feature = "server")] + /// Executes an internal query with no proof and returns the values and skipped items. + pub fn execute_no_proof( + &self, + drive: &Drive, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result>, Error> { + let path_query = self.construct_path_query(); + let query_result = drive.grove_get_path_query( + &path_query, + transaction, + QueryResultType::QueryPathKeyElementTrioResultType, + drive_operations, + &platform_version.drive, + ); + match query_result { + Err(Error::GroveDB(GroveError::PathKeyNotFound(_))) + | Err(Error::GroveDB(GroveError::PathNotFound(_))) + | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => { + Ok(BTreeMap::new()) + } + Err(e) => Err(e), + Ok((query_result_elements, _)) => { + let vote_polls_by_end_date = query_result_elements.to_key_elements().into_iter() + .map(|(key, element)| { + let timestamp = decode_u64(key).map_err(Error::from)?; + let contested_document_resource_vote_poll_bytes = element.into_item_bytes().map_err(Error::from)?; + let vote_poll = ContestedDocumentResourceVotePoll::deserialize_from_bytes(&contested_document_resource_vote_poll_bytes)?; + Ok((timestamp, vote_poll)) + }) + .collect::, Error>>()? + .into_iter() + .fold(BTreeMap::new(), |mut acc: BTreeMap>, (timestamp, vote_poll)| { + acc.entry(timestamp).or_default().push(vote_poll); + acc + }); + Ok(vote_polls_by_end_date) + } + } + } + + #[cfg(feature = "server")] + #[allow(unused)] + /// Executes an internal query with no proof and returns the values and skipped items. + pub(crate) fn execute_no_proof_internal( + &self, + drive: &Drive, + result_type: QueryResultType, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result { + let path_query = self.construct_path_query(); + let query_result = drive.grove_get_path_query( + &path_query, + transaction, + result_type, + drive_operations, + &platform_version.drive, + ); + match query_result { + Err(Error::GroveDB(GroveError::PathKeyNotFound(_))) + | Err(Error::GroveDB(GroveError::PathNotFound(_))) + | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => { + Ok(QueryResultElements::new()) + } + _ => { + let (data, _) = query_result?; + { + Ok(data) + } + } + } + } +} \ No newline at end of file diff --git a/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_extensions.rs b/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_extensions.rs index a65c4b3923..d59c44a91d 100644 --- a/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_extensions.rs +++ b/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_extensions.rs @@ -61,6 +61,20 @@ pub trait BTreeValueRemoveFromMapHelper { V: TryFrom; } +pub trait BTreeValueRemoveTupleFromMapHelper { + fn remove_tuple(&mut self, key: &str) -> Result<(K, V), Error> + where + K: TryFrom + Ord, + V: TryFrom; + fn remove_optional_tuple( + &mut self, + key: &str, + ) -> Result, Error> + where + K: TryFrom + Ord, + V: TryFrom; +} + impl BTreeValueRemoveFromMapHelper for BTreeMap { fn remove_optional_string(&mut self, key: &str) -> Result, Error> { self.remove(key) @@ -368,8 +382,8 @@ impl BTreeValueRemoveFromMapHelper for BTreeMap { } fn remove_optional_integer(&mut self, key: &str) -> Result, Error> - where - T: TryFrom + where + T: TryFrom + TryFrom + TryFrom + TryFrom @@ -392,8 +406,8 @@ impl BTreeValueRemoveFromMapHelper for BTreeMap { } fn remove_integer(&mut self, key: &str) -> Result - where - T: TryFrom + where + T: TryFrom + TryFrom + TryFrom + TryFrom @@ -578,9 +592,9 @@ impl BTreeValueRemoveFromMapHelper for BTreeMap { } fn remove_map_as_btree_map(&mut self, key: &str) -> Result, Error> - where - K: TryFrom + Ord, - V: TryFrom, + where + K: TryFrom + Ord, + V: TryFrom, { self.remove_optional_map_as_btree_map(key)? .ok_or_else(|| Error::StructureError(format!("unable to remove map property {key}"))) @@ -590,9 +604,9 @@ impl BTreeValueRemoveFromMapHelper for BTreeMap { &mut self, key: &str, ) -> Result>, Error> - where - K: TryFrom + Ord, - V: TryFrom, + where + K: TryFrom + Ord, + V: TryFrom, { self.remove(key) .and_then(|v| { @@ -611,3 +625,46 @@ impl BTreeValueRemoveFromMapHelper for BTreeMap { .transpose() } } + +impl BTreeValueRemoveTupleFromMapHelper for BTreeMap { + fn remove_tuple(&mut self, key: &str) -> Result<(K, V), Error> + where + K: TryFrom + Ord, + V: TryFrom, + { + self.remove_optional_tuple(key)? + .ok_or_else(|| Error::StructureError(format!("unable to remove tuple property {key}"))) + } + + fn remove_optional_tuple( + &mut self, + key: &str, + ) -> Result, Error> + where + K: TryFrom + Ord, + V: TryFrom, + { + self.remove(key) + .and_then(|v| { + if v.is_null() { + None + } else if let Value::Array(mut arr) = v { + if arr.len() == 2 { + let key_value = match arr.remove(0).try_into() { + Ok(key_value) => key_value, + Err(e) => return Some(Err(e)), + }; + let value_value: V = match arr.remove(1).try_into() { + Ok(key_value) => key_value, + Err(e) => return Some(Err(e)), + }; + Some(Ok((key_value, value_value))) + } else { + Some(Err(Error::StructureError(format!("Value for key {key} is not a tuple of length 2")))) + } + } else { + Some(Err(Error::StructureError(format!("Value for key {key} is not an array")))) + } + }).transpose() + } +} diff --git a/packages/rs-platform-value/src/btreemap_extensions/mod.rs b/packages/rs-platform-value/src/btreemap_extensions/mod.rs index 4ec94ce7a7..1f84c53d03 100644 --- a/packages/rs-platform-value/src/btreemap_extensions/mod.rs +++ b/packages/rs-platform-value/src/btreemap_extensions/mod.rs @@ -21,6 +21,7 @@ pub use btreemap_mut_value_extensions::BTreeMutValueMapHelper; pub use btreemap_path_extensions::BTreeValueMapPathHelper; pub use btreemap_path_insertion_extensions::BTreeValueMapInsertionPathHelper; pub use btreemap_removal_extensions::BTreeValueRemoveFromMapHelper; +pub use btreemap_removal_extensions::BTreeValueRemoveTupleFromMapHelper; pub use btreemap_removal_inner_value_extensions::BTreeValueRemoveInnerValueFromMapHelper; pub trait BTreeValueMapHelper { diff --git a/packages/rs-platform-version/src/version/drive_abci_versions.rs b/packages/rs-platform-version/src/version/drive_abci_versions.rs index 6c7f3fb381..27a30e4f2b 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions.rs @@ -40,6 +40,7 @@ pub struct DriveAbciQueryIdentityVersions { #[derive(Clone, Debug, Default)] pub struct DriveAbciQueryVotingVersions { + pub contested_vote_polls_by_end_date_query: FeatureVersionBounds, pub contested_resource_vote_state: FeatureVersionBounds, pub contested_resource_voters_for_identity: FeatureVersionBounds, pub contested_resource_identity_vote_status: FeatureVersionBounds, diff --git a/packages/rs-sdk/src/platform/fetch.rs b/packages/rs-sdk/src/platform/fetch.rs index 70266354d2..2b440967d1 100644 --- a/packages/rs-sdk/src/platform/fetch.rs +++ b/packages/rs-sdk/src/platform/fetch.rs @@ -17,6 +17,8 @@ use dpp::{document::Document, prelude::Identity}; use drive_proof_verifier::FromProof; use rs_dapi_client::{transport::TransportRequest, DapiRequest, RequestSettings}; use std::fmt::Debug; +use dpp::voting::votes::Vote; +use drive_proof_verifier::types::ContestedVote; use super::types::identity::IdentityRequest; use super::DocumentQuery; @@ -226,3 +228,7 @@ impl Fetch for drive_proof_verifier::types::DataContractHistory { impl Fetch for ExtendedEpochInfo { type Request = platform_proto::GetEpochsInfoRequest; } + +impl Fetch for ContestedVote { + type Request = platform_proto::GetContestedResourceIdentityVoteStatusRequest; +} diff --git a/packages/rs-sdk/src/platform/fetch_many.rs b/packages/rs-sdk/src/platform/fetch_many.rs index 674ccc8fa7..99942f94a9 100644 --- a/packages/rs-sdk/src/platform/fetch_many.rs +++ b/packages/rs-sdk/src/platform/fetch_many.rs @@ -11,11 +11,7 @@ use crate::{ platform::{document_query::DocumentQuery, query::Query}, Sdk, }; -use dapi_grpc::platform::v0::{ - GetDataContractsRequest, GetDocumentsResponse, GetEpochsInfoRequest, - GetIdentitiesContractKeysRequest, GetIdentityKeysRequest, - GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeVoteStatusRequest, -}; +use dapi_grpc::platform::v0::{GetContestedResourceVoteStateRequest, GetDataContractsRequest, GetDocumentsResponse, GetEpochsInfoRequest, GetIdentitiesContractKeysRequest, GetIdentityKeysRequest, GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeVoteStatusRequest}; use dashcore_rpc::dashcore::ProTxHash; use dpp::block::epoch::EpochIndex; use dpp::block::extended_epoch_info::ExtendedEpochInfo; @@ -29,6 +25,8 @@ use drive_proof_verifier::types::{MasternodeProtocolVote, RetrievedObjects}; use drive_proof_verifier::{types::Documents, FromProof}; use rs_dapi_client::{transport::TransportRequest, DapiRequest, RequestSettings}; use std::collections::BTreeMap; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use drive::query::vote_poll_vote_state_query::Contender; use super::LimitQuery; @@ -309,3 +307,10 @@ impl FetchMany for MasternodeProtocolVote { impl FetchMany for DataContract { type Request = GetDataContractsRequest; } + +/// Fetch multiple contenders for a contested document resource vote poll. +/// +/// Returns [Contender](drive_proof_verifier::types::Contenders) indexed by [Identifier](dpp::prelude::Identifier). +impl FetchMany for Contender { + type Request = GetContestedResourceVoteStateRequest; +} diff --git a/packages/rs-sdk/src/platform/query.rs b/packages/rs-sdk/src/platform/query.rs index aa946feed0..9881dc2f89 100644 --- a/packages/rs-sdk/src/platform/query.rs +++ b/packages/rs-sdk/src/platform/query.rs @@ -4,11 +4,7 @@ use std::fmt::Debug; use dapi_grpc::mock::Mockable; -use dapi_grpc::platform::v0::{ - self as proto, get_identity_keys_request, get_identity_keys_request::GetIdentityKeysRequestV0, - AllKeys, GetEpochsInfoRequest, GetIdentityKeysRequest, GetProtocolVersionUpgradeStateRequest, - GetProtocolVersionUpgradeVoteStatusRequest, KeyRequestType, -}; +use dapi_grpc::platform::v0::{self as proto, get_identity_keys_request, get_identity_keys_request::GetIdentityKeysRequestV0, AllKeys, GetEpochsInfoRequest, GetIdentityKeysRequest, GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeVoteStatusRequest, KeyRequestType, GetContestedResourceVoteStateRequest}; use dashcore_rpc::dashcore::{hashes::Hash, ProTxHash}; use dpp::{block::epoch::EpochIndex, prelude::Identifier}; use drive::query::DriveQuery; @@ -168,6 +164,12 @@ impl<'a> Query for DriveQuery<'a> { } } +#[derive(Debug, Clone)] +pub struct QueryStartInfo { + pub start_key: Vec, + pub start_included: bool, +} + /// Wrapper around query that allows to specify limit. /// /// A query that can be used specify limit when fetching multiple objects from the platform @@ -184,6 +186,7 @@ impl<'a> Query for DriveQuery<'a> { /// let sdk = Sdk::new_mock(); /// let query = LimitQuery { /// query: 1, +/// start_info: None, /// limit: Some(10), /// }; /// let epoch = ExtendedEpochInfo::fetch_many(&sdk, query); @@ -192,13 +195,15 @@ impl<'a> Query for DriveQuery<'a> { pub struct LimitQuery { /// Actual query to execute pub query: Q, + /// Start info + pub start_info: Option, /// Max number of records returned pub limit: Option, } impl From for LimitQuery { fn from(query: Q) -> Self { - Self { query, limit: None } + Self { query, start_info: None, limit: None } } } @@ -225,6 +230,7 @@ impl Query for EpochIndex { fn query(self, prove: bool) -> Result { LimitQuery { query: self, + start_info: None, limit: Some(1), } .query(prove) @@ -275,8 +281,13 @@ impl Query for LimitQuery fn query(self, prove: bool) -> Result { LimitQuery { query: Some(self.query), + start_info: None, limit: self.limit, } .query(prove) } } + +impl Query for LimitQuery<> { + +} diff --git a/packages/rs-sdk/src/platform/transition.rs b/packages/rs-sdk/src/platform/transition.rs index 985c730b05..bbe0df5085 100644 --- a/packages/rs-sdk/src/platform/transition.rs +++ b/packages/rs-sdk/src/platform/transition.rs @@ -13,6 +13,7 @@ pub mod transfer_document; mod txid; mod update_price_of_document; pub mod withdraw_from_identity; +mod vote; pub use context::*; diff --git a/packages/rs-sdk/src/platform/transition/vote.rs b/packages/rs-sdk/src/platform/transition/vote.rs new file mode 100644 index 0000000000..5bde9d96bb --- /dev/null +++ b/packages/rs-sdk/src/platform/transition/vote.rs @@ -0,0 +1,148 @@ +use crate::platform::transition::broadcast_request::BroadcastRequestForStateTransition; +use crate::platform::Fetch; +use crate::{Error, Sdk}; + +use dapi_grpc::platform::VersionedGrpcResponse; +use dpp::identity::IdentityPublicKey; +use dpp::identity::signer::Signer; +use dpp::prelude::Identifier; +use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; +use dpp::state_transition::masternode_vote_transition::methods::MasternodeVoteTransitionMethodsV0; + +use crate::platform::block_info_from_metadata::block_info_from_metadata; +use dpp::state_transition::proof_result::StateTransitionProofResult; +use dpp::voting::votes::Vote; +use drive::drive::Drive; +use rs_dapi_client::DapiRequest; +use crate::platform::transition::put_settings::PutSettings; + +#[async_trait::async_trait] +/// A trait for putting a vote on platform +pub trait PutVote { + /// Puts an identity on platform + async fn put_to_platform( + &self, + voter_pro_tx_hash: Identifier, + voting_public_key: &IdentityPublicKey, + sdk: &Sdk, + signer: &S, + settings: Option, + ) -> Result<(), Error>; + /// Puts an identity on platform and waits for the confirmation proof + async fn put_to_platform_and_wait_for_response( + &self, + voter_pro_tx_hash: Identifier, + voting_public_key: &IdentityPublicKey, + sdk: &Sdk, + signer: &S, + settings: Option, + ) -> Result; +} + +#[async_trait::async_trait] +impl PutVote for Vote { + async fn put_to_platform( + &self, + voter_pro_tx_hash: Identifier, + voting_public_key: &IdentityPublicKey, + sdk: &Sdk, + signer: &S, + settings: Option, + ) -> Result<(), Error> { + let new_masternode_voting_nonce = sdk + .get_identity_nonce( + voter_pro_tx_hash, + true, + settings, + ) + .await?; + + let settings = settings.unwrap_or_default(); + + let masternode_vote_transition = MasternodeVoteTransition::try_from_vote_with_signer( + self.clone(), + signer, + voter_pro_tx_hash, + voting_public_key, + new_masternode_voting_nonce, + sdk.version(), + None, + )?; + let request = masternode_vote_transition.broadcast_request_for_state_transition()?; + + request.execute(sdk, settings.request_settings) + .await?; + + Ok(()) + } + + async fn put_to_platform_and_wait_for_response( + &self, + voter_pro_tx_hash: Identifier, + voting_public_key: &IdentityPublicKey, + sdk: &Sdk, + signer: &S, + settings: Option, + ) -> Result { + let new_masternode_voting_nonce = sdk + .get_identity_nonce( + voter_pro_tx_hash, + true, + settings, + ) + .await?; + + let settings = settings.unwrap_or_default(); + + let masternode_vote_transition = MasternodeVoteTransition::try_from_vote_with_signer( + self.clone(), + signer, + voter_pro_tx_hash, + voting_public_key, + new_masternode_voting_nonce, + sdk.version(), + None, + )?; + let request = masternode_vote_transition.broadcast_request_for_state_transition()?; + + + let response_result = request + .execute(sdk, settings.request_settings) + .await; + + match response_result { + Ok(_) => {} + //todo make this more reliable + Err(e) => { + if e.to_string().contains("already exists") { + let vote = Vote::fetch(sdk, voter_pro_tx_hash).await?; + return vote.ok_or(Error::DapiClientError( + "vote was proved to not exist but was said to exist".to_string(), + )); + } + } + } + + let request = masternode_vote_transition.wait_for_state_transition_result_request()?; + + let response = request.execute(sdk, settings.request_settings).await?; + + let block_info = block_info_from_metadata(response.metadata()?)?; + let proof = response.proof_owned()?; + + let (_, result) = Drive::verify_state_transition_was_executed_with_proof( + &masternode_vote_transition, + &block_info, + proof.grovedb_proof.as_slice(), + &|_| Ok(None), + sdk.version(), + )?; + + //todo verify + + match result { + StateTransitionProofResult::VerifiedMasternodeVote(vote) => Ok(vote), + _ => Err(Error::DapiClientError("proved something that was not a vote".to_string())), + } + } +} From 56b888b961a02162f28a81f5a20db321bcd1bc19 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 22 May 2024 11:22:09 +0200 Subject: [PATCH 073/135] query working --- packages/dapi-grpc/build.rs | 16 +- .../protos/platform/v0/platform.proto | 21 ++- .../proto/org.dash.platform.dapi.v0.rs | 91 +++++++---- .../document_create_transition/v0/mod.rs | 1 - .../state_transitions/masternode_vote/mod.rs | 68 ++++++-- .../masternode_vote/state/v0/mod.rs | 8 +- packages/rs-drive-abci/src/query/service.rs | 42 +++-- .../contested_resource_vote_state/v0/mod.rs | 4 +- .../mod.rs | 8 +- .../v0/mod.rs | 153 ++++++++++++------ packages/rs-drive-proof-verifier/src/types.rs | 6 +- packages/rs-drive/src/common/encode.rs | 9 +- .../drive/batch/drive_op_batch/identity.rs | 2 +- .../mod.rs | 4 +- .../v0/mod.rs | 4 +- .../drive/object_size_info/contract_info.rs | 17 +- .../mod.rs | 2 +- .../v0/mod.rs | 20 ++- .../insert/register_identity_vote/mod.rs | 2 +- .../insert/register_identity_vote/v0/mod.rs | 6 +- packages/rs-drive/src/drive/votes/paths.rs | 6 +- .../rs-drive/src/drive/votes/resolved/mod.rs | 5 +- .../mod.rs | 46 ++++-- .../resolve.rs | 41 +++-- .../drive/votes/resolved/vote_polls/mod.rs | 22 +-- .../votes/resolved/vote_polls/resolve.rs | 54 +++++-- .../src/drive/votes/resolved/votes/mod.rs | 12 +- .../src/drive/votes/resolved/votes/resolve.rs | 38 +++-- .../resolved_resource_vote/accessors/mod.rs | 2 +- .../accessors/v0/mod.rs | 2 +- .../votes/resolved_resource_vote/mod.rs | 2 +- .../votes/resolved_resource_vote/resolve.rs | 38 +++-- .../votes/resolved_resource_vote/v0/mod.rs | 4 +- .../resolved_resource_vote/v0/resolve.rs | 34 ++-- packages/rs-drive/src/error/query.rs | 4 + .../query/vote_poll_contestant_votes_query.rs | 6 +- .../src/query/vote_poll_vote_state_query.rs | 6 +- .../src/query/vote_polls_by_end_date_query.rs | 128 +++++++++++---- .../identity/masternode_vote/mod.rs | 2 +- .../identity/masternode_vote/transformer.rs | 44 +++-- .../identity/masternode_vote/v0/mod.rs | 2 +- .../masternode_vote/v0/transformer.rs | 22 ++- .../btreemap_removal_extensions.rs | 65 ++++---- .../src/version/mocks/v2_test.rs | 5 + .../src/version/mocks/v3_test.rs | 5 + .../rs-platform-version/src/version/v1.rs | 5 + packages/rs-sdk/src/platform/fetch.rs | 4 +- packages/rs-sdk/src/platform/fetch_many.rs | 10 +- packages/rs-sdk/src/platform/query.rs | 17 +- packages/rs-sdk/src/platform/transition.rs | 2 +- .../rs-sdk/src/platform/transition/vote.rs | 36 ++--- 51 files changed, 785 insertions(+), 368 deletions(-) diff --git a/packages/dapi-grpc/build.rs b/packages/dapi-grpc/build.rs index c339c5f496..1161f2463a 100644 --- a/packages/dapi-grpc/build.rs +++ b/packages/dapi-grpc/build.rs @@ -39,7 +39,7 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig { // Derive features for versioned messages // // "GetConsensusParamsRequest" is excluded as this message does not support proofs - const VERSIONED_REQUESTS: [&str; 19] = [ + const VERSIONED_REQUESTS: [&str; 25] = [ "GetDataContractHistoryRequest", "GetDataContractRequest", "GetDataContractsRequest", @@ -59,10 +59,16 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig { "GetProtocolVersionUpgradeVoteStatusRequest", "GetPathElementsRequest", "GetIdentitiesContractKeysRequest", + "GetPrefundedSpecializedBalanceRequest", + "GetContestedResourcesRequest", + "GetContestedResourceVoteStateRequest", + "GetContestedResourceVotersForIdentityRequest", + "GetContestedResourceIdentityVoteStatusRequest", + "GetContestedVotePollsByEndDateRequest", ]; // "GetConsensusParamsResponse" is excluded as this message does not support proofs - const VERSIONED_RESPONSES: [&str; 20] = [ + const VERSIONED_RESPONSES: [&str; 26] = [ "GetDataContractHistoryResponse", "GetDataContractResponse", "GetDataContractsResponse", @@ -83,6 +89,12 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig { "GetProtocolVersionUpgradeVoteStatusResponse", "GetPathElementsResponse", "GetIdentitiesContractKeysResponse", + "GetPrefundedSpecializedBalanceResponse", + "GetContestedResourcesResponse", + "GetContestedResourceVoteStateResponse", + "GetContestedResourceVotersForIdentityResponse", + "GetContestedResourceIdentityVoteStatusResponse", + "GetContestedVotePollsByEndDateResponse", ]; // Derive VersionedGrpcMessage on requests diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index ed2a760594..c5e1b52f60 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -43,7 +43,7 @@ service Platform { // How did an identity vote? rpc getContestedResourceIdentityVoteStatus(GetContestedResourceIdentityVoteStatusRequest) returns (GetContestedResourceIdentityVoteStatusResponse); // What vote polls will end soon? - rpc getContestedResourcesByEndDate(GetContestedVotePollsByEndDateRequest) returns (GetContestedVotePollsByEndDateResponse); + rpc getContestedVotePollsByEndDate(GetContestedVotePollsByEndDateRequest) returns (GetContestedVotePollsByEndDateResponse); rpc getPrefundedSpecializedBalance(GetPrefundedSpecializedBalanceRequest) returns (GetPrefundedSpecializedBalanceResponse); rpc getPathElements(GetPathElementsRequest) returns (GetPathElementsResponse); } @@ -688,8 +688,9 @@ message GetContestedVotePollsByEndDateRequest { optional StartAtTimeInfo start_time_info = 1; optional EndAtTimeInfo end_time_info = 2; optional uint32 limit = 3; - bool ascending = 4; - bool prove = 5; + optional uint32 offset = 4; + bool ascending = 5; + bool prove = 6; } oneof version { @@ -699,22 +700,18 @@ message GetContestedVotePollsByEndDateRequest { message GetContestedVotePollsByEndDateResponse { message GetContestedVotePollsByEndDateResponseV0 { - message ContestedVotePoll { - repeated bytes serialized_vote_polls = 1; - } - - message ContestedVotePollsByTimestamp { + message SerializedContestedVotePollsByTimestamp { uint64 timestamp = 1; - repeated ContestedVotePoll vote_polls = 2; + repeated bytes serialized_contested_vote_polls = 2; } - message ContestedVotePollsByTimestamps { - repeated ContestedVotePollsByTimestamp contested_vote_polls_by_timestamps = 1; + message SerializedContestedVotePollsByTimestamps { + repeated SerializedContestedVotePollsByTimestamp contested_vote_polls_by_timestamps = 1; bool finished_results = 2; } oneof result { - ContestedVotePollsByTimestamps contested_vote_polls_by_timestamps = 1; + SerializedContestedVotePollsByTimestamps contested_vote_polls_by_timestamps = 1; Proof proof = 2; } ResponseMetadata metadata = 3; diff --git a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs index 1b72ba0e67..b323c4b979 100644 --- a/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs +++ b/packages/dapi-grpc/src/platform/proto/org.dash.platform.dapi.v0.rs @@ -2124,6 +2124,8 @@ pub mod get_epochs_info_response { } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] +#[derive(::dapi_grpc_macros::VersionedGrpcMessage)] +#[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2163,6 +2165,11 @@ pub mod get_contested_resources_request { } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] +#[derive( + ::dapi_grpc_macros::VersionedGrpcMessage, + ::dapi_grpc_macros::VersionedGrpcResponse +)] +#[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2227,6 +2234,8 @@ pub mod get_contested_resources_response { } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] +#[derive(::dapi_grpc_macros::VersionedGrpcMessage)] +#[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2254,9 +2263,11 @@ pub mod get_contested_vote_polls_by_end_date_request { >, #[prost(uint32, optional, tag = "3")] pub limit: ::core::option::Option, - #[prost(bool, tag = "4")] - pub ascending: bool, + #[prost(uint32, optional, tag = "4")] + pub offset: ::core::option::Option, #[prost(bool, tag = "5")] + pub ascending: bool, + #[prost(bool, tag = "6")] pub prove: bool, } /// Nested message and enum types in `GetContestedVotePollsByEndDateRequestV0`. @@ -2295,6 +2306,11 @@ pub mod get_contested_vote_polls_by_end_date_request { } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] +#[derive( + ::dapi_grpc_macros::VersionedGrpcMessage, + ::dapi_grpc_macros::VersionedGrpcResponse +)] +#[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2332,32 +2348,23 @@ pub mod get_contested_vote_polls_by_end_date_response { #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] - pub struct ContestedVotePoll { - #[prost(bytes = "vec", repeated, tag = "1")] - pub serialized_vote_polls: ::prost::alloc::vec::Vec< - ::prost::alloc::vec::Vec, - >, - } - #[derive(::serde::Serialize, ::serde::Deserialize)] - #[serde(rename_all = "snake_case")] - #[derive(::dapi_grpc_macros::Mockable)] - #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct ContestedVotePollsByTimestamp { + pub struct SerializedContestedVotePollsByTimestamp { #[prost(uint64, tag = "1")] pub timestamp: u64, - #[prost(message, repeated, tag = "2")] - pub vote_polls: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", repeated, tag = "2")] + pub serialized_contested_vote_polls: ::prost::alloc::vec::Vec< + ::prost::alloc::vec::Vec, + >, } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] - pub struct ContestedVotePollsByTimestamps { + pub struct SerializedContestedVotePollsByTimestamps { #[prost(message, repeated, tag = "1")] pub contested_vote_polls_by_timestamps: ::prost::alloc::vec::Vec< - ContestedVotePollsByTimestamp, + SerializedContestedVotePollsByTimestamp, >, #[prost(bool, tag = "2")] pub finished_results: bool, @@ -2368,7 +2375,7 @@ pub mod get_contested_vote_polls_by_end_date_response { #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Result { #[prost(message, tag = "1")] - ContestedVotePollsByTimestamps(ContestedVotePollsByTimestamps), + ContestedVotePollsByTimestamps(SerializedContestedVotePollsByTimestamps), #[prost(message, tag = "2")] Proof(super::super::Proof), } @@ -2385,6 +2392,8 @@ pub mod get_contested_vote_polls_by_end_date_response { /// What's the state of a contested resource vote? (ie who is winning?) #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] +#[derive(::dapi_grpc_macros::VersionedGrpcMessage)] +#[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2495,6 +2504,11 @@ pub mod get_contested_resource_vote_state_request { } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] +#[derive( + ::dapi_grpc_macros::VersionedGrpcMessage, + ::dapi_grpc_macros::VersionedGrpcResponse +)] +#[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2569,6 +2583,8 @@ pub mod get_contested_resource_vote_state_response { /// Who voted for a contested resource to go to a specific identity? #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] +#[derive(::dapi_grpc_macros::VersionedGrpcMessage)] +#[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2635,6 +2651,11 @@ pub mod get_contested_resource_voters_for_identity_request { } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] +#[derive( + ::dapi_grpc_macros::VersionedGrpcMessage, + ::dapi_grpc_macros::VersionedGrpcResponse +)] +#[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2701,6 +2722,8 @@ pub mod get_contested_resource_voters_for_identity_response { /// How did an identity vote? #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] +#[derive(::dapi_grpc_macros::VersionedGrpcMessage)] +#[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2745,6 +2768,11 @@ pub mod get_contested_resource_identity_vote_status_request { } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] +#[derive( + ::dapi_grpc_macros::VersionedGrpcMessage, + ::dapi_grpc_macros::VersionedGrpcResponse +)] +#[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2819,6 +2847,8 @@ pub mod get_contested_resource_identity_vote_status_response { } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] +#[derive(::dapi_grpc_macros::VersionedGrpcMessage)] +#[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -2853,6 +2883,11 @@ pub mod get_prefunded_specialized_balance_request { } #[derive(::serde::Serialize, ::serde::Deserialize)] #[serde(rename_all = "snake_case")] +#[derive( + ::dapi_grpc_macros::VersionedGrpcMessage, + ::dapi_grpc_macros::VersionedGrpcResponse +)] +#[grpc_versions(0)] #[derive(::dapi_grpc_macros::Mockable)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -3811,7 +3846,7 @@ pub mod platform_client { self.inner.unary(req, path, codec).await } /// What vote polls will end soon? - pub async fn get_contested_resources_by_end_date( + pub async fn get_contested_vote_polls_by_end_date( &mut self, request: impl tonic::IntoRequest< super::GetContestedVotePollsByEndDateRequest, @@ -3831,14 +3866,14 @@ pub mod platform_client { })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( - "/org.dash.platform.dapi.v0.Platform/getContestedResourcesByEndDate", + "/org.dash.platform.dapi.v0.Platform/getContestedVotePollsByEndDate", ); let mut req = request.into_request(); req.extensions_mut() .insert( GrpcMethod::new( "org.dash.platform.dapi.v0.Platform", - "getContestedResourcesByEndDate", + "getContestedVotePollsByEndDate", ), ); self.inner.unary(req, path, codec).await @@ -4080,7 +4115,7 @@ pub mod platform_server { tonic::Status, >; /// What vote polls will end soon? - async fn get_contested_resources_by_end_date( + async fn get_contested_vote_polls_by_end_date( &self, request: tonic::Request, ) -> std::result::Result< @@ -5280,14 +5315,14 @@ pub mod platform_server { }; Box::pin(fut) } - "/org.dash.platform.dapi.v0.Platform/getContestedResourcesByEndDate" => { + "/org.dash.platform.dapi.v0.Platform/getContestedVotePollsByEndDate" => { #[allow(non_camel_case_types)] - struct getContestedResourcesByEndDateSvc(pub Arc); + struct getContestedVotePollsByEndDateSvc(pub Arc); impl< T: Platform, > tonic::server::UnaryService< super::GetContestedVotePollsByEndDateRequest, - > for getContestedResourcesByEndDateSvc { + > for getContestedVotePollsByEndDateSvc { type Response = super::GetContestedVotePollsByEndDateResponse; type Future = BoxFuture< tonic::Response, @@ -5301,7 +5336,7 @@ pub mod platform_server { ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - (*inner).get_contested_resources_by_end_date(request).await + (*inner).get_contested_vote_polls_by_end_date(request).await }; Box::pin(fut) } @@ -5313,7 +5348,7 @@ pub mod platform_server { let inner = self.inner.clone(); let fut = async move { let inner = inner.0; - let method = getContestedResourcesByEndDateSvc(inner); + let method = getContestedVotePollsByEndDateSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) .apply_compression_config( diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs index bea69b8082..3eee8c3afd 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs @@ -121,7 +121,6 @@ impl DocumentCreateTransitionV0 { ); } - transition_base_map.extend(self.data.clone()); Ok(transition_base_map) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 78c71c5af4..ec5cfcf799 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -107,10 +107,12 @@ mod tests { use std::sync::Arc; use arc_swap::Guard; use rand::Rng; - use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse}; + use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, get_contested_vote_polls_by_end_date_request, get_contested_vote_polls_by_end_date_response, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetContestedVotePollsByEndDateRequest, GetContestedVotePollsByEndDateResponse}; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0::ResultType; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::GetContestedResourceVoteStateRequestV0; use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; + use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_request::GetContestedVotePollsByEndDateRequestV0; + use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_response::{get_contested_vote_polls_by_end_date_response_v0, GetContestedVotePollsByEndDateResponseV0}; use super::*; use dpp::document::Document; use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; @@ -752,9 +754,9 @@ mod tests { }, ), ) = result - else { - panic!("expected contenders") - }; + else { + panic!("expected contenders") + }; assert_eq!(contenders.len(), 2); @@ -771,7 +773,7 @@ mod tests { domain, platform_version, ) - .expect("expected to get document"); + .expect("expected to get document"); let second_contender_document = Document::from_bytes( second_contender @@ -782,7 +784,7 @@ mod tests { domain, platform_version, ) - .expect("expected to get document"); + .expect("expected to get document"); assert_ne!(first_contender_document, second_contender_document); @@ -826,9 +828,9 @@ mod tests { ) = version.expect("expected a version"); let Some(get_contested_resource_vote_state_response_v0::Result::Proof(proof)) = result - else { - panic!("expected contenders") - }; + else { + panic!("expected contenders") + }; let resolved_contested_document_vote_poll_drive_query = ResolvedContestedDocumentVotePollDriveQuery { @@ -867,7 +869,7 @@ mod tests { domain, platform_version, ) - .expect("expected to get document"); + .expect("expected to get document"); let second_contender_document = Document::from_bytes( second_contender @@ -878,7 +880,7 @@ mod tests { domain, platform_version, ) - .expect("expected to get document"); + .expect("expected to get document"); assert_ne!(first_contender_document, second_contender_document); @@ -894,10 +896,50 @@ mod tests { start_time: None, end_time: None, limit: None, + offset: None, order_ascending: true, }; - - vote_polls_by_end_date_query.execute_no_proof() + + let GetContestedVotePollsByEndDateResponse { version } = platform + .query_contested_vote_polls_by_end_date_query( + GetContestedVotePollsByEndDateRequest { + version: Some(get_contested_vote_polls_by_end_date_request::Version::V0( + GetContestedVotePollsByEndDateRequestV0 { + start_time_info: None, + end_time_info: None, + limit: None, + offset: None, + ascending: false, + prove: false, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_vote_polls_by_end_date_response::Version::V0( + GetContestedVotePollsByEndDateResponseV0 { + metadata: _, + result, + }, + ) = version.expect("expected a version"); + + let Some( + get_contested_vote_polls_by_end_date_response_v0::Result::ContestedVotePollsByTimestamps( + get_contested_vote_polls_by_end_date_response_v0::SerializedContestedVotePollsByTimestamps { + contested_vote_polls_by_timestamps, finished_results + }, + ), + ) = result + else { + panic!("expected contenders") + }; + + assert_eq!(finished_results, true); } } } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs index 48a87a1f84..55d5a5444b 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs @@ -44,7 +44,13 @@ impl MasternodeVoteStateTransitionStateValidationV0 for MasternodeVoteTransition platform_version: &PlatformVersion, ) -> Result, Error> { Ok(ConsensusValidationResult::new_with_data( - MasternodeVoteTransitionAction::transform_from_transition(self, platform.drive, tx, platform_version)?.into(), + MasternodeVoteTransitionAction::transform_from_transition( + self, + platform.drive, + tx, + platform_version, + )? + .into(), )) } } diff --git a/packages/rs-drive-abci/src/query/service.rs b/packages/rs-drive-abci/src/query/service.rs index fbf4c8cf52..87be95260d 100644 --- a/packages/rs-drive-abci/src/query/service.rs +++ b/packages/rs-drive-abci/src/query/service.rs @@ -14,20 +14,22 @@ use dapi_grpc::platform::v0::{ GetContestedResourceIdentityVoteStatusResponse, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse, GetContestedResourcesRequest, - GetContestedResourcesResponse, GetDataContractHistoryRequest, GetDataContractHistoryResponse, - GetDataContractRequest, GetDataContractResponse, GetDataContractsRequest, - GetDataContractsResponse, GetDocumentsRequest, GetDocumentsResponse, GetEpochsInfoRequest, - GetEpochsInfoResponse, GetIdentitiesContractKeysRequest, GetIdentitiesContractKeysResponse, - GetIdentityBalanceAndRevisionRequest, GetIdentityBalanceAndRevisionResponse, - GetIdentityBalanceRequest, GetIdentityBalanceResponse, GetIdentityByPublicKeyHashRequest, - GetIdentityByPublicKeyHashResponse, GetIdentityContractNonceRequest, - GetIdentityContractNonceResponse, GetIdentityKeysRequest, GetIdentityKeysResponse, - GetIdentityNonceRequest, GetIdentityNonceResponse, GetIdentityRequest, GetIdentityResponse, - GetPathElementsRequest, GetPathElementsResponse, GetPrefundedSpecializedBalanceRequest, - GetPrefundedSpecializedBalanceResponse, GetProofsRequest, GetProofsResponse, - GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, - GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, - WaitForStateTransitionResultRequest, WaitForStateTransitionResultResponse, + GetContestedResourcesResponse, GetContestedVotePollsByEndDateRequest, + GetContestedVotePollsByEndDateResponse, GetDataContractHistoryRequest, + GetDataContractHistoryResponse, GetDataContractRequest, GetDataContractResponse, + GetDataContractsRequest, GetDataContractsResponse, GetDocumentsRequest, GetDocumentsResponse, + GetEpochsInfoRequest, GetEpochsInfoResponse, GetIdentitiesContractKeysRequest, + GetIdentitiesContractKeysResponse, GetIdentityBalanceAndRevisionRequest, + GetIdentityBalanceAndRevisionResponse, GetIdentityBalanceRequest, GetIdentityBalanceResponse, + GetIdentityByPublicKeyHashRequest, GetIdentityByPublicKeyHashResponse, + GetIdentityContractNonceRequest, GetIdentityContractNonceResponse, GetIdentityKeysRequest, + GetIdentityKeysResponse, GetIdentityNonceRequest, GetIdentityNonceResponse, GetIdentityRequest, + GetIdentityResponse, GetPathElementsRequest, GetPathElementsResponse, + GetPrefundedSpecializedBalanceRequest, GetPrefundedSpecializedBalanceResponse, + GetProofsRequest, GetProofsResponse, GetProtocolVersionUpgradeStateRequest, + GetProtocolVersionUpgradeStateResponse, GetProtocolVersionUpgradeVoteStatusRequest, + GetProtocolVersionUpgradeVoteStatusResponse, WaitForStateTransitionResultRequest, + WaitForStateTransitionResultResponse, }; use dapi_grpc::tonic::{Request, Response, Status}; use dpp::version::PlatformVersion; @@ -441,6 +443,18 @@ impl PlatformService for QueryService { .await } + async fn get_contested_vote_polls_by_end_date( + &self, + request: Request, + ) -> Result, Status> { + self.handle_blocking_query( + request, + Platform::::query_contested_vote_polls_by_end_date_query, + "get_contested_vote_polls_by_end_date", + ) + .await + } + async fn get_prefunded_specialized_balance( &self, request: Request, diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs index 3c8a3d9272..73248c1588 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs @@ -15,7 +15,9 @@ use dpp::version::PlatformVersion; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::{check_validation_result_with_data, platform_value}; use drive::error::query::QuerySyntaxError; -use drive::query::vote_poll_vote_state_query::{ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQuery}; +use drive::query::vote_poll_vote_state_query::{ + ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQuery, +}; impl Platform { pub(super) fn query_contested_resource_vote_state_v0( diff --git a/packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/mod.rs index 9b6eef6837..4bee34c7f6 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/mod.rs @@ -3,9 +3,11 @@ use crate::error::Error; use crate::platform_types::platform::Platform; use crate::platform_types::platform_state::PlatformState; use crate::query::QueryValidationResult; -use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::Version as RequestVersion; -use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::Version as ResponseVersion; -use dapi_grpc::platform::v0::{GetContestedVotePollsByEndDateRequest, GetContestedVotePollsByEndDateResponse}; +use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_request::Version as RequestVersion; +use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_response::Version as ResponseVersion; +use dapi_grpc::platform::v0::{ + GetContestedVotePollsByEndDateRequest, GetContestedVotePollsByEndDateResponse, +}; use dpp::version::PlatformVersion; mod v0; diff --git a/packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/v0/mod.rs index 825301299b..4e0564b24c 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/v0/mod.rs @@ -3,51 +3,78 @@ use crate::error::Error; use crate::platform_types::platform::Platform; use crate::platform_types::platform_state::PlatformState; use crate::query::QueryValidationResult; -use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{ - get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0, -}; use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_request::GetContestedVotePollsByEndDateRequestV0; use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_response::{get_contested_vote_polls_by_end_date_response_v0, GetContestedVotePollsByEndDateResponseV0}; -use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_response::get_contested_vote_polls_by_end_date_response_v0::SerializedContestedVotePollsByTimestamp; +use dpp::check_validation_result_with_data; use dpp::version::PlatformVersion; +use dpp::validation::ValidationResult; use drive::error::query::QuerySyntaxError; -use drive::query::vote_poll_vote_state_query::{ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQuery}; use drive::query::VotePollsByEndDateDriveQuery; impl Platform { pub(super) fn query_contested_vote_polls_by_end_date_query_v0( &self, GetContestedVotePollsByEndDateRequestV0 { - start_time_info, end_time_info, limit, ascending, prove + start_time_info, + end_time_info, + limit, + offset, + ascending, + prove, }: GetContestedVotePollsByEndDateRequestV0, platform_state: &PlatformState, platform_version: &PlatformVersion, ) -> Result, Error> { let config = &self.config.drive; - - let start_time = start_time_info.map(|start_time_info| (start_time_info.start_time_ms, start_time_info.start_time_included)); - - let end_time = end_time_info.map(|end_time_info| (end_time_info.end_time_ms, end_time_info.end_time_included)); - - let limit = limit - .map_or(Some(config.default_query_limit), |limit_value| { - if limit_value == 0 - || limit_value > u16::MAX as u32 - || limit_value as u16 > config.default_query_limit - { - None + + let start_time = start_time_info.map(|start_time_info| { + ( + start_time_info.start_time_ms, + start_time_info.start_time_included, + ) + }); + + let end_time = end_time_info + .map(|end_time_info| (end_time_info.end_time_ms, end_time_info.end_time_included)); + + let limit = check_validation_result_with_data!(limit.map_or( + Ok(config.default_query_limit), + |limit| { + let limit = u16::try_from(limit) + .map_err(|_| QueryError::InvalidArgument("limit out of bounds".to_string()))?; + if limit == 0 || limit > config.default_query_limit { + Err(QueryError::InvalidArgument(format!( + "limit {} out of bounds of [1, {}]", + limit, config.default_query_limit + ))) } else { - Some(limit_value as u16) + Ok(limit) } + } + )); + + let offset = check_validation_result_with_data!(offset + .map(|offset| { + u16::try_from(offset) + .map_err(|_| QueryError::InvalidArgument("offset out of bounds".to_string())) }) - .ok_or(drive::error::Error::Query(QuerySyntaxError::InvalidLimit( - format!("limit greater than max limit {}", config.max_query_limit), - )))?; + .transpose()); + + if prove && offset.is_some() && offset != Some(0) { + return Ok(QueryValidationResult::new_with_error(QueryError::Query( + QuerySyntaxError::RequestingProofWithOffset(format!( + "requesting proved contested vote polls by end date with an offset {}", + offset.unwrap() + )), + ))); + } let query = VotePollsByEndDateDriveQuery { start_time, limit: Some(limit), + offset, order_ascending: ascending, end_time, }; @@ -72,8 +99,58 @@ impl Platform { metadata: Some(self.response_metadata_v0(platform_state)), } } else { - let results = - match query.execute_no_proof(&self.drive, None, &mut vec![], platform_version) { + let results = match query.execute_no_proof_keep_serialized( + &self.drive, + None, + &mut vec![], + platform_version, + ) { + Ok(result) => result, + Err(drive::error::Error::Query(query_error)) => { + return Ok(QueryValidationResult::new_with_error(QueryError::Query( + query_error, + ))); + } + Err(e) => return Err(e.into()), + }; + + let (contested_vote_polls_by_timestamps, counts): ( + Vec, + Vec, + ) = results + .into_iter() + .map(|(timestamp, contested_document_resource_vote_polls)| { + let len = contested_document_resource_vote_polls.len(); + ( + SerializedContestedVotePollsByTimestamp { + timestamp, + serialized_contested_vote_polls: contested_document_resource_vote_polls, + }, + len, + ) + }) + .unzip(); + + let count: usize = counts.into_iter().sum(); + + let finished_results = if count as u16 == limit { + let last = contested_vote_polls_by_timestamps + .last() + .expect("there should be a last one if count exists"); + let next_query = VotePollsByEndDateDriveQuery { + start_time: Some((last.timestamp, false)), + limit: Some(1), + offset: None, + order_ascending: ascending, + end_time, + }; + + let next_query_results = match next_query.execute_no_proof_keep_serialized( + &self.drive, + None, + &mut vec![], + platform_version, + ) { Ok(result) => result, Err(drive::error::Error::Query(query_error)) => { return Ok(QueryValidationResult::new_with_error(QueryError::Query( @@ -82,31 +159,17 @@ impl Platform { } Err(e) => return Err(e.into()), }; - - let contenders = results - .contenders - .into_iter() - .map( - |ContenderWithSerializedDocument { - identity_id, - serialized_document, - vote_tally, - }| { - get_contested_resource_vote_state_response_v0::Contender { - identifier: identity_id.to_vec(), - vote_count: vote_tally, - document: serialized_document, - } - }, - ) - .collect(); + next_query_results.len() == 0 + } else { + true + }; GetContestedVotePollsByEndDateResponseV0 { result: Some( get_contested_vote_polls_by_end_date_response_v0::Result::ContestedVotePollsByTimestamps( - get_contested_vote_polls_by_end_date_response_v0::ContestedVotePollsByTimestamps { - contested_vote_polls_by_timestamps: vec![], - finished_results: false, + get_contested_vote_polls_by_end_date_response_v0::SerializedContestedVotePollsByTimestamps { + contested_vote_polls_by_timestamps, + finished_results, }, ), ), diff --git a/packages/rs-drive-proof-verifier/src/types.rs b/packages/rs-drive-proof-verifier/src/types.rs index 7798c6dd5a..07a70ec363 100644 --- a/packages/rs-drive-proof-verifier/src/types.rs +++ b/packages/rs-drive-proof-verifier/src/types.rs @@ -9,6 +9,9 @@ use std::collections::BTreeMap; use dpp::prelude::IdentityNonce; pub use dpp::version::ProtocolVersionVoteCount; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::voting::votes::resource_vote::ResourceVote; use dpp::{ block::{epoch::EpochIndex, extended_epoch_info::ExtendedEpochInfo}, dashcore::ProTxHash, @@ -17,9 +20,6 @@ use dpp::{ prelude::{DataContract, Identifier, IdentityPublicKey, Revision}, util::deserializer::ProtocolVersion, }; -use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; -use dpp::voting::votes::resource_vote::ResourceVote; use drive::grovedb::Element; use drive::query::vote_poll_vote_state_query::Contender; diff --git a/packages/rs-drive/src/common/encode.rs b/packages/rs-drive/src/common/encode.rs index 0a38989be2..0ed7badd51 100644 --- a/packages/rs-drive/src/common/encode.rs +++ b/packages/rs-drive/src/common/encode.rs @@ -32,9 +32,9 @@ //! This module defines encoding functions. //! -use byteorder::{BigEndian, ByteOrder, WriteBytesExt}; use crate::error::drive::DriveError; use crate::error::Error; +use byteorder::{BigEndian, ByteOrder, WriteBytesExt}; /// Encodes an unsigned integer on 64 bits. pub fn encode_u64(val: u64) -> Vec { @@ -78,7 +78,11 @@ pub fn encode_u64(val: u64) -> Vec { pub fn decode_u64(bytes: Vec) -> Result { // Ensure the input vector has exactly 8 bytes if bytes.len() != 8 { - return Err(Error::Drive(DriveError::CorruptedDriveState(format!("Trying to decode a u64 from {} bytes {}", bytes.len(), hex::encode(bytes))))); + return Err(Error::Drive(DriveError::CorruptedDriveState(format!( + "Trying to decode a u64 from {} bytes {}", + bytes.len(), + hex::encode(bytes) + )))); } // Clone the input vector to modify it @@ -94,7 +98,6 @@ pub fn decode_u64(bytes: Vec) -> Result { Ok(BigEndian::read_u64(&wtr)) } - /// Encodes a signed integer on 64 bits. pub fn encode_i64(val: i64) -> Vec { // Positive integers are represented in binary with the signed bit set to 0 diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs index d1b64f39c6..a71e8d5e4d 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs @@ -7,11 +7,11 @@ use dpp::identity::{Identity, IdentityPublicKey, KeyID}; use dpp::prelude::{IdentityNonce, Revision}; use crate::drive::identity::update::methods::merge_identity_nonce::MergeIdentityContractNonceResultToResult; +use crate::drive::votes::resolved::votes::ResolvedVote; use dpp::version::PlatformVersion; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; -use crate::drive::votes::resolved::votes::ResolvedVote; /// Operations on Identities #[derive(Clone, Debug)] diff --git a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs index 8d082a1cb8..01af7dbb38 100644 --- a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs +++ b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs @@ -8,7 +8,9 @@ use grovedb::TransactionArg; mod v0; -use crate::query::vote_poll_vote_state_query::{ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQuery}; +use crate::query::vote_poll_vote_state_query::{ + ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQuery, +}; pub use v0::*; /// Represents the outcome of a query to retrieve documents. diff --git a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs index 8d7134eadd..8f42972a29 100644 --- a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs @@ -1,7 +1,9 @@ use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; -use crate::query::vote_poll_vote_state_query::{ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQuery}; +use crate::query::vote_poll_vote_state_query::{ + ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQuery, +}; use dpp::block::epoch::Epoch; use dpp::version::PlatformVersion; use grovedb::TransactionArg; diff --git a/packages/rs-drive/src/drive/object_size_info/contract_info.rs b/packages/rs-drive/src/drive/object_size_info/contract_info.rs index f49e1ff27a..7b8d00be28 100644 --- a/packages/rs-drive/src/drive/object_size_info/contract_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/contract_info.rs @@ -91,13 +91,14 @@ pub enum DataContractOwnedResolvedInfo { OwnedDataContract(DataContract), } - impl DataContractOwnedResolvedInfo { /// The id of the contract pub fn id(&self) -> Identifier { match self { - DataContractOwnedResolvedInfo::DataContractFetchInfo(fetch_info) => { fetch_info.contract.id() } - DataContractOwnedResolvedInfo::OwnedDataContract(data_contract) => { data_contract.id() } + DataContractOwnedResolvedInfo::DataContractFetchInfo(fetch_info) => { + fetch_info.contract.id() + } + DataContractOwnedResolvedInfo::OwnedDataContract(data_contract) => data_contract.id(), } } } @@ -105,7 +106,9 @@ impl AsRef for DataContractOwnedResolvedInfo { /// The ref of the contract fn as_ref(&self) -> &DataContract { match self { - DataContractOwnedResolvedInfo::DataContractFetchInfo(fetch_info) => &fetch_info.contract, + DataContractOwnedResolvedInfo::DataContractFetchInfo(fetch_info) => { + &fetch_info.contract + } DataContractOwnedResolvedInfo::OwnedDataContract(owned) => owned, } } @@ -134,9 +137,9 @@ impl<'a> DataContractResolvedInfo<'a> { /// The id of the contract pub fn id(&self) -> Identifier { match self { - DataContractResolvedInfo::DataContractFetchInfo(fetch_info) => { fetch_info.contract.id() } - DataContractResolvedInfo::BorrowedDataContract(data_contract) => { data_contract.id() } - DataContractResolvedInfo::OwnedDataContract(data_contract) => { data_contract.id() } + DataContractResolvedInfo::DataContractFetchInfo(fetch_info) => fetch_info.contract.id(), + DataContractResolvedInfo::BorrowedDataContract(data_contract) => data_contract.id(), + DataContractResolvedInfo::OwnedDataContract(data_contract) => data_contract.id(), } } } diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs index 0723070043..3009e41169 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs @@ -9,12 +9,12 @@ use crate::error::Error; use dpp::fee::fee_result::FeeResult; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use grovedb::{EstimatedLayerInformation, TransactionArg}; -use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; impl Drive { /// Registers a vote for a contested resource based on the voter's identifier, diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index 3d4d194f1d..4f5c24b891 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -1,3 +1,6 @@ +use crate::drive::object_size_info::PathKeyElementInfo::PathKeyElement; +use crate::drive::votes::paths::VotePollPaths; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; @@ -8,9 +11,6 @@ use grovedb::batch::KeyInfoPath; use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; use platform_version::version::PlatformVersion; use std::collections::HashMap; -use crate::drive::object_size_info::PathKeyElementInfo::PathKeyElement; -use crate::drive::votes::paths::VotePollPaths; -use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; impl Drive { pub(super) fn register_contested_resource_identity_vote_v0( @@ -76,9 +76,17 @@ impl Drive { // The vote at this point will have been verified as valid by rs-drive-abci let voting_path = vote_poll.contender_voting_path(vote_choice, platform_version)?; - - self.batch_insert::<0>(PathKeyElement((voting_path, voter_pro_tx_hash.to_vec(), Element::new_sum_item(1))), &mut drive_operations, &platform_version.drive)?; - + + self.batch_insert::<0>( + PathKeyElement(( + voting_path, + voter_pro_tx_hash.to_vec(), + Element::new_sum_item(1), + )), + &mut drive_operations, + &platform_version.drive, + )?; + Ok(drive_operations) } } diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs index b02b058bd7..97e743ba42 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs @@ -9,11 +9,11 @@ use crate::error::Error; use dpp::fee::fee_result::FeeResult; +use crate::drive::votes::resolved::votes::ResolvedVote; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; use grovedb::{EstimatedLayerInformation, TransactionArg}; -use crate::drive::votes::resolved::votes::ResolvedVote; impl Drive { /// Registers a vote associated with a specific identity using the given voter's ProRegTx hash. diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs index 93f34f1ddf..2a6287937e 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs @@ -1,3 +1,6 @@ +use crate::drive::votes::resolved::vote_polls::ResolvedVotePoll; +use crate::drive::votes::resolved::votes::resolved_resource_vote::accessors::v0::ResolvedResourceVoteGettersV0; +use crate::drive::votes::resolved::votes::ResolvedVote; use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; @@ -7,9 +10,6 @@ use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use platform_version::version::PlatformVersion; use std::collections::HashMap; -use crate::drive::votes::resolved::vote_polls::ResolvedVotePoll; -use crate::drive::votes::resolved::votes::resolved_resource_vote::accessors::v0::ResolvedResourceVoteGettersV0; -use crate::drive::votes::resolved::votes::ResolvedVote; impl Drive { pub(super) fn register_identity_vote_v0( diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index 4665781fec..9b6cb33c52 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -1,3 +1,7 @@ +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::{ + ContestedDocumentResourceVotePollWithContractInfo, + ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed, +}; use crate::drive::RootTree; use crate::error::Error; use dpp::data_contract::accessors::v0::DataContractV0Getters; @@ -7,7 +11,6 @@ use dpp::identifier::Identifier; use dpp::identity::TimestampMillis; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use platform_version::version::PlatformVersion; -use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::{ContestedDocumentResourceVotePollWithContractInfo, ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed}; /// The votes tree structure looks like this /// @@ -160,7 +163,6 @@ impl VotePollPaths for ContestedDocumentResourceVotePollWithContractInfo { } } - impl<'a> VotePollPaths for ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed<'a> { fn contract_path(&self) -> [&[u8]; 4] { vote_contested_resource_active_polls_contract_tree_path( diff --git a/packages/rs-drive/src/drive/votes/resolved/mod.rs b/packages/rs-drive/src/drive/votes/resolved/mod.rs index 015f74edec..4aecfaccdb 100644 --- a/packages/rs-drive/src/drive/votes/resolved/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolved/mod.rs @@ -1,5 +1,4 @@ - +/// vote polls module +pub mod vote_polls; /// votes module pub mod votes; -/// vote polls module -pub mod vote_polls; \ No newline at end of file diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/mod.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/mod.rs index 085eb5aafb..b73b1ba236 100644 --- a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/mod.rs @@ -8,10 +8,10 @@ use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::document_type::{DocumentType, DocumentTypeRef, Index}; use dpp::identifier::Identifier; use dpp::platform_value::Value; -use dpp::ProtocolError; use dpp::serialization::PlatformSerializable; use dpp::util::hash::hash_double; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::ProtocolError; /// Represents information related to a contested document resource vote poll, along with /// associated contract details. @@ -49,7 +49,12 @@ pub struct ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed<'a> { impl From for ContestedDocumentResourceVotePoll { fn from(value: ContestedDocumentResourceVotePollWithContractInfo) -> Self { - let ContestedDocumentResourceVotePollWithContractInfo { contract, document_type_name, index_name, index_values } = value; + let ContestedDocumentResourceVotePollWithContractInfo { + contract, + document_type_name, + index_name, + index_values, + } = value; ContestedDocumentResourceVotePoll { contract_id: contract.id(), @@ -60,9 +65,16 @@ impl From for ContestedDocume } } -impl<'a> From> for ContestedDocumentResourceVotePoll { +impl<'a> From> + for ContestedDocumentResourceVotePoll +{ fn from(value: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed) -> Self { - let ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { contract, document_type_name, index_name, index_values } = value; + let ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { + contract, + document_type_name, + index_name, + index_values, + } = value; ContestedDocumentResourceVotePoll { contract_id: contract.id(), @@ -73,27 +85,41 @@ impl<'a> From } } -impl From<&ContestedDocumentResourceVotePollWithContractInfo> for ContestedDocumentResourceVotePoll { +impl From<&ContestedDocumentResourceVotePollWithContractInfo> + for ContestedDocumentResourceVotePoll +{ fn from(value: &ContestedDocumentResourceVotePollWithContractInfo) -> Self { - let ContestedDocumentResourceVotePollWithContractInfo { contract, document_type_name, index_name, index_values } = value; + let ContestedDocumentResourceVotePollWithContractInfo { + contract, + document_type_name, + index_name, + index_values, + } = value; ContestedDocumentResourceVotePoll { contract_id: contract.id(), document_type_name: document_type_name.clone(), - index_name : index_name.clone(), + index_name: index_name.clone(), index_values: index_values.clone(), } } } -impl<'a> From<&ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed<'a>> for ContestedDocumentResourceVotePoll { +impl<'a> From<&ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed<'a>> + for ContestedDocumentResourceVotePoll +{ fn from(value: &ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed) -> Self { - let ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { contract, document_type_name, index_name, index_values } = value; + let ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { + contract, + document_type_name, + index_name, + index_values, + } = value; ContestedDocumentResourceVotePoll { contract_id: contract.id(), document_type_name: document_type_name.clone(), - index_name : index_name.clone(), + index_name: index_name.clone(), index_values: index_values.clone(), } } diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs index 96f03c2911..069a19c3b3 100644 --- a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs @@ -1,11 +1,14 @@ -use grovedb::TransactionArg; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; -use platform_version::version::PlatformVersion; -use crate::drive::Drive; use crate::drive::object_size_info::{DataContractOwnedResolvedInfo, DataContractResolvedInfo}; -use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::{ContestedDocumentResourceVotePollWithContractInfo, ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed}; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::{ + ContestedDocumentResourceVotePollWithContractInfo, + ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed, +}; +use crate::drive::Drive; use crate::error::contract::DataContractError; use crate::error::Error; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use grovedb::TransactionArg; +use platform_version::version::PlatformVersion; /// A trait for resolving information related to a contested document resource vote poll. /// @@ -120,12 +123,14 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote } = self; let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll".to_string())))?; - Ok(ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { - contract: DataContractResolvedInfo::DataContractFetchInfo(contract), - document_type_name: document_type_name.clone(), - index_name: index_name.clone(), - index_values: index_values.clone(), - }) + Ok( + ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { + contract: DataContractResolvedInfo::DataContractFetchInfo(contract), + document_type_name: document_type_name.clone(), + index_name: index_name.clone(), + index_values: index_values.clone(), + }, + ) } fn resolve_owned_allow_borrowed<'a>( @@ -142,11 +147,13 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote } = self; let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll".to_string())))?; - Ok(ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { - contract: DataContractResolvedInfo::DataContractFetchInfo(contract), - document_type_name, - index_name, - index_values, - }) + Ok( + ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { + contract: DataContractResolvedInfo::DataContractFetchInfo(contract), + document_type_name, + index_name, + index_values, + }, + ) } } diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs index 0f57140e4f..c63d696b32 100644 --- a/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs @@ -1,7 +1,7 @@ +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use derive_more::From; use dpp::identifier::Identifier; use dpp::ProtocolError; -use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; /// Module containing logic for contested document resource vote polls. pub mod contested_document_resource_vote_poll; @@ -13,7 +13,9 @@ pub(crate) mod resolve; #[derive(Debug, Clone, PartialEq, From)] pub enum ResolvedVotePoll { /// A resolved vote poll with contract information for a contested document resource. - ContestedDocumentResourceVotePollWithContractInfo(ContestedDocumentResourceVotePollWithContractInfo), + ContestedDocumentResourceVotePollWithContractInfo( + ContestedDocumentResourceVotePollWithContractInfo, + ), } impl ResolvedVotePoll { @@ -30,11 +32,11 @@ impl ResolvedVotePoll { /// Returns a `ProtocolError` if there is an issue retrieving the specialized balance ID. pub fn specialized_balance_id(&self) -> Result, ProtocolError> { match self { - ResolvedVotePoll::ContestedDocumentResourceVotePollWithContractInfo(contested_document_resource_vote_poll) => { - Ok(Some( - contested_document_resource_vote_poll.specialized_balance_id()?, - )) - } + ResolvedVotePoll::ContestedDocumentResourceVotePollWithContractInfo( + contested_document_resource_vote_poll, + ) => Ok(Some( + contested_document_resource_vote_poll.specialized_balance_id()?, + )), } } @@ -50,9 +52,9 @@ impl ResolvedVotePoll { /// Returns a `ProtocolError` if there is an issue retrieving the unique ID. pub fn unique_id(&self) -> Result { match self { - ResolvedVotePoll::ContestedDocumentResourceVotePollWithContractInfo(contested_document_resource_vote_poll) => { - contested_document_resource_vote_poll.unique_id() - } + ResolvedVotePoll::ContestedDocumentResourceVotePollWithContractInfo( + contested_document_resource_vote_poll, + ) => contested_document_resource_vote_poll.unique_id(), } } } diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/resolve.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/resolve.rs index c1980830a2..78a801e5a4 100644 --- a/packages/rs-drive/src/drive/votes/resolved/vote_polls/resolve.rs +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/resolve.rs @@ -1,10 +1,10 @@ -use grovedb::TransactionArg; -use dpp::voting::vote_polls::VotePoll; -use platform_version::version::PlatformVersion; -use crate::drive::Drive; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; use crate::drive::votes::resolved::vote_polls::ResolvedVotePoll; +use crate::drive::Drive; use crate::error::Error; +use dpp::voting::vote_polls::VotePoll; +use grovedb::TransactionArg; +use platform_version::version::PlatformVersion; pub trait VotePollResolver { /// Resolves the contested document resource vote poll information. @@ -43,17 +43,45 @@ pub trait VotePollResolver { } impl VotePollResolver for VotePoll { - fn resolve(&self, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { - match self { VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll) => { - Ok(ResolvedVotePoll::ContestedDocumentResourceVotePollWithContractInfo(contested_document_resource_vote_poll.resolve(drive, transaction, platform_version)?)) - } + fn resolve( + &self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + match self { + VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll) => { + Ok( + ResolvedVotePoll::ContestedDocumentResourceVotePollWithContractInfo( + contested_document_resource_vote_poll.resolve( + drive, + transaction, + platform_version, + )?, + ), + ) + } } } - fn resolve_owned(self, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { - match self { VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll) => { - Ok(ResolvedVotePoll::ContestedDocumentResourceVotePollWithContractInfo(contested_document_resource_vote_poll.resolve(drive, transaction, platform_version)?)) - } + fn resolve_owned( + self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + match self { + VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll) => { + Ok( + ResolvedVotePoll::ContestedDocumentResourceVotePollWithContractInfo( + contested_document_resource_vote_poll.resolve( + drive, + transaction, + platform_version, + )?, + ), + ) + } } } -} \ No newline at end of file +} diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/mod.rs b/packages/rs-drive/src/drive/votes/resolved/votes/mod.rs index b66dab8ae5..78d02ac876 100644 --- a/packages/rs-drive/src/drive/votes/resolved/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolved/votes/mod.rs @@ -1,11 +1,11 @@ +pub(crate) mod resolve; /// Resolved resource vote module pub mod resolved_resource_vote; -pub(crate) mod resolve; -use dpp::identifier::Identifier; -use dpp::ProtocolError; use crate::drive::votes::resolved::votes::resolved_resource_vote::accessors::v0::ResolvedResourceVoteGettersV0; use crate::drive::votes::resolved::votes::resolved_resource_vote::ResolvedResourceVote; +use dpp::identifier::Identifier; +use dpp::ProtocolError; /// Represents the different types of resolved votes within the system. #[derive(Debug, Clone, PartialEq)] @@ -28,7 +28,9 @@ impl ResolvedVote { /// Returns a `ProtocolError` if there is an issue retrieving the specialized balance ID. pub fn specialized_balance_id(&self) -> Result, ProtocolError> { match self { - ResolvedVote::ResolvedResourceVote(resource_vote) => resource_vote.vote_poll().specialized_balance_id(), + ResolvedVote::ResolvedResourceVote(resource_vote) => { + resource_vote.vote_poll().specialized_balance_id() + } } } -} \ No newline at end of file +} diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/resolve.rs b/packages/rs-drive/src/drive/votes/resolved/votes/resolve.rs index 4d82ca5e8e..363a29da07 100644 --- a/packages/rs-drive/src/drive/votes/resolved/votes/resolve.rs +++ b/packages/rs-drive/src/drive/votes/resolved/votes/resolve.rs @@ -1,10 +1,10 @@ -use grovedb::TransactionArg; -use dpp::voting::votes::Vote; -use platform_version::version::PlatformVersion; -use crate::drive::Drive; +use crate::drive::votes::resolved::votes::resolved_resource_vote::resolve::ResourceVoteResolver; use crate::drive::votes::resolved::votes::ResolvedVote; +use crate::drive::Drive; use crate::error::Error; -use crate::drive::votes::resolved::votes::resolved_resource_vote::resolve::ResourceVoteResolver; +use dpp::voting::votes::Vote; +use grovedb::TransactionArg; +use platform_version::version::PlatformVersion; pub trait VoteResolver { /// Resolves the contested document resource vote poll information. @@ -43,17 +43,29 @@ pub trait VoteResolver { } impl VoteResolver for Vote { - fn resolve(&self, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { - match self { Vote::ResourceVote(resource_vote) => { - Ok(ResolvedVote::ResolvedResourceVote(resource_vote.resolve(drive, transaction, platform_version)?)) - } + fn resolve( + &self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + match self { + Vote::ResourceVote(resource_vote) => Ok(ResolvedVote::ResolvedResourceVote( + resource_vote.resolve(drive, transaction, platform_version)?, + )), } } - fn resolve_owned(self, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { - match self { Vote::ResourceVote(resource_vote) => { - Ok(ResolvedVote::ResolvedResourceVote(resource_vote.resolve_owned(drive, transaction, platform_version)?)) - } + fn resolve_owned( + self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + match self { + Vote::ResourceVote(resource_vote) => Ok(ResolvedVote::ResolvedResourceVote( + resource_vote.resolve_owned(drive, transaction, platform_version)?, + )), } } } diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/accessors/mod.rs b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/accessors/mod.rs index 24420eea2c..85d425a483 100644 --- a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/accessors/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/accessors/mod.rs @@ -1,7 +1,7 @@ -use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use crate::drive::votes::resolved::vote_polls::ResolvedVotePoll; use crate::drive::votes::resolved::votes::resolved_resource_vote::accessors::v0::ResolvedResourceVoteGettersV0; use crate::drive::votes::resolved::votes::resolved_resource_vote::ResolvedResourceVote; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; /// Module containing version 0 of the implementation. pub mod v0; diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/accessors/v0/mod.rs b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/accessors/v0/mod.rs index 9059ea460a..2c6ad5d5cd 100644 --- a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/accessors/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/accessors/v0/mod.rs @@ -1,5 +1,5 @@ -use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use crate::drive::votes::resolved::vote_polls::ResolvedVotePoll; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; /// Trait for getters in Resource Vote pub trait ResolvedResourceVoteGettersV0 { diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/mod.rs b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/mod.rs index 8bff100321..efa0916bf3 100644 --- a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/mod.rs @@ -14,4 +14,4 @@ pub(crate) mod resolve; pub enum ResolvedResourceVote { /// Version 0 of the resolved resource vote. V0(ResolvedResourceVoteV0), -} \ No newline at end of file +} diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/resolve.rs b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/resolve.rs index 663e1bb069..64b987e2b0 100644 --- a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/resolve.rs +++ b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/resolve.rs @@ -1,11 +1,11 @@ -use grovedb::TransactionArg; -use dpp::voting::votes::resource_vote::ResourceVote; -use platform_version::version::PlatformVersion; -use crate::drive::Drive; use crate::drive::votes::resolved::votes::resolve::VoteResolver; -use crate::drive::votes::resolved::votes::resolved_resource_vote::ResolvedResourceVote; use crate::drive::votes::resolved::votes::resolved_resource_vote::v0::resolve::ResourceVoteResolverV0; +use crate::drive::votes::resolved::votes::resolved_resource_vote::ResolvedResourceVote; +use crate::drive::Drive; use crate::error::Error; +use dpp::voting::votes::resource_vote::ResourceVote; +use grovedb::TransactionArg; +use platform_version::version::PlatformVersion; pub trait ResourceVoteResolver { /// Resolves the contested document resource vote poll information. @@ -44,17 +44,29 @@ pub trait ResourceVoteResolver { } impl ResourceVoteResolver for ResourceVote { - fn resolve(&self, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { - match self { ResourceVote::V0(resource_vote) => { - Ok(ResolvedResourceVote::V0(resource_vote.resolve(drive, transaction, platform_version)?)) - } + fn resolve( + &self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + match self { + ResourceVote::V0(resource_vote) => Ok(ResolvedResourceVote::V0( + resource_vote.resolve(drive, transaction, platform_version)?, + )), } } - fn resolve_owned(self, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { - match self { ResourceVote::V0(resource_vote) => { - Ok(ResolvedResourceVote::V0(resource_vote.resolve_owned(drive, transaction, platform_version)?)) - } + fn resolve_owned( + self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { + match self { + ResourceVote::V0(resource_vote) => Ok(ResolvedResourceVote::V0( + resource_vote.resolve_owned(drive, transaction, platform_version)?, + )), } } } diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/mod.rs index e2a4f3b4c8..f53294e861 100644 --- a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/mod.rs @@ -1,7 +1,7 @@ pub(crate) mod resolve; -use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use crate::drive::votes::resolved::vote_polls::ResolvedVotePoll; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; /// Represents the version 0 of a resolved resource vote. #[derive(Debug, Clone, PartialEq)] @@ -10,4 +10,4 @@ pub struct ResolvedResourceVoteV0 { pub resolved_vote_poll: ResolvedVotePoll, /// The choice made in the resource vote. pub resource_vote_choice: ResourceVoteChoice, -} \ No newline at end of file +} diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/resolve.rs b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/resolve.rs index d23554da46..2f4803c71a 100644 --- a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/resolve.rs +++ b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/resolve.rs @@ -1,11 +1,11 @@ -use grovedb::TransactionArg; -use dpp::voting::votes::resource_vote::v0::ResourceVoteV0; -use platform_version::version::PlatformVersion; -use crate::drive::Drive; +use crate::drive::votes::resolved::vote_polls::resolve::VotePollResolver; use crate::drive::votes::resolved::votes::resolve::VoteResolver; use crate::drive::votes::resolved::votes::resolved_resource_vote::v0::ResolvedResourceVoteV0; +use crate::drive::Drive; use crate::error::Error; -use crate::drive::votes::resolved::vote_polls::resolve::VotePollResolver; +use dpp::voting::votes::resource_vote::v0::ResourceVoteV0; +use grovedb::TransactionArg; +use platform_version::version::PlatformVersion; pub(in crate::drive::votes::resolved::votes::resolved_resource_vote) trait ResourceVoteResolverV0 { /// Resolves the contested document resource vote poll information. @@ -44,22 +44,34 @@ pub(in crate::drive::votes::resolved::votes::resolved_resource_vote) trait Resou } impl ResourceVoteResolverV0 for ResourceVoteV0 { - fn resolve(&self, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { + fn resolve( + &self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { let ResourceVoteV0 { - vote_poll, resource_vote_choice + vote_poll, + resource_vote_choice, } = self; - + let resolved_vote_poll = vote_poll.resolve(drive, transaction, platform_version)?; - + Ok(ResolvedResourceVoteV0 { resolved_vote_poll, resource_vote_choice: *resource_vote_choice, }) } - fn resolve_owned(self, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { + fn resolve_owned( + self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { let ResourceVoteV0 { - vote_poll, resource_vote_choice + vote_poll, + resource_vote_choice, } = self; let resolved_vote_poll = vote_poll.resolve_owned(drive, transaction, platform_version)?; diff --git a/packages/rs-drive/src/error/query.rs b/packages/rs-drive/src/error/query.rs index f472519ef0..bf674aea0b 100644 --- a/packages/rs-drive/src/error/query.rs +++ b/packages/rs-drive/src/error/query.rs @@ -132,4 +132,8 @@ pub enum QuerySyntaxError { /// Invalid identity prove request error #[error("invalid identity prove request error: {0}")] InvalidIdentityProveRequest(&'static str), + + /// Requesting proof with offset error + #[error("requesting proof with offset error: {0}")] + RequestingProofWithOffset(String), } diff --git a/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs b/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs index 1c002dfb56..354d699ecb 100644 --- a/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs +++ b/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs @@ -1,4 +1,6 @@ use crate::drive::votes::paths::VotePollPaths; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; @@ -6,13 +8,11 @@ use crate::query::{GroveError, Query}; use dpp::block::block_info::BlockInfo; use dpp::identifier::Identifier; use dpp::platform_value; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice::TowardsIdentity; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use grovedb::query_result_type::{QueryResultElements, QueryResultType}; use grovedb::{PathQuery, SizedQuery, TransactionArg}; -use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice::TowardsIdentity; use platform_version::version::PlatformVersion; -use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; -use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; /// Vote Poll Drive Query struct #[derive(Debug, PartialEq, Clone)] diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index 82627816df..6cfda69bb1 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -1,4 +1,6 @@ use crate::drive::votes::paths::VotePollPaths; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::query::QuerySyntaxError; @@ -6,14 +8,12 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use crate::query::{GroveError, Query}; use dpp::block::block_info::BlockInfo; +use dpp::document::Document; use dpp::identifier::Identifier; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use grovedb::query_result_type::{QueryResultElements, QueryResultType}; use grovedb::{Element, PathQuery, SizedQuery, TransactionArg}; -use dpp::document::Document; use platform_version::version::PlatformVersion; -use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; -use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; /// Represents the types of results that can be obtained from a contested document vote poll query. /// diff --git a/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs b/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs index dc490e0609..b79cedb061 100644 --- a/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs +++ b/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs @@ -1,19 +1,19 @@ -use std::collections::BTreeMap; -use grovedb::query_result_type::{QueryResultElements, QueryResultType}; -use grovedb::{PathQuery, SizedQuery, TransactionArg}; +use crate::common::encode::{decode_u64, encode_u64}; +use crate::drive::votes::paths::vote_contested_resource_end_date_queries_tree_path_vec; +use crate::drive::Drive; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use crate::query::{GroveError, Query}; use dpp::block::block_info::BlockInfo; use dpp::data_contract::document_type::DocumentPropertyType; use dpp::fee::Credits; use dpp::prelude::{TimestampIncluded, TimestampMillis}; use dpp::serialization::PlatformDeserializable; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use grovedb::query_result_type::{Key, QueryResultElements, QueryResultType}; +use grovedb::{PathQuery, SizedQuery, TransactionArg}; use platform_version::version::PlatformVersion; -use crate::common::encode::{decode_u64, encode_u64}; -use crate::drive::Drive; -use crate::drive::votes::paths::{vote_contested_resource_end_date_queries_tree_path_vec}; -use crate::error::Error; -use crate::fee::op::LowLevelDriveOperation; -use crate::query::{GroveError, Query}; +use std::collections::BTreeMap; /// Vote Poll Drive Query struct #[derive(Debug, PartialEq, Clone)] @@ -24,20 +24,19 @@ pub struct VotePollsByEndDateDriveQuery { pub end_time: Option<(TimestampMillis, TimestampIncluded)>, /// Limit pub limit: Option, + /// Offset + pub offset: Option, /// Ascending pub order_ascending: bool, } - impl VotePollsByEndDateDriveQuery { /// Operations to construct a path query. - pub fn construct_path_query( - &self, - ) -> PathQuery{ + pub fn construct_path_query(&self) -> PathQuery { let path = vote_contested_resource_end_date_queries_tree_path_vec(); let mut query = Query::new_with_direction(self.order_ascending); - + // this is a range on all elements match &(self.start_time, self.end_time) { (None, None) => { @@ -57,18 +56,29 @@ impl VotePollsByEndDateDriveQuery { false => query.insert_range_to(..ends_at_key), } } - (Some((starts_at_key_bytes, start_at_included)), Some((ends_at_key_bytes, ends_at_included))) => { + ( + Some((starts_at_key_bytes, start_at_included)), + Some((ends_at_key_bytes, ends_at_included)), + ) => { let starts_at_key = encode_u64(*starts_at_key_bytes); let ends_at_key = encode_u64(*ends_at_key_bytes); match (start_at_included, ends_at_included) { (true, true) => query.insert_range_inclusive(starts_at_key..=ends_at_key), (true, false) => query.insert_range(starts_at_key..ends_at_key), - (false, true) => query.insert_range_after_to_inclusive(starts_at_key..=ends_at_key), + (false, true) => { + query.insert_range_after_to_inclusive(starts_at_key..=ends_at_key) + } (false, false) => query.insert_range_after_to(starts_at_key..ends_at_key), } } } - + + let mut sub_query = Query::new(); + + sub_query.insert_all(); + + query.default_subquery_branch.subquery = Some(sub_query.into()); + PathQuery { path, query: SizedQuery { @@ -135,7 +145,13 @@ impl VotePollsByEndDateDriveQuery { block_info: Option, transaction: TransactionArg, platform_version: &PlatformVersion, - ) -> Result<(BTreeMap>, Credits), Error> { + ) -> Result< + ( + BTreeMap>, + Credits, + ), + Error, + > { let mut drive_operations = vec![]; let result = self.execute_no_proof(drive, transaction, &mut drive_operations, platform_version)?; @@ -174,24 +190,78 @@ impl VotePollsByEndDateDriveQuery { match query_result { Err(Error::GroveDB(GroveError::PathKeyNotFound(_))) | Err(Error::GroveDB(GroveError::PathNotFound(_))) - | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => { - Ok(BTreeMap::new()) - } + | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok(BTreeMap::new()), Err(e) => Err(e), Ok((query_result_elements, _)) => { - let vote_polls_by_end_date = query_result_elements.to_key_elements().into_iter() + let vote_polls_by_end_date = query_result_elements + .to_key_elements() + .into_iter() .map(|(key, element)| { let timestamp = decode_u64(key).map_err(Error::from)?; - let contested_document_resource_vote_poll_bytes = element.into_item_bytes().map_err(Error::from)?; - let vote_poll = ContestedDocumentResourceVotePoll::deserialize_from_bytes(&contested_document_resource_vote_poll_bytes)?; + let contested_document_resource_vote_poll_bytes = + element.into_item_bytes().map_err(Error::from)?; + let vote_poll = ContestedDocumentResourceVotePoll::deserialize_from_bytes( + &contested_document_resource_vote_poll_bytes, + )?; Ok((timestamp, vote_poll)) }) .collect::, Error>>()? .into_iter() - .fold(BTreeMap::new(), |mut acc: BTreeMap>, (timestamp, vote_poll)| { - acc.entry(timestamp).or_default().push(vote_poll); - acc - }); + .fold( + BTreeMap::new(), + |mut acc: BTreeMap>, + (timestamp, vote_poll)| { + acc.entry(timestamp).or_default().push(vote_poll); + acc + }, + ); + Ok(vote_polls_by_end_date) + } + } + } + + #[cfg(feature = "server")] + /// Executes an internal query with no proof and returns the values and skipped items. + pub fn execute_no_proof_keep_serialized( + &self, + drive: &Drive, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result>>, Error> { + let path_query = self.construct_path_query(); + let query_result = drive.grove_get_path_query( + &path_query, + transaction, + QueryResultType::QueryPathKeyElementTrioResultType, + drive_operations, + &platform_version.drive, + ); + match query_result { + Err(Error::GroveDB(GroveError::PathKeyNotFound(_))) + | Err(Error::GroveDB(GroveError::PathNotFound(_))) + | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok(BTreeMap::new()), + Err(e) => Err(e), + Ok((query_result_elements, _)) => { + let vote_polls_by_end_date = query_result_elements + .to_key_elements() + .into_iter() + .map(|(key, element)| { + let timestamp = decode_u64(key).map_err(Error::from)?; + let contested_document_resource_vote_poll_bytes = + element.into_item_bytes().map_err(Error::from)?; + Ok((timestamp, contested_document_resource_vote_poll_bytes)) + }) + .collect::, Error>>()? + .into_iter() + .fold( + BTreeMap::new(), + |mut acc: BTreeMap>>, + (timestamp, vote_poll_serialized)| { + acc.entry(timestamp).or_default().push(vote_poll_serialized); + acc + }, + ); Ok(vote_polls_by_end_date) } } @@ -230,4 +300,4 @@ impl VotePollsByEndDateDriveQuery { } } } -} \ No newline at end of file +} diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs index 0c6d6cc058..b729ec3669 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs @@ -3,11 +3,11 @@ pub mod transformer; /// v0 pub mod v0; +use crate::drive::votes::resolved::votes::ResolvedVote; use crate::state_transition_action::identity::masternode_vote::v0::MasternodeVoteTransitionActionV0; use derive_more::From; use dpp::platform_value::Identifier; use dpp::prelude::IdentityNonce; -use crate::drive::votes::resolved::votes::ResolvedVote; /// action #[derive(Debug, Clone, From)] diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs index e43c2f75eb..bfca654d83 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs @@ -1,12 +1,12 @@ -use grovedb::TransactionArg; +use crate::drive::Drive; +use crate::error::Error; use crate::state_transition_action::identity::masternode_vote::v0::MasternodeVoteTransitionActionV0; use crate::state_transition_action::identity::masternode_vote::MasternodeVoteTransitionAction; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; +use grovedb::TransactionArg; use platform_version::version::PlatformVersion; -use crate::drive::Drive; -use crate::error::Error; -impl MasternodeVoteTransitionAction { +impl MasternodeVoteTransitionAction { /// Transforms an owned `MasternodeVoteTransition` into a `MasternodeVoteTransitionAction`. /// /// # Parameters @@ -19,9 +19,22 @@ impl MasternodeVoteTransitionAction { /// # Returns /// /// A `Result` containing the transformed `MasternodeVoteTransitionAction`, or an `Error` if the transformation fails. - pub fn transform_from_owned_transition(value: MasternodeVoteTransition, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { + pub fn transform_from_owned_transition( + value: MasternodeVoteTransition, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { match value { - MasternodeVoteTransition::V0(v0) => Ok(MasternodeVoteTransitionActionV0::transform_from_owned_transition(v0, drive, transaction, platform_version)?.into()), + MasternodeVoteTransition::V0(v0) => Ok( + MasternodeVoteTransitionActionV0::transform_from_owned_transition( + v0, + drive, + transaction, + platform_version, + )? + .into(), + ), } } @@ -37,9 +50,22 @@ impl MasternodeVoteTransitionAction { /// # Returns /// /// A `Result` containing the transformed `MasternodeVoteTransitionAction`, or an `Error` if the transformation fails. - pub fn transform_from_transition(value: &MasternodeVoteTransition, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { + pub fn transform_from_transition( + value: &MasternodeVoteTransition, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { match value { - MasternodeVoteTransition::V0(v0) => Ok(MasternodeVoteTransitionActionV0::transform_from_transition(v0, drive, transaction, platform_version)?.into()), + MasternodeVoteTransition::V0(v0) => { + Ok(MasternodeVoteTransitionActionV0::transform_from_transition( + v0, + drive, + transaction, + platform_version, + )? + .into()) + } } } -} \ No newline at end of file +} diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs index a077bf153b..196073ea4e 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs @@ -1,8 +1,8 @@ mod transformer; +use crate::drive::votes::resolved::votes::ResolvedVote; use dpp::platform_value::Identifier; use dpp::prelude::IdentityNonce; -use crate::drive::votes::resolved::votes::ResolvedVote; /// action v0 #[derive(Debug, Clone)] diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs index 31d3fdb9de..fe3473ed65 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs @@ -1,13 +1,18 @@ -use grovedb::TransactionArg; +use crate::drive::votes::resolved::votes::resolve::VoteResolver; +use crate::drive::Drive; +use crate::error::Error; use crate::state_transition_action::identity::masternode_vote::v0::MasternodeVoteTransitionActionV0; use dpp::state_transition::state_transitions::identity::masternode_vote_transition::v0::MasternodeVoteTransitionV0; +use grovedb::TransactionArg; use platform_version::version::PlatformVersion; -use crate::drive::Drive; -use crate::drive::votes::resolved::votes::resolve::VoteResolver; -use crate::error::Error; impl MasternodeVoteTransitionActionV0 { - pub(crate) fn transform_from_owned_transition(value: MasternodeVoteTransitionV0, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { + pub(crate) fn transform_from_owned_transition( + value: MasternodeVoteTransitionV0, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { let MasternodeVoteTransitionV0 { pro_tx_hash, vote, @@ -22,7 +27,12 @@ impl MasternodeVoteTransitionActionV0 { }) } - pub(crate) fn transform_from_transition(value: &MasternodeVoteTransitionV0, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion) -> Result { + pub(crate) fn transform_from_transition( + value: &MasternodeVoteTransitionV0, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result { let MasternodeVoteTransitionV0 { pro_tx_hash, vote, diff --git a/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_extensions.rs b/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_extensions.rs index d59c44a91d..8b2b2daa25 100644 --- a/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_extensions.rs +++ b/packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_extensions.rs @@ -63,16 +63,13 @@ pub trait BTreeValueRemoveFromMapHelper { pub trait BTreeValueRemoveTupleFromMapHelper { fn remove_tuple(&mut self, key: &str) -> Result<(K, V), Error> - where - K: TryFrom + Ord, - V: TryFrom; - fn remove_optional_tuple( - &mut self, - key: &str, - ) -> Result, Error> - where - K: TryFrom + Ord, - V: TryFrom; + where + K: TryFrom + Ord, + V: TryFrom; + fn remove_optional_tuple(&mut self, key: &str) -> Result, Error> + where + K: TryFrom + Ord, + V: TryFrom; } impl BTreeValueRemoveFromMapHelper for BTreeMap { @@ -382,8 +379,8 @@ impl BTreeValueRemoveFromMapHelper for BTreeMap { } fn remove_optional_integer(&mut self, key: &str) -> Result, Error> - where - T: TryFrom + where + T: TryFrom + TryFrom + TryFrom + TryFrom @@ -406,8 +403,8 @@ impl BTreeValueRemoveFromMapHelper for BTreeMap { } fn remove_integer(&mut self, key: &str) -> Result - where - T: TryFrom + where + T: TryFrom + TryFrom + TryFrom + TryFrom @@ -592,9 +589,9 @@ impl BTreeValueRemoveFromMapHelper for BTreeMap { } fn remove_map_as_btree_map(&mut self, key: &str) -> Result, Error> - where - K: TryFrom + Ord, - V: TryFrom, + where + K: TryFrom + Ord, + V: TryFrom, { self.remove_optional_map_as_btree_map(key)? .ok_or_else(|| Error::StructureError(format!("unable to remove map property {key}"))) @@ -604,9 +601,9 @@ impl BTreeValueRemoveFromMapHelper for BTreeMap { &mut self, key: &str, ) -> Result>, Error> - where - K: TryFrom + Ord, - V: TryFrom, + where + K: TryFrom + Ord, + V: TryFrom, { self.remove(key) .and_then(|v| { @@ -628,21 +625,18 @@ impl BTreeValueRemoveFromMapHelper for BTreeMap { impl BTreeValueRemoveTupleFromMapHelper for BTreeMap { fn remove_tuple(&mut self, key: &str) -> Result<(K, V), Error> - where - K: TryFrom + Ord, - V: TryFrom, + where + K: TryFrom + Ord, + V: TryFrom, { self.remove_optional_tuple(key)? .ok_or_else(|| Error::StructureError(format!("unable to remove tuple property {key}"))) } - fn remove_optional_tuple( - &mut self, - key: &str, - ) -> Result, Error> - where - K: TryFrom + Ord, - V: TryFrom, + fn remove_optional_tuple(&mut self, key: &str) -> Result, Error> + where + K: TryFrom + Ord, + V: TryFrom, { self.remove(key) .and_then(|v| { @@ -660,11 +654,16 @@ impl BTreeValueRemoveTupleFromMapHelper for BTreeMap { }; Some(Ok((key_value, value_value))) } else { - Some(Err(Error::StructureError(format!("Value for key {key} is not a tuple of length 2")))) + Some(Err(Error::StructureError(format!( + "Value for key {key} is not a tuple of length 2" + )))) } } else { - Some(Err(Error::StructureError(format!("Value for key {key} is not an array")))) + Some(Err(Error::StructureError(format!( + "Value for key {key} is not an array" + )))) } - }).transpose() + }) + .transpose() } } diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index c4459948e2..211c4c663b 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -859,6 +859,11 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { }, }, voting_based_queries: DriveAbciQueryVotingVersions { + contested_vote_polls_by_end_date_query: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, contested_resource_vote_state: FeatureVersionBounds { min_version: 0, max_version: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index e9189d67bc..e45020fed4 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -859,6 +859,11 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { }, }, voting_based_queries: DriveAbciQueryVotingVersions { + contested_vote_polls_by_end_date_query: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, contested_resource_vote_state: FeatureVersionBounds { min_version: 0, max_version: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 19411d7ce5..10a7538e10 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -858,6 +858,11 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { }, }, voting_based_queries: DriveAbciQueryVotingVersions { + contested_vote_polls_by_end_date_query: FeatureVersionBounds { + min_version: 0, + max_version: 0, + default_current_version: 0, + }, contested_resource_vote_state: FeatureVersionBounds { min_version: 0, max_version: 0, diff --git a/packages/rs-sdk/src/platform/fetch.rs b/packages/rs-sdk/src/platform/fetch.rs index 2b440967d1..1d3ae2567a 100644 --- a/packages/rs-sdk/src/platform/fetch.rs +++ b/packages/rs-sdk/src/platform/fetch.rs @@ -13,12 +13,12 @@ use crate::{error::Error, platform::query::Query, Sdk}; use dapi_grpc::platform::v0::{self as platform_proto, ResponseMetadata}; use dpp::block::extended_epoch_info::ExtendedEpochInfo; use dpp::platform_value::Identifier; +use dpp::voting::votes::Vote; use dpp::{document::Document, prelude::Identity}; +use drive_proof_verifier::types::ContestedVote; use drive_proof_verifier::FromProof; use rs_dapi_client::{transport::TransportRequest, DapiRequest, RequestSettings}; use std::fmt::Debug; -use dpp::voting::votes::Vote; -use drive_proof_verifier::types::ContestedVote; use super::types::identity::IdentityRequest; use super::DocumentQuery; diff --git a/packages/rs-sdk/src/platform/fetch_many.rs b/packages/rs-sdk/src/platform/fetch_many.rs index 99942f94a9..e061f02889 100644 --- a/packages/rs-sdk/src/platform/fetch_many.rs +++ b/packages/rs-sdk/src/platform/fetch_many.rs @@ -11,7 +11,11 @@ use crate::{ platform::{document_query::DocumentQuery, query::Query}, Sdk, }; -use dapi_grpc::platform::v0::{GetContestedResourceVoteStateRequest, GetDataContractsRequest, GetDocumentsResponse, GetEpochsInfoRequest, GetIdentitiesContractKeysRequest, GetIdentityKeysRequest, GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeVoteStatusRequest}; +use dapi_grpc::platform::v0::{ + GetContestedResourceVoteStateRequest, GetDataContractsRequest, GetDocumentsResponse, + GetEpochsInfoRequest, GetIdentitiesContractKeysRequest, GetIdentityKeysRequest, + GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeVoteStatusRequest, +}; use dashcore_rpc::dashcore::ProTxHash; use dpp::block::epoch::EpochIndex; use dpp::block::extended_epoch_info::ExtendedEpochInfo; @@ -21,12 +25,12 @@ use dpp::identity::KeyID; use dpp::prelude::{Identifier, IdentityPublicKey}; use dpp::util::deserializer::ProtocolVersion; use dpp::version::ProtocolVersionVoteCount; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use drive::query::vote_poll_vote_state_query::Contender; use drive_proof_verifier::types::{MasternodeProtocolVote, RetrievedObjects}; use drive_proof_verifier::{types::Documents, FromProof}; use rs_dapi_client::{transport::TransportRequest, DapiRequest, RequestSettings}; use std::collections::BTreeMap; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; -use drive::query::vote_poll_vote_state_query::Contender; use super::LimitQuery; diff --git a/packages/rs-sdk/src/platform/query.rs b/packages/rs-sdk/src/platform/query.rs index 9881dc2f89..a6eebda1c5 100644 --- a/packages/rs-sdk/src/platform/query.rs +++ b/packages/rs-sdk/src/platform/query.rs @@ -4,7 +4,12 @@ use std::fmt::Debug; use dapi_grpc::mock::Mockable; -use dapi_grpc::platform::v0::{self as proto, get_identity_keys_request, get_identity_keys_request::GetIdentityKeysRequestV0, AllKeys, GetEpochsInfoRequest, GetIdentityKeysRequest, GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeVoteStatusRequest, KeyRequestType, GetContestedResourceVoteStateRequest}; +use dapi_grpc::platform::v0::{ + self as proto, get_identity_keys_request, get_identity_keys_request::GetIdentityKeysRequestV0, + AllKeys, GetContestedResourceVoteStateRequest, GetEpochsInfoRequest, GetIdentityKeysRequest, + GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeVoteStatusRequest, + KeyRequestType, +}; use dashcore_rpc::dashcore::{hashes::Hash, ProTxHash}; use dpp::{block::epoch::EpochIndex, prelude::Identifier}; use drive::query::DriveQuery; @@ -203,7 +208,11 @@ pub struct LimitQuery { impl From for LimitQuery { fn from(query: Q) -> Self { - Self { query, start_info: None, limit: None } + Self { + query, + start_info: None, + limit: None, + } } } @@ -288,6 +297,4 @@ impl Query for LimitQuery } } -impl Query for LimitQuery<> { - -} +impl Query for LimitQuery {} diff --git a/packages/rs-sdk/src/platform/transition.rs b/packages/rs-sdk/src/platform/transition.rs index bbe0df5085..f11a706f69 100644 --- a/packages/rs-sdk/src/platform/transition.rs +++ b/packages/rs-sdk/src/platform/transition.rs @@ -12,8 +12,8 @@ pub mod top_up_identity; pub mod transfer_document; mod txid; mod update_price_of_document; -pub mod withdraw_from_identity; mod vote; +pub mod withdraw_from_identity; pub use context::*; diff --git a/packages/rs-sdk/src/platform/transition/vote.rs b/packages/rs-sdk/src/platform/transition/vote.rs index 5bde9d96bb..a23517c306 100644 --- a/packages/rs-sdk/src/platform/transition/vote.rs +++ b/packages/rs-sdk/src/platform/transition/vote.rs @@ -3,18 +3,18 @@ use crate::platform::Fetch; use crate::{Error, Sdk}; use dapi_grpc::platform::VersionedGrpcResponse; -use dpp::identity::IdentityPublicKey; use dpp::identity::signer::Signer; +use dpp::identity::IdentityPublicKey; use dpp::prelude::Identifier; -use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; use dpp::state_transition::masternode_vote_transition::methods::MasternodeVoteTransitionMethodsV0; +use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; use crate::platform::block_info_from_metadata::block_info_from_metadata; +use crate::platform::transition::put_settings::PutSettings; use dpp::state_transition::proof_result::StateTransitionProofResult; use dpp::voting::votes::Vote; use drive::drive::Drive; use rs_dapi_client::DapiRequest; -use crate::platform::transition::put_settings::PutSettings; #[async_trait::async_trait] /// A trait for putting a vote on platform @@ -50,15 +50,11 @@ impl PutVote for Vote { settings: Option, ) -> Result<(), Error> { let new_masternode_voting_nonce = sdk - .get_identity_nonce( - voter_pro_tx_hash, - true, - settings, - ) + .get_identity_nonce(voter_pro_tx_hash, true, settings) .await?; let settings = settings.unwrap_or_default(); - + let masternode_vote_transition = MasternodeVoteTransition::try_from_vote_with_signer( self.clone(), signer, @@ -69,10 +65,9 @@ impl PutVote for Vote { None, )?; let request = masternode_vote_transition.broadcast_request_for_state_transition()?; - - request.execute(sdk, settings.request_settings) - .await?; - + + request.execute(sdk, settings.request_settings).await?; + Ok(()) } @@ -85,11 +80,7 @@ impl PutVote for Vote { settings: Option, ) -> Result { let new_masternode_voting_nonce = sdk - .get_identity_nonce( - voter_pro_tx_hash, - true, - settings, - ) + .get_identity_nonce(voter_pro_tx_hash, true, settings) .await?; let settings = settings.unwrap_or_default(); @@ -105,10 +96,7 @@ impl PutVote for Vote { )?; let request = masternode_vote_transition.broadcast_request_for_state_transition()?; - - let response_result = request - .execute(sdk, settings.request_settings) - .await; + let response_result = request.execute(sdk, settings.request_settings).await; match response_result { Ok(_) => {} @@ -142,7 +130,9 @@ impl PutVote for Vote { match result { StateTransitionProofResult::VerifiedMasternodeVote(vote) => Ok(vote), - _ => Err(Error::DapiClientError("proved something that was not a vote".to_string())), + _ => Err(Error::DapiClientError( + "proved something that was not a vote".to_string(), + )), } } } From 203ce1e5182e39cfb20a3653e7c23e7b0f300494 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 22 May 2024 13:36:00 +0200 Subject: [PATCH 074/135] end date query working --- .../state_transitions/masternode_vote/mod.rs | 5 ++- packages/rs-drive/src/common/encode.rs | 38 +++++++++++++++++-- .../v0/mod.rs | 9 +++-- packages/rs-drive/src/drive/votes/paths.rs | 3 +- .../src/query/vote_polls_by_end_date_query.rs | 19 +++++++--- 5 files changed, 60 insertions(+), 14 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index ec5cfcf799..425d242ad7 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -113,6 +113,7 @@ mod tests { use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_request::GetContestedVotePollsByEndDateRequestV0; use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_response::{get_contested_vote_polls_by_end_date_response_v0, GetContestedVotePollsByEndDateResponseV0}; + use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_response::get_contested_vote_polls_by_end_date_response_v0::SerializedContestedVotePollsByTimestamp; use super::*; use dpp::document::Document; use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; @@ -939,7 +940,9 @@ mod tests { panic!("expected contenders") }; - assert_eq!(finished_results, true); + assert!(finished_results); + + assert_eq!(contested_vote_polls_by_timestamps, vec![SerializedContestedVotePollsByTimestamp { timestamp: 0, serialized_contested_vote_polls: vec![vec![0, 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, 6, 100, 111, 109, 97, 105, 110, 18, 112, 97, 114, 101, 110, 116, 78, 97, 109, 101, 65, 110, 100, 76, 97, 98, 101, 108, 2, 18, 4, 100, 97, 115, 104, 18, 7, 113, 117, 97, 110, 116, 117, 109]] }]); } } } diff --git a/packages/rs-drive/src/common/encode.rs b/packages/rs-drive/src/common/encode.rs index 0ed7badd51..a5236f8901 100644 --- a/packages/rs-drive/src/common/encode.rs +++ b/packages/rs-drive/src/common/encode.rs @@ -75,7 +75,7 @@ pub fn encode_u64(val: u64) -> Vec { /// # Panics /// /// This function will panic if the input vector does not have exactly 8 bytes. -pub fn decode_u64(bytes: Vec) -> Result { +pub fn decode_u64_owned(mut bytes: Vec) -> Result { // Ensure the input vector has exactly 8 bytes if bytes.len() != 8 { return Err(Error::Drive(DriveError::CorruptedDriveState(format!( @@ -85,8 +85,40 @@ pub fn decode_u64(bytes: Vec) -> Result { )))); } - // Clone the input vector to modify it - let mut wtr = bytes; + // Flip the sign bit back to its original state + // This reverses the transformation done in `encode_u64` + bytes[0] ^= 0b1000_0000; + + // Read the integer from the modified bytes + // The bytes are in big endian form, which preserves the correct order + // when they were written in the encode function + Ok(BigEndian::read_u64(&bytes)) +} + +/// Decodes a 64-bit unsigned integer from a vector of bytes encoded with `encode_u64`. +/// +/// # Arguments +/// +/// * `bytes` - A vector of bytes representing the encoded 64-bit unsigned integer. +/// +/// # Returns +/// +/// * A 64-bit unsigned integer decoded from the input bytes. +/// +/// # Panics +/// +/// This function will panic if the input vector does not have exactly 8 bytes. +pub fn decode_u64(bytes: &[u8]) -> Result { + // Ensure the input vector has exactly 8 bytes + if bytes.len() != 8 { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!( + "Trying to decode a u64 from {} bytes {}", + bytes.len(), + hex::encode(bytes) + )))); + } + + let mut wtr = bytes.to_vec(); // Flip the sign bit back to its original state // This reverses the transformation done in `encode_u64` diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs index 04a09d5c76..b9b76bdc7c 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs @@ -26,6 +26,7 @@ use grovedb::EstimatedSumTrees::NoSumTrees; use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; use platform_version::version::PlatformVersion; use std::collections::HashMap; +use crate::common::encode::encode_u64; impl Drive { /// We add votes poll references by end date in order to be able to check on every new block if @@ -91,7 +92,7 @@ impl Drive { let end_date_query_path = vote_contested_resource_end_date_queries_tree_path_vec(); - let drive_key = DriveKeyInfo::Key(end_date.to_be_bytes().to_vec()); + let drive_key = DriveKeyInfo::Key(encode_u64(end_date)); let path_key_info = drive_key.add_path_info::<0>(PathInfo::PathAsVec(end_date_query_path)); @@ -137,14 +138,16 @@ impl Drive { target: QueryTargetValue(item.serialized_size()? as u32), } }; + + let unique_id = vote_poll.unique_id()?; let path_key_element_info: PathKeyElementInfo<'_, 0> = if estimated_costs_only_with_layer_info.is_none() { - PathKeyRefElement((time_path, &[0], item)) + PathKeyRefElement((time_path, unique_id.as_bytes(), item)) } else { PathKeyElementSize(( KeyInfoPath::from_known_owned_path(time_path), - KeyInfo::KnownKey(vec![0u8]), + KeyInfo::KnownKey(unique_id.to_vec()), item, )) }; diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index 9b6cb33c52..8bd3206b6a 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -11,6 +11,7 @@ use dpp::identifier::Identifier; use dpp::identity::TimestampMillis; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use platform_version::version::PlatformVersion; +use crate::common::encode::encode_u64; /// The votes tree structure looks like this /// @@ -416,7 +417,7 @@ pub fn vote_contested_resource_end_date_queries_at_time_tree_path_vec( vec![RootTree::Votes as u8], vec![CONTESTED_RESOURCE_TREE_KEY as u8], vec![END_DATE_QUERIES_TREE_KEY as u8], - time.to_be_bytes().to_vec(), + encode_u64(time), ] } diff --git a/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs b/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs index b79cedb061..85a4d2f354 100644 --- a/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs +++ b/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs @@ -14,6 +14,7 @@ use grovedb::query_result_type::{Key, QueryResultElements, QueryResultType}; use grovedb::{PathQuery, SizedQuery, TransactionArg}; use platform_version::version::PlatformVersion; use std::collections::BTreeMap; +use crate::error::drive::DriveError; /// Vote Poll Drive Query struct #[derive(Debug, PartialEq, Clone)] @@ -194,10 +195,13 @@ impl VotePollsByEndDateDriveQuery { Err(e) => Err(e), Ok((query_result_elements, _)) => { let vote_polls_by_end_date = query_result_elements - .to_key_elements() + .to_path_key_elements() .into_iter() - .map(|(key, element)| { - let timestamp = decode_u64(key).map_err(Error::from)?; + .map(|(path, _, element)| { + let Some(last_path_component) = path.last() else { + return Err(Error::Drive(DriveError::CorruptedDriveState("we should always have a path not be null".to_string()))) + }; + let timestamp = decode_u64(last_path_component).map_err(Error::from)?; let contested_document_resource_vote_poll_bytes = element.into_item_bytes().map_err(Error::from)?; let vote_poll = ContestedDocumentResourceVotePoll::deserialize_from_bytes( @@ -244,10 +248,13 @@ impl VotePollsByEndDateDriveQuery { Err(e) => Err(e), Ok((query_result_elements, _)) => { let vote_polls_by_end_date = query_result_elements - .to_key_elements() + .to_path_key_elements() .into_iter() - .map(|(key, element)| { - let timestamp = decode_u64(key).map_err(Error::from)?; + .map(|(path, _, element)| { + let Some(last_path_component) = path.last() else { + return Err(Error::Drive(DriveError::CorruptedDriveState("we should always have a path not be null".to_string()))) + }; + let timestamp = decode_u64(last_path_component).map_err(Error::from)?; let contested_document_resource_vote_poll_bytes = element.into_item_bytes().map_err(Error::from)?; Ok((timestamp, contested_document_resource_vote_poll_bytes)) From bbdbf97426c0d5645fb0291022baebb6211082a9 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 22 May 2024 16:34:55 +0200 Subject: [PATCH 075/135] work --- .../state_transitions/masternode_vote/mod.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 425d242ad7..aa52d4f8a5 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -130,10 +130,9 @@ mod tests { use dpp::voting::votes::resource_vote::v0::ResourceVoteV0; use dpp::voting::votes::Vote; use drive::drive::object_size_info::DataContractResolvedInfo; - use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::{ContestedDocumentResourceVotePollWithContractInfo, ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed}; + use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; use drive::query::vote_poll_vote_state_query::ResolvedContestedDocumentVotePollDriveQuery; - use drive::query::VotePollsByEndDateDriveQuery; use simple_signer::signer::SimpleSigner; use crate::platform_types::platform_state::PlatformState; use crate::rpc::core::MockCoreRPCLike; @@ -893,14 +892,6 @@ mod tests { assert_eq!(second_contender.vote_tally, Some(0)); - let vote_polls_by_end_date_query = VotePollsByEndDateDriveQuery { - start_time: None, - end_time: None, - limit: None, - offset: None, - order_ascending: true, - }; - let GetContestedVotePollsByEndDateResponse { version } = platform .query_contested_vote_polls_by_end_date_query( GetContestedVotePollsByEndDateRequest { @@ -942,6 +933,7 @@ mod tests { assert!(finished_results); + // The timestamp is 0 because there were no blocks assert_eq!(contested_vote_polls_by_timestamps, vec![SerializedContestedVotePollsByTimestamp { timestamp: 0, serialized_contested_vote_polls: vec![vec![0, 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, 6, 100, 111, 109, 97, 105, 110, 18, 112, 97, 114, 101, 110, 116, 78, 97, 109, 101, 65, 110, 100, 76, 97, 98, 101, 108, 2, 18, 4, 100, 97, 115, 104, 18, 7, 113, 117, 97, 110, 116, 117, 109]] }]); } } From a3d13507daafa8ff03b53507ff4c0154d5dd29e9 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Thu, 23 May 2024 03:41:07 +0200 Subject: [PATCH 076/135] much more work --- .../src/execution/platform_events/mod.rs | 1 + .../voting/award_document_to_winner/mod.rs | 1 + .../mod.rs | 40 +++++++++ .../v0/mod.rs | 82 +++++++++++++++++++ .../voting/check_for_ended_vote_polls/mod.rs | 36 ++++++++ .../check_for_ended_vote_polls/v0/mod.rs | 27 ++++++ .../voting/delay_vote_poll/mod.rs | 1 + .../voting/lock_vote_poll/mod.rs | 1 + .../execution/platform_events/voting/mod.rs | 6 ++ .../mod.rs | 46 +++++++++++ .../v0/mod.rs | 52 ++++++++++++ .../state_transitions/masternode_vote/mod.rs | 16 +++- packages/rs-drive/src/common/encode.rs | 2 +- .../v0/mod.rs | 4 +- packages/rs-drive/src/drive/votes/paths.rs | 2 +- .../src/query/vote_poll_vote_state_query.rs | 74 +++++++++++++++++ .../src/query/vote_polls_by_end_date_query.rs | 78 ++++++++++++++++-- .../src/version/drive_abci_versions.rs | 18 ++++ 18 files changed, 476 insertions(+), 11 deletions(-) create mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/delay_vote_poll/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/lock_vote_poll/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/v0/mod.rs diff --git a/packages/rs-drive-abci/src/execution/platform_events/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/mod.rs index 79821827be..54ad88cc60 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/mod.rs @@ -26,3 +26,4 @@ pub(in crate::execution) mod block_start; /// Verify the chain lock pub(in crate::execution) mod core_chain_lock; +mod voting; diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/mod.rs new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/mod.rs @@ -0,0 +1 @@ + diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/mod.rs new file mode 100644 index 0000000000..ca9daeae31 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/mod.rs @@ -0,0 +1,40 @@ +use crate::error::execution::ExecutionError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::rpc::core::CoreRPCLike; +use dpp::block::block_info::BlockInfo; +use dpp::version::PlatformVersion; +use drive::grovedb::TransactionArg; + +mod v0; + +impl Platform +where + C: CoreRPCLike, +{ + /// Checks for ended vote polls + pub(in crate::execution) fn check_for_ended_contested_resource_vote_polls( + &self, + block_info: &BlockInfo, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive_abci + .methods + .voting + .check_for_ended_contested_resource_vote_polls + { + 0 => self.check_for_ended_contested_resource_vote_polls_v0( + block_info, + transaction, + platform_version, + ), + version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { + method: "check_for_ended_contested_resource_vote_polls".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs new file mode 100644 index 0000000000..0e6ead4dcf --- /dev/null +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs @@ -0,0 +1,82 @@ +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::rpc::core::CoreRPCLike; +use dpp::block::block_info::BlockInfo; +use dpp::document::DocumentV0Getters; +use drive::grovedb::TransactionArg; +use drive::query::vote_poll_vote_state_query::FinalizedContender; +use drive::query::VotePollsByEndDateDriveQuery; +use platform_version::version::PlatformVersion; + +impl Platform +where + C: CoreRPCLike, +{ + /// Checks for ended vote polls + #[inline(always)] + pub(super) fn check_for_ended_contested_resource_vote_polls_v0( + &self, + block_info: &BlockInfo, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + // let's start by getting the vote polls that have finished + let vote_polls = + VotePollsByEndDateDriveQuery::execute_no_proof_for_specialized_end_time_query( + block_info.time_ms, + platform_version + .drive_abci + .validation_and_processing + .event_constants + .maximum_vote_polls_to_process, + &self.drive, + transaction, + &mut [], + platform_version, + )?; + + for vote_poll in vote_polls { + let resolved_vote_poll = + vote_poll.resolve(&self.drive, transaction, platform_version)?; + let document_type = resolved_vote_poll.document_type()?; + // let's see who actually won + let mut contenders = self.tally_votes_for_contested_document_resource_vote_poll( + &vote_poll, + transaction, + platform_version, + )?; + let max_vote_tally = contenders.iter().map(|c| c.final_vote_tally).max(); + + if let Some(max_tally) = max_vote_tally { + // These are all the people who got top votes + let top_contenders: Vec = contenders + .into_iter() + .filter(|c| c.final_vote_tally == max_tally) + .map(|contender| { + FinalizedContender::try_from_contender_with_serialized_document( + contender, + document_type, + platform_version, + ) + }) + .collect()?; + // Now we sort by the document creation date + let maybe_top_contender = top_contenders.into_iter().max_by(|a, b| { + a.document + .created_at() + .cmp(&b.document.created_at()) + .then_with(|| { + // Second criterion: length of the serialized document + a.document.id().cmp(&b.document.id()) + // Alternatively, you can use another field, such as identity_id + // a.identity_id.cmp(&b.identity_id) + }) + }); + + // We award the document to the top contender + } + } + + Ok(()) + } +} diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/mod.rs new file mode 100644 index 0000000000..2b27616301 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/mod.rs @@ -0,0 +1,36 @@ +use crate::error::execution::ExecutionError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::rpc::core::CoreRPCLike; +use dpp::block::block_info::BlockInfo; +use dpp::version::PlatformVersion; +use drive::grovedb::TransactionArg; + +mod v0; + +impl Platform +where + C: CoreRPCLike, +{ + /// Checks for ended vote polls + pub(in crate::execution) fn check_for_ended_vote_polls( + &self, + block_info: &BlockInfo, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive_abci + .methods + .voting + .check_for_ended_vote_polls + { + 0 => self.check_for_ended_vote_polls_v0(block_info, transaction, platform_version), + version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { + method: "check_for_ended_vote_polls".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs new file mode 100644 index 0000000000..0a56c1fc19 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs @@ -0,0 +1,27 @@ +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::rpc::core::CoreRPCLike; +use dpp::block::block_info::BlockInfo; +use drive::grovedb::TransactionArg; +use platform_version::version::PlatformVersion; + +impl Platform +where + C: CoreRPCLike, +{ + /// Checks for ended vote polls + #[inline(always)] + pub(in crate::execution) fn check_for_ended_vote_polls_v0( + &self, + block_info: &BlockInfo, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + // Only contested vote polls for v0 + self.check_for_ended_contested_resource_vote_polls( + block_info, + transaction, + platform_version, + ) + } +} diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/delay_vote_poll/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/delay_vote_poll/mod.rs new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/delay_vote_poll/mod.rs @@ -0,0 +1 @@ + diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/lock_vote_poll/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/lock_vote_poll/mod.rs new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/lock_vote_poll/mod.rs @@ -0,0 +1 @@ + diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs new file mode 100644 index 0000000000..7017840eaf --- /dev/null +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs @@ -0,0 +1,6 @@ +mod award_document_to_winner; +mod check_for_ended_contested_resource_vote_polls; +mod check_for_ended_vote_polls; +mod delay_vote_poll; +mod lock_vote_poll; +mod tally_votes_for_contested_document_resource_vote_poll; diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/mod.rs new file mode 100644 index 0000000000..ffa8f6bc17 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/mod.rs @@ -0,0 +1,46 @@ +use crate::error::execution::ExecutionError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::rpc::core::CoreRPCLike; +use dpp::block::block_info::BlockInfo; +use dpp::prelude::Identifier; +use dpp::version::PlatformVersion; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use drive::grovedb::TransactionArg; +use drive::query::vote_poll_vote_state_query::{ + ContenderWithSerializedDocument, FinalizedContenderWithSerializedDocument, +}; +use serde_json::map::BTreeMap; + +mod v0; + +impl Platform +where + C: CoreRPCLike, +{ + /// Tally the votes for a contested resource vote poll + pub(in crate::execution) fn tally_votes_for_contested_document_resource_vote_poll( + &self, + contested_document_resource_vote_poll: &ContestedDocumentResourceVotePoll, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + match platform_version + .drive_abci + .methods + .voting + .tally_votes_for_contested_document_resource_vote_poll + { + 0 => self.tally_votes_for_contested_document_resource_vote_poll_v0( + contested_document_resource_vote_poll, + transaction, + platform_version, + ), + version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { + method: "tally_votes_for_contested_resource_vote_poll".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/v0/mod.rs new file mode 100644 index 0000000000..e0ede371ad --- /dev/null +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/v0/mod.rs @@ -0,0 +1,52 @@ +use crate::error::execution::ExecutionError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::rpc::core::CoreRPCLike; +use dpp::block::block_info::BlockInfo; +use dpp::version::PlatformVersion; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use drive::grovedb::TransactionArg; +use drive::query::vote_poll_vote_state_query::{ + ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQuery, + ContestedDocumentVotePollDriveQueryResultType, FinalizedContenderWithSerializedDocument, +}; + +impl Platform +where + C: CoreRPCLike, +{ + /// Checks for ended vote polls + pub(super) fn tally_votes_for_contested_document_resource_vote_poll_v0( + &self, + contested_document_resource_vote_poll: &ContestedDocumentResourceVotePoll, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + //todo: try to figure out how to do this without a clone + //we start by only requesting the vote tally because we don't want to load all the documents + let query = ContestedDocumentVotePollDriveQuery { + vote_poll: contested_document_resource_vote_poll.clone(), + result_type: ContestedDocumentVotePollDriveQueryResultType::Documents, + offset: None, + limit: Some( + platform_version + .drive_abci + .validation_and_processing + .event_constants + .maximum_contenders_to_consider, + ), + start_at: None, + order_ascending: true, + }; + + Ok(query + .execute_no_proof(&self.drive, transaction, &mut vec![], platform_version)? + .contenders + .into_iter() + .map(|contender| { + let finalized: FinalizedContenderWithSerializedDocument = contender.into(); + finalized + }) + .collect()) + } +} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index aa52d4f8a5..19d94599f5 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -932,9 +932,21 @@ mod tests { }; assert!(finished_results); - + // The timestamp is 0 because there were no blocks - assert_eq!(contested_vote_polls_by_timestamps, vec![SerializedContestedVotePollsByTimestamp { timestamp: 0, serialized_contested_vote_polls: vec![vec![0, 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, 6, 100, 111, 109, 97, 105, 110, 18, 112, 97, 114, 101, 110, 116, 78, 97, 109, 101, 65, 110, 100, 76, 97, 98, 101, 108, 2, 18, 4, 100, 97, 115, 104, 18, 7, 113, 117, 97, 110, 116, 117, 109]] }]); + assert_eq!( + contested_vote_polls_by_timestamps, + vec![SerializedContestedVotePollsByTimestamp { + timestamp: 0, + serialized_contested_vote_polls: vec![vec![ + 0, 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, 6, + 100, 111, 109, 97, 105, 110, 18, 112, 97, 114, 101, 110, 116, 78, 97, 109, + 101, 65, 110, 100, 76, 97, 98, 101, 108, 2, 18, 4, 100, 97, 115, 104, 18, + 7, 113, 117, 97, 110, 116, 117, 109 + ]] + }] + ); } } } diff --git a/packages/rs-drive/src/common/encode.rs b/packages/rs-drive/src/common/encode.rs index a5236f8901..9515d9a4ae 100644 --- a/packages/rs-drive/src/common/encode.rs +++ b/packages/rs-drive/src/common/encode.rs @@ -117,7 +117,7 @@ pub fn decode_u64(bytes: &[u8]) -> Result { hex::encode(bytes) )))); } - + let mut wtr = bytes.to_vec(); // Flip the sign bit back to its original state diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs index b9b76bdc7c..e065943a8b 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs @@ -1,3 +1,4 @@ +use crate::common::encode::encode_u64; use crate::drive::defaults::{ AVERAGE_CONTESTED_RESOURCE_ITEM_REFERENCE_SIZE, DEFAULT_HASH_SIZE_U8, U64_SIZE_U8, }; @@ -26,7 +27,6 @@ use grovedb::EstimatedSumTrees::NoSumTrees; use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; use platform_version::version::PlatformVersion; use std::collections::HashMap; -use crate::common::encode::encode_u64; impl Drive { /// We add votes poll references by end date in order to be able to check on every new block if @@ -138,7 +138,7 @@ impl Drive { target: QueryTargetValue(item.serialized_size()? as u32), } }; - + let unique_id = vote_poll.unique_id()?; let path_key_element_info: PathKeyElementInfo<'_, 0> = diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index 8bd3206b6a..a5d59d7368 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -1,3 +1,4 @@ +use crate::common::encode::encode_u64; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::{ ContestedDocumentResourceVotePollWithContractInfo, ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed, @@ -11,7 +12,6 @@ use dpp::identifier::Identifier; use dpp::identity::TimestampMillis; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use platform_version::version::PlatformVersion; -use crate::common::encode::encode_u64; /// The votes tree structure looks like this /// diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index 6cfda69bb1..addc02f7c5 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -8,6 +8,8 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use crate::query::{GroveError, Query}; use dpp::block::block_info::BlockInfo; +use dpp::data_contract::document_type::DocumentTypeRef; +use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use dpp::document::Document; use dpp::identifier::Identifier; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; @@ -80,6 +82,78 @@ pub struct ContenderWithSerializedDocument { pub vote_tally: Option, } +/// Represents a finalized contender in the contested document vote poll. +/// This is for internal use where the document is in serialized form +/// +/// This struct holds the identity ID of the contender, the serialized document, +/// and the vote tally. +#[derive(Debug, PartialEq, Eq, Clone, Default)] +pub struct FinalizedContenderWithSerializedDocument { + /// The identity ID of the contender. + pub identity_id: Identifier, + /// The serialized document associated with the contender. + pub serialized_document: Vec, + /// The vote tally for the contender. + pub final_vote_tally: u32, +} + +/// Represents a finalized contender in the contested document vote poll. +/// This is for internal use where the document is in serialized form +/// +/// This struct holds the identity ID of the contender, the document, +/// and the vote tally. +#[derive(Debug, PartialEq, Clone)] +pub struct FinalizedContender { + /// The identity ID of the contender. + pub identity_id: Identifier, + /// The document associated with the contender. + pub document: Document, + /// The vote tally for the contender. + pub final_vote_tally: u32, +} + +impl FinalizedContender { + pub fn try_from_contender_with_serialized_document( + value: FinalizedContenderWithSerializedDocument, + document_type: DocumentTypeRef, + platform_version: &PlatformVersion, + ) -> Result { + let FinalizedContenderWithSerializedDocument { + identity_id, + serialized_document, + final_vote_tally, + } = value; + + Ok(FinalizedContender { + identity_id, + document: Document::from_bytes(&serialized_document, document_type, platform_version)?, + final_vote_tally, + }) + } +} + +impl TryFrom for FinalizedContenderWithSerializedDocument { + type Error = Error; + + fn try_from(value: ContenderWithSerializedDocument) -> Result { + let ContenderWithSerializedDocument { + identity_id, + serialized_document, + vote_tally, + } = value; + + Ok(FinalizedContenderWithSerializedDocument { + identity_id, + serialized_document: serialized_document.ok_or(Error::Drive( + DriveError::CorruptedCodeExecution("expected serialized document"), + ))?, + final_vote_tally: vote_tally.ok_or(Error::Drive( + DriveError::CorruptedCodeExecution("expected vote tally"), + ))?, + }) + } +} + /// Represents a contender in the contested document vote poll. /// /// This struct holds the identity ID of the contender, the serialized document, diff --git a/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs b/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs index 85a4d2f354..44fee6a2f3 100644 --- a/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs +++ b/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs @@ -1,6 +1,7 @@ use crate::common::encode::{decode_u64, encode_u64}; use crate::drive::votes::paths::vote_contested_resource_end_date_queries_tree_path_vec; use crate::drive::Drive; +use crate::error::drive::DriveError; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use crate::query::{GroveError, Query}; @@ -14,7 +15,6 @@ use grovedb::query_result_type::{Key, QueryResultElements, QueryResultType}; use grovedb::{PathQuery, SizedQuery, TransactionArg}; use platform_version::version::PlatformVersion; use std::collections::BTreeMap; -use crate::error::drive::DriveError; /// Vote Poll Drive Query struct #[derive(Debug, PartialEq, Clone)] @@ -32,6 +32,70 @@ pub struct VotePollsByEndDateDriveQuery { } impl VotePollsByEndDateDriveQuery { + pub fn path_query_for_end_time_included(end_time: TimestampMillis, limit: u16) -> PathQuery { + let path = vote_contested_resource_end_date_queries_tree_path_vec(); + + let mut query = Query::new_with_direction(true); + + let encoded_time = encode_u64(end_time); + + query.insert_range_to_inclusive(..=encoded_time); + + let mut sub_query = Query::new(); + + sub_query.insert_all(); + + query.default_subquery_branch.subquery = Some(sub_query.into()); + + PathQuery { + path, + query: SizedQuery { + query, + limit: Some(limit), + offset: None, + }, + } + } + + #[cfg(feature = "server")] + /// Executes a special query with no proof to get contested document resource vote polls. + /// This is meant for platform abci to get votes that have finished + pub fn execute_no_proof_for_specialized_end_time_query( + end_time: TimestampMillis, + limit: u16, + drive: &Drive, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let path_query = Self::path_query_for_end_time_included(end_time, limit); + let query_result = drive.grove_get_path_query( + &path_query, + transaction, + QueryResultType::QueryPathKeyElementTrioResultType, + drive_operations, + &platform_version.drive, + ); + match query_result { + Err(Error::GroveDB(GroveError::PathKeyNotFound(_))) + | Err(Error::GroveDB(GroveError::PathNotFound(_))) + | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok(Vec::new()), + Err(e) => Err(e), + Ok((query_result_elements, _)) => query_result_elements + .to_elements() + .into_iter() + .map(|element| { + let contested_document_resource_vote_poll_bytes = + element.into_item_bytes().map_err(Error::from)?; + let vote_poll = ContestedDocumentResourceVotePoll::deserialize_from_bytes( + &contested_document_resource_vote_poll_bytes, + )?; + Ok(vote_poll) + }) + .collect::, Error>>(), + } + } + /// Operations to construct a path query. pub fn construct_path_query(&self) -> PathQuery { let path = vote_contested_resource_end_date_queries_tree_path_vec(); @@ -44,14 +108,14 @@ impl VotePollsByEndDateDriveQuery { query.insert_all(); } (Some((starts_at_key_bytes, start_at_included)), None) => { - let starts_at_key = DocumentPropertyType::encode_u64(*starts_at_key_bytes); + let starts_at_key = encode_u64(*starts_at_key_bytes); match start_at_included { true => query.insert_range_from(starts_at_key..), false => query.insert_range_after(starts_at_key..), } } (None, Some((ends_at_key_bytes, ends_at_included))) => { - let ends_at_key = DocumentPropertyType::encode_u64(*ends_at_key_bytes); + let ends_at_key = encode_u64(*ends_at_key_bytes); match ends_at_included { true => query.insert_range_to_inclusive(..=ends_at_key), false => query.insert_range_to(..ends_at_key), @@ -199,7 +263,9 @@ impl VotePollsByEndDateDriveQuery { .into_iter() .map(|(path, _, element)| { let Some(last_path_component) = path.last() else { - return Err(Error::Drive(DriveError::CorruptedDriveState("we should always have a path not be null".to_string()))) + return Err(Error::Drive(DriveError::CorruptedDriveState( + "we should always have a path not be null".to_string(), + ))); }; let timestamp = decode_u64(last_path_component).map_err(Error::from)?; let contested_document_resource_vote_poll_bytes = @@ -252,7 +318,9 @@ impl VotePollsByEndDateDriveQuery { .into_iter() .map(|(path, _, element)| { let Some(last_path_component) = path.last() else { - return Err(Error::Drive(DriveError::CorruptedDriveState("we should always have a path not be null".to_string()))) + return Err(Error::Drive(DriveError::CorruptedDriveState( + "we should always have a path not be null".to_string(), + ))); }; let timestamp = decode_u64(last_path_component).map_err(Error::from)?; let contested_document_resource_vote_poll_bytes = diff --git a/packages/rs-platform-version/src/version/drive_abci_versions.rs b/packages/rs-platform-version/src/version/drive_abci_versions.rs index 27a30e4f2b..cbcab8c17a 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions.rs @@ -83,6 +83,7 @@ pub struct DriveAbciMethodVersions { pub fee_pool_inwards_distribution: DriveAbciFeePoolInwardsDistributionMethodVersions, pub fee_pool_outwards_distribution: DriveAbciFeePoolOutwardsDistributionMethodVersions, pub withdrawals: DriveAbciIdentityCreditWithdrawalMethodVersions, + pub voting: DriveAbciVotingMethodVersions, pub state_transition_processing: DriveAbciStateTransitionProcessingMethodVersions, pub epoch: DriveAbciEpochMethodVersions, pub block_start: DriveAbciBlockStartMethodVersions, @@ -96,6 +97,13 @@ pub struct DriveAbciValidationVersions { pub process_state_transition: FeatureVersion, pub state_transition_to_execution_event_for_check_tx: FeatureVersion, pub penalties: PenaltyAmounts, + pub event_constants: DriveAbciValidationConstants, +} + +#[derive(Clone, Debug, Default)] +pub struct DriveAbciValidationConstants { + pub maximum_vote_polls_to_process: u16, + pub maximum_contenders_to_consider: u16, } /// All of these penalty amounts are in credits @@ -290,6 +298,16 @@ pub struct DriveAbciBlockEndMethodVersions { pub validator_set_update: FeatureVersion, } +#[derive(Clone, Debug, Default)] +pub struct DriveAbciVotingMethodVersions { + pub check_for_ended_vote_polls: FeatureVersion, + pub check_for_ended_contested_resource_vote_polls: FeatureVersion, + pub tally_votes_for_contested_document_resource_vote_poll: FeatureVersion, + pub award_document_to_winner: FeatureVersion, + pub lock_vote_poll: FeatureVersion, + pub delay_vote_poll: FeatureVersion, +} + #[derive(Clone, Debug, Default)] pub struct DriveAbciIdentityCreditWithdrawalMethodVersions { pub build_untied_withdrawal_transactions_from_documents: FeatureVersion, From 21d4b81c27e383df90e24f45503d3da5e729e56f Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 24 May 2024 03:34:02 +0200 Subject: [PATCH 077/135] more work --- .../engine/run_block_proposal/v0/mod.rs | 4 ++ .../voting/award_document_to_winner/mod.rs | 44 +++++++++++++++ .../voting/award_document_to_winner/v0/mod.rs | 54 +++++++++++++++++++ .../v0/mod.rs | 32 ++++++++--- .../check_for_ended_vote_polls/v0/mod.rs | 4 +- .../mod.rs | 7 +-- .../v0/mod.rs | 14 +++-- .../masternode_vote/state/v0/mod.rs | 1 - .../verify_state_transitions.rs | 11 ++-- .../tests/strategy_tests/voting_tests.rs | 11 ++-- .../v0/mod.rs | 3 ++ .../voting/verify_masternode_vote/mod.rs | 3 +- .../voting/verify_masternode_vote/v0/mod.rs | 3 +- .../mod.rs | 3 +- .../resolve.rs | 3 ++ .../src/query/vote_poll_vote_state_query.rs | 4 ++ .../src/query/vote_polls_by_end_date_query.rs | 1 + .../src/version/mocks/v2_test.rs | 17 +++++- .../src/version/mocks/v3_test.rs | 17 +++++- .../rs-platform-version/src/version/v1.rs | 17 +++++- 20 files changed, 209 insertions(+), 44 deletions(-) create mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/v0/mod.rs diff --git a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs index 38939ca2a7..cca7fff4b9 100644 --- a/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs @@ -313,6 +313,10 @@ where platform_version, )?; + // Check for any vote polls that might have ended + + self.check_for_ended_vote_polls(&block_info, Some(transaction), platform_version)?; + // Create a new block execution context let mut block_execution_context: BlockExecutionContext = diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/mod.rs index 8b13789179..3342fbccb2 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/mod.rs @@ -1 +1,45 @@ +use crate::error::execution::ExecutionError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::rpc::core::CoreRPCLike; +use dpp::block::block_info::BlockInfo; +use dpp::version::PlatformVersion; +use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use drive::grovedb::TransactionArg; +use drive::query::vote_poll_vote_state_query::FinalizedContender; +mod v0; +impl Platform +where + C: CoreRPCLike, +{ + /// Checks for ended vote polls + pub(in crate::execution) fn award_document_to_winner( + &self, + block_info: &BlockInfo, + contender: FinalizedContender, + vote_poll: ContestedDocumentResourceVotePollWithContractInfo, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive_abci + .methods + .voting + .award_document_to_winner + { + 0 => self.award_document_to_winner_v0( + block_info, + contender, + vote_poll, + transaction, + platform_version, + ), + version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { + method: "award_document_to_winner".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/v0/mod.rs new file mode 100644 index 0000000000..d74c3b130a --- /dev/null +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/v0/mod.rs @@ -0,0 +1,54 @@ +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::rpc::core::CoreRPCLike; +use dpp::block::block_info::BlockInfo; +use dpp::version::PlatformVersion; +use drive::drive::object_size_info::DocumentInfo::DocumentAndSerialization; +use drive::drive::object_size_info::{DocumentAndContractInfo, OwnedDocumentInfo}; +use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use drive::grovedb::TransactionArg; +use drive::query::vote_poll_vote_state_query::FinalizedContender; + +impl Platform +where + C: CoreRPCLike, +{ + /// Awards a document to the winner of a contest + #[inline(always)] + pub(super) fn award_document_to_winner_v0( + &self, + block_info: &BlockInfo, + contender: FinalizedContender, + vote_poll: ContestedDocumentResourceVotePollWithContractInfo, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + let FinalizedContender { + identity_id, + document, + serialized_document, + .. + } = contender; + // Let's start by getting the identity + + let owned_document_info = OwnedDocumentInfo { + document_info: DocumentAndSerialization((document, serialized_document, None)), + owner_id: Some(identity_id.to_buffer()), + }; + + // Let's insert the document into the state + self.drive.add_document_for_contract( + DocumentAndContractInfo { + owned_document_info, + contract: vote_poll.contract.as_ref(), + document_type: vote_poll.document_type()?, + }, + false, + *block_info, + true, + transaction, + platform_version, + )?; + Ok(()) + } +} diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs index 0e6ead4dcf..c4adb0a249 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs @@ -3,10 +3,11 @@ use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; use dpp::block::block_info::BlockInfo; use dpp::document::DocumentV0Getters; +use dpp::version::PlatformVersion; +use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; use drive::grovedb::TransactionArg; use drive::query::vote_poll_vote_state_query::FinalizedContender; use drive::query::VotePollsByEndDateDriveQuery; -use platform_version::version::PlatformVersion; impl Platform where @@ -31,7 +32,7 @@ where .maximum_vote_polls_to_process, &self.drive, transaction, - &mut [], + &mut vec![], platform_version, )?; @@ -40,7 +41,7 @@ where vote_poll.resolve(&self.drive, transaction, platform_version)?; let document_type = resolved_vote_poll.document_type()?; // let's see who actually won - let mut contenders = self.tally_votes_for_contested_document_resource_vote_poll( + let contenders = self.tally_votes_for_contested_document_resource_vote_poll( &vote_poll, transaction, platform_version, @@ -58,22 +59,37 @@ where document_type, platform_version, ) + .map_err(Error::Drive) }) - .collect()?; + .collect::, Error>>()?; // Now we sort by the document creation date let maybe_top_contender = top_contenders.into_iter().max_by(|a, b| { a.document .created_at() .cmp(&b.document.created_at()) .then_with(|| { - // Second criterion: length of the serialized document - a.document.id().cmp(&b.document.id()) - // Alternatively, you can use another field, such as identity_id - // a.identity_id.cmp(&b.identity_id) + a.document + .created_at_block_height() + .cmp(&b.document.created_at_block_height()) }) + .then_with(|| { + a.document + .created_at_core_block_height() + .cmp(&b.document.created_at_core_block_height()) + }) + .then_with(|| a.document.id().cmp(&b.document.id())) }); // We award the document to the top contender + if let Some(top_contender) = maybe_top_contender { + self.award_document_to_winner( + block_info, + top_contender, + resolved_vote_poll, + transaction, + platform_version, + )?; + } } } diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs index 0a56c1fc19..511418f05e 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs @@ -2,8 +2,8 @@ use crate::error::Error; use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; use dpp::block::block_info::BlockInfo; +use dpp::version::PlatformVersion; use drive::grovedb::TransactionArg; -use platform_version::version::PlatformVersion; impl Platform where @@ -11,7 +11,7 @@ where { /// Checks for ended vote polls #[inline(always)] - pub(in crate::execution) fn check_for_ended_vote_polls_v0( + pub(super) fn check_for_ended_vote_polls_v0( &self, block_info: &BlockInfo, transaction: TransactionArg, diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/mod.rs index ffa8f6bc17..d4176cbe27 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/mod.rs @@ -2,15 +2,10 @@ use crate::error::execution::ExecutionError; use crate::error::Error; use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; -use dpp::block::block_info::BlockInfo; -use dpp::prelude::Identifier; use dpp::version::PlatformVersion; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use drive::grovedb::TransactionArg; -use drive::query::vote_poll_vote_state_query::{ - ContenderWithSerializedDocument, FinalizedContenderWithSerializedDocument, -}; -use serde_json::map::BTreeMap; +use drive::query::vote_poll_vote_state_query::FinalizedContenderWithSerializedDocument; mod v0; diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/v0/mod.rs index e0ede371ad..92f326c0a3 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/v0/mod.rs @@ -1,14 +1,12 @@ -use crate::error::execution::ExecutionError; use crate::error::Error; use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; -use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use drive::grovedb::TransactionArg; use drive::query::vote_poll_vote_state_query::{ - ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQuery, - ContestedDocumentVotePollDriveQueryResultType, FinalizedContenderWithSerializedDocument, + ContestedDocumentVotePollDriveQuery, ContestedDocumentVotePollDriveQueryResultType, + FinalizedContenderWithSerializedDocument, }; impl Platform @@ -39,14 +37,14 @@ where order_ascending: true, }; - Ok(query + query .execute_no_proof(&self.drive, transaction, &mut vec![], platform_version)? .contenders .into_iter() .map(|contender| { - let finalized: FinalizedContenderWithSerializedDocument = contender.into(); - finalized + let finalized: FinalizedContenderWithSerializedDocument = contender.try_into()?; + Ok(finalized) }) - .collect()) + .collect::, Error>>() } } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs index 55d5a5444b..4945c0515b 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs @@ -1,6 +1,5 @@ use crate::error::Error; use crate::platform_types::platform::PlatformRef; -use crate::rpc::core::CoreRPCLike; use dpp::prelude::ConsensusValidationResult; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; diff --git a/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs b/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs index 98eac5773f..489c99f9f3 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs @@ -26,6 +26,9 @@ use dpp::state_transition::documents_batch_transition::accessors::DocumentsBatch use dpp::voting::vote_polls::VotePoll; use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; use dpp::voting::votes::Vote; +use drive::drive::votes::resolved::vote_polls::ResolvedVotePoll; +use drive::drive::votes::resolved::votes::resolved_resource_vote::accessors::v0::ResolvedResourceVoteGettersV0; +use drive::drive::votes::resolved::votes::ResolvedVote; use drive::state_transition_action::document::documents_batch::document_transition::document_base_transition_action::DocumentBaseTransitionActionAccessorsV0; use drive::state_transition_action::document::documents_batch::document_transition::document_create_transition_action::{DocumentCreateTransitionActionAccessorsV0, DocumentFromCreateTransitionAction}; use drive::state_transition_action::document::documents_batch::document_transition::document_purchase_transition_action::DocumentPurchaseTransitionActionAccessorsV0; @@ -751,8 +754,10 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed( } StateTransitionAction::MasternodeVoteAction(masternode_vote_action) => { match masternode_vote_action.vote_ref() { - Vote::ResourceVote(resource_vote) => match resource_vote.vote_poll() { - VotePoll::ContestedDocumentResourceVotePoll( + ResolvedVote::ResolvedResourceVote(resource_vote) => match resource_vote + .vote_poll() + { + ResolvedVotePoll::ContestedDocumentResourceVotePollWithContractInfo( contested_document_resource_vote_poll, ) => { let config = bincode::config::standard() @@ -771,7 +776,7 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed( .votes .push(get_proofs_request_v0::VoteStatusRequest{ request_type: Some(RequestType::ContestedResourceVoteStatusRequest(vote_status_request::ContestedResourceVoteStatusRequest { - contract_id: contested_document_resource_vote_poll.contract_id.to_vec(), + contract_id: contested_document_resource_vote_poll.contract.id().to_vec(), document_type_name: contested_document_resource_vote_poll.document_type_name.clone(), index_name: contested_document_resource_vote_poll.index_name.clone(), voter_identifier: masternode_vote_action.pro_tx_hash().to_vec(), diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index 1d7081b373..aabbd98e17 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -9,7 +9,6 @@ mod tests { use dpp::identity::accessors::IdentityGettersV0; use dpp::identity::Identity; use dpp::platform_value::Value; - use drive::drive::config::DriveConfig; use drive_abci::config::{ExecutionConfig, PlatformConfig}; use drive_abci::test::helpers::setup::TestPlatformBuilder; use platform_version::version::PlatformVersion; @@ -18,23 +17,21 @@ mod tests { use simple_signer::signer::SimpleSigner; use std::collections::BTreeMap; use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse}; - use dapi_grpc::platform::v0::get_consensus_params_response::Version; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0::ResultType; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::GetContestedResourceVoteStateRequestV0; use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; - use dpp::document::{Document, DocumentV0Getters}; + use dpp::document::Document; use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use drive::drive::object_size_info::DataContractResolvedInfo; - use drive::drive::votes::resolve_contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; - use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; + use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; use drive::query::vote_poll_vote_state_query::ResolvedContestedDocumentVotePollDriveQuery; use drive_abci::platform_types::platform_state::v0::PlatformStateV0Methods; use strategy_tests::frequency::Frequency; use strategy_tests::operations::{DocumentAction, DocumentOp, Operation, OperationType}; use strategy_tests::transitions::create_state_transitions_for_identities; - use strategy_tests::{IdentityInsertInfo, StartIdentities, Strategy}; + use strategy_tests::{StartIdentities, Strategy}; #[test] fn run_chain_block_two_state_transitions_conflicting_unique_index_inserted_same_block() { @@ -351,7 +348,7 @@ mod tests { let resolved_contested_document_vote_poll_drive_query = ResolvedContestedDocumentVotePollDriveQuery { - vote_poll: ContestedDocumentResourceVotePollWithContractInfo { + vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { contract: DataContractResolvedInfo::BorrowedDataContract(&dpns_contract), document_type_name: document_type.name().clone(), index_name: index_name.clone(), diff --git a/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs b/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs index a401f2ebe7..245510a16a 100644 --- a/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs @@ -38,6 +38,8 @@ use platform_version::version::PlatformVersion; use crate::drive::Drive; use crate::drive::identity::key::fetch::IdentityKeysRequest; use crate::drive::verify::RootHash; +use crate::drive::votes::resolved::votes::resolve::VoteResolver; +use crate::drive::votes::resolved::votes::ResolvedVote; use crate::error::Error; use crate::error::proof::ProofError; use crate::query::{SingleDocumentDriveQuery, SingleDocumentDriveQueryContestedStatus}; @@ -377,6 +379,7 @@ impl Drive { StateTransition::MasternodeVote(masternode_vote) => { let pro_tx_hash = masternode_vote.pro_tx_hash(); let vote = masternode_vote.vote(); + vote.resolve(); // we expect to get an identity that matches the state transition let (root_hash, vote) = Drive::verify_masternode_vote( proof, diff --git a/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/mod.rs index dbbb7b89ad..47e38d2e85 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/mod.rs @@ -8,6 +8,7 @@ use crate::error::Error; use crate::drive::verify::RootHash; +use crate::drive::votes::resolved::votes::ResolvedVote; use dpp::version::PlatformVersion; use dpp::voting::votes::Vote; @@ -40,7 +41,7 @@ impl Drive { pub fn verify_masternode_vote( proof: &[u8], masternode_pro_tx_hash: [u8; 32], - vote: &Vote, + vote: &ResolvedVote, verify_subset_of_proof: bool, platform_version: &PlatformVersion, ) -> Result<(RootHash, Option), Error> { diff --git a/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs index fe9d51c9ef..2349a39a0d 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs @@ -4,6 +4,7 @@ use crate::error::Error; use crate::drive::verify::RootHash; +use crate::drive::votes::resolved::votes::ResolvedVote; use dpp::voting::votes::Vote; impl Drive { @@ -37,7 +38,7 @@ impl Drive { pub(crate) fn verify_masternode_vote_v0( proof: &[u8], masternode_pro_tx_hash: [u8; 32], - vote: &Vote, + vote: &ResolvedVote, verify_subset_of_proof: bool, ) -> Result<(RootHash, Option), Error> { todo!() diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/mod.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/mod.rs index b73b1ba236..a344636454 100644 --- a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/mod.rs @@ -1,4 +1,5 @@ -pub(crate) mod resolve; +/// resolver module +pub mod resolve; use crate::drive::object_size_info::{DataContractOwnedResolvedInfo, DataContractResolvedInfo}; use crate::error::drive::DriveError; diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs index 069a19c3b3..e18f474a76 100644 --- a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs @@ -42,6 +42,7 @@ pub trait ContestedDocumentResourceVotePollResolver { platform_version: &PlatformVersion, ) -> Result; + /// Resolve owned fn resolve_owned( self, drive: &Drive, @@ -49,6 +50,7 @@ pub trait ContestedDocumentResourceVotePollResolver { platform_version: &PlatformVersion, ) -> Result; + /// Resolve into a struct that allows for a borrowed contract fn resolve_allow_borrowed<'a>( &self, drive: &Drive, @@ -56,6 +58,7 @@ pub trait ContestedDocumentResourceVotePollResolver { platform_version: &PlatformVersion, ) -> Result, Error>; + /// Resolve owned into a struct that allows for a borrowed contract fn resolve_owned_allow_borrowed<'a>( self, drive: &Drive, diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index addc02f7c5..4f9205400e 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -108,11 +108,14 @@ pub struct FinalizedContender { pub identity_id: Identifier, /// The document associated with the contender. pub document: Document, + /// The still serialized document + pub serialized_document: Vec, /// The vote tally for the contender. pub final_vote_tally: u32, } impl FinalizedContender { + /// Try to get the finalized contender from a finalized contender with a serialized document pub fn try_from_contender_with_serialized_document( value: FinalizedContenderWithSerializedDocument, document_type: DocumentTypeRef, @@ -127,6 +130,7 @@ impl FinalizedContender { Ok(FinalizedContender { identity_id, document: Document::from_bytes(&serialized_document, document_type, platform_version)?, + serialized_document, final_vote_tally, }) } diff --git a/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs b/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs index 44fee6a2f3..07172d14f3 100644 --- a/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs +++ b/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs @@ -32,6 +32,7 @@ pub struct VotePollsByEndDateDriveQuery { } impl VotePollsByEndDateDriveQuery { + /// Get the path query for an abci query that gets vote polls by the end time pub fn path_query_for_end_time_included(end_time: TimestampMillis, limit: u16) -> PathQuery { let path = vote_contested_resource_end_date_queries_tree_path_vec(); diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 211c4c663b..016921e5ae 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -29,8 +29,9 @@ use crate::version::drive_abci_versions::{ DriveAbciStateTransitionCommonValidationVersions, DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, - DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, - DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts, + DriveAbciValidationConstants, DriveAbciValidationDataTriggerAndBindingVersions, + DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, + DriveAbciVotingMethodVersions, PenaltyAmounts, }; use crate::version::drive_versions::{ DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, @@ -623,6 +624,14 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { update_broadcasted_withdrawal_statuses: 0, append_signatures_and_broadcast_withdrawal_transactions: 0, }, + voting: DriveAbciVotingMethodVersions { + check_for_ended_vote_polls: 0, + check_for_ended_contested_resource_vote_polls: 0, + tally_votes_for_contested_document_resource_vote_poll: 0, + award_document_to_winner: 0, + lock_vote_poll: 0, + delay_vote_poll: 0, + }, state_transition_processing: DriveAbciStateTransitionProcessingMethodVersions { execute_event: 0, process_raw_state_transitions: 0, @@ -778,6 +787,10 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { validation_of_added_keys_structure_failure: 10000000, validation_of_added_keys_proof_of_possession_failure: 50000000, }, + event_constants: DriveAbciValidationConstants { + maximum_vote_polls_to_process: 0, + maximum_contenders_to_consider: 0, + }, }, query: DriveAbciQueryVersions { max_returned_elements: 100, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index e45020fed4..714e0c3495 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -29,8 +29,9 @@ use crate::version::drive_abci_versions::{ DriveAbciStateTransitionCommonValidationVersions, DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, - DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, - DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts, + DriveAbciValidationConstants, DriveAbciValidationDataTriggerAndBindingVersions, + DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, + DriveAbciVotingMethodVersions, PenaltyAmounts, }; use crate::version::drive_versions::{ DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, @@ -623,6 +624,14 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { update_broadcasted_withdrawal_statuses: 0, append_signatures_and_broadcast_withdrawal_transactions: 0, }, + voting: DriveAbciVotingMethodVersions { + check_for_ended_vote_polls: 0, + check_for_ended_contested_resource_vote_polls: 0, + tally_votes_for_contested_document_resource_vote_poll: 0, + award_document_to_winner: 0, + lock_vote_poll: 0, + delay_vote_poll: 0, + }, state_transition_processing: DriveAbciStateTransitionProcessingMethodVersions { execute_event: 0, process_raw_state_transitions: 0, @@ -778,6 +787,10 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { validation_of_added_keys_structure_failure: 10000000, validation_of_added_keys_proof_of_possession_failure: 50000000, }, + event_constants: DriveAbciValidationConstants { + maximum_vote_polls_to_process: 0, + maximum_contenders_to_consider: 0, + }, }, query: DriveAbciQueryVersions { max_returned_elements: 100, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 10a7538e10..05a83eb0ef 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -29,8 +29,9 @@ use crate::version::drive_abci_versions::{ DriveAbciStateTransitionCommonValidationVersions, DriveAbciStateTransitionProcessingMethodVersions, DriveAbciStateTransitionValidationVersion, DriveAbciStateTransitionValidationVersions, DriveAbciStructureVersions, - DriveAbciValidationDataTriggerAndBindingVersions, DriveAbciValidationDataTriggerVersions, - DriveAbciValidationVersions, DriveAbciVersion, PenaltyAmounts, + DriveAbciValidationConstants, DriveAbciValidationDataTriggerAndBindingVersions, + DriveAbciValidationDataTriggerVersions, DriveAbciValidationVersions, DriveAbciVersion, + DriveAbciVotingMethodVersions, PenaltyAmounts, }; use crate::version::drive_versions::{ DriveAssetLockMethodVersions, DriveBalancesMethodVersions, DriveBatchOperationsMethodVersion, @@ -622,6 +623,14 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { update_broadcasted_withdrawal_statuses: 0, append_signatures_and_broadcast_withdrawal_transactions: 0, }, + voting: DriveAbciVotingMethodVersions { + check_for_ended_vote_polls: 0, + check_for_ended_contested_resource_vote_polls: 0, + tally_votes_for_contested_document_resource_vote_poll: 0, + award_document_to_winner: 0, + lock_vote_poll: 0, + delay_vote_poll: 0, + }, state_transition_processing: DriveAbciStateTransitionProcessingMethodVersions { execute_event: 0, process_raw_state_transitions: 0, @@ -777,6 +786,10 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { validation_of_added_keys_structure_failure: 10000000, validation_of_added_keys_proof_of_possession_failure: 50000000, }, + event_constants: DriveAbciValidationConstants { + maximum_vote_polls_to_process: 0, + maximum_contenders_to_consider: 0, + }, }, query: DriveAbciQueryVersions { max_returned_elements: 100, From 37074bebefb58a7096b2e677942da07ad78ca780 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sat, 25 May 2024 00:41:05 +0200 Subject: [PATCH 078/135] more work on abci execution --- .../v0/mod.rs | 17 ++++++++ .../clean_up_after_vote_poll_end/mod.rs | 38 ++++++++++++++++++ .../clean_up_after_vote_poll_end/v0/mod.rs | 0 .../voting/keep_record_of_vote_poll/mod.rs | 40 +++++++++++++++++++ .../voting/keep_record_of_vote_poll/v0/mod.rs | 0 .../execution/platform_events/voting/mod.rs | 2 + .../v0/mod.rs | 22 +++++++++- .../voting/verify_masternode_vote/mod.rs | 8 +++- .../voting/verify_masternode_vote/v0/mod.rs | 22 +++++++++- .../src/version/drive_abci_versions.rs | 2 + 10 files changed, 146 insertions(+), 5 deletions(-) create mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/v0/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs index c4adb0a249..9849c719cb 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs @@ -82,6 +82,23 @@ where // We award the document to the top contender if let Some(top_contender) = maybe_top_contender { + // We want to keep a record of how everyone voted + self.keep_record_of_vote_poll( + block_info, + &top_contender, + &resolved_vote_poll, + transaction, + platform_version, + )?; + // We need to clean up the vote poll + // This means removing it and also removing all current votes + self.clean_up_after_vote_poll_end( + block_info, + &resolved_vote_poll, + transaction, + platform_version, + )?; + // We award the document to the winner of the vote poll self.award_document_to_winner( block_info, top_contender, diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/mod.rs new file mode 100644 index 0000000000..3148fe9268 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/mod.rs @@ -0,0 +1,38 @@ +use crate::error::execution::ExecutionError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::rpc::core::CoreRPCLike; +use dpp::block::block_info::BlockInfo; +use dpp::version::PlatformVersion; +use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use drive::grovedb::TransactionArg; + +mod v0; + +impl Platform + where + C: CoreRPCLike, +{ + /// Checks for ended vote polls + pub(in crate::execution) fn clean_up_after_vote_poll_end( + &self, + block_info: &BlockInfo, + vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive_abci + .methods + .voting + .clean_up_after_vote_poll_end + { + 0 => self.clean_up_after_vote_poll_end_v0(block_info, transaction, platform_version), + version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { + method: "clean_up_after_vote_poll_end".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/v0/mod.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/mod.rs new file mode 100644 index 0000000000..5d8250c9d5 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/mod.rs @@ -0,0 +1,40 @@ +use crate::error::execution::ExecutionError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::rpc::core::CoreRPCLike; +use dpp::block::block_info::BlockInfo; +use dpp::version::PlatformVersion; +use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use drive::grovedb::TransactionArg; +use drive::query::vote_poll_vote_state_query::FinalizedContender; + +mod v0; + +impl Platform + where + C: CoreRPCLike, +{ + /// Keeps a record of the vote poll after it has finished + pub(in crate::execution) fn keep_record_of_vote_poll( + &self, + block_info: &BlockInfo, + contender: &FinalizedContender, + vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive_abci + .methods + .voting + .keep_record_of_vote_poll + { + 0 => self.keep_record_of_vote_poll_v0(block_info, contender, vote_poll, transaction, platform_version), + version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { + method: "keep_record_of_vote_poll".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs index 7017840eaf..8795742c2b 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs @@ -4,3 +4,5 @@ mod check_for_ended_vote_polls; mod delay_vote_poll; mod lock_vote_poll; mod tally_votes_for_contested_document_resource_vote_poll; +mod clean_up_after_vote_poll_end; +mod keep_record_of_vote_poll; diff --git a/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs b/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs index 245510a16a..0cf3715cc6 100644 --- a/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs @@ -33,10 +33,14 @@ use dpp::state_transition::documents_batch_transition::document_transition::docu use dpp::state_transition::masternode_vote_transition::accessors::MasternodeVoteTransitionAccessorsV0; use dpp::state_transition::proof_result::StateTransitionProofResult; use dpp::state_transition::proof_result::StateTransitionProofResult::{VerifiedBalanceTransfer, VerifiedDataContract, VerifiedDocuments, VerifiedIdentity, VerifiedMasternodeVote, VerifiedPartialIdentity}; +use dpp::voting::vote_polls::VotePoll; +use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; +use dpp::voting::votes::Vote; use platform_version::TryIntoPlatformVersioned; use platform_version::version::PlatformVersion; use crate::drive::Drive; use crate::drive::identity::key::fetch::IdentityKeysRequest; +use crate::drive::object_size_info::{DataContractResolvedInfo, DocumentTypeInfo}; use crate::drive::verify::RootHash; use crate::drive::votes::resolved::votes::resolve::VoteResolver; use crate::drive::votes::resolved::votes::ResolvedVote; @@ -379,13 +383,27 @@ impl Drive { StateTransition::MasternodeVote(masternode_vote) => { let pro_tx_hash = masternode_vote.pro_tx_hash(); let vote = masternode_vote.vote(); - vote.resolve(); + let (contract, document_type_name) = match vote { Vote::ResourceVote(resource_vote) => { + match resource_vote.vote_poll() { + VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll) => { + (known_contracts_provider_fn(&contested_document_resource_vote_poll.contract_id)?.ok_or( + Error::Proof(ProofError::UnknownContract(format!( + "unknown contract with id {}", + contested_document_resource_vote_poll.contract_id + ))), + )?, contested_document_resource_vote_poll.document_type_name.as_str()) + } + } + } }; + // we expect to get an identity that matches the state transition let (root_hash, vote) = Drive::verify_masternode_vote( proof, pro_tx_hash.to_buffer(), vote, - true, + DataContractResolvedInfo::BorrowedDataContract(&contract), + DocumentTypeInfo::DocumentTypeNameAsStr(document_type_name), + false, platform_version, )?; let vote = vote.ok_or(Error::Proof(ProofError::IncorrectProof(format!("proof did not contain actual vote for masternode {} expected to exist because of state transition (masternode vote)", masternode_vote.pro_tx_hash()))))?; diff --git a/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/mod.rs index 47e38d2e85..c1d89062fc 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/mod.rs @@ -8,9 +8,9 @@ use crate::error::Error; use crate::drive::verify::RootHash; -use crate::drive::votes::resolved::votes::ResolvedVote; use dpp::version::PlatformVersion; use dpp::voting::votes::Vote; +use crate::drive::object_size_info::{DataContractResolvedInfo, DocumentTypeInfo}; impl Drive { /// Verifies the authenticity of a masternode vote using the provided proof. @@ -41,7 +41,9 @@ impl Drive { pub fn verify_masternode_vote( proof: &[u8], masternode_pro_tx_hash: [u8; 32], - vote: &ResolvedVote, + vote: &Vote, + contract: DataContractResolvedInfo, + document_type: DocumentTypeInfo, verify_subset_of_proof: bool, platform_version: &PlatformVersion, ) -> Result<(RootHash, Option), Error> { @@ -56,6 +58,8 @@ impl Drive { proof, masternode_pro_tx_hash, vote, + contract, + document_type, verify_subset_of_proof, ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { diff --git a/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs index 2349a39a0d..308ae4f37b 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs @@ -1,3 +1,6 @@ +use grovedb::{PathQuery, SizedQuery}; +use dpp::data_contract::DataContract; +use dpp::data_contract::document_type::DocumentTypeRef; use crate::drive::Drive; use crate::error::Error; @@ -6,6 +9,9 @@ use crate::drive::verify::RootHash; use crate::drive::votes::resolved::votes::ResolvedVote; use dpp::voting::votes::Vote; +use crate::drive::object_size_info::{DataContractResolvedInfo, DocumentTypeInfo}; +use crate::drive::votes::paths::vote_contested_resource_identity_votes_tree_path_for_identity_vec; +use crate::query::Query; impl Drive { /// Verifies the balance of an identity by their identity ID. @@ -38,9 +44,23 @@ impl Drive { pub(crate) fn verify_masternode_vote_v0( proof: &[u8], masternode_pro_tx_hash: [u8; 32], - vote: &ResolvedVote, + vote: &Vote, + contract: DataContractResolvedInfo, + document_type: DocumentTypeInfo, verify_subset_of_proof: bool, ) -> Result<(RootHash, Option), Error> { + // First we should get the overall document_type_path + let path = vote_contested_resource_identity_votes_tree_path_for_identity_vec( + &masternode_pro_tx_hash, + ); + + let vote_id = vote.unique_id()?; + + let mut query = Query::new(); + query.insert_key(vote_id.to_vec()); + + Ok(PathQuery::new(path, SizedQuery::new(query, Some(1), None))) + todo!() // let mut path_query = Self::identity_balance_query(&identity_id); // path_query.query.limit = Some(1); diff --git a/packages/rs-platform-version/src/version/drive_abci_versions.rs b/packages/rs-platform-version/src/version/drive_abci_versions.rs index cbcab8c17a..2133ca715e 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions.rs @@ -300,6 +300,8 @@ pub struct DriveAbciBlockEndMethodVersions { #[derive(Clone, Debug, Default)] pub struct DriveAbciVotingMethodVersions { + pub keep_record_of_vote_poll: FeatureVersion, + pub clean_up_after_vote_poll_end: FeatureVersion, pub check_for_ended_vote_polls: FeatureVersion, pub check_for_ended_contested_resource_vote_polls: FeatureVersion, pub tally_votes_for_contested_document_resource_vote_poll: FeatureVersion, From 7c3c5fdcb6f4ae718978b951180f87b3157adb57 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sat, 25 May 2024 09:01:49 +0200 Subject: [PATCH 079/135] work on cleanup --- .../v0/mod.rs | 136 +++++++++--------- .../clean_up_after_vote_poll_end/mod.rs | 4 +- .../clean_up_after_vote_poll_end/v0/mod.rs | 25 ++++ .../voting/keep_record_of_vote_poll/mod.rs | 12 +- .../voting/keep_record_of_vote_poll/v0/mod.rs | 26 ++++ .../execution/platform_events/voting/mod.rs | 4 +- .../v0/mod.rs | 2 +- .../src/drive/grove_operations/mod.rs | 1 + .../mod.rs | 2 +- .../src/drive/votes/insert/vote_poll/mod.rs | 1 + .../mod.rs | 49 +++++++ .../v0/mod.rs | 74 ++++++++++ .../src/query/vote_polls_by_end_date_query.rs | 46 ++++-- .../src/version/dpp_versions.rs | 2 +- .../src/version/drive_versions.rs | 3 +- .../src/version/mocks/v2_test.rs | 4 +- .../src/version/mocks/v3_test.rs | 4 +- .../rs-platform-version/src/version/v1.rs | 4 +- 18 files changed, 301 insertions(+), 98 deletions(-) create mode 100644 packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/v0/mod.rs diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs index 9849c719cb..dfa9d6aa85 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs @@ -36,76 +36,78 @@ where platform_version, )?; - for vote_poll in vote_polls { - let resolved_vote_poll = - vote_poll.resolve(&self.drive, transaction, platform_version)?; - let document_type = resolved_vote_poll.document_type()?; - // let's see who actually won - let contenders = self.tally_votes_for_contested_document_resource_vote_poll( - &vote_poll, - transaction, - platform_version, - )?; - let max_vote_tally = contenders.iter().map(|c| c.final_vote_tally).max(); + for (end_date, vote_polls) in vote_polls { + for vote_poll in vote_polls { + let resolved_vote_poll = + vote_poll.resolve(&self.drive, transaction, platform_version)?; + let document_type = resolved_vote_poll.document_type()?; + // let's see who actually won + let contenders = self.tally_votes_for_contested_document_resource_vote_poll( + &vote_poll, + transaction, + platform_version, + )?; + let max_vote_tally = contenders.iter().map(|c| c.final_vote_tally).max(); - if let Some(max_tally) = max_vote_tally { - // These are all the people who got top votes - let top_contenders: Vec = contenders - .into_iter() - .filter(|c| c.final_vote_tally == max_tally) - .map(|contender| { - FinalizedContender::try_from_contender_with_serialized_document( - contender, - document_type, - platform_version, - ) - .map_err(Error::Drive) - }) - .collect::, Error>>()?; - // Now we sort by the document creation date - let maybe_top_contender = top_contenders.into_iter().max_by(|a, b| { - a.document - .created_at() - .cmp(&b.document.created_at()) - .then_with(|| { - a.document - .created_at_block_height() - .cmp(&b.document.created_at_block_height()) + if let Some(max_tally) = max_vote_tally { + // These are all the people who got top votes + let top_contenders: Vec = contenders + .into_iter() + .filter(|c| c.final_vote_tally == max_tally) + .map(|contender| { + FinalizedContender::try_from_contender_with_serialized_document( + contender, + document_type, + platform_version, + ) + .map_err(Error::Drive) }) - .then_with(|| { - a.document - .created_at_core_block_height() - .cmp(&b.document.created_at_core_block_height()) - }) - .then_with(|| a.document.id().cmp(&b.document.id())) - }); + .collect::, Error>>()?; + // Now we sort by the document creation date + let maybe_top_contender = top_contenders.into_iter().max_by(|a, b| { + a.document + .created_at() + .cmp(&b.document.created_at()) + .then_with(|| { + a.document + .created_at_block_height() + .cmp(&b.document.created_at_block_height()) + }) + .then_with(|| { + a.document + .created_at_core_block_height() + .cmp(&b.document.created_at_core_block_height()) + }) + .then_with(|| a.document.id().cmp(&b.document.id())) + }); - // We award the document to the top contender - if let Some(top_contender) = maybe_top_contender { - // We want to keep a record of how everyone voted - self.keep_record_of_vote_poll( - block_info, - &top_contender, - &resolved_vote_poll, - transaction, - platform_version, - )?; - // We need to clean up the vote poll - // This means removing it and also removing all current votes - self.clean_up_after_vote_poll_end( - block_info, - &resolved_vote_poll, - transaction, - platform_version, - )?; - // We award the document to the winner of the vote poll - self.award_document_to_winner( - block_info, - top_contender, - resolved_vote_poll, - transaction, - platform_version, - )?; + // We award the document to the top contender + if let Some(top_contender) = maybe_top_contender { + // We want to keep a record of how everyone voted + self.keep_record_of_vote_poll( + block_info, + &top_contender, + &resolved_vote_poll, + transaction, + platform_version, + )?; + // We need to clean up the vote poll + // This means removing it and also removing all current votes + self.clean_up_after_vote_poll_end( + block_info, + &resolved_vote_poll, + transaction, + platform_version, + )?; + // We award the document to the winner of the vote poll + self.award_document_to_winner( + block_info, + top_contender, + resolved_vote_poll, + transaction, + platform_version, + )?; + } } } } diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/mod.rs index 3148fe9268..6f3c8133e7 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/mod.rs @@ -10,8 +10,8 @@ use drive::grovedb::TransactionArg; mod v0; impl Platform - where - C: CoreRPCLike, +where + C: CoreRPCLike, { /// Checks for ended vote polls pub(in crate::execution) fn clean_up_after_vote_poll_end( diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/v0/mod.rs index e69de29bb2..14e9587b31 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/v0/mod.rs @@ -0,0 +1,25 @@ +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::rpc::core::CoreRPCLike; +use dpp::block::block_info::BlockInfo; +use dpp::document::DocumentV0Getters; +use dpp::version::PlatformVersion; +use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; +use drive::grovedb::TransactionArg; +use drive::query::vote_poll_vote_state_query::FinalizedContender; +use drive::query::VotePollsByEndDateDriveQuery; + +impl Platform +where + C: CoreRPCLike, +{ + /// Checks for ended vote polls + #[inline(always)] + pub(super) fn clean_up_after_vote_poll_end_v0( + &self, + block_info: &BlockInfo, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + } +} diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/mod.rs index 5d8250c9d5..d897187c53 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/mod.rs @@ -11,8 +11,8 @@ use drive::query::vote_poll_vote_state_query::FinalizedContender; mod v0; impl Platform - where - C: CoreRPCLike, +where + C: CoreRPCLike, { /// Keeps a record of the vote poll after it has finished pub(in crate::execution) fn keep_record_of_vote_poll( @@ -29,7 +29,13 @@ impl Platform .voting .keep_record_of_vote_poll { - 0 => self.keep_record_of_vote_poll_v0(block_info, contender, vote_poll, transaction, platform_version), + 0 => self.keep_record_of_vote_poll_v0( + block_info, + contender, + vote_poll, + transaction, + platform_version, + ), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { method: "keep_record_of_vote_poll".to_string(), known_versions: vec![0], diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs index e69de29bb2..1414cd0ecd 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs @@ -0,0 +1,26 @@ +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::rpc::core::CoreRPCLike; +use dpp::block::block_info::BlockInfo; +use dpp::version::PlatformVersion; +use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use drive::grovedb::TransactionArg; +use drive::query::vote_poll_vote_state_query::FinalizedContender; + +impl Platform +where + C: CoreRPCLike, +{ + /// Keeps a record of the vote poll after it has finished + #[inline(always)] + pub(super) fn keep_record_of_vote_poll_v0( + &self, + block_info: &BlockInfo, + contender: &FinalizedContender, + vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + // We want to store information about the vote poll in an efficient way + } +} diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs index 8795742c2b..a0d5b6b604 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs @@ -1,8 +1,8 @@ mod award_document_to_winner; mod check_for_ended_contested_resource_vote_polls; mod check_for_ended_vote_polls; +mod clean_up_after_vote_poll_end; mod delay_vote_poll; +mod keep_record_of_vote_poll; mod lock_vote_poll; mod tally_votes_for_contested_document_resource_vote_poll; -mod clean_up_after_vote_poll_end; -mod keep_record_of_vote_poll; diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs index f32b71345e..575aa41402 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs @@ -50,7 +50,7 @@ impl Drive { let end_date = block_info .time_ms - .saturating_add(platform_version.dpp.voting_versions.default_vote_time_ms); + .saturating_add(platform_version.dpp.voting_versions.default_vote_poll_time_duration_ms); self.add_vote_poll_end_date_query_operations( document_and_contract_info.owned_document_info.owner_id, diff --git a/packages/rs-drive/src/drive/grove_operations/mod.rs b/packages/rs-drive/src/drive/grove_operations/mod.rs index 12207cd0a5..b622df63b6 100644 --- a/packages/rs-drive/src/drive/grove_operations/mod.rs +++ b/packages/rs-drive/src/drive/grove_operations/mod.rs @@ -181,6 +181,7 @@ pub type IsSumSubTree = bool; pub type IsSumTree = bool; /// Batch delete apply type +#[derive(Debug, Copy, Clone)] pub enum BatchDeleteApplyType { /// Stateless batch delete StatelessBatchDelete { diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs index d7fab10e7e..e7e279fdba 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/mod.rs @@ -36,7 +36,7 @@ impl Drive { .methods .vote .contested_resource_insert - .add_vote_poll_end_date_query + .add_vote_poll_end_date_query_operations { 0 => self.add_vote_poll_end_date_query_operations_v0( creator_identity_id, diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/mod.rs index 26d37fb179..405420e10a 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/mod.rs @@ -1 +1,2 @@ mod add_vote_poll_end_date_query_operations; +mod remove_vote_poll_end_date_query_operations; diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/mod.rs new file mode 100644 index 0000000000..e9141fe740 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/mod.rs @@ -0,0 +1,49 @@ +mod v0; + +use crate::drive::Drive; +use grovedb::batch::KeyInfoPath; +use std::collections::HashMap; + +use crate::error::drive::DriveError; +use crate::error::Error; + +use crate::fee::op::LowLevelDriveOperation; +use dpp::block::block_info::BlockInfo; +use dpp::prelude::TimestampMillis; +use dpp::version::PlatformVersion; +use dpp::voting::vote_polls::VotePoll; +use grovedb::{EstimatedLayerInformation, TransactionArg}; + +impl Drive { + /// We add votes poll references by end date in order to be able to check on every new block if + /// any votes poll should be closed. This will remove them to recoup space + pub fn remove_vote_poll_end_date_query_operations( + &self, + vote_polls: Vec, + end_date: TimestampMillis, + batch_operations: &mut Vec, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive + .methods + .vote + .contested_resource_insert + .remove_vote_poll_end_date_query_operations + { + 0 => self.remove_vote_poll_end_date_query_operations_v0( + vote_polls, + end_date, + batch_operations, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "remove_vote_poll_end_date_query".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/v0/mod.rs new file mode 100644 index 0000000000..e2449a36cd --- /dev/null +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/v0/mod.rs @@ -0,0 +1,74 @@ +use crate::drive::votes::paths::{vote_contested_resource_end_date_queries_at_time_tree_path_vec, vote_contested_resource_end_date_queries_tree_path_vec}; +use crate::drive::Drive; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use dpp::identity::TimestampMillis; +use dpp::serialization::PlatformSerializable; +use dpp::voting::vote_polls::VotePoll; +use grovedb::TransactionArg; +use platform_version::version::PlatformVersion; +use crate::common::encode::encode_u64; +use crate::drive::grove_operations::BatchDeleteApplyType::StatefulBatchDelete; + +impl Drive { + /// We add votes poll references by end date in order to be able to check on every new block if + /// any vote polls should be closed. + pub(in crate::drive::votes::insert) fn remove_vote_poll_end_date_query_operations_v0( + &self, + vote_polls: Vec, + end_date: TimestampMillis, + batch_operations: &mut Vec, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + // This is a GroveDB Tree (Not Sub Tree Merk representation) + // End Date queries + // / \ + // 15/08/2025 5PM 15/08/2025 6PM + // / \ | + // VotePoll Info 1 VotePoll Info 2 VotePoll Info 3 + + // Let's start by inserting a tree for the end date + + + let time_path = vote_contested_resource_end_date_queries_at_time_tree_path_vec(end_date); + + let delete_apply_type = StatefulBatchDelete { + is_known_to_be_subtree_with_sum: Some((false, false)), + }; + + for vote_poll in vote_polls { + let unique_id = vote_poll.unique_id()?; + + self.batch_delete( + time_path.as_ref().into(), + unique_id.as_bytes(), + delete_apply_type, + transaction, + batch_operations, + &platform_version.drive, + )?; + } + + + + let end_date_query_path = vote_contested_resource_end_date_queries_tree_path_vec(); + + let end_date_key = encode_u64(end_date); + + let delete_apply_type = StatefulBatchDelete { + is_known_to_be_subtree_with_sum: Some((true, false)), + }; + + self.batch_delete( + end_date_query_path.into(), + end_date_key.as_bytes(), + delete_apply_type, + transaction, + batch_operations, + &platform_version.drive, + )?; + + Ok(()) + } +} diff --git a/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs b/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs index 07172d14f3..a234cb9acf 100644 --- a/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs +++ b/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs @@ -68,7 +68,7 @@ impl VotePollsByEndDateDriveQuery { transaction: TransactionArg, drive_operations: &mut Vec, platform_version: &PlatformVersion, - ) -> Result, Error> { + ) -> Result>, Error> { let path_query = Self::path_query_for_end_time_included(end_time, limit); let query_result = drive.grove_get_path_query( &path_query, @@ -80,20 +80,38 @@ impl VotePollsByEndDateDriveQuery { match query_result { Err(Error::GroveDB(GroveError::PathKeyNotFound(_))) | Err(Error::GroveDB(GroveError::PathNotFound(_))) - | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok(Vec::new()), + | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok(BTreeMap::new()), Err(e) => Err(e), - Ok((query_result_elements, _)) => query_result_elements - .to_elements() - .into_iter() - .map(|element| { - let contested_document_resource_vote_poll_bytes = - element.into_item_bytes().map_err(Error::from)?; - let vote_poll = ContestedDocumentResourceVotePoll::deserialize_from_bytes( - &contested_document_resource_vote_poll_bytes, - )?; - Ok(vote_poll) - }) - .collect::, Error>>(), + Ok((query_result_elements, _)) => { + let vote_polls_by_end_date = query_result_elements + .to_path_key_elements() + .into_iter() + .map(|(path, _, element)| { + let Some(last_path_component) = path.last() else { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "we should always have a path not be null".to_string(), + ))); + }; + let timestamp = decode_u64(last_path_component).map_err(Error::from)?; + let contested_document_resource_vote_poll_bytes = + element.into_item_bytes().map_err(Error::from)?; + let vote_poll = ContestedDocumentResourceVotePoll::deserialize_from_bytes( + &contested_document_resource_vote_poll_bytes, + )?; + Ok((timestamp, vote_poll)) + }) + .collect::, Error>>()? + .into_iter() + .fold( + BTreeMap::new(), + |mut acc: BTreeMap>, + (timestamp, vote_poll)| { + acc.entry(timestamp).or_default().push(vote_poll); + acc + }, + ); + Ok(vote_polls_by_end_date) + }, } } diff --git a/packages/rs-platform-version/src/version/dpp_versions.rs b/packages/rs-platform-version/src/version/dpp_versions.rs index ec83575ddc..16c0a0ed90 100644 --- a/packages/rs-platform-version/src/version/dpp_versions.rs +++ b/packages/rs-platform-version/src/version/dpp_versions.rs @@ -225,7 +225,7 @@ pub struct IdentityVersions { #[derive(Clone, Debug, Default)] pub struct VotingVersions { - pub default_vote_time_ms: u64, + pub default_vote_poll_time_duration_ms: u64, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 7bba988667..207ead0352 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -285,7 +285,8 @@ pub struct DriveVoteInsertMethodVersions { pub struct DriveVoteContestedResourceInsertMethodVersions { pub register_contested_resource_identity_vote: FeatureVersion, pub register_identity_vote: FeatureVersion, - pub add_vote_poll_end_date_query: FeatureVersion, + pub add_vote_poll_end_date_query_operations: FeatureVersion, + pub remove_vote_poll_end_date_query_operations: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 016921e5ae..4ccf10d9ed 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -231,7 +231,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { register_contested_resource_identity_vote: 0, register_identity_vote: 0, - add_vote_poll_end_date_query: 0, + add_vote_poll_end_date_query_operations: 0, }, cleanup: DriveVoteCleanupMethodVersions { remove_votes_for_identity: 0, @@ -1162,7 +1162,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { }, }, voting_versions: VotingVersions { - default_vote_time_ms: 0, + default_vote_poll_time_duration_ms: 1_209_600_000, //2 weeks }, asset_lock_versions: AssetLockVersions { reduced_asset_lock_value: FeatureVersionBounds { diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 714e0c3495..8ae0edaf62 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -239,7 +239,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { register_contested_resource_identity_vote: 0, register_identity_vote: 0, - add_vote_poll_end_date_query: 0, + add_vote_poll_end_date_query_operations: 0, }, cleanup: DriveVoteCleanupMethodVersions { remove_votes_for_identity: 0, @@ -1162,7 +1162,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { }, }, voting_versions: VotingVersions { - default_vote_time_ms: 0, + default_vote_poll_time_duration_ms: 1_209_600_000, //2 weeks }, asset_lock_versions: AssetLockVersions { reduced_asset_lock_value: FeatureVersionBounds { diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 05a83eb0ef..591294c53e 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -230,7 +230,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { register_contested_resource_identity_vote: 0, register_identity_vote: 0, - add_vote_poll_end_date_query: 0, + add_vote_poll_end_date_query_operations: 0, }, cleanup: DriveVoteCleanupMethodVersions { remove_votes_for_identity: 0, @@ -1161,7 +1161,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { }, }, voting_versions: VotingVersions { - default_vote_time_ms: 0, + default_vote_poll_time_duration_ms: 1_209_600_000, //2 weeks }, asset_lock_versions: AssetLockVersions { reduced_asset_lock_value: FeatureVersionBounds { From 9e09c5ac86d503272fda3bcf81e0fd4728b1a8dc Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 27 May 2024 10:13:17 +0200 Subject: [PATCH 080/135] small fixes --- .../voting/clean_up_after_vote_poll_end/v0/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/v0/mod.rs index 14e9587b31..1058e06a95 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/v0/mod.rs @@ -4,6 +4,8 @@ use crate::rpc::core::CoreRPCLike; use dpp::block::block_info::BlockInfo; use dpp::document::DocumentV0Getters; use dpp::version::PlatformVersion; +use dpp::voting::vote_polls::VotePoll; +use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; use drive::grovedb::TransactionArg; use drive::query::vote_poll_vote_state_query::FinalizedContender; @@ -15,11 +17,13 @@ where { /// Checks for ended vote polls #[inline(always)] - pub(super) fn clean_up_after_vote_poll_end_v0( + pub(super) fn clean_up_after_vote_polls_end_v0( &self, block_info: &BlockInfo, + vote_poll: &[&VotePoll], transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { + self.drive.remove_vote_poll_end_date_query_operations(vote_poll) } } From bc51eca280aa7fbed5733fb51e00c0b2c45a62cc Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 27 May 2024 12:31:59 +0200 Subject: [PATCH 081/135] more fixes --- .../v0/mod.rs | 12 +++++++----- .../rs-platform-version/src/version/mocks/v2_test.rs | 3 +++ .../rs-platform-version/src/version/mocks/v3_test.rs | 3 +++ packages/rs-platform-version/src/version/v1.rs | 3 +++ 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/v0/mod.rs index e2449a36cd..a682a9417d 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/v0/mod.rs @@ -1,4 +1,4 @@ -use crate::drive::votes::paths::{vote_contested_resource_end_date_queries_at_time_tree_path_vec, vote_contested_resource_end_date_queries_tree_path_vec}; +use crate::drive::votes::paths::{vote_contested_resource_end_date_queries_at_time_tree_path_vec, vote_contested_resource_end_date_queries_tree_path, vote_contested_resource_end_date_queries_tree_path_vec}; use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; @@ -37,11 +37,13 @@ impl Drive { is_known_to_be_subtree_with_sum: Some((false, false)), }; + let time_path_borrowed: Vec<&[u8]> = time_path.iter().map(|a| a.as_slice()).collect(); + for vote_poll in vote_polls { let unique_id = vote_poll.unique_id()?; self.batch_delete( - time_path.as_ref().into(), + time_path_borrowed.as_slice().into(), unique_id.as_bytes(), delete_apply_type, transaction, @@ -52,7 +54,7 @@ impl Drive { - let end_date_query_path = vote_contested_resource_end_date_queries_tree_path_vec(); + let end_date_query_path = vote_contested_resource_end_date_queries_tree_path(); let end_date_key = encode_u64(end_date); @@ -61,8 +63,8 @@ impl Drive { }; self.batch_delete( - end_date_query_path.into(), - end_date_key.as_bytes(), + (&end_date_query_path).into(), + end_date_key.as_slice(), delete_apply_type, transaction, batch_operations, diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 4ccf10d9ed..c1bafea963 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -232,6 +232,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { register_contested_resource_identity_vote: 0, register_identity_vote: 0, add_vote_poll_end_date_query_operations: 0, + remove_vote_poll_end_date_query_operations: 0, }, cleanup: DriveVoteCleanupMethodVersions { remove_votes_for_identity: 0, @@ -625,6 +626,8 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { append_signatures_and_broadcast_withdrawal_transactions: 0, }, voting: DriveAbciVotingMethodVersions { + keep_record_of_vote_poll: 0, + clean_up_after_vote_poll_end: 0, check_for_ended_vote_polls: 0, check_for_ended_contested_resource_vote_polls: 0, tally_votes_for_contested_document_resource_vote_poll: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 8ae0edaf62..019145b61f 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -240,6 +240,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { register_contested_resource_identity_vote: 0, register_identity_vote: 0, add_vote_poll_end_date_query_operations: 0, + remove_vote_poll_end_date_query_operations: 0, }, cleanup: DriveVoteCleanupMethodVersions { remove_votes_for_identity: 0, @@ -625,6 +626,8 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { append_signatures_and_broadcast_withdrawal_transactions: 0, }, voting: DriveAbciVotingMethodVersions { + keep_record_of_vote_poll: 0, + clean_up_after_vote_poll_end: 0, check_for_ended_vote_polls: 0, check_for_ended_contested_resource_vote_polls: 0, tally_votes_for_contested_document_resource_vote_poll: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 591294c53e..eb8c5079f4 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -231,6 +231,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { register_contested_resource_identity_vote: 0, register_identity_vote: 0, add_vote_poll_end_date_query_operations: 0, + remove_vote_poll_end_date_query_operations: 0, }, cleanup: DriveVoteCleanupMethodVersions { remove_votes_for_identity: 0, @@ -624,6 +625,8 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { append_signatures_and_broadcast_withdrawal_transactions: 0, }, voting: DriveAbciVotingMethodVersions { + keep_record_of_vote_poll: 0, + clean_up_after_vote_poll_end: 0, check_for_ended_vote_polls: 0, check_for_ended_contested_resource_vote_polls: 0, tally_votes_for_contested_document_resource_vote_poll: 0, From d21ee73a3f9bbbed0e907688ba46e69e6b13d21f Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 27 May 2024 13:31:10 +0200 Subject: [PATCH 082/135] builds --- .../src/data_contract/accessors/v0/mod.rs | 2 +- .../v0/mod.rs | 6 +- .../v0/mod.rs | 8 +-- packages/rs-dpp/src/state_transition/mod.rs | 2 +- .../v0/from_document.rs | 1 - .../document_create_transition/v0/mod.rs | 1 + packages/rs-dpp/src/voting/votes/mod.rs | 5 ++ .../src/voting/votes/resource_vote/v0/mod.rs | 7 ++ .../v0/mod.rs | 20 +++--- .../mod.rs | 15 ++-- .../v0/mod.rs | 19 +++-- .../voting/keep_record_of_vote_poll/v0/mod.rs | 1 + .../execution/platform_events/voting/mod.rs | 2 +- .../verify_state_transitions.rs | 8 ++- .../v0/mod.rs | 9 ++- .../v0/mod.rs | 34 +++++---- .../voting/verify_masternode_vote/mod.rs | 6 +- .../voting/verify_masternode_vote/v0/mod.rs | 69 ++++++------------- .../mod.rs | 17 ++--- .../v0/mod.rs | 23 +++---- .../src/drive/votes/resolved/votes/mod.rs | 30 ++++++++ .../votes/resolved_resource_vote/resolve.rs | 1 - .../resolved_resource_vote/v0/resolve.rs | 1 - .../src/query/vote_polls_by_end_date_query.rs | 5 +- .../src/version/drive_versions.rs | 2 +- .../src/version/mocks/v2_test.rs | 2 +- .../src/version/mocks/v3_test.rs | 2 +- .../rs-platform-version/src/version/v1.rs | 2 +- 28 files changed, 165 insertions(+), 135 deletions(-) rename packages/rs-drive-abci/src/execution/platform_events/voting/{clean_up_after_vote_poll_end => clean_up_after_contested_resources_vote_polls_end}/mod.rs (61%) rename packages/rs-drive-abci/src/execution/platform_events/voting/{clean_up_after_vote_poll_end => clean_up_after_contested_resources_vote_polls_end}/v0/mod.rs (62%) diff --git a/packages/rs-dpp/src/data_contract/accessors/v0/mod.rs b/packages/rs-dpp/src/data_contract/accessors/v0/mod.rs index 32b53e9572..e2e3e5fcd4 100644 --- a/packages/rs-dpp/src/data_contract/accessors/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/accessors/v0/mod.rs @@ -1,7 +1,7 @@ use crate::data_contract::config::DataContractConfig; use crate::data_contract::document_type::{DocumentType, DocumentTypeRef}; use crate::data_contract::errors::DataContractError; -use crate::data_contract::{DataContract, DocumentName}; +use crate::data_contract::DocumentName; use crate::metadata::Metadata; use platform_value::Identifier; diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/contested_vote_poll_for_document/v0/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/contested_vote_poll_for_document/v0/mod.rs index 8067ef598b..d8f419a1a4 100644 --- a/packages/rs-dpp/src/data_contract/document_type/methods/contested_vote_poll_for_document/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/methods/contested_vote_poll_for_document/v0/mod.rs @@ -11,8 +11,8 @@ impl DocumentTypeV0 { document: &Document, ) -> Option { self.indexes() - .iter() - .find(|(name, index)| { + .values() + .find(|index| { if let Some(contested_index_info) = &index.contested_index { contested_index_info .field_matches @@ -28,7 +28,7 @@ impl DocumentTypeV0 { false } }) - .map(|(name, index)| { + .map(|index| { let index_values = index.extract_values(document.properties()); VotePoll::ContestedDocumentResourceVotePoll(ContestedDocumentResourceVotePoll { contract_id: self.data_contract_id, diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/v0/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/v0/mod.rs index 15311deae3..f89a96efb7 100644 --- a/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/v0/mod.rs @@ -12,8 +12,8 @@ impl DocumentTypeV0 { platform_version: &PlatformVersion, ) -> Option<(String, Credits)> { self.indexes() - .iter() - .find(|(name, index)| { + .values() + .find(|index| { if let Some(contested_index_info) = &index.contested_index { contested_index_info .field_matches @@ -29,9 +29,9 @@ impl DocumentTypeV0 { false } }) - .map(|(index_name, _)| { + .map(|index| { ( - index_name.clone(), + index.name.clone(), platform_version .fee_version .vote_resolution_fund_fees diff --git a/packages/rs-dpp/src/state_transition/mod.rs b/packages/rs-dpp/src/state_transition/mod.rs index 646fcf5396..1eb1f4da05 100644 --- a/packages/rs-dpp/src/state_transition/mod.rs +++ b/packages/rs-dpp/src/state_transition/mod.rs @@ -713,7 +713,7 @@ impl StateTransition { let data = self.signable_bytes()?; bls.verify_signature(self.signature().as_slice(), &data, public_key) - .map(|e| ()) + .map(|_| ()) .map_err(|e| { // TODO: it shouldn't respond with consensus error ProtocolError::from(ConsensusError::SignatureError( diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/from_document.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/from_document.rs index b334ae71e5..3132a4ba07 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/from_document.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/from_document.rs @@ -1,4 +1,3 @@ -use crate::data_contract::document_type::accessors::DocumentTypeV0Getters; use crate::data_contract::document_type::methods::DocumentTypeV0Methods; use crate::data_contract::document_type::DocumentTypeRef; use crate::document::{Document, DocumentV0Getters}; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs index 3eee8c3afd..b2ec1c22a7 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs @@ -31,6 +31,7 @@ use crate::state_transition::documents_batch_transition::document_base_transitio use crate::state_transition::documents_batch_transition::document_base_transition::v0::DocumentTransitionObjectLike; use crate::state_transition::documents_batch_transition::document_base_transition::DocumentBaseTransition; use derive_more::Display; +#[cfg(feature = "state-transition-value-conversion")] use platform_value::btreemap_extensions::BTreeValueRemoveTupleFromMapHelper; use platform_version::version::PlatformVersion; diff --git a/packages/rs-dpp/src/voting/votes/mod.rs b/packages/rs-dpp/src/voting/votes/mod.rs index 636cd5d302..b2c019b858 100644 --- a/packages/rs-dpp/src/voting/votes/mod.rs +++ b/packages/rs-dpp/src/voting/votes/mod.rs @@ -31,4 +31,9 @@ impl Vote { Vote::ResourceVote(resource_vote) => resource_vote.vote_poll().specialized_balance_id(), } } + pub fn unique_id(&self) -> Result { + match self { + Vote::ResourceVote(resource_vote) => resource_vote.vote_poll().unique_id(), + } + } } diff --git a/packages/rs-dpp/src/voting/votes/resource_vote/v0/mod.rs b/packages/rs-dpp/src/voting/votes/resource_vote/v0/mod.rs index 446e80e0c4..9e05b3044d 100644 --- a/packages/rs-dpp/src/voting/votes/resource_vote/v0/mod.rs +++ b/packages/rs-dpp/src/voting/votes/resource_vote/v0/mod.rs @@ -3,6 +3,7 @@ use crate::voting::vote_polls::VotePoll; use crate::ProtocolError; use bincode::{Decode, Encode}; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +use platform_value::Identifier; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Encode, Decode, PlatformDeserialize, PlatformSerialize, PartialEq)] @@ -25,3 +26,9 @@ impl Default for ResourceVoteV0 { } } } + +impl ResourceVoteV0 { + pub fn vote_poll_unique_id(&self) -> Result { + self.vote_poll.unique_id() + } +} diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs index dfa9d6aa85..e00994f9eb 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs @@ -37,13 +37,13 @@ where )?; for (end_date, vote_polls) in vote_polls { - for vote_poll in vote_polls { + for vote_poll in &vote_polls { let resolved_vote_poll = vote_poll.resolve(&self.drive, transaction, platform_version)?; let document_type = resolved_vote_poll.document_type()?; // let's see who actually won let contenders = self.tally_votes_for_contested_document_resource_vote_poll( - &vote_poll, + vote_poll, transaction, platform_version, )?; @@ -91,14 +91,6 @@ where transaction, platform_version, )?; - // We need to clean up the vote poll - // This means removing it and also removing all current votes - self.clean_up_after_vote_poll_end( - block_info, - &resolved_vote_poll, - transaction, - platform_version, - )?; // We award the document to the winner of the vote poll self.award_document_to_winner( block_info, @@ -110,6 +102,14 @@ where } } } + // We need to clean up the vote poll + // This means removing it and also removing all current votes + self.clean_up_after_contested_resources_vote_polls_end( + block_info, + &vote_polls, + transaction, + platform_version, + )?; } Ok(()) diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/mod.rs similarity index 61% rename from packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/mod.rs rename to packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/mod.rs index 6f3c8133e7..fd787e0759 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/mod.rs @@ -4,7 +4,7 @@ use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; -use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use drive::grovedb::TransactionArg; mod v0; @@ -14,10 +14,10 @@ where C: CoreRPCLike, { /// Checks for ended vote polls - pub(in crate::execution) fn clean_up_after_vote_poll_end( + pub(in crate::execution) fn clean_up_after_contested_resources_vote_polls_end( &self, block_info: &BlockInfo, - vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, + vote_polls: &[ContestedDocumentResourceVotePoll], transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { @@ -27,9 +27,14 @@ where .voting .clean_up_after_vote_poll_end { - 0 => self.clean_up_after_vote_poll_end_v0(block_info, transaction, platform_version), + 0 => self.clean_up_after_contested_resources_vote_polls_end_v0( + block_info, + vote_polls, + transaction, + platform_version, + ), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { - method: "clean_up_after_vote_poll_end".to_string(), + method: "clean_up_after_contested_resources_vote_polls_end".to_string(), known_versions: vec![0], received: version, })), diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs similarity index 62% rename from packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/v0/mod.rs rename to packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs index 1058e06a95..9edae1d363 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_poll_end/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs @@ -4,9 +4,10 @@ use crate::rpc::core::CoreRPCLike; use dpp::block::block_info::BlockInfo; use dpp::document::DocumentV0Getters; use dpp::version::PlatformVersion; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::voting::vote_polls::VotePoll; -use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; +use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use drive::grovedb::TransactionArg; use drive::query::vote_poll_vote_state_query::FinalizedContender; use drive::query::VotePollsByEndDateDriveQuery; @@ -17,13 +18,23 @@ where { /// Checks for ended vote polls #[inline(always)] - pub(super) fn clean_up_after_vote_polls_end_v0( + pub(super) fn clean_up_after_contested_resources_vote_polls_end_v0( &self, block_info: &BlockInfo, - vote_poll: &[&VotePoll], + vote_polls: &[ContestedDocumentResourceVotePoll], transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { - self.drive.remove_vote_poll_end_date_query_operations(vote_poll) + let mut operations = vec![]; + self.drive + .remove_contested_resource_vote_poll_end_date_query_operations( + vote_polls, + block_info.time_ms, + &mut operations, + transaction, + platform_version, + )?; + //todo() + Ok(()) } } diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs index 1414cd0ecd..06b3897188 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs @@ -22,5 +22,6 @@ where platform_version: &PlatformVersion, ) -> Result<(), Error> { // We want to store information about the vote poll in an efficient way + todo!() } } diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs index a0d5b6b604..fbc3fba77e 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs @@ -1,7 +1,7 @@ mod award_document_to_winner; mod check_for_ended_contested_resource_vote_polls; mod check_for_ended_vote_polls; -mod clean_up_after_vote_poll_end; +mod clean_up_after_contested_resources_vote_polls_end; mod delay_vote_poll; mod keep_record_of_vote_poll; mod lock_vote_poll; diff --git a/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs b/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs index 489c99f9f3..a5787e38d2 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs @@ -799,11 +799,13 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed( let response_proof = response.proof_owned().expect("proof should be present"); + let vote: Vote = masternode_vote_action.vote_ref().clone().into(); + // we expect to get a vote that matches the state transition let (root_hash_vote, maybe_vote) = Drive::verify_masternode_vote( &response_proof.grovedb_proof, masternode_vote_action.pro_tx_hash().into_buffer(), - masternode_vote_action.vote_ref(), + &vote, true, platform_version, ) @@ -817,9 +819,9 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed( ); if *was_executed { - let vote = maybe_vote.expect("expected a vote"); + let executed_vote = maybe_vote.expect("expected a vote"); - assert_eq!(&vote, masternode_vote_action.vote_ref()); + assert_eq!(&executed_vote, &vote); } } StateTransitionAction::BumpIdentityNonceAction(_) => {} diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs index 575aa41402..49e0a63715 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs @@ -48,9 +48,12 @@ impl Drive { platform_version, )?; - let end_date = block_info - .time_ms - .saturating_add(platform_version.dpp.voting_versions.default_vote_poll_time_duration_ms); + let end_date = block_info.time_ms.saturating_add( + platform_version + .dpp + .voting_versions + .default_vote_poll_time_duration_ms, + ); self.add_vote_poll_end_date_query_operations( document_and_contract_info.owned_document_info.owner_id, diff --git a/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs b/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs index 0cf3715cc6..fbd432a5d8 100644 --- a/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs @@ -42,8 +42,6 @@ use crate::drive::Drive; use crate::drive::identity::key::fetch::IdentityKeysRequest; use crate::drive::object_size_info::{DataContractResolvedInfo, DocumentTypeInfo}; use crate::drive::verify::RootHash; -use crate::drive::votes::resolved::votes::resolve::VoteResolver; -use crate::drive::votes::resolved::votes::ResolvedVote; use crate::error::Error; use crate::error::proof::ProofError; use crate::query::{SingleDocumentDriveQuery, SingleDocumentDriveQueryContestedStatus}; @@ -383,26 +381,32 @@ impl Drive { StateTransition::MasternodeVote(masternode_vote) => { let pro_tx_hash = masternode_vote.pro_tx_hash(); let vote = masternode_vote.vote(); - let (contract, document_type_name) = match vote { Vote::ResourceVote(resource_vote) => { - match resource_vote.vote_poll() { - VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll) => { - (known_contracts_provider_fn(&contested_document_resource_vote_poll.contract_id)?.ok_or( - Error::Proof(ProofError::UnknownContract(format!( + let (contract, document_type_name) = match vote { + Vote::ResourceVote(resource_vote) => match resource_vote.vote_poll() { + VotePoll::ContestedDocumentResourceVotePoll( + contested_document_resource_vote_poll, + ) => ( + known_contracts_provider_fn( + &contested_document_resource_vote_poll.contract_id, + )? + .ok_or(Error::Proof( + ProofError::UnknownContract(format!( "unknown contract with id {}", contested_document_resource_vote_poll.contract_id - ))), - )?, contested_document_resource_vote_poll.document_type_name.as_str()) - } - } - } }; - + )), + ))?, + contested_document_resource_vote_poll + .document_type_name + .as_str(), + ), + }, + }; + // we expect to get an identity that matches the state transition let (root_hash, vote) = Drive::verify_masternode_vote( proof, pro_tx_hash.to_buffer(), vote, - DataContractResolvedInfo::BorrowedDataContract(&contract), - DocumentTypeInfo::DocumentTypeNameAsStr(document_type_name), false, platform_version, )?; diff --git a/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/mod.rs index c1d89062fc..0ce8a57e74 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/mod.rs @@ -8,9 +8,9 @@ use crate::error::Error; use crate::drive::verify::RootHash; +use crate::drive::object_size_info::{DataContractResolvedInfo, DocumentTypeInfo}; use dpp::version::PlatformVersion; use dpp::voting::votes::Vote; -use crate::drive::object_size_info::{DataContractResolvedInfo, DocumentTypeInfo}; impl Drive { /// Verifies the authenticity of a masternode vote using the provided proof. @@ -42,8 +42,6 @@ impl Drive { proof: &[u8], masternode_pro_tx_hash: [u8; 32], vote: &Vote, - contract: DataContractResolvedInfo, - document_type: DocumentTypeInfo, verify_subset_of_proof: bool, platform_version: &PlatformVersion, ) -> Result<(RootHash, Option), Error> { @@ -58,8 +56,6 @@ impl Drive { proof, masternode_pro_tx_hash, vote, - contract, - document_type, verify_subset_of_proof, ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { diff --git a/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs index 308ae4f37b..6065543903 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs @@ -1,17 +1,18 @@ -use grovedb::{PathQuery, SizedQuery}; -use dpp::data_contract::DataContract; -use dpp::data_contract::document_type::DocumentTypeRef; use crate::drive::Drive; +use dpp::data_contract::document_type::DocumentTypeRef; +use dpp::data_contract::DataContract; +use grovedb::{GroveDb, PathQuery, SizedQuery}; use crate::error::Error; use crate::drive::verify::RootHash; -use crate::drive::votes::resolved::votes::ResolvedVote; -use dpp::voting::votes::Vote; use crate::drive::object_size_info::{DataContractResolvedInfo, DocumentTypeInfo}; use crate::drive::votes::paths::vote_contested_resource_identity_votes_tree_path_for_identity_vec; +use crate::drive::votes::resolved::votes::ResolvedVote; +use crate::error::proof::ProofError; use crate::query::Query; +use dpp::voting::votes::Vote; impl Drive { /// Verifies the balance of an identity by their identity ID. @@ -45,8 +46,6 @@ impl Drive { proof: &[u8], masternode_pro_tx_hash: [u8; 32], vote: &Vote, - contract: DataContractResolvedInfo, - document_type: DocumentTypeInfo, verify_subset_of_proof: bool, ) -> Result<(RootHash, Option), Error> { // First we should get the overall document_type_path @@ -59,46 +58,20 @@ impl Drive { let mut query = Query::new(); query.insert_key(vote_id.to_vec()); - Ok(PathQuery::new(path, SizedQuery::new(query, Some(1), None))) - - todo!() - // let mut path_query = Self::identity_balance_query(&identity_id); - // path_query.query.limit = Some(1); - // let (root_hash, mut proved_key_values) = if verify_subset_of_proof { - // GroveDb::verify_subset_query_with_absence_proof(proof, &path_query)? - // } else { - // GroveDb::verify_query_with_absence_proof(proof, &path_query)? - // }; - // if proved_key_values.len() == 1 { - // let (path, key, maybe_element) = &proved_key_values.remove(0); - // if path != &balance_path() { - // return Err(Error::Proof(ProofError::CorruptedProof( - // "we did not get back an element for the correct path in balances".to_string(), - // ))); - // } - // if key != &identity_id { - // return Err(Error::Proof(ProofError::CorruptedProof( - // "we did not get back an element for the correct key in balances".to_string(), - // ))); - // } - // - // let signed_balance = maybe_element - // .as_ref() - // .map(|element| { - // element - // .as_sum_item_value() - // .map_err(Error::GroveDB)? - // .try_into() - // .map_err(|_| { - // Error::Proof(ProofError::IncorrectValueSize("value size is incorrect")) - // }) - // }) - // .transpose()?; - // Ok((root_hash, signed_balance)) - // } else { - // Err(Error::Proof(ProofError::TooManyElements( - // "expected one identity balance", - // ))) - // } + let path_query = PathQuery::new(path, SizedQuery::new(query, Some(1), None)); + + let (root_hash, mut proved_key_values) = if verify_subset_of_proof { + GroveDb::verify_subset_query_with_absence_proof(proof, &path_query)? + } else { + GroveDb::verify_query_with_absence_proof(proof, &path_query)? + }; + if proved_key_values.len() == 1 { + let (path, key, maybe_element) = &proved_key_values.remove(0); + todo!() + } else { + Err(Error::Proof(ProofError::TooManyElements( + "expected one masternode vote", + ))) + } } } diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/mod.rs index e9141fe740..635e594367 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/mod.rs @@ -1,25 +1,22 @@ mod v0; use crate::drive::Drive; -use grovedb::batch::KeyInfoPath; -use std::collections::HashMap; use crate::error::drive::DriveError; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; -use dpp::block::block_info::BlockInfo; use dpp::prelude::TimestampMillis; use dpp::version::PlatformVersion; -use dpp::voting::vote_polls::VotePoll; -use grovedb::{EstimatedLayerInformation, TransactionArg}; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use grovedb::TransactionArg; impl Drive { /// We add votes poll references by end date in order to be able to check on every new block if /// any votes poll should be closed. This will remove them to recoup space - pub fn remove_vote_poll_end_date_query_operations( + pub fn remove_contested_resource_vote_poll_end_date_query_operations( &self, - vote_polls: Vec, + vote_polls: &[ContestedDocumentResourceVotePoll], end_date: TimestampMillis, batch_operations: &mut Vec, transaction: TransactionArg, @@ -30,9 +27,9 @@ impl Drive { .methods .vote .contested_resource_insert - .remove_vote_poll_end_date_query_operations + .remove_contested_resource_vote_poll_end_date_query_operations { - 0 => self.remove_vote_poll_end_date_query_operations_v0( + 0 => self.remove_contested_resource_vote_poll_end_date_query_operations_v0( vote_polls, end_date, batch_operations, @@ -40,7 +37,7 @@ impl Drive { platform_version, ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "remove_vote_poll_end_date_query".to_string(), + method: "remove_contested_resource_vote_poll_end_date_query_operations".to_string(), known_versions: vec![0], received: version, })), diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/v0/mod.rs index a682a9417d..bf1817314b 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/v0/mod.rs @@ -1,21 +1,23 @@ -use crate::drive::votes::paths::{vote_contested_resource_end_date_queries_at_time_tree_path_vec, vote_contested_resource_end_date_queries_tree_path, vote_contested_resource_end_date_queries_tree_path_vec}; +use crate::common::encode::encode_u64; +use crate::drive::grove_operations::BatchDeleteApplyType::StatefulBatchDelete; +use crate::drive::votes::paths::{ + vote_contested_resource_end_date_queries_at_time_tree_path_vec, + vote_contested_resource_end_date_queries_tree_path, +}; use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::identity::TimestampMillis; -use dpp::serialization::PlatformSerializable; -use dpp::voting::vote_polls::VotePoll; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use grovedb::TransactionArg; use platform_version::version::PlatformVersion; -use crate::common::encode::encode_u64; -use crate::drive::grove_operations::BatchDeleteApplyType::StatefulBatchDelete; impl Drive { /// We add votes poll references by end date in order to be able to check on every new block if /// any vote polls should be closed. - pub(in crate::drive::votes::insert) fn remove_vote_poll_end_date_query_operations_v0( + pub(in crate::drive::votes::insert) fn remove_contested_resource_vote_poll_end_date_query_operations_v0( &self, - vote_polls: Vec, + vote_polls: &[ContestedDocumentResourceVotePoll], end_date: TimestampMillis, batch_operations: &mut Vec, transaction: TransactionArg, @@ -30,15 +32,14 @@ impl Drive { // Let's start by inserting a tree for the end date - let time_path = vote_contested_resource_end_date_queries_at_time_tree_path_vec(end_date); let delete_apply_type = StatefulBatchDelete { is_known_to_be_subtree_with_sum: Some((false, false)), }; - + let time_path_borrowed: Vec<&[u8]> = time_path.iter().map(|a| a.as_slice()).collect(); - + for vote_poll in vote_polls { let unique_id = vote_poll.unique_id()?; @@ -52,8 +53,6 @@ impl Drive { )?; } - - let end_date_query_path = vote_contested_resource_end_date_queries_tree_path(); let end_date_key = encode_u64(end_date); diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/mod.rs b/packages/rs-drive/src/drive/votes/resolved/votes/mod.rs index 78d02ac876..e994280193 100644 --- a/packages/rs-drive/src/drive/votes/resolved/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolved/votes/mod.rs @@ -2,9 +2,15 @@ pub(crate) mod resolve; /// Resolved resource vote module pub mod resolved_resource_vote; +use crate::drive::votes::resolved::vote_polls::ResolvedVotePoll; use crate::drive::votes::resolved::votes::resolved_resource_vote::accessors::v0::ResolvedResourceVoteGettersV0; use crate::drive::votes::resolved::votes::resolved_resource_vote::ResolvedResourceVote; use dpp::identifier::Identifier; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::voting::vote_polls::VotePoll; +use dpp::voting::votes::resource_vote::v0::ResourceVoteV0; +use dpp::voting::votes::resource_vote::ResourceVote; +use dpp::voting::votes::Vote; use dpp::ProtocolError; /// Represents the different types of resolved votes within the system. @@ -34,3 +40,27 @@ impl ResolvedVote { } } } + +impl From for Vote { + fn from(value: ResolvedVote) -> Self { + match value { + ResolvedVote::ResolvedResourceVote(resolved_resource_vote) => { + match resolved_resource_vote { + ResolvedResourceVote::V0(v0) => { + let vote_choice = v0.resource_vote_choice; + match v0.resolved_vote_poll { + ResolvedVotePoll::ContestedDocumentResourceVotePollWithContractInfo( + contested_document_resource, + ) => Self::ResourceVote(ResourceVote::V0(ResourceVoteV0 { + vote_poll: VotePoll::ContestedDocumentResourceVotePoll( + contested_document_resource.into(), + ), + resource_vote_choice: vote_choice, + })), + } + } + } + } + } + } +} diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/resolve.rs b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/resolve.rs index 64b987e2b0..a52017c0f5 100644 --- a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/resolve.rs +++ b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/resolve.rs @@ -1,4 +1,3 @@ -use crate::drive::votes::resolved::votes::resolve::VoteResolver; use crate::drive::votes::resolved::votes::resolved_resource_vote::v0::resolve::ResourceVoteResolverV0; use crate::drive::votes::resolved::votes::resolved_resource_vote::ResolvedResourceVote; use crate::drive::Drive; diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/resolve.rs b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/resolve.rs index 2f4803c71a..975ccc234c 100644 --- a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/resolve.rs +++ b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/resolve.rs @@ -1,5 +1,4 @@ use crate::drive::votes::resolved::vote_polls::resolve::VotePollResolver; -use crate::drive::votes::resolved::votes::resolve::VoteResolver; use crate::drive::votes::resolved::votes::resolved_resource_vote::v0::ResolvedResourceVoteV0; use crate::drive::Drive; use crate::error::Error; diff --git a/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs b/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs index a234cb9acf..4a28938447 100644 --- a/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs +++ b/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs @@ -6,12 +6,11 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use crate::query::{GroveError, Query}; use dpp::block::block_info::BlockInfo; -use dpp::data_contract::document_type::DocumentPropertyType; use dpp::fee::Credits; use dpp::prelude::{TimestampIncluded, TimestampMillis}; use dpp::serialization::PlatformDeserializable; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; -use grovedb::query_result_type::{Key, QueryResultElements, QueryResultType}; +use grovedb::query_result_type::{QueryResultElements, QueryResultType}; use grovedb::{PathQuery, SizedQuery, TransactionArg}; use platform_version::version::PlatformVersion; use std::collections::BTreeMap; @@ -111,7 +110,7 @@ impl VotePollsByEndDateDriveQuery { }, ); Ok(vote_polls_by_end_date) - }, + } } } diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 207ead0352..140742002c 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -286,7 +286,7 @@ pub struct DriveVoteContestedResourceInsertMethodVersions { pub register_contested_resource_identity_vote: FeatureVersion, pub register_identity_vote: FeatureVersion, pub add_vote_poll_end_date_query_operations: FeatureVersion, - pub remove_vote_poll_end_date_query_operations: FeatureVersion, + pub remove_contested_resource_vote_poll_end_date_query_operations: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index c1bafea963..1dedb87b92 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -232,7 +232,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { register_contested_resource_identity_vote: 0, register_identity_vote: 0, add_vote_poll_end_date_query_operations: 0, - remove_vote_poll_end_date_query_operations: 0, + remove_contested_resource_vote_poll_end_date_query_operations: 0, }, cleanup: DriveVoteCleanupMethodVersions { remove_votes_for_identity: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 019145b61f..6bf5cd6f86 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -240,7 +240,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { register_contested_resource_identity_vote: 0, register_identity_vote: 0, add_vote_poll_end_date_query_operations: 0, - remove_vote_poll_end_date_query_operations: 0, + remove_contested_resource_vote_poll_end_date_query_operations: 0, }, cleanup: DriveVoteCleanupMethodVersions { remove_votes_for_identity: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index eb8c5079f4..1dd3e76c26 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -231,7 +231,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { register_contested_resource_identity_vote: 0, register_identity_vote: 0, add_vote_poll_end_date_query_operations: 0, - remove_vote_poll_end_date_query_operations: 0, + remove_contested_resource_vote_poll_end_date_query_operations: 0, }, cleanup: DriveVoteCleanupMethodVersions { remove_votes_for_identity: 0, From 24c4eb8a5c1e6f0fe1ecfc0cbbfb9b8d5190e18c Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 27 May 2024 14:53:35 +0200 Subject: [PATCH 083/135] resolve with provided contract --- .../resolve.rs | 32 +++++++++++++++++++ packages/rs-drive/src/error/contract.rs | 4 +++ .../src/query/vote_poll_vote_state_query.rs | 23 +++++++++++++ 3 files changed, 59 insertions(+) diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs index e18f474a76..efe2610fb8 100644 --- a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs @@ -8,6 +8,8 @@ use crate::error::contract::DataContractError; use crate::error::Error; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use grovedb::TransactionArg; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::prelude::DataContract; use platform_version::version::PlatformVersion; /// A trait for resolving information related to a contested document resource vote poll. @@ -58,6 +60,12 @@ pub trait ContestedDocumentResourceVotePollResolver { platform_version: &PlatformVersion, ) -> Result, Error>; + /// Resolve by providing the contract + fn resolve_with_provided_borrowed_contract<'a>( + &self, + data_contract: &'a DataContract, + ) -> Result, Error>; + /// Resolve owned into a struct that allows for a borrowed contract fn resolve_owned_allow_borrowed<'a>( self, @@ -136,6 +144,30 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote ) } + fn resolve_with_provided_borrowed_contract<'a>( + &self, + data_contract: &'a DataContract, + ) -> Result, Error> { + let ContestedDocumentResourceVotePoll { + contract_id, + document_type_name, + index_name, + index_values, + } = self; + + if contract_id != data_contract.id_ref() { + return Err(Error::DataContract(DataContractError::ProvidedContractMismatch(format!("data contract provided {} is not the one required {}", data_contract.id_ref(), contract_id)))); + } + Ok( + ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { + contract: DataContractResolvedInfo::BorrowedDataContract(data_contract), + document_type_name: document_type_name.clone(), + index_name: index_name.clone(), + index_values: index_values.clone(), + }, + ) + } + fn resolve_owned_allow_borrowed<'a>( self, drive: &Drive, diff --git a/packages/rs-drive/src/error/contract.rs b/packages/rs-drive/src/error/contract.rs index ef08a8f961..805249aa28 100644 --- a/packages/rs-drive/src/error/contract.rs +++ b/packages/rs-drive/src/error/contract.rs @@ -13,6 +13,10 @@ pub enum DataContractError { #[error("data contract cannot be retrieved: {0}")] MissingContract(String), + /// Data contract provided is not the one we want + #[error("data contract provided is incorrect: {0}")] + ProvidedContractMismatch(String), + /// Data contract storage error when data contract is too big #[error("data contract is too big to be stored: {0}")] ContractTooBig(String), diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index 4f9205400e..8009870be0 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -15,6 +15,7 @@ use dpp::identifier::Identifier; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use grovedb::query_result_type::{QueryResultElements, QueryResultType}; use grovedb::{Element, PathQuery, SizedQuery, TransactionArg}; +use dpp::data_contract::DataContract; use platform_version::version::PlatformVersion; /// Represents the types of results that can be obtained from a contested document vote poll query. @@ -229,6 +230,28 @@ impl ContestedDocumentVotePollDriveQuery { }) } + pub fn resolve_with_provided_borrowed_contract<'a>( + &self, + data_contract: &'a DataContract, + ) -> Result, Error> { + let ContestedDocumentVotePollDriveQuery { + vote_poll, + result_type, + offset, + limit, + start_at, + order_ascending, + } = self; + Ok(ResolvedContestedDocumentVotePollDriveQuery { + vote_poll: vote_poll.resolve_with_provided_borrowed_contract(data_contract)?, + result_type: *result_type, + offset: *offset, + limit: *limit, + start_at: *start_at, + order_ascending: *order_ascending, + }) + } + #[cfg(feature = "server")] /// Executes a query with proof and returns the items and fee. pub fn execute_with_proof( From 5c0547ff42d4957baa215e382e89ce96bbeee6b9 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 27 May 2024 15:20:04 +0200 Subject: [PATCH 084/135] fixes --- .../data_contract/document_type/index/mod.rs | 106 ++++++++++++++++-- .../document_type/index_level/mod.rs | 1 + .../drive/object_size_info/contract_info.rs | 15 ++- .../resolve.rs | 36 +++++- .../src/query/vote_poll_vote_state_query.rs | 25 +++++ 5 files changed, 166 insertions(+), 17 deletions(-) diff --git a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs index 2add8aa91f..36c6fa822e 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs @@ -1,4 +1,4 @@ -use serde::{Deserialize, Serialize}; +use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; #[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone, Eq)] pub enum OrderBy { @@ -13,18 +13,20 @@ use crate::data_contract::errors::DataContractError; use crate::ProtocolError; use anyhow::anyhow; -use crate::data_contract::document_type::ContestedIndexFieldMatch::Regex; use crate::data_contract::document_type::ContestedIndexResolution::MasternodeVote; use crate::data_contract::errors::DataContractError::RegexError; use platform_value::{Value, ValueMap}; use rand::distributions::{Alphanumeric, DistString}; use std::cmp::Ordering; -use std::{collections::BTreeMap, convert::TryFrom}; +use std::{collections::BTreeMap, convert::TryFrom, fmt}; +use serde::de::{VariantAccess, Visitor}; +use regex::Regex; pub mod random_index; #[repr(u8)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd)] +#[cfg_attr(feature = "index-serde-conversion", derive(Serialize, Deserialize))] pub enum ContestedIndexResolution { MasternodeVote = 0, } @@ -50,6 +52,91 @@ pub enum ContestedIndexFieldMatch { PositiveIntegerMatch(u128), } +#[cfg(feature = "index-serde-conversion")] +impl Serialize for ContestedIndexFieldMatch { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + ContestedIndexFieldMatch::Regex(ref regex) => { + serializer.serialize_newtype_variant("ContestedIndexFieldMatch", 0, "Regex", regex.as_str()) + } + ContestedIndexFieldMatch::PositiveIntegerMatch(ref num) => { + serializer.serialize_newtype_variant("ContestedIndexFieldMatch", 1, "PositiveIntegerMatch", num) + } + } + } +} + +#[cfg(feature = "index-serde-conversion")] +impl<'de> Deserialize<'de> for ContestedIndexFieldMatch { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + #[derive(Deserialize)] + #[serde(field_identifier, rename_all = "snake_case")] + enum Field { Regex, PositiveIntegerMatch } + + struct FieldVisitor; + + impl<'de> Visitor<'de> for FieldVisitor { + type Value = Field; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("`regex` or `positive_integer_match`") + } + + fn visit_str(self, value: &str) -> Result + where + E: de::Error, + { + match value { + "regex" => Ok(Field::Regex), + "positive_integer_match" => Ok(Field::PositiveIntegerMatch), + _ => Err(de::Error::unknown_variant(value, &["regex", "positive_integer_match"])), + } + } + } + + struct ContestedIndexFieldMatchVisitor; + + impl<'de> Visitor<'de> for ContestedIndexFieldMatchVisitor { + type Value = ContestedIndexFieldMatch; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("enum ContestedIndexFieldMatch") + } + + fn visit_enum(self, mut visitor: V) -> Result + where + V: de::EnumAccess<'de>, + { + match visitor.variant()? { + (Field::Regex, v) => { + let regex_str: &str = v.newtype_variant()?; + Regex::new(regex_str) + .map(ContestedIndexFieldMatch::Regex) + .map_err(de::Error::custom) + } + (Field::PositiveIntegerMatch, v) => { + let num: u128 = v.newtype_variant()?; + Ok(ContestedIndexFieldMatch::PositiveIntegerMatch(num)) + } + } + } + } + + deserializer.deserialize_enum( + "ContestedIndexFieldMatch", + &["regex", "positive_integer_match"], + ContestedIndexFieldMatchVisitor, + ) + } +} + + impl PartialOrd for ContestedIndexFieldMatch { fn partial_cmp(&self, other: &Self) -> Option { use ContestedIndexFieldMatch::*; @@ -87,7 +174,7 @@ impl Ord for ContestedIndexFieldMatch { impl Clone for ContestedIndexFieldMatch { fn clone(&self) -> Self { match self { - Regex(regex) => Regex(regex::Regex::new(regex.as_str()).unwrap()), + ContestedIndexFieldMatch::Regex(regex) => ContestedIndexFieldMatch::Regex(regex::Regex::new(regex.as_str()).unwrap()), ContestedIndexFieldMatch::PositiveIntegerMatch(int) => { ContestedIndexFieldMatch::PositiveIntegerMatch(*int) } @@ -98,8 +185,8 @@ impl Clone for ContestedIndexFieldMatch { impl PartialEq for ContestedIndexFieldMatch { fn eq(&self, other: &Self) -> bool { match self { - Regex(regex) => match other { - Regex(other_regex) => regex.as_str() == other_regex.as_str(), + ContestedIndexFieldMatch::Regex(regex) => match other { + ContestedIndexFieldMatch::Regex(other_regex) => regex.as_str() == other_regex.as_str(), _ => false, }, ContestedIndexFieldMatch::PositiveIntegerMatch(int) => match other { @@ -115,7 +202,7 @@ impl Eq for ContestedIndexFieldMatch {} impl ContestedIndexFieldMatch { pub fn matches(&self, value: &Value) -> bool { match self { - Regex(regex) => { + ContestedIndexFieldMatch::Regex(regex) => { if let Some(string) = value.as_str() { regex.is_match(string) } else { @@ -131,6 +218,7 @@ impl ContestedIndexFieldMatch { } #[derive(Clone, Debug, PartialEq, Eq, Ord, PartialOrd)] +#[cfg_attr(feature = "index-serde-conversion", derive(Serialize, Deserialize))] pub struct ContestedIndexInformation { pub field_matches: BTreeMap, pub resolution: ContestedIndexResolution, @@ -375,8 +463,8 @@ impl TryFrom<&[(Value, Value)]> for Index { } "regexPattern" => { let regex = field_match_value.to_str()?.to_owned(); - field_matches = Some(Regex( - regex::Regex::new(®ex).map_err(|e| { + field_matches = Some(ContestedIndexFieldMatch::Regex( + Regex::new(®ex).map_err(|e| { RegexError(format!( "invalid field match regex: {}", e.to_string() diff --git a/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs b/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs index 26777190dc..86c50018f2 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs @@ -309,6 +309,7 @@ mod tests { ascending: false, }], unique: false, + contested_index: None, }]; let old_index_structure = diff --git a/packages/rs-drive/src/drive/object_size_info/contract_info.rs b/packages/rs-drive/src/drive/object_size_info/contract_info.rs index 7b8d00be28..9665e9cff4 100644 --- a/packages/rs-drive/src/drive/object_size_info/contract_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/contract_info.rs @@ -59,12 +59,12 @@ impl<'a> DataContractInfo<'a> { platform_version, )? .ok_or(Error::Document(DocumentError::DataContractNotFound))?; - Ok(DataContractResolvedInfo::DataContractFetchInfo( + Ok(DataContractResolvedInfo::ArcDataContractFetchInfo( contract_fetch_info, )) } DataContractInfo::DataContractFetchInfo(contract_fetch_info) => Ok( - DataContractResolvedInfo::DataContractFetchInfo(contract_fetch_info), + DataContractResolvedInfo::ArcDataContractFetchInfo(contract_fetch_info), ), DataContractInfo::BorrowedDataContract(contract) => { Ok(DataContractResolvedInfo::BorrowedDataContract(contract)) @@ -121,7 +121,10 @@ impl AsRef for DataContractOwnedResolvedInfo { pub enum DataContractResolvedInfo<'a> { /// Information necessary for fetched data contracts, encapsulated in an /// `Arc` to ensure thread-safe shared ownership and access. - DataContractFetchInfo(Arc), + ArcDataContractFetchInfo(Arc), + + /// Arc Data contract + ArcDataContract(Arc), /// A borrowed reference to a resolved data contract. This variant is suitable /// for scenarios where temporary, read-only access to a data contract is required. @@ -137,9 +140,10 @@ impl<'a> DataContractResolvedInfo<'a> { /// The id of the contract pub fn id(&self) -> Identifier { match self { - DataContractResolvedInfo::DataContractFetchInfo(fetch_info) => fetch_info.contract.id(), + DataContractResolvedInfo::ArcDataContractFetchInfo(fetch_info) => fetch_info.contract.id(), DataContractResolvedInfo::BorrowedDataContract(data_contract) => data_contract.id(), DataContractResolvedInfo::OwnedDataContract(data_contract) => data_contract.id(), + DataContractResolvedInfo::ArcDataContract(data_contract) => data_contract.id(), } } } @@ -147,9 +151,10 @@ impl<'a> AsRef for DataContractResolvedInfo<'a> { /// The ref of the contract fn as_ref(&self) -> &DataContract { match self { - DataContractResolvedInfo::DataContractFetchInfo(fetch_info) => &fetch_info.contract, + DataContractResolvedInfo::ArcDataContractFetchInfo(fetch_info) => &fetch_info.contract, DataContractResolvedInfo::BorrowedDataContract(borrowed) => borrowed, DataContractResolvedInfo::OwnedDataContract(owned) => owned, + DataContractResolvedInfo::ArcDataContract(data_contract) => data_contract.as_ref(), } } } diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs index efe2610fb8..ae785c6fd5 100644 --- a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs @@ -1,3 +1,4 @@ +use std::sync::Arc; use crate::drive::object_size_info::{DataContractOwnedResolvedInfo, DataContractResolvedInfo}; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::{ ContestedDocumentResourceVotePollWithContractInfo, @@ -9,6 +10,7 @@ use crate::error::Error; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use grovedb::TransactionArg; use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::identifier::Identifier; use dpp::prelude::DataContract; use platform_version::version::PlatformVersion; @@ -60,6 +62,12 @@ pub trait ContestedDocumentResourceVotePollResolver { platform_version: &PlatformVersion, ) -> Result, Error>; + /// Resolves into a struct, the contract itself will be held with Arc + fn resolve_with_known_contracts_provider<'a>( + &self, + known_contracts_provider_fn: &impl Fn(&Identifier) -> Result>, Error>, + ) -> Result, Error>; + /// Resolve by providing the contract fn resolve_with_provided_borrowed_contract<'a>( &self, @@ -136,7 +144,29 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll".to_string())))?; Ok( ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { - contract: DataContractResolvedInfo::DataContractFetchInfo(contract), + contract: DataContractResolvedInfo::ArcDataContractFetchInfo(contract), + document_type_name: document_type_name.clone(), + index_name: index_name.clone(), + index_values: index_values.clone(), + }, + ) + } + + fn resolve_with_known_contracts_provider<'a>( + &self, + known_contracts_provider_fn: &impl Fn(&Identifier) -> Result>, Error>, + ) -> Result, Error> { + let ContestedDocumentResourceVotePoll { + contract_id, + document_type_name, + index_name, + index_values, + } = self; + + let contract = known_contracts_provider_fn(contract_id)?.ok_or(Error::DataContract(DataContractError::MissingContract(format!("data contract with id {} can not be provided", contract_id))))?; + Ok( + ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { + contract: DataContractResolvedInfo::ArcDataContract(contract), document_type_name: document_type_name.clone(), index_name: index_name.clone(), index_values: index_values.clone(), @@ -154,7 +184,7 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote index_name, index_values, } = self; - + if contract_id != data_contract.id_ref() { return Err(Error::DataContract(DataContractError::ProvidedContractMismatch(format!("data contract provided {} is not the one required {}", data_contract.id_ref(), contract_id)))); } @@ -184,7 +214,7 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll".to_string())))?; Ok( ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { - contract: DataContractResolvedInfo::DataContractFetchInfo(contract), + contract: DataContractResolvedInfo::ArcDataContractFetchInfo(contract), document_type_name, index_name, index_values, diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index 8009870be0..bfa1ab04b9 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -1,3 +1,4 @@ +use std::sync::Arc; use crate::drive::votes::paths::VotePollPaths; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; @@ -230,6 +231,30 @@ impl ContestedDocumentVotePollDriveQuery { }) } + /// Resolves with a known contract provider + pub fn resolve_with_known_contracts_provider<'a>( + &self, + known_contracts_provider_fn: &impl Fn(&Identifier) -> Result>, Error>, + ) -> Result, Error> { + let ContestedDocumentVotePollDriveQuery { + vote_poll, + result_type, + offset, + limit, + start_at, + order_ascending, + } = self; + Ok(ResolvedContestedDocumentVotePollDriveQuery { + vote_poll: vote_poll.resolve_with_known_contracts_provider(known_contracts_provider_fn)?, + result_type: *result_type, + offset: *offset, + limit: *limit, + start_at: *start_at, + order_ascending: *order_ascending, + }) + } + + /// Resolves with a provided borrowed contract pub fn resolve_with_provided_borrowed_contract<'a>( &self, data_contract: &'a DataContract, From 9cfbebb93e6f4b40dedc2f0552d4fe210ab8287b Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 27 May 2024 15:27:44 +0200 Subject: [PATCH 085/135] fixes --- .../src/data_contract/document_type/index_level/mod.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs b/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs index 86c50018f2..409e23281f 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index_level/mod.rs @@ -335,6 +335,7 @@ mod tests { ascending: false, }], unique: false, + contested_index: None, }]; let new_indices = vec![ @@ -345,6 +346,7 @@ mod tests { ascending: false, }], unique: false, + contested_index: None, }, Index { name: "test2".to_string(), @@ -353,6 +355,7 @@ mod tests { ascending: false, }], unique: false, + contested_index: None, }, ]; @@ -387,6 +390,7 @@ mod tests { ascending: false, }], unique: false, + contested_index: None, }, Index { name: "test2".to_string(), @@ -395,6 +399,7 @@ mod tests { ascending: false, }], unique: false, + contested_index: None, }, ]; @@ -405,6 +410,7 @@ mod tests { ascending: false, }], unique: false, + contested_index: None, }]; let old_index_structure = @@ -437,6 +443,7 @@ mod tests { ascending: false, }], unique: false, + contested_index: None, }]; let new_indices = vec![Index { @@ -452,6 +459,7 @@ mod tests { }, ], unique: false, + contested_index: None, }]; let old_index_structure = @@ -490,6 +498,7 @@ mod tests { }, ], unique: false, + contested_index: None, }]; let new_indices = vec![Index { @@ -499,6 +508,7 @@ mod tests { ascending: false, }], unique: false, + contested_index: None, }]; let old_index_structure = From f6f770c9921182cc652c56d35d93effd0da7a0f7 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 28 May 2024 07:06:55 +0200 Subject: [PATCH 086/135] a lot more work --- .../protos/platform/v0/platform.proto | 24 +- .../methods/deserialize_value_for_key/mod.rs | 1 + .../deserialize_value_for_key/v0/mod.rs | 58 +++ .../document_type/methods/mod.rs | 30 ++ .../src/data_contract/document_type/mod.rs | 11 + .../document_type/property/mod.rs | 154 ++++++- .../state_transitions/masternode_vote/mod.rs | 65 ++- .../voting/contested_resources/v0/mod.rs | 211 +++++++++- packages/rs-drive/src/error/contract.rs | 4 + packages/rs-drive/src/error/query.rs | 8 + packages/rs-drive/src/query/mod.rs | 9 +- .../vote_polls_by_document_type_query.rs | 376 ++++++++++++++++++ .../src/version/dpp_versions.rs | 1 + 13 files changed, 935 insertions(+), 17 deletions(-) create mode 100644 packages/rs-dpp/src/data_contract/document_type/methods/deserialize_value_for_key/mod.rs create mode 100644 packages/rs-dpp/src/data_contract/document_type/methods/deserialize_value_for_key/v0/mod.rs create mode 100644 packages/rs-drive/src/query/vote_polls_by_document_type_query.rs diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index c5e1b52f60..3504a1a323 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -639,12 +639,20 @@ message GetEpochsInfoResponse { message GetContestedResourcesRequest { message GetContestedResourcesRequestV0 { + message StartAtValueInfo { + bytes start_value = 1; + bool start_value_included = 2; + } + bytes contract_id = 1; string document_type_name = 2; string index_name = 3; - optional uint32 count = 4; - bool ascending = 5; - bool prove = 6; + repeated bytes start_index_values = 4; + repeated bytes end_index_values = 5; + optional StartAtValueInfo start_at_value_info = 6; + optional uint32 count = 7; + bool order_ascending = 8; + bool prove = 9; } oneof version { @@ -654,17 +662,13 @@ message GetContestedResourcesRequest { message GetContestedResourcesResponse { message GetContestedResourcesResponseV0 { - message ContestedResources { - repeated ContestedResource contested_resources = 1; + message ContestedResourceValues { + repeated bytes contested_resource_values = 1; bool finished_results = 2; } - message ContestedResource { - repeated bytes index_values = 1; - } - oneof result { - ContestedResources contested_resources = 1; + ContestedResourceValues contested_resource_values = 1; Proof proof = 2; } ResponseMetadata metadata = 3; diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/deserialize_value_for_key/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/deserialize_value_for_key/mod.rs new file mode 100644 index 0000000000..7affabc980 --- /dev/null +++ b/packages/rs-dpp/src/data_contract/document_type/methods/deserialize_value_for_key/mod.rs @@ -0,0 +1 @@ +mod v0; \ No newline at end of file diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/deserialize_value_for_key/v0/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/deserialize_value_for_key/v0/mod.rs new file mode 100644 index 0000000000..5bc20f8667 --- /dev/null +++ b/packages/rs-dpp/src/data_contract/document_type/methods/deserialize_value_for_key/v0/mod.rs @@ -0,0 +1,58 @@ +use crate::data_contract::document_type::v0::{DocumentTypeV0, DEFAULT_HASH_SIZE, MAX_INDEX_SIZE}; +use crate::data_contract::document_type::DocumentPropertyType; +use crate::data_contract::errors::DataContractError; +use crate::ProtocolError; +use itertools::Itertools; +use platform_value::{Identifier, Value}; + +// If another document type (like V1) ever were to exist we would need to implement serialize_value_for_key_v0 again + +impl DocumentTypeV0 { + pub(in crate::data_contract::document_type) fn deserialize_value_for_key_v0( + &self, + key: &str, + value: &[u8], + ) -> Result { + match key { + "$ownerId" | "$id" => { + let bytes = Identifier::from_bytes(value)?; + Ok(Value::Identifier(bytes.to_buffer())) + } + "$createdAt" | "$updatedAt" | "$transferredAt" => { + Ok(Value::U64(DocumentPropertyType::decode_date_timestamp( + value, + ).ok_or(ProtocolError::DataContractError( + DataContractError::FieldRequirementUnmet( + "value must be 8 bytes long".to_string(), + ), + ))?)) + } + "$createdAtBlockHeight" | "$updatedAtBlockHeight" | "$transferredAtBlockHeight" => { + Ok(Value::U64(DocumentPropertyType::decode_u64( + value, + ).ok_or(ProtocolError::DataContractError( + DataContractError::FieldRequirementUnmet( + "value must be 8 bytes long".to_string(), + ), + ))?)) + } + "$createdAtCoreBlockHeight" + | "$updatedAtCoreBlockHeight" + | "$transferredAtCoreBlockHeight" => { + Ok(Value::U32(DocumentPropertyType::decode_u32( + value, + ).ok_or(ProtocolError::DataContractError( + DataContractError::FieldRequirementUnmet( + "value must be 4 bytes long".to_string(), + ), + ))?)) + }, + _ => { + let property = self.flattened_properties.get(key).ok_or_else(|| { + DataContractError::DocumentTypeFieldNotFound(format!("expected contract to have field: {key}, contract fields are {} on document type {}", self.flattened_properties.keys().join(" | "), self.name)) + })?; + property.property_type.decode_value_for_tree_keys(value) + } + } + } +} diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs index fc4856985f..0471b91484 100644 --- a/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs @@ -8,6 +8,7 @@ mod prefunded_voting_balances_for_document; mod serialize_value_for_key; #[cfg(feature = "validation")] mod validate_update; +mod deserialize_value_for_key; use std::collections::BTreeMap; @@ -24,6 +25,7 @@ use crate::ProtocolError; use crate::fee::Credits; use crate::voting::vote_polls::VotePoll; use platform_value::{Identifier, Value}; +use crate::data_contract::document_type::DocumentTypeRef; // TODO: Some of those methods are only for tests. Hide under feature pub trait DocumentTypeV0Methods { @@ -41,6 +43,12 @@ pub trait DocumentTypeV0Methods { value: &Value, platform_version: &PlatformVersion, ) -> Result, ProtocolError>; + fn deserialize_value_for_key( + &self, + key: &str, + serialized_value: &Vec, + platform_version: &PlatformVersion, + ) -> Result; fn max_size(&self, platform_version: &PlatformVersion) -> Result; @@ -179,6 +187,28 @@ impl DocumentTypeV0Methods for DocumentTypeV0 { } } + fn deserialize_value_for_key( + &self, + key: &str, + value: &Vec, + platform_version: &PlatformVersion, + ) -> Result { + match platform_version + .dpp + .contract_versions + .document_type_versions + .methods + .deserialize_value_for_key + { + 0 => self.deserialize_value_for_key_v0(key, value), + version => Err(ProtocolError::UnknownVersionMismatch { + method: "deserialize_value_for_key".to_string(), + known_versions: vec![0], + received: version, + }), + } + } + fn max_size(&self, platform_version: &PlatformVersion) -> Result { match platform_version .dpp diff --git a/packages/rs-dpp/src/data_contract/document_type/mod.rs b/packages/rs-dpp/src/data_contract/document_type/mod.rs index 3f37e60ac2..06381e366f 100644 --- a/packages/rs-dpp/src/data_contract/document_type/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/mod.rs @@ -135,6 +135,17 @@ impl<'a> DocumentTypeV0Methods for DocumentTypeRef<'a> { } } + fn deserialize_value_for_key( + &self, + key: &str, + serialized_value: &Vec, + platform_version: &PlatformVersion, + ) -> Result { + match self { + DocumentTypeRef::V0(v0) => v0.deserialize_value_for_key(key, serialized_value, platform_version), + } + } + fn max_size(&self, platform_version: &PlatformVersion) -> Result { match self { DocumentTypeRef::V0(v0) => v0.max_size(platform_version), diff --git a/packages/rs-dpp/src/data_contract/document_type/property/mod.rs b/packages/rs-dpp/src/data_contract/document_type/property/mod.rs index e3a4003239..ba7b718753 100644 --- a/packages/rs-dpp/src/data_contract/document_type/property/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/property/mod.rs @@ -1,6 +1,6 @@ use std::convert::TryInto; -use std::io::{BufReader, Read}; +use std::io::{BufReader, Cursor, Read}; use crate::data_contract::errors::DataContractError; @@ -11,11 +11,12 @@ use array::ArrayItemType; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use indexmap::IndexMap; use integer_encoding::{VarInt, VarIntReader}; -use platform_value::Value; +use platform_value::{Identifier, Value}; use rand::distributions::{Alphanumeric, Standard}; use rand::rngs::StdRng; use rand::Rng; use serde::Serialize; +use crate::util::vec::DecodeError; pub mod array; @@ -836,6 +837,64 @@ impl DocumentPropertyType { } } + // Given a field type and a Vec this function chooses and executes the right decoding method + pub fn decode_value_for_tree_keys(&self, value: &[u8]) -> Result { + if value.is_null() { + return Ok(Value::Null); + } + match self { + DocumentPropertyType::String(_, _) => { + let value_as_text = value.as_text().ok_or_else(get_field_type_matching_error)?; + let vec = value_as_text.as_bytes().to_vec(); + if vec == &vec![0] { + // we don't want to collide with the definition of an empty string + Ok(Value::Text("".to_string())) + } else { + Ok(Value::Text(String::from_utf8(value).map_err(ProtocolError::DecodingError("could not decode ut8 bytes into string")))) + } + } + DocumentPropertyType::Date => DocumentPropertyType::decode_date_timestamp( + value + ).ok_or(ProtocolError::DecodingError("could not decode data timestamp")), + DocumentPropertyType::Integer => { + DocumentPropertyType::decode_i64(value).ok_or(ProtocolError::DecodingError("could not decode integer")) + } + DocumentPropertyType::Number => DocumentPropertyType::decode_float( + value, + ).ok_or(ProtocolError::DecodingError("could not decode float")), + DocumentPropertyType::ByteArray(_, _) => { + Ok(Value::Bytes(value.to_vec())) + } + DocumentPropertyType::Identifier => { + let identifier = Identifier::from_bytes(value)?; + Ok(identifier.into()) + }, + DocumentPropertyType::Boolean => { + if value == &vec![0] { + Ok(Value::Bool(false)) + } else if value == &vec![1] { + Ok(Value::Bool(true)) + } else { + Err(DataContractError::ValueWrongType( + "document field type doesn't match document value".to_string(), + )) + } + } + DocumentPropertyType::Object(_) => Err(ProtocolError::DataContractError( + DataContractError::EncodingDataStructureNotSupported( + "we should never try decoding an object".to_string(), + ), + )), + DocumentPropertyType::Array(_) | DocumentPropertyType::VariableTypeArray(_) => { + Err(ProtocolError::DataContractError( + DataContractError::EncodingDataStructureNotSupported( + "we should never try decoding an array".to_string(), + ), + )) + } + } + } + // Given a field type and a value this function chooses and executes the right encoding method pub fn value_from_string(&self, str: &str) -> Result { match self { @@ -919,6 +978,10 @@ impl DocumentPropertyType { Self::encode_u64(val) } + pub fn decode_date_timestamp(val: &[u8]) -> Option { + Self::decode_u64(val) + } + pub fn encode_u64(val: u64) -> Vec { // Positive integers are represented in binary with the signed bit set to 0 // Negative integers are represented in 2's complement form @@ -944,6 +1007,28 @@ impl DocumentPropertyType { wtr } + /// Decodes an unsigned integer on 64 bits. + pub fn decode_u64(val: &[u8]) -> Option { + // Flip the sign bit + // to deal with interaction between the domains + // 2's complement values have the sign bit set to 1 + // this makes them greater than the positive domain in terms of sort order + // to fix this, we just flip the sign bit + // so positive integers have the high bit and negative integers have the low bit + // the relative order of elements in each domain is still maintained, as the + // change was uniform across all elements + let mut val = val.to_vec(); + val[0] ^= 0b1000_0000; + + // Decode the integer in big endian form + // This ensures that most significant bits are compared first + // a bigger positive number would be greater than a smaller one + // and a bigger negative number would be greater than a smaller one + // maintains sort order for each domain + let mut rdr = val.as_slice(); + rdr.read_u64::().ok() + } + pub fn encode_u32(val: u32) -> Vec { // Positive integers are represented in binary with the signed bit set to 0 // Negative integers are represented in 2's complement form @@ -969,6 +1054,28 @@ impl DocumentPropertyType { wtr } + /// Decodes an unsigned integer on 32 bits. + pub fn decode_u32(val: &[u8]) -> Option { + // Flip the sign bit + // to deal with interaction between the domains + // 2's complement values have the sign bit set to 1 + // this makes them greater than the positive domain in terms of sort order + // to fix this, we just flip the sign bit + // so positive integers have the high bit and negative integers have the low bit + // the relative order of elements in each domain is still maintained, as the + // change was uniform across all elements + let mut val = val.to_vec(); + val[0] ^= 0b1000_0000; + + // Decode the integer in big endian form + // This ensures that most significant bits are compared first + // a bigger positive number would be greater than a smaller one + // and a bigger negative number would be greater than a smaller one + // maintains sort order for each domain + let mut rdr = val.as_slice(); + rdr.read_u32::().ok() + } + pub fn encode_i64(val: i64) -> Vec { // Positive integers are represented in binary with the signed bit set to 0 // Negative integers are represented in 2's complement form @@ -994,6 +1101,27 @@ impl DocumentPropertyType { wtr } + pub fn decode_i64(val: &[u8]) -> Option { + // Flip the sign bit + // to deal with interaction between the domains + // 2's complement values have the sign bit set to 1 + // this makes them greater than the positive domain in terms of sort order + // to fix this, we just flip the sign bit + // so positive integers have the high bit and negative integers have the low bit + // the relative order of elements in each domain is still maintained, as the + // change was uniform across all elements + let mut val = val.to_vec(); + val[0] ^= 0b1000_0000; + + // Decode the integer in big endian form + // This ensures that most significant bits are compared first + // a bigger positive number would be greater than a smaller one + // and a bigger negative number would be greater than a smaller one + // maintains sort order for each domain + let mut rdr = val.as_slice(); + rdr.read_i64::().ok() + } + pub fn encode_float(val: f64) -> Vec { // Floats are represented based on the IEEE 754-2008 standard // [sign bit] [biased exponent] [mantissa] @@ -1032,6 +1160,28 @@ impl DocumentPropertyType { wtr } + + /// Decodes a float on 64 bits. + pub fn decode_float(encoded: &[u8]) -> f64 { + // Check if the value is negative by looking at the original sign bit + let is_negative = (encoded[0] & 0b1000_0000) == 0; + + // Create a mutable copy of the encoded vector to apply transformations + let mut wtr = encoded.to_vec(); + + if is_negative { + // For originally negative values, flip all the bits back + wtr = wtr.iter().map(|byte| !byte).collect(); + } else { + // For originally positive values, just flip the sign bit back + wtr[0] ^= 0b1000_0000; + } + + // Read the float value from the transformed vector + let val = wtr.read_f64::().unwrap(); + + val + } } fn get_field_type_matching_error() -> DataContractError { diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 19d94599f5..f04c38ff12 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -107,10 +107,12 @@ mod tests { use std::sync::Arc; use arc_swap::Guard; use rand::Rng; - use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, get_contested_vote_polls_by_end_date_request, get_contested_vote_polls_by_end_date_response, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetContestedVotePollsByEndDateRequest, GetContestedVotePollsByEndDateResponse}; + use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, get_contested_resources_request, get_contested_resources_response, get_contested_vote_polls_by_end_date_request, get_contested_vote_polls_by_end_date_response, GetContestedResourcesRequest, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetContestedVotePollsByEndDateRequest, GetContestedVotePollsByEndDateResponse}; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0::ResultType; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::GetContestedResourceVoteStateRequestV0; use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; + use dapi_grpc::platform::v0::get_contested_resources_request::GetContestedResourcesRequestV0; + use dapi_grpc::platform::v0::get_contested_resources_response::{get_contested_resources_response_v0, GetContestedResourcesResponseV0}; use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_request::GetContestedVotePollsByEndDateRequestV0; use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_response::{get_contested_vote_polls_by_end_date_response_v0, GetContestedVotePollsByEndDateResponseV0}; use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_response::get_contested_vote_polls_by_end_date_response_v0::SerializedContestedVotePollsByTimestamp; @@ -628,6 +630,65 @@ mod tests { (identity_1, identity_2, dpns_contract) } + #[test] + fn test_contests_request() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = + create_dpns_name_contest(&mut platform, &platform_state, 7, platform_version); + + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); + + let index_name = "parentNameAndLabel".to_string(); + + let query_validation_result = platform.query_contested_resources(GetContestedResourcesRequest { + version: Some(get_contested_resources_request::Version::V0( + GetContestedResourcesRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + count: None, + ascending: true, + prove: false, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resources_response::Version::V0( + GetContestedResourcesResponseV0 { + metadata: _, + result, + }, + ) = query_validation_result.version.expect("expected a version"); + + let Some( + get_contested_resources_response_v0::Result::ContestedResources( + get_contested_resources_response_v0::ContestedResources { + contested_resources, finished_results + }, + ), + ) = result + else { + panic!("expected contested resources") + }; + + assert_eq!(contested_resources.len(), 1); + assert!(finished_results); + } + #[test] fn test_masternode_voting() { let platform_version = PlatformVersion::latest(); @@ -937,7 +998,7 @@ mod tests { assert_eq!( contested_vote_polls_by_timestamps, vec![SerializedContestedVotePollsByTimestamp { - timestamp: 0, + timestamp: 1_209_600_000, // in ms, 2 weeks after Jan 1 1970 serialized_contested_vote_polls: vec![vec![ 0, 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, 6, diff --git a/packages/rs-drive-abci/src/query/voting/contested_resources/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resources/v0/mod.rs index e15c5960ec..7181be8498 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resources/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resources/v0/mod.rs @@ -1,10 +1,20 @@ +use dapi_grpc::platform::v0::get_contested_resources_response::{get_contested_resources_response_v0}; use crate::error::Error; use crate::platform_types::platform::Platform; use crate::platform_types::platform_state::PlatformState; use crate::query::QueryValidationResult; use dapi_grpc::platform::v0::get_contested_resources_request::GetContestedResourcesRequestV0; use dapi_grpc::platform::v0::get_contested_resources_response::GetContestedResourcesResponseV0; +use dpp::{check_validation_result_with_data, platform_value}; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::validation::ValidationResult; +use dpp::identifier::Identifier; +use dpp::platform_value::Value; use dpp::version::PlatformVersion; +use drive::error::query::QuerySyntaxError; +use drive::query::vote_polls_by_document_type_query::VotePollsByDocumentTypeQuery; +use crate::error::query::QueryError; impl Platform { pub(super) fn query_contested_resources_v0( @@ -13,13 +23,210 @@ impl Platform { contract_id, document_type_name, index_name, + start_index_values, + end_index_values, + start_at_value_info, count, - ascending, + order_ascending, prove, }: GetContestedResourcesRequestV0, platform_state: &PlatformState, platform_version: &PlatformVersion, ) -> Result, Error> { - todo!() + let config = &self.config.drive; + let contract_id: Identifier = + check_validation_result_with_data!(contract_id.try_into().map_err(|_| { + QueryError::InvalidArgument( + "contract_id must be a valid identifier (32 bytes long) (contested resources query)".to_string(), + ) + })); + + let (_, contract) = self.drive.get_contract_with_fetch_info_and_fee( + contract_id.to_buffer(), + None, + true, + None, + platform_version, + )?; + + let contract = check_validation_result_with_data!(contract.ok_or(QueryError::Query( + QuerySyntaxError::DataContractNotFound( + "contract not found when querying from value with contract info (contested resources query)", + ) + ))); + + let contract_ref = &contract.contract; + + let document_type = check_validation_result_with_data!(contract_ref + .document_type_for_name(document_type_name.as_str()) + .map_err(|_| QueryError::InvalidArgument(format!( + "document type {} not found for contract {} (contested resources query)", + document_type_name, contract_id + )))); + + let index = check_validation_result_with_data!(document_type.find_contested_index().ok_or( + QueryError::InvalidArgument(format!( + "document type {} does not have a contested index (contested resources query)", + document_type_name + )) + )); + + if index.name != index_name { + return Ok(QueryValidationResult::new_with_error(QueryError::InvalidArgument(format!( + "index with name {} is not the contested index on the document type {}, {} is the name of the only contested index (contested resources query)", + index_name, document_type_name, index.name + )))); + } + + let bincode_config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + + let start_index_values = match start_index_values + .into_iter() + .enumerate() + .map(|(pos, serialized_value)| { + Ok(bincode::decode_from_slice( + serialized_value.as_slice(), + bincode_config, + ) + .map_err(|_| { + QueryError::InvalidArgument(format!( + "could not convert {:?} to a value in the start index values at position {}", + serialized_value, pos + )) + })? + .0) + }) + .collect::, QueryError>>() + { + Ok(index_values) => index_values, + Err(e) => return Ok(QueryValidationResult::new_with_error(e)), + }; + + + + let end_index_values = match end_index_values + .into_iter() + .enumerate() + .map(|(pos, serialized_value)| { + Ok(bincode::decode_from_slice( + serialized_value.as_slice(), + bincode_config, + ) + .map_err(|_| { + QueryError::InvalidArgument(format!( + "could not convert {:?} to a value in the end index values at position {}", + serialized_value, pos + start_index_values.len() + 1 + )) + })? + .0) + }) + .collect::, QueryError>>() + { + Ok(index_values) => index_values, + Err(e) => return Ok(QueryValidationResult::new_with_error(e)), + }; + + let limit = count + .map_or(Some(config.default_query_limit), |limit_value| { + if limit_value == 0 + || limit_value > u16::MAX as u32 + || limit_value as u16 > config.default_query_limit + { + None + } else { + Some(limit_value as u16) + } + }) + .ok_or(drive::error::Error::Query(QuerySyntaxError::InvalidLimit( + format!("limit greater than max limit {}", config.max_query_limit), + )))?; + + let query = VotePollsByDocumentTypeQuery { + contract_id, + document_type_name, + index_name, + start_index_values, + end_index_values, + start_at_value: start_at_value_info + .map(|start_at_value_info| { + + (start_at_value_info.start_value, + start_at_value_info.start_value_included, + ) + }), + limit: Some(limit), + order_ascending, + }; + + let response = if prove { + let proof = match query.execute_with_proof(&self.drive, None, None, platform_version) { + Ok(result) => result, + Err(drive::error::Error::Query(query_error)) => { + return Ok(QueryValidationResult::new_with_error(QueryError::Query( + query_error, + ))); + } + Err(e) => return Err(e.into()), + }; + + GetContestedResourcesResponseV0 { + result: Some( + get_contested_resources_response_v0::Result::Proof( + self.response_proof_v0(platform_state, proof), + ), + ), + metadata: Some(self.response_metadata_v0(platform_state)), + } + } else { + let results = + match query.execute_no_proof(&self.drive, None, &mut vec![], platform_version) { + Ok(result) => result, + Err(drive::error::Error::Query(query_error)) => { + return Ok(QueryValidationResult::new_with_error(QueryError::Query( + query_error, + ))); + } + Err(e) => return Err(e.into()), + }; + + let contested_resource_values = results.into_iter().map(|value| value.).collect(); + + let finished_results = if contested_resource_values.len() = limit { + let query = VotePollsByDocumentTypeQuery { + contract_id, + document_type_name, + index_name, + start_index_values, + end_index_values, + start_at_value: start_at_value_info + .map(|start_at_value_info| { + + (start_at_value_info.start_value, + start_at_value_info.start_value_included, + ) + }), + limit: Some(limit), + order_ascending, + }; + } else { + true + }; + + GetContestedResourcesResponseV0 { + result: Some( + get_contested_resources_response_v0::Result::ContestedResourceValues( + get_contested_resources_response_v0::ContestedResourceValues { + contested_resource_values, + finished_results, + }, + ), + ), + metadata: Some(self.response_metadata_v0(platform_state)), + } + }; + + Ok(QueryValidationResult::new_with_data(response)) } } diff --git a/packages/rs-drive/src/error/contract.rs b/packages/rs-drive/src/error/contract.rs index 805249aa28..b677c345ef 100644 --- a/packages/rs-drive/src/error/contract.rs +++ b/packages/rs-drive/src/error/contract.rs @@ -17,6 +17,10 @@ pub enum DataContractError { #[error("data contract provided is incorrect: {0}")] ProvidedContractMismatch(String), + /// Data contract is corrupted + #[error("data contract is corrupted: {0}")] + CorruptedDataContract(String), + /// Data contract storage error when data contract is too big #[error("data contract is too big to be stored: {0}")] ContractTooBig(String), diff --git a/packages/rs-drive/src/error/query.rs b/packages/rs-drive/src/error/query.rs index fd1f326749..d62ee8a89b 100644 --- a/packages/rs-drive/src/error/query.rs +++ b/packages/rs-drive/src/error/query.rs @@ -136,4 +136,12 @@ pub enum QuerySyntaxError { /// Requesting proof with offset error #[error("requesting proof with offset error: {0}")] RequestingProofWithOffset(String), + + /// Unknown index error + #[error("unknown error: {0}")] + UnknownIndex(String), + + /// Missing index values for query + #[error("missing index values error: {0}")] + MissingIndexValues(String), } diff --git a/packages/rs-drive/src/query/mod.rs b/packages/rs-drive/src/query/mod.rs index eeb2907a54..a001297857 100644 --- a/packages/rs-drive/src/query/mod.rs +++ b/packages/rs-drive/src/query/mod.rs @@ -85,7 +85,14 @@ pub mod vote_query; #[cfg(any(feature = "server", feature = "verify"))] /// Vote poll contestant votes query module pub mod vote_poll_contestant_votes_query; -mod vote_polls_by_end_date_query; + +#[cfg(any(feature = "server", feature = "verify"))] +/// Vote polls by end date query +pub mod vote_polls_by_end_date_query; + +#[cfg(any(feature = "server", feature = "verify"))] +/// Vote polls by document type query +pub mod vote_polls_by_document_type_query; #[cfg(any(feature = "server", feature = "verify"))] /// Internal clauses struct diff --git a/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs b/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs new file mode 100644 index 0000000000..d9f3a71353 --- /dev/null +++ b/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs @@ -0,0 +1,376 @@ +use crate::common::encode::{decode_u64, encode_u64}; +use crate::drive::votes::paths::{vote_contested_resource_active_polls_tree_path_vec, vote_contested_resource_end_date_queries_tree_path_vec}; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use crate::query::{GroveError, Query}; +use dpp::block::block_info::BlockInfo; +use dpp::fee::Credits; +use dpp::prelude::TimestampMillis; +use dpp::serialization::PlatformDeserializable; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use grovedb::query_result_type::{QueryResultElements, QueryResultType}; +use grovedb::{PathQuery, SizedQuery, TransactionArg}; +use platform_version::version::PlatformVersion; +use std::collections::BTreeMap; +use std::sync::Arc; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::DataContract; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::data_contract::document_type::{DocumentType, DocumentTypeRef, Index}; +use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; +use dpp::identifier::Identifier; +use dpp::platform_value::Value; +use crate::drive::object_size_info::DataContractResolvedInfo; +use crate::error::contract::DataContractError; +use crate::error::query::QuerySyntaxError; +use crate::query::vote_poll_vote_state_query::{ContestedDocumentVotePollDriveQuery, ResolvedContestedDocumentVotePollDriveQuery}; + +/// Vote Poll Drive Query struct +#[derive(Debug, PartialEq, Clone)] +pub struct VotePollsByDocumentTypeQuery { + /// The contract information associated with the document. + pub contract_id: Identifier, + /// The name of the document type. + pub document_type_name: String, + /// The name of the index. + pub index_name: String, + /// All values that are before the missing property number + pub start_index_values: Vec, + /// All values that are after the missing property number + pub end_index_values: Vec, + /// Start at value + pub start_at_value: Option<(Vec, bool)>, + /// Limit + pub limit: Option, + /// Ascending + pub order_ascending: bool, +} + +/// Vote Poll Drive Query struct +#[derive(Debug, PartialEq, Clone)] +pub struct ResolvedVotePollsByDocumentTypeQuery<'a> { + /// What vote poll are we asking for? + pub contract: DataContractResolvedInfo<'a>, + /// The name of the document type. + pub document_type_name: &'a String, + /// The name of the index. + pub index_name: &'a String, + /// All values that are before the missing property number + pub start_index_values: &'a Vec, + /// All values that are after the missing property number + pub end_index_values: &'a Vec, + /// Start at value + pub start_at_value: &'a Option<(Vec, bool)>, + /// Limit + pub limit: Option, + /// Ascending + pub order_ascending: bool, +} + + +impl VotePollsByDocumentTypeQuery { + /// Resolves the contested document vote poll drive query. + /// + /// This method processes the query by interacting with the drive, using the provided + /// transaction and platform version to ensure consistency and compatibility. + /// + /// # Parameters + /// + /// * `drive`: A reference to the `Drive` object used for database interactions. + /// * `transaction`: The transaction argument used to ensure consistency during the resolve operation. + /// * `platform_version`: The platform version to ensure compatibility. + /// + /// # Returns + /// + /// * `Ok(ResolvedContestedDocumentVotePollDriveQuery)` - The resolved query information. + /// * `Err(Error)` - An error if the resolution process fails. + /// + /// # Errors + /// + /// This method returns an `Error` variant if there is an issue resolving the query. + /// The specific error depends on the underlying problem encountered during resolution. + pub fn resolve<'a>( + &'a self, + drive: &Drive, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let VotePollsByDocumentTypeQuery { + contract_id, document_type_name, index_name, start_index_values, end_index_values, start_at_value, limit, order_ascending + } = self; + let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll".to_string())))?; + + Ok(ResolvedVotePollsByDocumentTypeQuery { + contract: DataContractResolvedInfo::ArcDataContractFetchInfo(contract), + document_type_name, + index_name, + start_index_values, + end_index_values, + start_at_value, + limit: *limit, + order_ascending: *order_ascending, + }) + } + + /// Resolves with a known contract provider + pub fn resolve_with_known_contracts_provider( + &self, + known_contracts_provider_fn: &impl Fn(&Identifier) -> Result>, Error>, + ) -> Result { + let VotePollsByDocumentTypeQuery { + contract_id, document_type_name, index_name, start_index_values, end_index_values, start_at_value, limit, order_ascending + } = self; + let contract = known_contracts_provider_fn(contract_id)?.ok_or(Error::DataContract(DataContractError::MissingContract(format!("data contract with id {} can not be provided", contract_id))))?; + + Ok(ResolvedVotePollsByDocumentTypeQuery { + contract: DataContractResolvedInfo::ArcDataContract(contract), + document_type_name, + index_name, + start_index_values, + end_index_values, + start_at_value, + limit: *limit, + order_ascending: *order_ascending, + }) + } + + /// Resolves with a provided borrowed contract + pub fn resolve_with_provided_borrowed_contract<'a>( + &'a self, + data_contract: &'a DataContract, + ) -> Result, Error> { + let VotePollsByDocumentTypeQuery { + contract_id, document_type_name, index_name, start_index_values, end_index_values, start_at_value, limit, order_ascending + } = self; + if contract_id != data_contract.id_ref() { + return Err(Error::DataContract(DataContractError::ProvidedContractMismatch(format!("data contract provided {} is not the one required {}", data_contract.id_ref(), contract_id)))); + } + Ok(ResolvedVotePollsByDocumentTypeQuery { + contract: DataContractResolvedInfo::BorrowedDataContract(data_contract), + document_type_name, + index_name, + start_index_values, + end_index_values, + start_at_value, + limit: *limit, + order_ascending: *order_ascending, + }) + } + + #[cfg(feature = "server")] + /// Executes an internal query with proof and returns the items. + pub fn execute_with_proof( + self, + drive: &Drive, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let resolved = self.resolve(drive, transaction, platform_version)?; + resolved.execute_with_proof(drive, transaction, drive_operations, platform_version) + } + #[cfg(feature = "server")] + /// Executes a query with no proof and returns the items, skipped items, and fee. + pub fn execute_no_proof_with_cost( + &self, + drive: &Drive, + block_info: Option, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result< + ( + Vec, + Credits, + ), + Error, + > { + let mut drive_operations = vec![]; + let result = + self.execute_no_proof(drive, transaction, &mut drive_operations, platform_version)?; + let cost = if let Some(block_info) = block_info { + let fee_result = Drive::calculate_fee( + None, + Some(drive_operations), + &block_info.epoch, + drive.config.epochs_per_era, + platform_version, + )?; + fee_result.processing_fee + } else { + 0 + }; + Ok((result, cost)) + } + + #[cfg(feature = "server")] + /// Executes an internal query with no proof and returns the values and skipped items. + pub fn execute_no_proof( + &self, + drive: &Drive, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let resolved = self.resolve(drive, transaction, platform_version)?; + resolved.execute_no_proof(drive, transaction, drive_operations, platform_version) + } +} + +impl<'a> ResolvedVotePollsByDocumentTypeQuery<'a> { + fn document_type(&self) -> Result { + Ok(self.contract.as_ref().document_type_for_name(self.document_type_name.as_str())?) + } + fn index(&self) -> Result<&Index, Error> { + let index = self.contract.as_ref().document_type_borrowed_for_name(self.document_type_name.as_str())?.find_contested_index().ok_or( + Error::Query(QuerySyntaxError::UnknownIndex(format!( + "document type {} does not have a contested index", + self.document_type_name.as_str() + ))) + )?; + if index.name.as_str() != self.index_name.as_str() { + return Err(Error::Query(QuerySyntaxError::UnknownIndex(format!( + "index with name {} is not the contested index on the document type {}, {} is the name of the only contested index (contested resources query)", + self.index_name.as_str(), self.document_type_name.as_str(), &index.name + )))); + } + Ok(index) + } + fn indexes_vectors(&self, platform_version: &PlatformVersion) -> Result<(Vec>, Vec>, Vec), Error> { + let document_type = self.document_type()?; + let index = self.index()?; + let mut properties_iter = index.properties.iter(); + let mut start_values_iter = self.start_index_values.iter(); + let mut end_values_iter = self.end_index_values.iter(); + let mut start_values_vec = vec![]; + let mut end_values_vec = vec![]; + let mut ended_start_values = false; + let mut started_end_values = false; + while let Some(index_property) = properties_iter.next() { + if !ended_start_values { + if let Some(start_value) = start_values_iter.next() { + let encoded = document_type.serialize_value_for_key(&index_property.name, start_value, platform_version)?; + start_values_vec.push(encoded); + } else { + ended_start_values = true; + } + } else if started_end_values { + if let Some(end_value) = end_values_iter.next() { + let encoded = document_type.serialize_value_for_key(&index_property.name, end_value, platform_version)?; + end_values_vec.push(encoded); + } else { + return Err(Error::Query(QuerySyntaxError::MissingIndexValues("the start index values and the end index values must be equal to the amount of properties in the contested index minus one".to_string()))) + } + } else { + started_end_values = true; + } + } + Ok((start_values_vec, end_values_vec)) + } + + pub fn result_is_in_key(&self) -> bool { + // this means that the keys are the values that we are interested in + self.end_index_values.is_empty() + } + + fn result_path_index(&self) -> usize { + 5 + self.start_index_values.len() + } + + /// Operations to construct a path query. + pub fn construct_path_query( + &self, + platform_version: &PlatformVersion, + ) -> Result { + let mut path = vote_contested_resource_active_polls_tree_path_vec(); + + let (mut start, end) = self.indexes_vectors(platform_version)?; + + if !start.is_empty() { + path.append(&mut start); + } + + let mut query = Query::new_with_direction(self.order_ascending); + + if !end.is_empty(){ + query.default_subquery_branch.subquery_path = Some(end); + } + + Ok(PathQuery { + path, + query: SizedQuery { + query, + limit: self.limit, + offset: None, + }, + }) + } + + #[cfg(feature = "server")] + /// Executes an internal query with proof and returns the items. + pub fn execute_with_proof( + self, + drive: &Drive, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let path_query = self.construct_path_query(platform_version)?; + drive.grove_get_proved_path_query( + &path_query, + false, + transaction, + drive_operations, + &platform_version.drive, + ) + } + + #[cfg(feature = "server")] + /// Executes an internal query with no proof and returns the values and skipped items. + pub fn execute_no_proof( + &self, + drive: &Drive, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let path_query = self.construct_path_query(platform_version)?; + let query_result = drive.grove_get_path_query( + &path_query, + transaction, + QueryResultType::QueryPathKeyElementTrioResultType, + drive_operations, + &platform_version.drive, + ); + match query_result { + Err(Error::GroveDB(GroveError::PathKeyNotFound(_))) + | Err(Error::GroveDB(GroveError::PathNotFound(_))) + | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok(vec![]), + Err(e) => Err(e), + Ok((query_result_elements, _)) => { + let result_is_in_key = self.result_is_in_key(); + let result_path_index = if result_is_in_key { + None + } else { + Some(self.result_path_index()) + }; + let document_type = self.document_type()?; + query_result_elements.to_path_key_elements() + .into_iter() + .map(|(mut path, key, _)| { + if result_is_in_key { + document_type.deserialize_value_for_key() + Ok(key) + } else if path.len() < result_path_index.unwrap() { + + Err() + } else { + Ok(path.remove(result_path_index.unwrap())) + } + }).collect::, Error>>() + + } + } + } +} diff --git a/packages/rs-platform-version/src/version/dpp_versions.rs b/packages/rs-platform-version/src/version/dpp_versions.rs index dcde48522e..b582adca4c 100644 --- a/packages/rs-platform-version/src/version/dpp_versions.rs +++ b/packages/rs-platform-version/src/version/dpp_versions.rs @@ -192,6 +192,7 @@ pub struct DocumentTypeMethodVersions { pub index_for_types: FeatureVersion, pub max_size: FeatureVersion, pub serialize_value_for_key: FeatureVersion, + pub deserialize_value_for_key: FeatureVersion, } #[derive(Clone, Debug, Default)] From cf9513b961f3a70aa89b9e116aa0aa0516170cbf Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 28 May 2024 13:46:09 +0200 Subject: [PATCH 087/135] contested resource query done --- .../protos/platform/v0/platform.proto | 1 - .../data_contract/document_type/index/mod.rs | 75 +++--- .../methods/deserialize_value_for_key/mod.rs | 2 +- .../deserialize_value_for_key/v0/mod.rs | 36 ++- .../document_type/methods/mod.rs | 8 +- .../src/data_contract/document_type/mod.rs | 6 +- .../document_type/property/mod.rs | 54 +++-- .../src/errors/consensus/basic/basic_error.rs | 1 - .../process_raw_state_transitions/v0/mod.rs | 4 +- .../v0/mod.rs | 6 - .../data_contract_update/mod.rs | 1 - .../state_transitions/documents_batch/mod.rs | 2 +- .../state_transitions/masternode_vote/mod.rs | 71 +++--- .../voting/contested_resources/v0/mod.rs | 87 +++---- .../drive/object_size_info/contract_info.rs | 6 +- .../resolve.rs | 21 +- packages/rs-drive/src/error/query.rs | 2 +- .../src/query/vote_poll_vote_state_query.rs | 7 +- .../vote_polls_by_document_type_query.rs | 215 +++++++++++++----- .../src/version/mocks/v2_test.rs | 1 + .../src/version/mocks/v3_test.rs | 1 + .../rs-platform-version/src/version/v1.rs | 1 + 22 files changed, 362 insertions(+), 246 deletions(-) diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index 3504a1a323..dcb66be31c 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -664,7 +664,6 @@ message GetContestedResourcesResponse { message GetContestedResourcesResponseV0 { message ContestedResourceValues { repeated bytes contested_resource_values = 1; - bool finished_results = 2; } oneof result { diff --git a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs index 36c6fa822e..f5309413c5 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs @@ -17,10 +17,10 @@ use crate::data_contract::document_type::ContestedIndexResolution::MasternodeVot use crate::data_contract::errors::DataContractError::RegexError; use platform_value::{Value, ValueMap}; use rand::distributions::{Alphanumeric, DistString}; +use regex::Regex; +use serde::de::{VariantAccess, Visitor}; use std::cmp::Ordering; use std::{collections::BTreeMap, convert::TryFrom, fmt}; -use serde::de::{VariantAccess, Visitor}; -use regex::Regex; pub mod random_index; @@ -55,16 +55,23 @@ pub enum ContestedIndexFieldMatch { #[cfg(feature = "index-serde-conversion")] impl Serialize for ContestedIndexFieldMatch { fn serialize(&self, serializer: S) -> Result - where - S: Serializer, + where + S: Serializer, { match *self { - ContestedIndexFieldMatch::Regex(ref regex) => { - serializer.serialize_newtype_variant("ContestedIndexFieldMatch", 0, "Regex", regex.as_str()) - } - ContestedIndexFieldMatch::PositiveIntegerMatch(ref num) => { - serializer.serialize_newtype_variant("ContestedIndexFieldMatch", 1, "PositiveIntegerMatch", num) - } + ContestedIndexFieldMatch::Regex(ref regex) => serializer.serialize_newtype_variant( + "ContestedIndexFieldMatch", + 0, + "Regex", + regex.as_str(), + ), + ContestedIndexFieldMatch::PositiveIntegerMatch(ref num) => serializer + .serialize_newtype_variant( + "ContestedIndexFieldMatch", + 1, + "PositiveIntegerMatch", + num, + ), } } } @@ -72,12 +79,15 @@ impl Serialize for ContestedIndexFieldMatch { #[cfg(feature = "index-serde-conversion")] impl<'de> Deserialize<'de> for ContestedIndexFieldMatch { fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, + where + D: Deserializer<'de>, { #[derive(Deserialize)] #[serde(field_identifier, rename_all = "snake_case")] - enum Field { Regex, PositiveIntegerMatch } + enum Field { + Regex, + PositiveIntegerMatch, + } struct FieldVisitor; @@ -89,13 +99,16 @@ impl<'de> Deserialize<'de> for ContestedIndexFieldMatch { } fn visit_str(self, value: &str) -> Result - where - E: de::Error, + where + E: de::Error, { match value { "regex" => Ok(Field::Regex), "positive_integer_match" => Ok(Field::PositiveIntegerMatch), - _ => Err(de::Error::unknown_variant(value, &["regex", "positive_integer_match"])), + _ => Err(de::Error::unknown_variant( + value, + &["regex", "positive_integer_match"], + )), } } } @@ -110,8 +123,8 @@ impl<'de> Deserialize<'de> for ContestedIndexFieldMatch { } fn visit_enum(self, mut visitor: V) -> Result - where - V: de::EnumAccess<'de>, + where + V: de::EnumAccess<'de>, { match visitor.variant()? { (Field::Regex, v) => { @@ -136,7 +149,6 @@ impl<'de> Deserialize<'de> for ContestedIndexFieldMatch { } } - impl PartialOrd for ContestedIndexFieldMatch { fn partial_cmp(&self, other: &Self) -> Option { use ContestedIndexFieldMatch::*; @@ -174,7 +186,9 @@ impl Ord for ContestedIndexFieldMatch { impl Clone for ContestedIndexFieldMatch { fn clone(&self) -> Self { match self { - ContestedIndexFieldMatch::Regex(regex) => ContestedIndexFieldMatch::Regex(regex::Regex::new(regex.as_str()).unwrap()), + ContestedIndexFieldMatch::Regex(regex) => { + ContestedIndexFieldMatch::Regex(regex::Regex::new(regex.as_str()).unwrap()) + } ContestedIndexFieldMatch::PositiveIntegerMatch(int) => { ContestedIndexFieldMatch::PositiveIntegerMatch(*int) } @@ -186,7 +200,9 @@ impl PartialEq for ContestedIndexFieldMatch { fn eq(&self, other: &Self) -> bool { match self { ContestedIndexFieldMatch::Regex(regex) => match other { - ContestedIndexFieldMatch::Regex(other_regex) => regex.as_str() == other_regex.as_str(), + ContestedIndexFieldMatch::Regex(other_regex) => { + regex.as_str() == other_regex.as_str() + } _ => false, }, ContestedIndexFieldMatch::PositiveIntegerMatch(int) => match other { @@ -463,14 +479,15 @@ impl TryFrom<&[(Value, Value)]> for Index { } "regexPattern" => { let regex = field_match_value.to_str()?.to_owned(); - field_matches = Some(ContestedIndexFieldMatch::Regex( - Regex::new(®ex).map_err(|e| { - RegexError(format!( - "invalid field match regex: {}", - e.to_string() - )) - })?, - )); + field_matches = + Some(ContestedIndexFieldMatch::Regex( + Regex::new(®ex).map_err(|e| { + RegexError(format!( + "invalid field match regex: {}", + e.to_string() + )) + })?, + )); } key => { return Err(DataContractError::ValueWrongType( diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/deserialize_value_for_key/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/deserialize_value_for_key/mod.rs index 7affabc980..e084dffc38 100644 --- a/packages/rs-dpp/src/data_contract/document_type/methods/deserialize_value_for_key/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/methods/deserialize_value_for_key/mod.rs @@ -1 +1 @@ -mod v0; \ No newline at end of file +mod v0; diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/deserialize_value_for_key/v0/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/deserialize_value_for_key/v0/mod.rs index 5bc20f8667..e5dd0b3096 100644 --- a/packages/rs-dpp/src/data_contract/document_type/methods/deserialize_value_for_key/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/methods/deserialize_value_for_key/v0/mod.rs @@ -18,35 +18,29 @@ impl DocumentTypeV0 { let bytes = Identifier::from_bytes(value)?; Ok(Value::Identifier(bytes.to_buffer())) } - "$createdAt" | "$updatedAt" | "$transferredAt" => { - Ok(Value::U64(DocumentPropertyType::decode_date_timestamp( - value, - ).ok_or(ProtocolError::DataContractError( - DataContractError::FieldRequirementUnmet( + "$createdAt" | "$updatedAt" | "$transferredAt" => Ok(Value::U64( + DocumentPropertyType::decode_date_timestamp(value).ok_or( + ProtocolError::DataContractError(DataContractError::FieldRequirementUnmet( "value must be 8 bytes long".to_string(), - ), - ))?)) - } + )), + )?, + )), "$createdAtBlockHeight" | "$updatedAtBlockHeight" | "$transferredAtBlockHeight" => { - Ok(Value::U64(DocumentPropertyType::decode_u64( - value, - ).ok_or(ProtocolError::DataContractError( - DataContractError::FieldRequirementUnmet( + Ok(Value::U64(DocumentPropertyType::decode_u64(value).ok_or( + ProtocolError::DataContractError(DataContractError::FieldRequirementUnmet( "value must be 8 bytes long".to_string(), - ), - ))?)) + )), + )?)) } "$createdAtCoreBlockHeight" | "$updatedAtCoreBlockHeight" | "$transferredAtCoreBlockHeight" => { - Ok(Value::U32(DocumentPropertyType::decode_u32( - value, - ).ok_or(ProtocolError::DataContractError( - DataContractError::FieldRequirementUnmet( + Ok(Value::U32(DocumentPropertyType::decode_u32(value).ok_or( + ProtocolError::DataContractError(DataContractError::FieldRequirementUnmet( "value must be 4 bytes long".to_string(), - ), - ))?)) - }, + )), + )?)) + } _ => { let property = self.flattened_properties.get(key).ok_or_else(|| { DataContractError::DocumentTypeFieldNotFound(format!("expected contract to have field: {key}, contract fields are {} on document type {}", self.flattened_properties.keys().join(" | "), self.name)) diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs index 0471b91484..e56475cd1d 100644 --- a/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs @@ -1,6 +1,7 @@ mod contested_vote_poll_for_document; mod create_document_from_data; mod create_document_with_prevalidated_properties; +mod deserialize_value_for_key; mod estimated_size; mod index_for_types; mod max_size; @@ -8,7 +9,6 @@ mod prefunded_voting_balances_for_document; mod serialize_value_for_key; #[cfg(feature = "validation")] mod validate_update; -mod deserialize_value_for_key; use std::collections::BTreeMap; @@ -22,10 +22,10 @@ use crate::prelude::{BlockHeight, CoreBlockHeight, Revision}; use crate::version::PlatformVersion; use crate::ProtocolError; +use crate::data_contract::document_type::DocumentTypeRef; use crate::fee::Credits; use crate::voting::vote_polls::VotePoll; use platform_value::{Identifier, Value}; -use crate::data_contract::document_type::DocumentTypeRef; // TODO: Some of those methods are only for tests. Hide under feature pub trait DocumentTypeV0Methods { @@ -46,7 +46,7 @@ pub trait DocumentTypeV0Methods { fn deserialize_value_for_key( &self, key: &str, - serialized_value: &Vec, + serialized_value: &[u8], platform_version: &PlatformVersion, ) -> Result; @@ -190,7 +190,7 @@ impl DocumentTypeV0Methods for DocumentTypeV0 { fn deserialize_value_for_key( &self, key: &str, - value: &Vec, + value: &[u8], platform_version: &PlatformVersion, ) -> Result { match platform_version diff --git a/packages/rs-dpp/src/data_contract/document_type/mod.rs b/packages/rs-dpp/src/data_contract/document_type/mod.rs index 06381e366f..748e571ae4 100644 --- a/packages/rs-dpp/src/data_contract/document_type/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/mod.rs @@ -138,11 +138,13 @@ impl<'a> DocumentTypeV0Methods for DocumentTypeRef<'a> { fn deserialize_value_for_key( &self, key: &str, - serialized_value: &Vec, + serialized_value: &[u8], platform_version: &PlatformVersion, ) -> Result { match self { - DocumentTypeRef::V0(v0) => v0.deserialize_value_for_key(key, serialized_value, platform_version), + DocumentTypeRef::V0(v0) => { + v0.deserialize_value_for_key(key, serialized_value, platform_version) + } } } diff --git a/packages/rs-dpp/src/data_contract/document_type/property/mod.rs b/packages/rs-dpp/src/data_contract/document_type/property/mod.rs index ba7b718753..5d5a5c8c9b 100644 --- a/packages/rs-dpp/src/data_contract/document_type/property/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/property/mod.rs @@ -6,6 +6,7 @@ use crate::data_contract::errors::DataContractError; use crate::consensus::basic::decode::DecodingError; use crate::prelude::TimestampMillis; +use crate::util::vec::DecodeError; use crate::ProtocolError; use array::ArrayItemType; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; @@ -16,7 +17,6 @@ use rand::distributions::{Alphanumeric, Standard}; use rand::rngs::StdRng; use rand::Rng; use serde::Serialize; -use crate::util::vec::DecodeError; pub mod array; @@ -839,44 +839,55 @@ impl DocumentPropertyType { // Given a field type and a Vec this function chooses and executes the right decoding method pub fn decode_value_for_tree_keys(&self, value: &[u8]) -> Result { - if value.is_null() { + if value.is_empty() { return Ok(Value::Null); } match self { DocumentPropertyType::String(_, _) => { - let value_as_text = value.as_text().ok_or_else(get_field_type_matching_error)?; - let vec = value_as_text.as_bytes().to_vec(); - if vec == &vec![0] { + if value == &vec![0] { // we don't want to collide with the definition of an empty string Ok(Value::Text("".to_string())) } else { - Ok(Value::Text(String::from_utf8(value).map_err(ProtocolError::DecodingError("could not decode ut8 bytes into string")))) + Ok(Value::Text(String::from_utf8(value.to_vec()).map_err( + |_| { + ProtocolError::DecodingError( + "could not decode ut8 bytes into string".to_string(), + ) + }, + )?)) } } - DocumentPropertyType::Date => DocumentPropertyType::decode_date_timestamp( - value - ).ok_or(ProtocolError::DecodingError("could not decode data timestamp")), + DocumentPropertyType::Date => { + let timestamp = DocumentPropertyType::decode_date_timestamp(value).ok_or( + ProtocolError::DecodingError("could not decode data timestamp".to_string()), + )?; + Ok(Value::U64(timestamp)) + } DocumentPropertyType::Integer => { - DocumentPropertyType::decode_i64(value).ok_or(ProtocolError::DecodingError("could not decode integer")) + let integer = DocumentPropertyType::decode_i64(value).ok_or( + ProtocolError::DecodingError("could not decode integer".to_string()), + )?; + Ok(Value::I64(integer)) } - DocumentPropertyType::Number => DocumentPropertyType::decode_float( - value, - ).ok_or(ProtocolError::DecodingError("could not decode float")), - DocumentPropertyType::ByteArray(_, _) => { - Ok(Value::Bytes(value.to_vec())) + DocumentPropertyType::Number => { + let float = DocumentPropertyType::decode_float(value).ok_or( + ProtocolError::DecodingError("could not decode float".to_string()), + )?; + Ok(Value::Float(float)) } + DocumentPropertyType::ByteArray(_, _) => Ok(Value::Bytes(value.to_vec())), DocumentPropertyType::Identifier => { let identifier = Identifier::from_bytes(value)?; Ok(identifier.into()) - }, + } DocumentPropertyType::Boolean => { if value == &vec![0] { Ok(Value::Bool(false)) } else if value == &vec![1] { Ok(Value::Bool(true)) } else { - Err(DataContractError::ValueWrongType( - "document field type doesn't match document value".to_string(), + Err(ProtocolError::DecodingError( + "could not decode bool".to_string(), )) } } @@ -1162,7 +1173,7 @@ impl DocumentPropertyType { } /// Decodes a float on 64 bits. - pub fn decode_float(encoded: &[u8]) -> f64 { + pub fn decode_float(encoded: &[u8]) -> Option { // Check if the value is negative by looking at the original sign bit let is_negative = (encoded[0] & 0b1000_0000) == 0; @@ -1178,9 +1189,8 @@ impl DocumentPropertyType { } // Read the float value from the transformed vector - let val = wtr.read_f64::().unwrap(); - - val + let mut cursor = Cursor::new(wtr); + cursor.read_f64::().ok() } } diff --git a/packages/rs-dpp/src/errors/consensus/basic/basic_error.rs b/packages/rs-dpp/src/errors/consensus/basic/basic_error.rs index 7e4e6e75d9..7f4931eb60 100644 --- a/packages/rs-dpp/src/errors/consensus/basic/basic_error.rs +++ b/packages/rs-dpp/src/errors/consensus/basic/basic_error.rs @@ -376,7 +376,6 @@ pub enum BasicError { #[error(transparent)] OverflowError(OverflowError), - } impl From for ConsensusError { diff --git a/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/process_raw_state_transitions/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/process_raw_state_transitions/v0/mod.rs index 675af20f48..527c760b8e 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/process_raw_state_transitions/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/process_raw_state_transitions/v0/mod.rs @@ -89,7 +89,7 @@ where let start_time = Instant::now(); let state_transition_name = state_transition.name(); - + if tracing::enabled!(tracing::Level::TRACE) { let st_hash = hex::encode(hash_single(raw_state_transition)); @@ -125,7 +125,7 @@ where state_transition_name: Some(state_transition_name.to_string()), }) .unwrap_or_else(error_to_internal_error_execution_result); - + // Store metrics let elapsed_time = start_time.elapsed() + decoding_elapsed_time; diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs index 9edae1d363..907f38a916 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs @@ -2,15 +2,9 @@ use crate::error::Error; use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; use dpp::block::block_info::BlockInfo; -use dpp::document::DocumentV0Getters; use dpp::version::PlatformVersion; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; -use dpp::voting::vote_polls::VotePoll; -use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; -use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use drive::grovedb::TransactionArg; -use drive::query::vote_poll_vote_state_query::FinalizedContender; -use drive::query::VotePollsByEndDateDriveQuery; impl Platform where 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 dffa542954..77a3e0dae4 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 @@ -57,7 +57,6 @@ mod tests { use crate::rpc::core::MockCoreRPCLike; use crate::test::helpers::setup::{TempPlatform, TestPlatformBuilder}; use dpp::block::block_info::BlockInfo; - use dpp::consensus::basic::BasicError; use dpp::consensus::state::state_error::StateError; use dpp::consensus::ConsensusError; use dpp::dash_to_credits; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs index 4b16058787..e20cfb1244 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs @@ -278,7 +278,7 @@ mod tests { use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use dpp::util::hash::hash_double; use drive::drive::object_size_info::DataContractResolvedInfo; - use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::{ContestedDocumentResourceVotePollWithContractInfo, ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed}; + use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; use drive::query::vote_poll_vote_state_query::ResolvedContestedDocumentVotePollDriveQuery; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index f04c38ff12..91cb5f592e 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -648,45 +648,52 @@ mod tests { let index_name = "parentNameAndLabel".to_string(); - let query_validation_result = platform.query_contested_resources(GetContestedResourcesRequest { - version: Some(get_contested_resources_request::Version::V0( - GetContestedResourcesRequestV0 { - contract_id: dpns_contract.id().to_vec(), - document_type_name: domain.name().clone(), - index_name: index_name.clone(), - count: None, - ascending: true, - prove: false, + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + + let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) + .expect("expected to encode value"); + + let query_validation_result = platform + .query_contested_resources( + GetContestedResourcesRequest { + version: Some(get_contested_resources_request::Version::V0( + GetContestedResourcesRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + start_index_values: vec![dash_encoded], + end_index_values: vec![], + start_at_value_info: None, + count: None, + order_ascending: true, + prove: false, + }, + )), }, - )), - }, - &platform_state, - platform_version, - ) + &platform_state, + platform_version, + ) .expect("expected to execute query") .into_data() .expect("expected query to be valid"); - let get_contested_resources_response::Version::V0( - GetContestedResourcesResponseV0 { - metadata: _, - result, - }, - ) = query_validation_result.version.expect("expected a version"); + let get_contested_resources_response::Version::V0(GetContestedResourcesResponseV0 { + metadata: _, + result, + }) = query_validation_result.version.expect("expected a version"); - let Some( - get_contested_resources_response_v0::Result::ContestedResources( - get_contested_resources_response_v0::ContestedResources { - contested_resources, finished_results - }, - ), - ) = result - else { - panic!("expected contested resources") - }; + let Some(get_contested_resources_response_v0::Result::ContestedResourceValues( + get_contested_resources_response_v0::ContestedResourceValues { + contested_resource_values, + }, + )) = result + else { + panic!("expected contested resources") + }; - assert_eq!(contested_resources.len(), 1); - assert!(finished_results); + assert_eq!(contested_resource_values.len(), 1); } #[test] diff --git a/packages/rs-drive-abci/src/query/voting/contested_resources/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resources/v0/mod.rs index 7181be8498..656fc78be1 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resources/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resources/v0/mod.rs @@ -1,20 +1,21 @@ -use dapi_grpc::platform::v0::get_contested_resources_response::{get_contested_resources_response_v0}; +use crate::error::query::QueryError; use crate::error::Error; use crate::platform_types::platform::Platform; use crate::platform_types::platform_state::PlatformState; use crate::query::QueryValidationResult; +use bincode::error::EncodeError; use dapi_grpc::platform::v0::get_contested_resources_request::GetContestedResourcesRequestV0; +use dapi_grpc::platform::v0::get_contested_resources_response::get_contested_resources_response_v0; use dapi_grpc::platform::v0::get_contested_resources_response::GetContestedResourcesResponseV0; -use dpp::{check_validation_result_with_data, platform_value}; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; -use dpp::validation::ValidationResult; use dpp::identifier::Identifier; use dpp::platform_value::Value; +use dpp::validation::ValidationResult; use dpp::version::PlatformVersion; +use dpp::{check_validation_result_with_data, ProtocolError}; use drive::error::query::QuerySyntaxError; use drive::query::vote_polls_by_document_type_query::VotePollsByDocumentTypeQuery; -use crate::error::query::QueryError; impl Platform { pub(super) fn query_contested_resources_v0( @@ -25,7 +26,7 @@ impl Platform { index_name, start_index_values, end_index_values, - start_at_value_info, + start_at_value_info, count, order_ascending, prove, @@ -78,7 +79,7 @@ impl Platform { )))); } - let bincode_config = bincode::config::standard() + let bincode_config = bincode::config::standard() .with_big_endian() .with_no_limit(); @@ -103,8 +104,6 @@ impl Platform { Ok(index_values) => index_values, Err(e) => return Ok(QueryValidationResult::new_with_error(e)), }; - - let end_index_values = match end_index_values .into_iter() @@ -149,34 +148,32 @@ impl Platform { index_name, start_index_values, end_index_values, - start_at_value: start_at_value_info - .map(|start_at_value_info| { - - (start_at_value_info.start_value, - start_at_value_info.start_value_included, - ) - }), + start_at_value: start_at_value_info.map(|start_at_value_info| { + ( + start_at_value_info.start_value, + start_at_value_info.start_value_included, + ) + }), limit: Some(limit), order_ascending, }; let response = if prove { - let proof = match query.execute_with_proof(&self.drive, None, None, platform_version) { - Ok(result) => result, - Err(drive::error::Error::Query(query_error)) => { - return Ok(QueryValidationResult::new_with_error(QueryError::Query( - query_error, - ))); - } - Err(e) => return Err(e.into()), - }; + let proof = + match query.execute_with_proof(&self.drive, None, &mut vec![], platform_version) { + Ok(result) => result, + Err(drive::error::Error::Query(query_error)) => { + return Ok(QueryValidationResult::new_with_error(QueryError::Query( + query_error, + ))); + } + Err(e) => return Err(e.into()), + }; GetContestedResourcesResponseV0 { - result: Some( - get_contested_resources_response_v0::Result::Proof( - self.response_proof_v0(platform_state, proof), - ), - ), + result: Some(get_contested_resources_response_v0::Result::Proof( + self.response_proof_v0(platform_state, proof), + )), metadata: Some(self.response_metadata_v0(platform_state)), } } else { @@ -190,36 +187,20 @@ impl Platform { } Err(e) => return Err(e.into()), }; - - let contested_resource_values = results.into_iter().map(|value| value.).collect(); - - let finished_results = if contested_resource_values.len() = limit { - let query = VotePollsByDocumentTypeQuery { - contract_id, - document_type_name, - index_name, - start_index_values, - end_index_values, - start_at_value: start_at_value_info - .map(|start_at_value_info| { - - (start_at_value_info.start_value, - start_at_value_info.start_value_included, - ) - }), - limit: Some(limit), - order_ascending, - }; - } else { - true - }; + + let contested_resource_values = results + .into_iter() + .map(|value| bincode::encode_to_vec(value, bincode_config)) + .collect::>, EncodeError>>() + .map_err(|e| { + Error::Protocol(ProtocolError::CorruptedSerialization(e.to_string())) + })?; GetContestedResourcesResponseV0 { result: Some( get_contested_resources_response_v0::Result::ContestedResourceValues( get_contested_resources_response_v0::ContestedResourceValues { contested_resource_values, - finished_results, }, ), ), diff --git a/packages/rs-drive/src/drive/object_size_info/contract_info.rs b/packages/rs-drive/src/drive/object_size_info/contract_info.rs index 9665e9cff4..9195c04f83 100644 --- a/packages/rs-drive/src/drive/object_size_info/contract_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/contract_info.rs @@ -122,7 +122,7 @@ pub enum DataContractResolvedInfo<'a> { /// Information necessary for fetched data contracts, encapsulated in an /// `Arc` to ensure thread-safe shared ownership and access. ArcDataContractFetchInfo(Arc), - + /// Arc Data contract ArcDataContract(Arc), @@ -140,7 +140,9 @@ impl<'a> DataContractResolvedInfo<'a> { /// The id of the contract pub fn id(&self) -> Identifier { match self { - DataContractResolvedInfo::ArcDataContractFetchInfo(fetch_info) => fetch_info.contract.id(), + DataContractResolvedInfo::ArcDataContractFetchInfo(fetch_info) => { + fetch_info.contract.id() + } DataContractResolvedInfo::BorrowedDataContract(data_contract) => data_contract.id(), DataContractResolvedInfo::OwnedDataContract(data_contract) => data_contract.id(), DataContractResolvedInfo::ArcDataContract(data_contract) => data_contract.id(), diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs index ae785c6fd5..57dae784ed 100644 --- a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs @@ -1,4 +1,3 @@ -use std::sync::Arc; use crate::drive::object_size_info::{DataContractOwnedResolvedInfo, DataContractResolvedInfo}; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::{ ContestedDocumentResourceVotePollWithContractInfo, @@ -7,12 +6,13 @@ use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_ use crate::drive::Drive; use crate::error::contract::DataContractError; use crate::error::Error; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; -use grovedb::TransactionArg; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::identifier::Identifier; use dpp::prelude::DataContract; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use grovedb::TransactionArg; use platform_version::version::PlatformVersion; +use std::sync::Arc; /// A trait for resolving information related to a contested document resource vote poll. /// @@ -163,7 +163,12 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote index_values, } = self; - let contract = known_contracts_provider_fn(contract_id)?.ok_or(Error::DataContract(DataContractError::MissingContract(format!("data contract with id {} can not be provided", contract_id))))?; + let contract = known_contracts_provider_fn(contract_id)?.ok_or(Error::DataContract( + DataContractError::MissingContract(format!( + "data contract with id {} can not be provided", + contract_id + )), + ))?; Ok( ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { contract: DataContractResolvedInfo::ArcDataContract(contract), @@ -186,7 +191,13 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote } = self; if contract_id != data_contract.id_ref() { - return Err(Error::DataContract(DataContractError::ProvidedContractMismatch(format!("data contract provided {} is not the one required {}", data_contract.id_ref(), contract_id)))); + return Err(Error::DataContract( + DataContractError::ProvidedContractMismatch(format!( + "data contract provided {} is not the one required {}", + data_contract.id_ref(), + contract_id + )), + )); } Ok( ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { diff --git a/packages/rs-drive/src/error/query.rs b/packages/rs-drive/src/error/query.rs index d62ee8a89b..f51c776f10 100644 --- a/packages/rs-drive/src/error/query.rs +++ b/packages/rs-drive/src/error/query.rs @@ -143,5 +143,5 @@ pub enum QuerySyntaxError { /// Missing index values for query #[error("missing index values error: {0}")] - MissingIndexValues(String), + IndexValuesError(String), } diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index bfa1ab04b9..fdebeb991a 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -1,4 +1,3 @@ -use std::sync::Arc; use crate::drive::votes::paths::VotePollPaths; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; @@ -10,14 +9,15 @@ use crate::fee::op::LowLevelDriveOperation; use crate::query::{GroveError, Query}; use dpp::block::block_info::BlockInfo; use dpp::data_contract::document_type::DocumentTypeRef; +use dpp::data_contract::DataContract; use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use dpp::document::Document; use dpp::identifier::Identifier; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use grovedb::query_result_type::{QueryResultElements, QueryResultType}; use grovedb::{Element, PathQuery, SizedQuery, TransactionArg}; -use dpp::data_contract::DataContract; use platform_version::version::PlatformVersion; +use std::sync::Arc; /// Represents the types of results that can be obtained from a contested document vote poll query. /// @@ -245,7 +245,8 @@ impl ContestedDocumentVotePollDriveQuery { order_ascending, } = self; Ok(ResolvedContestedDocumentVotePollDriveQuery { - vote_poll: vote_poll.resolve_with_known_contracts_provider(known_contracts_provider_fn)?, + vote_poll: vote_poll + .resolve_with_known_contracts_provider(known_contracts_provider_fn)?, result_type: *result_type, offset: *offset, limit: *limit, diff --git a/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs b/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs index d9f3a71353..81272a6a6a 100644 --- a/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs +++ b/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs @@ -1,31 +1,29 @@ -use crate::common::encode::{decode_u64, encode_u64}; -use crate::drive::votes::paths::{vote_contested_resource_active_polls_tree_path_vec, vote_contested_resource_end_date_queries_tree_path_vec}; +use crate::drive::object_size_info::DataContractResolvedInfo; +use crate::drive::votes::paths::{ + vote_contested_resource_active_polls_contract_document_tree_path, + vote_contested_resource_active_polls_contract_document_tree_path_vec, + vote_contested_resource_active_polls_tree_path_vec, +}; use crate::drive::Drive; +use crate::error::contract::DataContractError; use crate::error::drive::DriveError; +use crate::error::query::QuerySyntaxError; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use crate::query::{GroveError, Query}; use dpp::block::block_info::BlockInfo; -use dpp::fee::Credits; -use dpp::prelude::TimestampMillis; -use dpp::serialization::PlatformDeserializable; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; -use grovedb::query_result_type::{QueryResultElements, QueryResultType}; -use grovedb::{PathQuery, SizedQuery, TransactionArg}; -use platform_version::version::PlatformVersion; -use std::collections::BTreeMap; -use std::sync::Arc; use dpp::data_contract::accessors::v0::DataContractV0Getters; -use dpp::data_contract::DataContract; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; -use dpp::data_contract::document_type::{DocumentType, DocumentTypeRef, Index}; use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; +use dpp::data_contract::document_type::{DocumentTypeRef, Index, IndexProperty}; +use dpp::data_contract::DataContract; +use dpp::fee::Credits; use dpp::identifier::Identifier; use dpp::platform_value::Value; -use crate::drive::object_size_info::DataContractResolvedInfo; -use crate::error::contract::DataContractError; -use crate::error::query::QuerySyntaxError; -use crate::query::vote_poll_vote_state_query::{ContestedDocumentVotePollDriveQuery, ResolvedContestedDocumentVotePollDriveQuery}; +use grovedb::query_result_type::QueryResultType; +use grovedb::{PathQuery, SizedQuery, TransactionArg}; +use platform_version::version::PlatformVersion; +use std::sync::Arc; /// Vote Poll Drive Query struct #[derive(Debug, PartialEq, Clone)] @@ -69,7 +67,6 @@ pub struct ResolvedVotePollsByDocumentTypeQuery<'a> { pub order_ascending: bool, } - impl VotePollsByDocumentTypeQuery { /// Resolves the contested document vote poll drive query. /// @@ -98,7 +95,14 @@ impl VotePollsByDocumentTypeQuery { platform_version: &PlatformVersion, ) -> Result, Error> { let VotePollsByDocumentTypeQuery { - contract_id, document_type_name, index_name, start_index_values, end_index_values, start_at_value, limit, order_ascending + contract_id, + document_type_name, + index_name, + start_index_values, + end_index_values, + start_at_value, + limit, + order_ascending, } = self; let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll".to_string())))?; @@ -120,9 +124,21 @@ impl VotePollsByDocumentTypeQuery { known_contracts_provider_fn: &impl Fn(&Identifier) -> Result>, Error>, ) -> Result { let VotePollsByDocumentTypeQuery { - contract_id, document_type_name, index_name, start_index_values, end_index_values, start_at_value, limit, order_ascending + contract_id, + document_type_name, + index_name, + start_index_values, + end_index_values, + start_at_value, + limit, + order_ascending, } = self; - let contract = known_contracts_provider_fn(contract_id)?.ok_or(Error::DataContract(DataContractError::MissingContract(format!("data contract with id {} can not be provided", contract_id))))?; + let contract = known_contracts_provider_fn(contract_id)?.ok_or(Error::DataContract( + DataContractError::MissingContract(format!( + "data contract with id {} can not be provided", + contract_id + )), + ))?; Ok(ResolvedVotePollsByDocumentTypeQuery { contract: DataContractResolvedInfo::ArcDataContract(contract), @@ -142,10 +158,23 @@ impl VotePollsByDocumentTypeQuery { data_contract: &'a DataContract, ) -> Result, Error> { let VotePollsByDocumentTypeQuery { - contract_id, document_type_name, index_name, start_index_values, end_index_values, start_at_value, limit, order_ascending + contract_id, + document_type_name, + index_name, + start_index_values, + end_index_values, + start_at_value, + limit, + order_ascending, } = self; if contract_id != data_contract.id_ref() { - return Err(Error::DataContract(DataContractError::ProvidedContractMismatch(format!("data contract provided {} is not the one required {}", data_contract.id_ref(), contract_id)))); + return Err(Error::DataContract( + DataContractError::ProvidedContractMismatch(format!( + "data contract provided {} is not the one required {}", + data_contract.id_ref(), + contract_id + )), + )); } Ok(ResolvedVotePollsByDocumentTypeQuery { contract: DataContractResolvedInfo::BorrowedDataContract(data_contract), @@ -179,13 +208,7 @@ impl VotePollsByDocumentTypeQuery { block_info: Option, transaction: TransactionArg, platform_version: &PlatformVersion, - ) -> Result< - ( - Vec, - Credits, - ), - Error, - > { + ) -> Result<(Vec, Credits), Error> { let mut drive_operations = vec![]; let result = self.execute_no_proof(drive, transaction, &mut drive_operations, platform_version)?; @@ -220,15 +243,21 @@ impl VotePollsByDocumentTypeQuery { impl<'a> ResolvedVotePollsByDocumentTypeQuery<'a> { fn document_type(&self) -> Result { - Ok(self.contract.as_ref().document_type_for_name(self.document_type_name.as_str())?) + Ok(self + .contract + .as_ref() + .document_type_for_name(self.document_type_name.as_str())?) } fn index(&self) -> Result<&Index, Error> { - let index = self.contract.as_ref().document_type_borrowed_for_name(self.document_type_name.as_str())?.find_contested_index().ok_or( - Error::Query(QuerySyntaxError::UnknownIndex(format!( + let index = self + .contract + .as_ref() + .document_type_borrowed_for_name(self.document_type_name.as_str())? + .find_contested_index() + .ok_or(Error::Query(QuerySyntaxError::UnknownIndex(format!( "document type {} does not have a contested index", self.document_type_name.as_str() - ))) - )?; + ))))?; if index.name.as_str() != self.index_name.as_str() { return Err(Error::Query(QuerySyntaxError::UnknownIndex(format!( "index with name {} is not the contested index on the document type {}, {} is the name of the only contested index (contested resources query)", @@ -237,9 +266,14 @@ impl<'a> ResolvedVotePollsByDocumentTypeQuery<'a> { } Ok(index) } - fn indexes_vectors(&self, platform_version: &PlatformVersion) -> Result<(Vec>, Vec>, Vec), Error> { + + /// Creates the vectors of indexes + fn indexes_vectors( + &self, + index: &Index, + platform_version: &PlatformVersion, + ) -> Result<(Vec>, Vec>), Error> { let document_type = self.document_type()?; - let index = self.index()?; let mut properties_iter = index.properties.iter(); let mut start_values_iter = self.start_index_values.iter(); let mut end_values_iter = self.end_index_values.iter(); @@ -250,17 +284,25 @@ impl<'a> ResolvedVotePollsByDocumentTypeQuery<'a> { while let Some(index_property) = properties_iter.next() { if !ended_start_values { if let Some(start_value) = start_values_iter.next() { - let encoded = document_type.serialize_value_for_key(&index_property.name, start_value, platform_version)?; + let encoded = document_type.serialize_value_for_key( + &index_property.name, + start_value, + platform_version, + )?; start_values_vec.push(encoded); } else { ended_start_values = true; } } else if started_end_values { if let Some(end_value) = end_values_iter.next() { - let encoded = document_type.serialize_value_for_key(&index_property.name, end_value, platform_version)?; + let encoded = document_type.serialize_value_for_key( + &index_property.name, + end_value, + platform_version, + )?; end_values_vec.push(encoded); } else { - return Err(Error::Query(QuerySyntaxError::MissingIndexValues("the start index values and the end index values must be equal to the amount of properties in the contested index minus one".to_string()))) + return Err(Error::Query(QuerySyntaxError::IndexValuesError("the start index values and the end index values must be equal to the amount of properties in the contested index minus one".to_string()))); } } else { started_end_values = true; @@ -268,32 +310,80 @@ impl<'a> ResolvedVotePollsByDocumentTypeQuery<'a> { } Ok((start_values_vec, end_values_vec)) } - - pub fn result_is_in_key(&self) -> bool { + + fn property_name_being_searched(&self, index: &'a Index) -> Result<&'a IndexProperty, Error> { + let offset = self.start_index_values.len(); + index + .properties + .get(offset) + .ok_or(Error::Query(QuerySyntaxError::IndexValuesError(format!( + "there are too many start index values to be able to make a search max is {}, got {}", + index.properties.len() - 1, + offset + )))) + } + + fn result_is_in_key(&self) -> bool { // this means that the keys are the values that we are interested in self.end_index_values.is_empty() } - + fn result_path_index(&self) -> usize { + // 5 because of: + // voting sub tree (112) + // contested ('c') + // voting part + // contract id + // document type name 5 + self.start_index_values.len() } - + + /// Operations to construct a path query. + fn construct_path_query(&self, platform_version: &PlatformVersion) -> Result { + let index = self.index()?; + self.construct_path_query_internal(index, platform_version) + } + /// Operations to construct a path query. - pub fn construct_path_query( + fn construct_path_query_internal( &self, + index: &Index, platform_version: &PlatformVersion, ) -> Result { - let mut path = vote_contested_resource_active_polls_tree_path_vec(); - - let (mut start, end) = self.indexes_vectors(platform_version)?; + let mut path = vote_contested_resource_active_polls_contract_document_tree_path_vec( + self.contract.id().as_ref(), + self.document_type_name, + ); + + let (mut start, end) = self.indexes_vectors(index, platform_version)?; if !start.is_empty() { path.append(&mut start); } let mut query = Query::new_with_direction(self.order_ascending); - - if !end.is_empty(){ + + // this is a range on all elements + match &self.start_at_value { + None => { + query.insert_all(); + } + Some((starts_at_key_bytes, start_at_included)) => { + let starts_at_key = starts_at_key_bytes.to_vec(); + match self.order_ascending { + true => match start_at_included { + true => query.insert_range_from(starts_at_key..), + false => query.insert_range_after(starts_at_key..), + }, + false => match start_at_included { + true => query.insert_range_to_inclusive(..=starts_at_key), + false => query.insert_range_to(..starts_at_key), + }, + } + } + } + + if !end.is_empty() { query.default_subquery_branch.subquery_path = Some(end); } @@ -335,8 +425,9 @@ impl<'a> ResolvedVotePollsByDocumentTypeQuery<'a> { drive_operations: &mut Vec, platform_version: &PlatformVersion, ) -> Result, Error> { - let path_query = self.construct_path_query(platform_version)?; - let query_result = drive.grove_get_path_query( + let index = self.index()?; + let path_query = self.construct_path_query_internal(index, platform_version)?; + let query_result = drive.grove_get_raw_path_query( &path_query, transaction, QueryResultType::QueryPathKeyElementTrioResultType, @@ -356,20 +447,26 @@ impl<'a> ResolvedVotePollsByDocumentTypeQuery<'a> { Some(self.result_path_index()) }; let document_type = self.document_type()?; + let property_name_being_searched = self.property_name_being_searched(index)?; query_result_elements.to_path_key_elements() .into_iter() .map(|(mut path, key, _)| { if result_is_in_key { - document_type.deserialize_value_for_key() - Ok(key) + // the result is in the key because we did not provide any end index values + // like this <------ start index values (path) ---> Key + // properties ------- --------- --------- ---------- ------- + document_type.deserialize_value_for_key(property_name_being_searched.name.as_str(), key.as_slice(), platform_version).map_err(Error::Protocol) } else if path.len() < result_path_index.unwrap() { - - Err() + + Err(Error::Drive(DriveError::CorruptedCodeExecution("the path length should always be bigger or equal to the result path index"))) } else { - Ok(path.remove(result_path_index.unwrap())) + // the result is in the path because we did not provide any end index values + // like this <------ start index values (path) ---> Key + // properties ------- --------- --------- ---------- ------- + let inner_path_value_bytes = path.remove(result_path_index.unwrap()); + document_type.deserialize_value_for_key(property_name_being_searched.name.as_str(), inner_path_value_bytes.as_slice(), platform_version).map_err(Error::Protocol) } - }).collect::, Error>>() - + }).collect::, Error>>() } } } diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index cf5c1517c9..5285c5dec1 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -1129,6 +1129,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { index_for_types: 0, max_size: 0, serialize_value_for_key: 0, + deserialize_value_for_key: 0, }, }, }, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index a47bbf6b19..45274e3e5c 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -1129,6 +1129,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { index_for_types: 0, max_size: 0, serialize_value_for_key: 0, + deserialize_value_for_key: 0, }, }, }, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index f3747ea775..96c26f96d2 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -1128,6 +1128,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { index_for_types: 0, max_size: 0, serialize_value_for_key: 0, + deserialize_value_for_key: 0, }, }, }, From 02a6a4fcfc46983917193448fd7cd47b59de632f Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 28 May 2024 14:00:26 +0200 Subject: [PATCH 088/135] fix --- .../identity/masternode_vote_transition/methods/mod.rs | 1 + .../identity/masternode_vote_transition/v0/v0_methods.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/mod.rs index ab84344af4..3a4e9eed96 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/mod.rs @@ -14,6 +14,7 @@ use crate::state_transition::StateTransition; use crate::voting::votes::Vote; impl MasternodeVoteTransitionMethodsV0 for MasternodeVoteTransition { + #[cfg(feature = "state-transition-signing")] fn try_from_vote_with_signer( vote: Vote, signer: &S, diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/v0_methods.rs index 8b7a02a9e1..c9fa350524 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/v0_methods.rs @@ -9,6 +9,7 @@ use crate::ProtocolError; use platform_value::Identifier; impl MasternodeVoteTransitionV0 { + #[cfg(feature = "state-transition-signing")] pub fn try_from_vote_with_signer( vote: Vote, signer: &S, From 0991a26eda5e21a6bd4712f96f706dc324121c1a Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 28 May 2024 14:45:24 +0200 Subject: [PATCH 089/135] feature fixes --- .../data_contract/document_type/index/mod.rs | 13 ++++++--- .../deserialize_value_for_key/v0/mod.rs | 2 +- .../document_type/methods/mod.rs | 1 - .../document_type/property/mod.rs | 1 - .../src/data_contract/errors/contract.rs | 1 - .../document_create_transition/v0/mod.rs | 4 +-- packages/rs-drive/Cargo.toml | 3 +-- packages/rs-drive/src/drive/document/paths.rs | 10 ++++--- packages/rs-drive/src/drive/mod.rs | 2 +- .../drive/object_size_info/contract_info.rs | 11 ++++++++ .../src/drive/object_size_info/mod.rs | 26 ++++++++++++++++++ .../prefunded_specialized_balances/mod.rs | 11 ++++++++ .../v0/mod.rs | 1 - .../voting/verify_masternode_vote/mod.rs | 1 - .../voting/verify_masternode_vote/v0/mod.rs | 4 --- .../resolve.rs | 27 +++++++++++++++---- .../drive/votes/resolved/vote_polls/mod.rs | 1 + .../src/drive/votes/resolved/votes/mod.rs | 1 + .../votes/resolved_resource_vote/mod.rs | 1 + .../votes/resolved_resource_vote/v0/mod.rs | 1 + .../query/vote_poll_contestant_votes_query.rs | 15 +++++++++-- .../src/query/vote_poll_vote_state_query.rs | 11 ++++++-- .../vote_polls_by_document_type_query.rs | 21 ++++++++++----- .../src/query/vote_polls_by_end_date_query.rs | 18 +++++++++++-- 24 files changed, 146 insertions(+), 41 deletions(-) diff --git a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs index f5309413c5..24f6c75090 100644 --- a/packages/rs-dpp/src/data_contract/document_type/index/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/index/mod.rs @@ -1,10 +1,12 @@ +#[cfg(feature = "index-serde-conversion")] use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; -#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone, Eq)] +#[derive(Debug, PartialEq, PartialOrd, Clone, Eq)] +#[cfg_attr(feature = "index-serde-conversion", derive(Serialize, Deserialize))] pub enum OrderBy { - #[serde(rename = "asc")] + #[cfg_attr(feature = "index-serde-conversion", serde(rename = "asc"))] Asc, - #[serde(rename = "desc")] + #[cfg_attr(feature = "index-serde-conversion", serde(rename = "desc"))] Desc, } @@ -18,9 +20,12 @@ use crate::data_contract::errors::DataContractError::RegexError; use platform_value::{Value, ValueMap}; use rand::distributions::{Alphanumeric, DistString}; use regex::Regex; +#[cfg(feature = "index-serde-conversion")] use serde::de::{VariantAccess, Visitor}; use std::cmp::Ordering; -use std::{collections::BTreeMap, convert::TryFrom, fmt}; +#[cfg(feature = "index-serde-conversion")] +use std::fmt; +use std::{collections::BTreeMap, convert::TryFrom}; pub mod random_index; diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/deserialize_value_for_key/v0/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/deserialize_value_for_key/v0/mod.rs index e5dd0b3096..cfba305c39 100644 --- a/packages/rs-dpp/src/data_contract/document_type/methods/deserialize_value_for_key/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/methods/deserialize_value_for_key/v0/mod.rs @@ -1,4 +1,4 @@ -use crate::data_contract::document_type::v0::{DocumentTypeV0, DEFAULT_HASH_SIZE, MAX_INDEX_SIZE}; +use crate::data_contract::document_type::v0::DocumentTypeV0; use crate::data_contract::document_type::DocumentPropertyType; use crate::data_contract::errors::DataContractError; use crate::ProtocolError; diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs index e56475cd1d..ca83589ccc 100644 --- a/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/methods/mod.rs @@ -22,7 +22,6 @@ use crate::prelude::{BlockHeight, CoreBlockHeight, Revision}; use crate::version::PlatformVersion; use crate::ProtocolError; -use crate::data_contract::document_type::DocumentTypeRef; use crate::fee::Credits; use crate::voting::vote_polls::VotePoll; use platform_value::{Identifier, Value}; diff --git a/packages/rs-dpp/src/data_contract/document_type/property/mod.rs b/packages/rs-dpp/src/data_contract/document_type/property/mod.rs index 5d5a5c8c9b..f881f37719 100644 --- a/packages/rs-dpp/src/data_contract/document_type/property/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/property/mod.rs @@ -6,7 +6,6 @@ use crate::data_contract::errors::DataContractError; use crate::consensus::basic::decode::DecodingError; use crate::prelude::TimestampMillis; -use crate::util::vec::DecodeError; use crate::ProtocolError; use array::ArrayItemType; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; diff --git a/packages/rs-dpp/src/data_contract/errors/contract.rs b/packages/rs-dpp/src/data_contract/errors/contract.rs index 5cec2e2bf6..db6df72423 100644 --- a/packages/rs-dpp/src/data_contract/errors/contract.rs +++ b/packages/rs-dpp/src/data_contract/errors/contract.rs @@ -3,7 +3,6 @@ use crate::consensus::basic::decode::DecodingError; use crate::consensus::basic::BasicError; use bincode::{Decode, Encode}; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; -use platform_value::Identifier; use thiserror::Error; use crate::consensus::basic::document::InvalidDocumentTypeError; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs index b2ec1c22a7..17e5b782f3 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/document_create_transition/v0/mod.rs @@ -5,9 +5,9 @@ use bincode::{Decode, Encode}; #[cfg(feature = "state-transition-value-conversion")] use platform_value::btreemap_extensions::BTreeValueRemoveFromMapHelper; -use platform_value::{Identifier, Value}; #[cfg(feature = "state-transition-value-conversion")] -use platform_value::{ValueMap, ValueMapHelper}; +use platform_value::ValueMapHelper; +use platform_value::{Identifier, Value}; #[cfg(feature = "state-transition-serde-conversion")] use serde::{Deserialize, Serialize}; diff --git a/packages/rs-drive/Cargo.toml b/packages/rs-drive/Cargo.toml index b5fca98b50..9e9d205f72 100644 --- a/packages/rs-drive/Cargo.toml +++ b/packages/rs-drive/Cargo.toml @@ -28,7 +28,7 @@ nohash-hasher = { version = "0.2.0" } dpp = { path = "../rs-dpp", features = ["state-transitions"], default-features = false, optional = true } thiserror = { version = "1.0.59" } tracing = { version = "0.1.37", default-features = false, features = [] } -derive_more = { version = "0.99.17", optional = true} +derive_more = { version = "0.99.17"} hex = { version = "0.4.3" } # optional dependencies @@ -92,7 +92,6 @@ server = [ "grovedb-costs", "itertools", "rand", #todo: this should be removed eventually - "derive_more", "enum-map", "intmap", ] diff --git a/packages/rs-drive/src/drive/document/paths.rs b/packages/rs-drive/src/drive/document/paths.rs index 6fe1639fc6..f14b76aa80 100644 --- a/packages/rs-drive/src/drive/document/paths.rs +++ b/packages/rs-drive/src/drive/document/paths.rs @@ -3,7 +3,9 @@ use crate::drive::{defaults, RootTree}; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; use dpp::data_contract::document_type::DocumentTypeRef; +#[cfg(feature = "server")] use grovedb::batch::key_info::KeyInfo; +#[cfg(feature = "server")] use grovedb::batch::KeyInfoPath; #[cfg(any(feature = "server", feature = "verify"))] @@ -20,7 +22,7 @@ pub(crate) fn contract_document_type_path<'a>( ] } -#[cfg(feature = "server")] +#[cfg(any(feature = "server", feature = "verify"))] /// Returns the path to a contract document type. pub(crate) fn contract_document_type_path_vec( contract_id: &[u8], @@ -34,7 +36,7 @@ pub(crate) fn contract_document_type_path_vec( ] } -#[cfg(feature = "server")] +#[cfg(any(feature = "server", feature = "verify"))] /// Returns the path to the primary keys of a contract document type. pub(crate) fn contract_documents_primary_key_path<'a>( contract_id: &'a [u8], @@ -49,7 +51,7 @@ pub(crate) fn contract_documents_primary_key_path<'a>( ] } -#[cfg(feature = "server")] +#[cfg(any(feature = "server", feature = "verify"))] /// Returns the path to a contract document. pub fn contract_documents_keeping_history_primary_key_path_for_document_id<'a>( contract_id: &'a [u8], @@ -95,7 +97,7 @@ fn contract_documents_keeping_history_primary_key_path_for_document_id_size( + document_type_name_len } -#[cfg(feature = "server")] +#[cfg(any(feature = "server", feature = "verify"))] /// Returns the size of the path to the time at which a document type was stored. pub fn contract_documents_keeping_history_storage_time_reference_path_size( document_type_name_len: u32, diff --git a/packages/rs-drive/src/drive/mod.rs b/packages/rs-drive/src/drive/mod.rs index 1075819162..497ecddf2f 100644 --- a/packages/rs-drive/src/drive/mod.rs +++ b/packages/rs-drive/src/drive/mod.rs @@ -39,7 +39,7 @@ pub mod grove_operations; pub mod identity; #[cfg(feature = "server")] pub mod initialization; -#[cfg(feature = "server")] +#[cfg(any(feature = "server", feature = "verify"))] pub mod object_size_info; /// Protocol upgrade module diff --git a/packages/rs-drive/src/drive/object_size_info/contract_info.rs b/packages/rs-drive/src/drive/object_size_info/contract_info.rs index 9195c04f83..70be1a8db2 100644 --- a/packages/rs-drive/src/drive/object_size_info/contract_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/contract_info.rs @@ -1,7 +1,9 @@ +#[cfg(feature = "server")] use crate::drive::contract::DataContractFetchInfo; use crate::drive::Drive; use crate::error::document::DocumentError; use crate::error::Error; +#[cfg(feature = "server")] use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::data_contract::accessors::v0::DataContractV0Getters; @@ -9,6 +11,7 @@ use dpp::data_contract::document_type::DocumentTypeRef; use dpp::data_contract::DataContract; use dpp::identifier::Identifier; use dpp::ProtocolError; +#[cfg(feature = "server")] use grovedb::TransactionArg; use platform_version::version::PlatformVersion; use std::sync::Arc; @@ -23,6 +26,7 @@ pub enum DataContractInfo<'a> { /// to access the full contract itself. DataContractId(Identifier), + #[cfg(feature = "server")] /// Information necessary for fetching a data contract, encapsulated in an /// `Arc` for thread-safe shared ownership. This variant is used when the /// data needs to be fetched or is not immediately available. @@ -38,6 +42,7 @@ pub enum DataContractInfo<'a> { } impl<'a> DataContractInfo<'a> { + #[cfg(feature = "server")] /// Resolve the data contract info into an object that contains the data contract pub(crate) fn resolve( self, @@ -81,6 +86,7 @@ impl<'a> DataContractInfo<'a> { /// of data contract states post-retrieval. #[derive(Clone, Debug, PartialEq)] pub enum DataContractOwnedResolvedInfo { + #[cfg(feature = "server")] /// Information necessary for fetched data contracts, encapsulated in an /// `Arc` to ensure thread-safe shared ownership and access. DataContractFetchInfo(Arc), @@ -95,6 +101,7 @@ impl DataContractOwnedResolvedInfo { /// The id of the contract pub fn id(&self) -> Identifier { match self { + #[cfg(feature = "server")] DataContractOwnedResolvedInfo::DataContractFetchInfo(fetch_info) => { fetch_info.contract.id() } @@ -106,6 +113,7 @@ impl AsRef for DataContractOwnedResolvedInfo { /// The ref of the contract fn as_ref(&self) -> &DataContract { match self { + #[cfg(feature = "server")] DataContractOwnedResolvedInfo::DataContractFetchInfo(fetch_info) => { &fetch_info.contract } @@ -119,6 +127,7 @@ impl AsRef for DataContractOwnedResolvedInfo { /// of data contract states post-retrieval. #[derive(Clone, Debug, PartialEq)] pub enum DataContractResolvedInfo<'a> { + #[cfg(feature = "server")] /// Information necessary for fetched data contracts, encapsulated in an /// `Arc` to ensure thread-safe shared ownership and access. ArcDataContractFetchInfo(Arc), @@ -140,6 +149,7 @@ impl<'a> DataContractResolvedInfo<'a> { /// The id of the contract pub fn id(&self) -> Identifier { match self { + #[cfg(feature = "server")] DataContractResolvedInfo::ArcDataContractFetchInfo(fetch_info) => { fetch_info.contract.id() } @@ -153,6 +163,7 @@ impl<'a> AsRef for DataContractResolvedInfo<'a> { /// The ref of the contract fn as_ref(&self) -> &DataContract { match self { + #[cfg(feature = "server")] DataContractResolvedInfo::ArcDataContractFetchInfo(fetch_info) => &fetch_info.contract, DataContractResolvedInfo::BorrowedDataContract(borrowed) => borrowed, DataContractResolvedInfo::OwnedDataContract(owned) => owned, diff --git a/packages/rs-drive/src/drive/object_size_info/mod.rs b/packages/rs-drive/src/drive/object_size_info/mod.rs index 7f739bb9b7..e3c5f19577 100644 --- a/packages/rs-drive/src/drive/object_size_info/mod.rs +++ b/packages/rs-drive/src/drive/object_size_info/mod.rs @@ -3,28 +3,54 @@ //! This module defines enums and implements functions relevant to the sizes of objects. //! +#[cfg(any(feature = "server", feature = "verify"))] mod contract_info; +#[cfg(feature = "server")] mod deletion_info; +#[cfg(feature = "server")] mod document_and_contract_info; +#[cfg(feature = "server")] mod document_info; +#[cfg(feature = "server")] mod drive_key_info; +#[cfg(feature = "server")] mod element_info; +#[cfg(feature = "server")] mod key_element_info; +#[cfg(feature = "server")] mod key_value_info; +#[cfg(feature = "server")] mod owned_document_info; +#[cfg(feature = "server")] mod path_info; +#[cfg(feature = "server")] mod path_key_element_info; +#[cfg(feature = "server")] mod path_key_info; +#[cfg(feature = "server")] pub use contract_info::*; +#[cfg(all(feature = "verify", not(feature = "server")))] +pub use contract_info::{DataContractOwnedResolvedInfo, DataContractResolvedInfo}; +#[cfg(feature = "server")] pub use deletion_info::*; +#[cfg(feature = "server")] pub use document_and_contract_info::*; +#[cfg(feature = "server")] pub use document_info::*; +#[cfg(feature = "server")] pub use drive_key_info::*; +#[cfg(feature = "server")] pub use element_info::*; +#[cfg(feature = "server")] pub use key_element_info::*; +#[cfg(feature = "server")] pub use key_value_info::*; +#[cfg(feature = "server")] pub use owned_document_info::*; +#[cfg(feature = "server")] pub use path_info::*; +#[cfg(feature = "server")] pub use path_key_element_info::*; +#[cfg(feature = "server")] pub use path_key_info::*; diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs index a1bf76dac4..54a30be6e5 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/mod.rs @@ -1,13 +1,23 @@ +#[cfg(feature = "server")] mod add_prefunded_specialized_balance; +#[cfg(feature = "server")] mod add_prefunded_specialized_balance_operations; +#[cfg(feature = "server")] mod deduct_from_prefunded_specialized_balance; +#[cfg(feature = "server")] mod deduct_from_prefunded_specialized_balance_operations; +#[cfg(feature = "server")] mod estimation_costs; +#[cfg(feature = "server")] mod fetch; +#[cfg(feature = "server")] mod prove; +#[cfg(feature = "server")] use crate::drive::batch::grovedb_op_batch::GroveDbOpBatchV0Methods; +#[cfg(feature = "server")] use crate::drive::batch::GroveDbOpBatch; +#[cfg(any(feature = "server", feature = "verify"))] use crate::drive::{Drive, RootTree}; pub const PREFUNDED_BALANCES_FOR_VOTING: u8 = 128; @@ -36,6 +46,7 @@ pub(crate) fn prefunded_specialized_balances_for_voting_path_vec() -> Vec Result; + #[cfg(feature = "server")] /// Resolve owned fn resolve_owned( @@ -54,6 +60,7 @@ pub trait ContestedDocumentResourceVotePollResolver { platform_version: &PlatformVersion, ) -> Result; + #[cfg(feature = "server")] /// Resolve into a struct that allows for a borrowed contract fn resolve_allow_borrowed<'a>( &self, @@ -62,18 +69,22 @@ pub trait ContestedDocumentResourceVotePollResolver { platform_version: &PlatformVersion, ) -> Result, Error>; + #[cfg(feature = "verify")] + /// Resolves into a struct, the contract itself will be held with Arc fn resolve_with_known_contracts_provider<'a>( &self, known_contracts_provider_fn: &impl Fn(&Identifier) -> Result>, Error>, ) -> Result, Error>; + #[cfg(feature = "verify")] /// Resolve by providing the contract fn resolve_with_provided_borrowed_contract<'a>( &self, data_contract: &'a DataContract, ) -> Result, Error>; + #[cfg(feature = "server")] /// Resolve owned into a struct that allows for a borrowed contract fn resolve_owned_allow_borrowed<'a>( self, @@ -84,6 +95,7 @@ pub trait ContestedDocumentResourceVotePollResolver { } impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVotePoll { + #[cfg(feature = "server")] fn resolve( &self, drive: &Drive, @@ -106,6 +118,7 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote }) } + #[cfg(feature = "server")] fn resolve_owned( self, drive: &Drive, @@ -128,6 +141,7 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote }) } + #[cfg(feature = "server")] fn resolve_allow_borrowed<'a>( &self, drive: &Drive, @@ -152,6 +166,7 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote ) } + #[cfg(feature = "verify")] fn resolve_with_known_contracts_provider<'a>( &self, known_contracts_provider_fn: &impl Fn(&Identifier) -> Result>, Error>, @@ -179,6 +194,7 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote ) } + #[cfg(feature = "verify")] fn resolve_with_provided_borrowed_contract<'a>( &self, data_contract: &'a DataContract, @@ -209,6 +225,7 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote ) } + #[cfg(feature = "server")] fn resolve_owned_allow_borrowed<'a>( self, drive: &Drive, diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs index c63d696b32..864e863aa4 100644 --- a/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs @@ -7,6 +7,7 @@ use dpp::ProtocolError; pub mod contested_document_resource_vote_poll; /// Module containing logic to resolve various components. +#[cfg(feature = "server")] pub(crate) mod resolve; /// Represents a resolved vote poll in the system. diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/mod.rs b/packages/rs-drive/src/drive/votes/resolved/votes/mod.rs index e994280193..fed49e98e2 100644 --- a/packages/rs-drive/src/drive/votes/resolved/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolved/votes/mod.rs @@ -1,3 +1,4 @@ +#[cfg(feature = "server")] pub(crate) mod resolve; /// Resolved resource vote module pub mod resolved_resource_vote; diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/mod.rs b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/mod.rs index efa0916bf3..2ceaf7cc39 100644 --- a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/mod.rs @@ -7,6 +7,7 @@ pub mod accessors; pub mod v0; /// Module containing logic to resolve resources. +#[cfg(feature = "server")] pub(crate) mod resolve; /// Represents a resolved resource vote in the system. diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/mod.rs index f53294e861..b529a42791 100644 --- a/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolved/votes/resolved_resource_vote/v0/mod.rs @@ -1,3 +1,4 @@ +#[cfg(feature = "server")] pub(crate) mod resolve; use crate::drive::votes::resolved::vote_polls::ResolvedVotePoll; diff --git a/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs b/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs index 354d699ecb..5f28e42ab7 100644 --- a/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs +++ b/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs @@ -1,17 +1,27 @@ use crate::drive::votes::paths::VotePollPaths; +#[cfg(feature = "server")] use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; +#[cfg(feature = "server")] use crate::drive::Drive; use crate::error::Error; +#[cfg(feature = "server")] use crate::fee::op::LowLevelDriveOperation; -use crate::query::{GroveError, Query}; +#[cfg(feature = "server")] +use crate::query::GroveError; +use crate::query::Query; +#[cfg(feature = "server")] use dpp::block::block_info::BlockInfo; use dpp::identifier::Identifier; +#[cfg(feature = "server")] use dpp::platform_value; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice::TowardsIdentity; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +#[cfg(feature = "server")] use grovedb::query_result_type::{QueryResultElements, QueryResultType}; -use grovedb::{PathQuery, SizedQuery, TransactionArg}; +#[cfg(feature = "server")] +use grovedb::TransactionArg; +use grovedb::{PathQuery, SizedQuery}; use platform_version::version::PlatformVersion; /// Vote Poll Drive Query struct @@ -32,6 +42,7 @@ pub struct ContestedDocumentVotePollVotesDriveQuery { } impl ContestedDocumentVotePollVotesDriveQuery { + #[cfg(feature = "server")] /// Resolves the contested document vote poll drive query. /// /// This method processes the query by interacting with the drive, using the provided diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index fdebeb991a..f914366845 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -5,8 +5,11 @@ use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::query::QuerySyntaxError; use crate::error::Error; +#[cfg(feature = "server")] use crate::fee::op::LowLevelDriveOperation; -use crate::query::{GroveError, Query}; +#[cfg(feature = "server")] +use crate::query::GroveError; +#[cfg(feature = "server")] use dpp::block::block_info::BlockInfo; use dpp::data_contract::document_type::DocumentTypeRef; use dpp::data_contract::DataContract; @@ -14,8 +17,11 @@ use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use dpp::document::Document; use dpp::identifier::Identifier; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +#[cfg(feature = "server")] use grovedb::query_result_type::{QueryResultElements, QueryResultType}; -use grovedb::{Element, PathQuery, SizedQuery, TransactionArg}; +#[cfg(feature = "server")] +use grovedb::{Element, TransactionArg}; +use grovedb::{PathQuery, Query, SizedQuery}; use platform_version::version::PlatformVersion; use std::sync::Arc; @@ -187,6 +193,7 @@ pub struct ContestedDocumentVotePollDriveQueryExecutionResult { } impl ContestedDocumentVotePollDriveQuery { + #[cfg(feature = "server")] /// Resolves the contested document vote poll drive query. /// /// This method processes the query by interacting with the drive, using the provided diff --git a/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs b/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs index 81272a6a6a..c3eb31a0bc 100644 --- a/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs +++ b/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs @@ -1,27 +1,33 @@ use crate::drive::object_size_info::DataContractResolvedInfo; -use crate::drive::votes::paths::{ - vote_contested_resource_active_polls_contract_document_tree_path, - vote_contested_resource_active_polls_contract_document_tree_path_vec, - vote_contested_resource_active_polls_tree_path_vec, -}; +use crate::drive::votes::paths::vote_contested_resource_active_polls_contract_document_tree_path_vec; +#[cfg(feature = "server")] use crate::drive::Drive; use crate::error::contract::DataContractError; +#[cfg(feature = "server")] use crate::error::drive::DriveError; use crate::error::query::QuerySyntaxError; use crate::error::Error; +#[cfg(feature = "server")] use crate::fee::op::LowLevelDriveOperation; -use crate::query::{GroveError, Query}; +#[cfg(feature = "server")] +use crate::query::GroveError; +use crate::query::Query; +#[cfg(feature = "server")] use dpp::block::block_info::BlockInfo; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; use dpp::data_contract::document_type::{DocumentTypeRef, Index, IndexProperty}; use dpp::data_contract::DataContract; +#[cfg(feature = "server")] use dpp::fee::Credits; use dpp::identifier::Identifier; use dpp::platform_value::Value; +#[cfg(feature = "server")] use grovedb::query_result_type::QueryResultType; -use grovedb::{PathQuery, SizedQuery, TransactionArg}; +#[cfg(feature = "server")] +use grovedb::TransactionArg; +use grovedb::{PathQuery, SizedQuery}; use platform_version::version::PlatformVersion; use std::sync::Arc; @@ -68,6 +74,7 @@ pub struct ResolvedVotePollsByDocumentTypeQuery<'a> { } impl VotePollsByDocumentTypeQuery { + #[cfg(feature = "server")] /// Resolves the contested document vote poll drive query. /// /// This method processes the query by interacting with the drive, using the provided diff --git a/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs b/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs index 4a28938447..28d7b5636a 100644 --- a/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs +++ b/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs @@ -1,18 +1,32 @@ use crate::common::encode::{decode_u64, encode_u64}; use crate::drive::votes::paths::vote_contested_resource_end_date_queries_tree_path_vec; use crate::drive::Drive; +#[cfg(feature = "server")] use crate::error::drive::DriveError; +#[cfg(feature = "server")] use crate::error::Error; +#[cfg(feature = "server")] use crate::fee::op::LowLevelDriveOperation; -use crate::query::{GroveError, Query}; +#[cfg(feature = "server")] +use crate::query::GroveError; +use crate::query::Query; +#[cfg(feature = "server")] use dpp::block::block_info::BlockInfo; +#[cfg(feature = "server")] use dpp::fee::Credits; use dpp::prelude::{TimestampIncluded, TimestampMillis}; +#[cfg(feature = "server")] use dpp::serialization::PlatformDeserializable; +#[cfg(feature = "server")] use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +#[cfg(feature = "server")] use grovedb::query_result_type::{QueryResultElements, QueryResultType}; -use grovedb::{PathQuery, SizedQuery, TransactionArg}; +#[cfg(feature = "server")] +use grovedb::TransactionArg; +use grovedb::{PathQuery, SizedQuery}; +#[cfg(feature = "server")] use platform_version::version::PlatformVersion; +#[cfg(feature = "server")] use std::collections::BTreeMap; /// Vote Poll Drive Query struct From 7832cd9e2c4372f8ed2f318b2a99ea69df5cfe26 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 28 May 2024 15:32:26 +0200 Subject: [PATCH 090/135] more fixes --- .../document_type/class_methods/mod.rs | 2 + .../masternode_vote_transition/methods/mod.rs | 12 +++- .../methods/v0/mod.rs | 11 +++- .../masternode_vote_transition/mod.rs | 1 + .../v0/v0_methods.rs | 8 +++ .../vote_choices/resource_vote_choice/mod.rs | 1 + .../yes_no_abstain_vote_choice/mod.rs | 1 + packages/rs-dpp/src/voting/vote_polls/mod.rs | 1 + packages/rs-dpp/src/voting/votes/mod.rs | 1 + .../src/voting/votes/resource_vote/v0/mod.rs | 1 + packages/rs-drive/src/common/mod.rs | 10 ++- .../v0/mod.rs | 2 +- .../add_new_masternode_vote_type/mod.rs | 61 ------------------- .../add_new_masternode_vote_type/v0/mod.rs | 24 -------- .../rs-drive/src/drive/votes/insert/mod.rs | 1 - .../resolve.rs | 9 ++- .../src/drive/votes/resolved/votes/mod.rs | 1 - .../src/query/vote_poll_vote_state_query.rs | 3 + 18 files changed, 51 insertions(+), 99 deletions(-) delete mode 100644 packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/mod.rs delete mode 100644 packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs diff --git a/packages/rs-dpp/src/data_contract/document_type/class_methods/mod.rs b/packages/rs-dpp/src/data_contract/document_type/class_methods/mod.rs index 4f8220661f..1a38953a78 100644 --- a/packages/rs-dpp/src/data_contract/document_type/class_methods/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/class_methods/mod.rs @@ -1,4 +1,6 @@ +#[cfg(feature = "validation")] use crate::consensus::basic::BasicError; +#[cfg(feature = "validation")] use crate::consensus::ConsensusError; use crate::data_contract::errors::DataContractError; use crate::ProtocolError; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/mod.rs index 3a4e9eed96..e5aad46bd0 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/mod.rs @@ -1,16 +1,26 @@ mod v0; +pub use v0::*; + +#[cfg(feature = "state-transition-signing")] use crate::identity::signer::Signer; +#[cfg(feature = "state-transition-signing")] use crate::identity::IdentityPublicKey; +#[cfg(feature = "state-transition-signing")] use crate::prelude::IdentityNonce; +#[cfg(feature = "state-transition-signing")] use crate::ProtocolError; +#[cfg(feature = "state-transition-signing")] use platform_value::Identifier; +#[cfg(feature = "state-transition-signing")] use platform_version::version::{FeatureVersion, PlatformVersion}; -pub use v0::*; +#[cfg(feature = "state-transition-signing")] use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; use crate::state_transition::masternode_vote_transition::MasternodeVoteTransition; +#[cfg(feature = "state-transition-signing")] use crate::state_transition::StateTransition; +#[cfg(feature = "state-transition-signing")] use crate::voting::votes::Vote; impl MasternodeVoteTransitionMethodsV0 for MasternodeVoteTransition { diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/v0/mod.rs index f4053bb30e..f6fde73f8e 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/methods/v0/mod.rs @@ -1,10 +1,19 @@ +#[cfg(feature = "state-transition-signing")] use crate::identity::signer::Signer; +#[cfg(feature = "state-transition-signing")] use crate::identity::IdentityPublicKey; +#[cfg(feature = "state-transition-signing")] use crate::prelude::IdentityNonce; -use crate::state_transition::{StateTransition, StateTransitionType}; +#[cfg(feature = "state-transition-signing")] +use crate::state_transition::StateTransition; +use crate::state_transition::StateTransitionType; +#[cfg(feature = "state-transition-signing")] use crate::voting::votes::Vote; +#[cfg(feature = "state-transition-signing")] use crate::ProtocolError; +#[cfg(feature = "state-transition-signing")] use platform_value::Identifier; +#[cfg(feature = "state-transition-signing")] use platform_version::version::{FeatureVersion, PlatformVersion}; pub trait MasternodeVoteTransitionMethodsV0 { diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs index ac6c64a019..a1b75dae20 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/mod.rs @@ -23,6 +23,7 @@ use fields::*; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize, PlatformSignable}; use platform_version::version::PlatformVersion; use platform_versioning::PlatformVersioned; +#[cfg(feature = "state-transition-serde-conversion")] use serde::{Deserialize, Serialize}; pub type MasternodeVoteTransitionLatest = MasternodeVoteTransitionV0; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/v0_methods.rs index c9fa350524..ad7fbd60fc 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/masternode_vote_transition/v0/v0_methods.rs @@ -1,11 +1,19 @@ +#[cfg(feature = "state-transition-signing")] use crate::identity::signer::Signer; +#[cfg(feature = "state-transition-signing")] use crate::identity::{IdentityPublicKey, SecurityLevel}; +#[cfg(feature = "state-transition-signing")] use crate::prelude::IdentityNonce; use crate::state_transition::masternode_vote_transition::v0::MasternodeVoteTransitionV0; +#[cfg(feature = "state-transition-signing")] use crate::state_transition::masternode_vote_transition::MasternodeVoteTransition; +#[cfg(feature = "state-transition-signing")] use crate::state_transition::StateTransition; +#[cfg(feature = "state-transition-signing")] use crate::voting::votes::Vote; +#[cfg(feature = "state-transition-signing")] use crate::ProtocolError; +#[cfg(feature = "state-transition-signing")] use platform_value::Identifier; impl MasternodeVoteTransitionV0 { diff --git a/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs b/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs index 2ff2bce069..c7348bd0c3 100644 --- a/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs +++ b/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs @@ -1,5 +1,6 @@ use bincode::{Decode, Encode}; use platform_value::Identifier; +#[cfg(feature = "state-transition-serde-conversion")] use serde::{Deserialize, Serialize}; /// A resource votes is a votes determining what we should do with a contested resource. diff --git a/packages/rs-dpp/src/voting/vote_choices/yes_no_abstain_vote_choice/mod.rs b/packages/rs-dpp/src/voting/vote_choices/yes_no_abstain_vote_choice/mod.rs index 185928fc76..5f4a4cd32e 100644 --- a/packages/rs-dpp/src/voting/vote_choices/yes_no_abstain_vote_choice/mod.rs +++ b/packages/rs-dpp/src/voting/vote_choices/yes_no_abstain_vote_choice/mod.rs @@ -1,4 +1,5 @@ use bincode::{Decode, Encode}; +#[cfg(feature = "state-transition-serde-conversion")] use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, Encode, Decode, PartialEq, Default)] diff --git a/packages/rs-dpp/src/voting/vote_polls/mod.rs b/packages/rs-dpp/src/voting/vote_polls/mod.rs index 576abdbb10..77c8a14f7d 100644 --- a/packages/rs-dpp/src/voting/vote_polls/mod.rs +++ b/packages/rs-dpp/src/voting/vote_polls/mod.rs @@ -4,6 +4,7 @@ use crate::ProtocolError; use derive_more::From; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use platform_value::Identifier; +#[cfg(feature = "state-transition-serde-conversion")] use serde::{Deserialize, Serialize}; pub mod contested_document_resource_vote_poll; diff --git a/packages/rs-dpp/src/voting/votes/mod.rs b/packages/rs-dpp/src/voting/votes/mod.rs index b2c019b858..fd95aaa23b 100644 --- a/packages/rs-dpp/src/voting/votes/mod.rs +++ b/packages/rs-dpp/src/voting/votes/mod.rs @@ -6,6 +6,7 @@ use crate::ProtocolError; use bincode::{Decode, Encode}; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use platform_value::Identifier; +#[cfg(feature = "state-transition-serde-conversion")] use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize, PartialEq)] diff --git a/packages/rs-dpp/src/voting/votes/resource_vote/v0/mod.rs b/packages/rs-dpp/src/voting/votes/resource_vote/v0/mod.rs index 9e05b3044d..dce25bd1d6 100644 --- a/packages/rs-dpp/src/voting/votes/resource_vote/v0/mod.rs +++ b/packages/rs-dpp/src/voting/votes/resource_vote/v0/mod.rs @@ -4,6 +4,7 @@ use crate::ProtocolError; use bincode::{Decode, Encode}; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use platform_value::Identifier; +#[cfg(feature = "state-transition-serde-conversion")] use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Encode, Decode, PlatformDeserialize, PlatformSerialize, PartialEq)] diff --git a/packages/rs-drive/src/common/mod.rs b/packages/rs-drive/src/common/mod.rs index 1e915cddc0..232d1341a6 100644 --- a/packages/rs-drive/src/common/mod.rs +++ b/packages/rs-drive/src/common/mod.rs @@ -19,19 +19,17 @@ use std::io; #[cfg(feature = "server")] use std::io::BufRead; #[cfg(feature = "server")] -use std::option::Option::None; -#[cfg(feature = "server")] use std::path::Path; -#[cfg(feature = "server")] +#[cfg(feature = "fixtures-and-mocks")] use grovedb::TransactionArg; -#[cfg(feature = "server")] +#[cfg(feature = "fixtures-and-mocks")] use crate::drive::Drive; -#[cfg(feature = "server")] +#[cfg(feature = "fixtures-and-mocks")] use dpp::data_contract::DataContract; -#[cfg(feature = "server")] +#[cfg(feature = "fixtures-and-mocks")] use dpp::block::block_info::BlockInfo; #[cfg(feature = "fixtures-and-mocks")] use dpp::prelude::Identifier; diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs index 885d338e3a..90e7a29374 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs @@ -32,7 +32,7 @@ impl Drive { pub(super) fn add_contested_reference_and_vote_subtree_to_document_operations_v0( &self, document_and_contract_info: &DocumentAndContractInfo, - mut index_path_info: PathInfo<0>, + index_path_info: PathInfo<0>, storage_flags: Option<&StorageFlags>, estimated_costs_only_with_layer_info: &mut Option< HashMap, diff --git a/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/mod.rs b/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/mod.rs deleted file mode 100644 index a77c4d994e..0000000000 --- a/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/mod.rs +++ /dev/null @@ -1,61 +0,0 @@ -mod v0; - -use crate::drive::object_size_info::OwnedDocumentInfo; -use crate::drive::Drive; - -use crate::error::drive::DriveError; -use crate::error::Error; - -use dpp::block::block_info::BlockInfo; -use dpp::fee::fee_result::FeeResult; -use dpp::identifier::Identifier; - -use dpp::version::PlatformVersion; -use grovedb::TransactionArg; - -impl Drive { - /// Adds a document using bincode serialization - /// - /// # Parameters - /// * `owned_document_info`: The document info to be added. - /// * `data_contract_id`: The identifier for the data contract. - /// * `document_type_name`: The document type name. - /// * `override_document`: Whether to override the document. - /// * `block_info`: The block info. - /// * `apply`: Whether to apply the operation. - /// * `transaction`: The transaction argument. - /// * `platform_version`: The platform version to select the correct function version to run. - /// - /// # Returns - /// * `Ok(FeeResult)` if the operation was successful. - /// * `Err(DriveError::UnknownVersionMismatch)` if the drive version does not match known versions. - pub fn add_new_masternode_vote_type( - &self, - owned_document_info: OwnedDocumentInfo, - data_contract_id: Identifier, - document_type_name: &str, - override_document: bool, - block_info: &BlockInfo, - apply: bool, - transaction: TransactionArg, - platform_version: &PlatformVersion, - ) -> Result { - match platform_version.drive.methods.document.insert.add_document { - 0 => self.add_new_masternode_vote_type_v0( - owned_document_info, - data_contract_id, - document_type_name, - override_document, - block_info, - apply, - transaction, - platform_version, - ), - version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "add_new_masternode_vote_type".to_string(), - known_versions: vec![0], - received: version, - })), - } - } -} diff --git a/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs deleted file mode 100644 index 0ebdb2d9f1..0000000000 --- a/packages/rs-drive/src/drive/votes/insert/add_new_masternode_vote_type/v0/mod.rs +++ /dev/null @@ -1,24 +0,0 @@ -use crate::drive::object_size_info::OwnedDocumentInfo; -use crate::drive::Drive; -use crate::error::Error; -use dpp::block::block_info::BlockInfo; -use dpp::fee::fee_result::FeeResult; -use dpp::identifier::Identifier; -use grovedb::TransactionArg; -use platform_version::version::PlatformVersion; - -impl Drive { - pub(super) fn add_new_masternode_vote_type_v0( - &self, - owned_document_info: OwnedDocumentInfo, - data_contract_id: Identifier, - document_type_name: &str, - override_document: bool, - block_info: &BlockInfo, - apply: bool, - transaction: TransactionArg, - platform_version: &PlatformVersion, - ) -> Result { - todo!() - } -} diff --git a/packages/rs-drive/src/drive/votes/insert/mod.rs b/packages/rs-drive/src/drive/votes/insert/mod.rs index d044cd2ad2..67ea229fe2 100644 --- a/packages/rs-drive/src/drive/votes/insert/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/mod.rs @@ -1,4 +1,3 @@ -mod add_new_masternode_vote_type; mod contested_resource; mod register_identity_vote; mod vote_poll; diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs index b4016258fd..db992f239e 100644 --- a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs @@ -4,18 +4,21 @@ use crate::drive::object_size_info::DataContractOwnedResolvedInfo; use crate::drive::object_size_info::DataContractResolvedInfo; #[cfg(feature = "server")] use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; -#[cfg(feature = "verify")] +#[cfg(any(feature = "server", feature = "verify"))] use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; use crate::drive::Drive; use crate::error::contract::DataContractError; use crate::error::Error; use dpp::data_contract::accessors::v0::DataContractV0Getters; +#[cfg(feature = "verify")] use dpp::identifier::Identifier; +#[cfg(any(feature = "server", feature = "verify"))] use dpp::prelude::DataContract; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; #[cfg(feature = "server")] use grovedb::TransactionArg; use platform_version::version::PlatformVersion; +#[cfg(feature = "verify")] use std::sync::Arc; /// A trait for resolving information related to a contested document resource vote poll. @@ -77,7 +80,7 @@ pub trait ContestedDocumentResourceVotePollResolver { known_contracts_provider_fn: &impl Fn(&Identifier) -> Result>, Error>, ) -> Result, Error>; - #[cfg(feature = "verify")] + #[cfg(any(feature = "verify", feature = "server"))] /// Resolve by providing the contract fn resolve_with_provided_borrowed_contract<'a>( &self, @@ -194,7 +197,7 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote ) } - #[cfg(feature = "verify")] + #[cfg(any(feature = "verify", feature = "server"))] fn resolve_with_provided_borrowed_contract<'a>( &self, data_contract: &'a DataContract, diff --git a/packages/rs-drive/src/drive/votes/resolved/votes/mod.rs b/packages/rs-drive/src/drive/votes/resolved/votes/mod.rs index fed49e98e2..99a31f50a6 100644 --- a/packages/rs-drive/src/drive/votes/resolved/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolved/votes/mod.rs @@ -7,7 +7,6 @@ use crate::drive::votes::resolved::vote_polls::ResolvedVotePoll; use crate::drive::votes::resolved::votes::resolved_resource_vote::accessors::v0::ResolvedResourceVoteGettersV0; use crate::drive::votes::resolved::votes::resolved_resource_vote::ResolvedResourceVote; use dpp::identifier::Identifier; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::voting::vote_polls::VotePoll; use dpp::voting::votes::resource_vote::v0::ResourceVoteV0; use dpp::voting::votes::resource_vote::ResourceVote; diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index f914366845..f7717d5883 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -23,6 +23,7 @@ use grovedb::query_result_type::{QueryResultElements, QueryResultType}; use grovedb::{Element, TransactionArg}; use grovedb::{PathQuery, Query, SizedQuery}; use platform_version::version::PlatformVersion; +#[cfg(feature = "verify")] use std::sync::Arc; /// Represents the types of results that can be obtained from a contested document vote poll query. @@ -238,6 +239,7 @@ impl ContestedDocumentVotePollDriveQuery { }) } + #[cfg(feature = "verify")] /// Resolves with a known contract provider pub fn resolve_with_known_contracts_provider<'a>( &self, @@ -262,6 +264,7 @@ impl ContestedDocumentVotePollDriveQuery { }) } + #[cfg(any(feature = "verify", feature = "server"))] /// Resolves with a provided borrowed contract pub fn resolve_with_provided_borrowed_contract<'a>( &self, From cd12857c8eb1994ca0fd31e2ddba7ab5f5da807e Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 28 May 2024 15:52:43 +0200 Subject: [PATCH 091/135] more fixes --- packages/check-features/src/main.rs | 18 +++++++++--------- packages/rs-dpp/src/state_transition/mod.rs | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/check-features/src/main.rs b/packages/check-features/src/main.rs index c74fa560c8..cdd6503a4b 100644 --- a/packages/check-features/src/main.rs +++ b/packages/check-features/src/main.rs @@ -4,19 +4,19 @@ use toml::Value; fn main() { let crates = [ - "rs-sdk", - "rs-drive-abci", - "rs-dpp", - "rs-drive", - "rs-drive-proof-verifier", + //("rs-sdk", vec![]), + ("rs-drive-abci", vec![]), + ("rs-dpp", vec!["documents-faker"]), + ("rs-drive", vec![]), + ("rs-drive-proof-verifier", vec![]), ]; - for specific_crate in crates { - check_crate(specific_crate) + for (specific_crate, to_ignore) in crates { + check_crate(specific_crate, to_ignore) } } -fn check_crate(crate_name: &str) { +fn check_crate(crate_name: &str, to_ignore: Vec<&str>) { // Construct the path to the Cargo.toml file for each crate let cargo_toml_path = format!("packages/{}/Cargo.toml", crate_name); @@ -77,7 +77,7 @@ fn check_crate(crate_name: &str) { for (feature, _) in features.as_table().unwrap().iter() { // Skip special feature groups - if feature == "default" || feature.ends_with("features") { + if feature == "default" || feature.ends_with("features") || to_ignore.contains(&feature.as_str()) { continue; } diff --git a/packages/rs-dpp/src/state_transition/mod.rs b/packages/rs-dpp/src/state_transition/mod.rs index 1eb1f4da05..ee3b318932 100644 --- a/packages/rs-dpp/src/state_transition/mod.rs +++ b/packages/rs-dpp/src/state_transition/mod.rs @@ -13,6 +13,7 @@ use bincode::{Decode, Encode}; feature = "state-transition-validation" ))] use dashcore::signer; +#[cfg(feature = "state-transition-validation")] use dashcore::signer::double_sha; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize, PlatformSignable}; use platform_version::version::PlatformVersion; From a19f5997ec2cd564b260ca92fb99d3f669ad31a9 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 28 May 2024 16:11:37 +0200 Subject: [PATCH 092/135] feature fixes --- packages/check-features/src/main.rs | 7 +++++-- .../src/voting/vote_choices/resource_vote_choice/mod.rs | 4 ++-- packages/rs-dpp/src/voting/vote_polls/mod.rs | 4 ++-- packages/rs-dpp/src/voting/votes/mod.rs | 2 +- packages/rs-dpp/src/voting/votes/resource_vote/v0/mod.rs | 4 ++-- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/check-features/src/main.rs b/packages/check-features/src/main.rs index cdd6503a4b..f610b8dce3 100644 --- a/packages/check-features/src/main.rs +++ b/packages/check-features/src/main.rs @@ -4,7 +4,7 @@ use toml::Value; fn main() { let crates = [ - //("rs-sdk", vec![]), + ("rs-sdk", vec![]), ("rs-drive-abci", vec![]), ("rs-dpp", vec!["documents-faker"]), ("rs-drive", vec![]), @@ -77,7 +77,10 @@ fn check_crate(crate_name: &str, to_ignore: Vec<&str>) { for (feature, _) in features.as_table().unwrap().iter() { // Skip special feature groups - if feature == "default" || feature.ends_with("features") || to_ignore.contains(&feature.as_str()) { + if feature == "default" + || feature.ends_with("features") + || to_ignore.contains(&feature.as_str()) + { continue; } diff --git a/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs b/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs index c7348bd0c3..d05e5ca9c5 100644 --- a/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs +++ b/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs @@ -1,6 +1,6 @@ use bincode::{Decode, Encode}; use platform_value::Identifier; -#[cfg(feature = "state-transition-serde-conversion")] +#[cfg(feature = "vote-serde-conversion")] use serde::{Deserialize, Serialize}; /// A resource votes is a votes determining what we should do with a contested resource. @@ -14,7 +14,7 @@ use serde::{Deserialize, Serialize}; /// #[derive(Debug, Clone, Copy, Encode, Decode, PartialEq, Default)] #[cfg_attr( - feature = "state-transition-serde-conversion", + feature = "vote-serde-conversion", derive(Serialize, Deserialize), serde(rename_all = "camelCase") )] diff --git a/packages/rs-dpp/src/voting/vote_polls/mod.rs b/packages/rs-dpp/src/voting/vote_polls/mod.rs index 77c8a14f7d..d05bcb344d 100644 --- a/packages/rs-dpp/src/voting/vote_polls/mod.rs +++ b/packages/rs-dpp/src/voting/vote_polls/mod.rs @@ -4,14 +4,14 @@ use crate::ProtocolError; use derive_more::From; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use platform_value::Identifier; -#[cfg(feature = "state-transition-serde-conversion")] +#[cfg(feature = "vote-serde-conversion")] use serde::{Deserialize, Serialize}; pub mod contested_document_resource_vote_poll; #[derive(Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize, PartialEq, From)] #[cfg_attr( - feature = "state-transition-serde-conversion", + feature = "vote-serde-conversion", derive(Serialize, Deserialize), serde(rename_all = "camelCase") )] diff --git a/packages/rs-dpp/src/voting/votes/mod.rs b/packages/rs-dpp/src/voting/votes/mod.rs index fd95aaa23b..0fb65a204b 100644 --- a/packages/rs-dpp/src/voting/votes/mod.rs +++ b/packages/rs-dpp/src/voting/votes/mod.rs @@ -6,7 +6,7 @@ use crate::ProtocolError; use bincode::{Decode, Encode}; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use platform_value::Identifier; -#[cfg(feature = "state-transition-serde-conversion")] +#[cfg(feature = "vote-serde-conversion")] use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize, PartialEq)] diff --git a/packages/rs-dpp/src/voting/votes/resource_vote/v0/mod.rs b/packages/rs-dpp/src/voting/votes/resource_vote/v0/mod.rs index dce25bd1d6..5a7a0a407f 100644 --- a/packages/rs-dpp/src/voting/votes/resource_vote/v0/mod.rs +++ b/packages/rs-dpp/src/voting/votes/resource_vote/v0/mod.rs @@ -4,12 +4,12 @@ use crate::ProtocolError; use bincode::{Decode, Encode}; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use platform_value::Identifier; -#[cfg(feature = "state-transition-serde-conversion")] +#[cfg(feature = "vote-serde-conversion")] use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Encode, Decode, PlatformDeserialize, PlatformSerialize, PartialEq)] #[cfg_attr( - feature = "state-transition-serde-conversion", + feature = "vote-serde-conversion", derive(Serialize, Deserialize), serde(rename_all = "camelCase") )] From cfd29588b8a599aa42000213ab1ff0f32eeb1e32 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 29 May 2024 01:10:17 +0200 Subject: [PATCH 093/135] more fixes --- .../state_transitions/masternode_vote/mod.rs | 93 +++++++++++++++---- 1 file changed, 77 insertions(+), 16 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 91cb5f592e..68c2af3a93 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -125,6 +125,7 @@ mod tests { use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; use dpp::state_transition::masternode_vote_transition::methods::MasternodeVoteTransitionMethodsV0; use dpp::util::hash::hash_double; + use dpp::util::strings::convert_to_homograph_safe_chars; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice::TowardsIdentity; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::voting::vote_polls::VotePoll; @@ -184,6 +185,7 @@ mod tests { platform: &mut TempPlatform, platform_state: &Guard>, seed: u64, + name: &str, platform_version: &PlatformVersion, ) -> (Identity, Identity, Arc) { let mut rng = StdRng::seed_from_u64(seed); @@ -269,15 +271,21 @@ mod tests { document_1.set("parentDomainName", "dash".into()); document_1.set("normalizedParentDomainName", "dash".into()); - document_1.set("label", "quantum".into()); - document_1.set("normalizedLabel", "quantum".into()); + document_1.set("label", name.into()); + document_1.set( + "normalizedLabel", + convert_to_homograph_safe_chars(name).into(), + ); document_1.set("records.dashUniqueIdentityId", document_1.owner_id().into()); document_1.set("subdomainRules.allowSubdomains", false.into()); document_2.set("parentDomainName", "dash".into()); document_2.set("normalizedParentDomainName", "dash".into()); - document_2.set("label", "quantum".into()); - document_2.set("normalizedLabel", "quantum".into()); + document_2.set("label", name.into()); + document_2.set( + "normalizedLabel", + convert_to_homograph_safe_chars(name).into(), + ); document_2.set("records.dashUniqueIdentityId", document_2.owner_id().into()); document_2.set("subdomainRules.allowSubdomains", false.into()); @@ -286,13 +294,15 @@ mod tests { let mut salted_domain_buffer_1: Vec = vec![]; salted_domain_buffer_1.extend(salt_1); - salted_domain_buffer_1.extend("quantum.dash".as_bytes()); + salted_domain_buffer_1 + .extend((convert_to_homograph_safe_chars(name) + ".dash").as_bytes()); let salted_domain_hash_1 = hash_double(salted_domain_buffer_1); let mut salted_domain_buffer_2: Vec = vec![]; salted_domain_buffer_2.extend(salt_2); - salted_domain_buffer_2.extend("quantum.dash".as_bytes()); + salted_domain_buffer_2 + .extend((convert_to_homograph_safe_chars(name) + ".dash").as_bytes()); let salted_domain_hash_2 = hash_double(salted_domain_buffer_2); @@ -435,9 +445,24 @@ mod tests { .expect("expected to commit transaction"); assert_eq!(processing_result.valid_count(), 2); + (identity_1, identity_2, dpns_contract) + } + fn verify_dpns_name_contest( + platform: &mut TempPlatform, + platform_state: &Guard>, + dpns_contract: &DataContract, + identity_1: &Identity, + identity_2: &Identity, + name: &str, + platform_version: &PlatformVersion, + ) { // Now let's run a query for the vote totals + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); + let config = bincode::config::standard() .with_big_endian() .with_no_limit(); @@ -446,7 +471,7 @@ mod tests { .expect("expected to encode the word dash"); let quantum_encoded = - bincode::encode_to_vec(Value::Text("quantum".to_string()), config) + bincode::encode_to_vec(Value::Text(convert_to_homograph_safe_chars(name)), config) .expect("expected to encode the word quantum"); let index_name = "parentNameAndLabel".to_string(); @@ -570,12 +595,12 @@ mod tests { let resolved_contested_document_vote_poll_drive_query = ResolvedContestedDocumentVotePollDriveQuery { vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { - contract: DataContractResolvedInfo::BorrowedDataContract(&dpns_contract), + contract: DataContractResolvedInfo::BorrowedDataContract(dpns_contract), document_type_name: domain.name().clone(), index_name: index_name.clone(), index_values: vec![ Value::Text("dash".to_string()), - Value::Text("quantum".to_string()), + Value::Text(convert_to_homograph_safe_chars(name)), ], }, result_type: DocumentsAndVoteTally, @@ -626,8 +651,6 @@ mod tests { assert_eq!(first_contender.vote_tally, Some(0)); assert_eq!(second_contender.vote_tally, Some(0)); - - (identity_1, identity_2, dpns_contract) } #[test] @@ -639,8 +662,41 @@ mod tests { let platform_state = platform.state.load(); - let (contender_1, contender_2, dpns_contract) = - create_dpns_name_contest(&mut platform, &platform_state, 7, platform_version); + let (identity_1, identity_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + verify_dpns_name_contest( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + &identity_1, + &identity_2, + "quantum", + platform_version, + ); + + let (identity_3, identity_4, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 8, + "cooldog", + platform_version, + ); + + verify_dpns_name_contest( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + &identity_3, + &identity_4, + "cooldog", + platform_version, + ); let domain = dpns_contract .document_type_for_name("domain") @@ -693,7 +749,7 @@ mod tests { panic!("expected contested resources") }; - assert_eq!(contested_resource_values.len(), 1); + assert_eq!(contested_resource_values.len(), 2); } #[test] @@ -705,8 +761,13 @@ mod tests { let platform_state = platform.state.load(); - let (contender_1, contender_2, dpns_contract) = - create_dpns_name_contest(&mut platform, &platform_state, 7, platform_version); + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); let (masternode_1, signer_1, voting_key_1) = setup_masternode_identity(&mut platform, 29, platform_version); From 170706aa0c37c40160ba5807292401e7732a91e4 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 29 May 2024 01:41:46 +0200 Subject: [PATCH 094/135] another verification --- .../state_transitions/masternode_vote/mod.rs | 56 +++++++++++- .../rs-drive/src/drive/verify/voting/mod.rs | 1 + .../voting/verify_contests_proof/mod.rs | 54 ++++++++++++ .../voting/verify_contests_proof/v0/mod.rs | 88 +++++++++++++++++++ .../vote_polls_by_document_type_query.rs | 24 +++-- .../src/version/drive_versions.rs | 1 + .../src/version/mocks/v2_test.rs | 1 + .../src/version/mocks/v3_test.rs | 1 + .../rs-platform-version/src/version/v1.rs | 1 + 9 files changed, 217 insertions(+), 10 deletions(-) create mode 100644 packages/rs-drive/src/drive/verify/voting/verify_contests_proof/mod.rs create mode 100644 packages/rs-drive/src/drive/verify/voting/verify_contests_proof/v0/mod.rs diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 68c2af3a93..978cc70193 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -136,6 +136,7 @@ mod tests { use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; use drive::query::vote_poll_vote_state_query::ResolvedContestedDocumentVotePollDriveQuery; + use drive::query::vote_polls_by_document_type_query::ResolvedVotePollsByDocumentTypeQuery; use simple_signer::signer::SimpleSigner; use crate::platform_types::platform_state::PlatformState; use crate::rpc::core::MockCoreRPCLike; @@ -719,7 +720,7 @@ mod tests { contract_id: dpns_contract.id().to_vec(), document_type_name: domain.name().clone(), index_name: index_name.clone(), - start_index_values: vec![dash_encoded], + start_index_values: vec![dash_encoded.clone()], end_index_values: vec![], start_at_value_info: None, count: None, @@ -750,6 +751,59 @@ mod tests { }; assert_eq!(contested_resource_values.len(), 2); + + let query_validation_result = platform + .query_contested_resources( + GetContestedResourcesRequest { + version: Some(get_contested_resources_request::Version::V0( + GetContestedResourcesRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + start_index_values: vec![dash_encoded], + end_index_values: vec![], + start_at_value_info: None, + count: None, + order_ascending: true, + prove: true, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resources_response::Version::V0(GetContestedResourcesResponseV0 { + metadata: _, + result, + }) = query_validation_result.version.expect("expected a version"); + + let Some(get_contested_resources_response_v0::Result::Proof(proof)) = result else { + panic!("expected proof") + }; + + let resolved_contested_document_vote_poll_drive_query = + ResolvedVotePollsByDocumentTypeQuery { + contract: DataContractResolvedInfo::BorrowedDataContract( + dpns_contract.as_ref(), + ), + document_type_name: domain.name(), + index_name: &index_name, + start_index_values: &vec!["dash".into()], + end_index_values: &vec![], + limit: None, + order_ascending: true, + start_at_value: &None, + }; + + let (_, contests) = resolved_contested_document_vote_poll_drive_query + .verify_contests_proof(proof.grovedb_proof.as_ref(), platform_version) + .expect("expected to verify proof"); + + assert_eq!(contests.len(), 2); } #[test] diff --git a/packages/rs-drive/src/drive/verify/voting/mod.rs b/packages/rs-drive/src/drive/verify/voting/mod.rs index ea312a70e7..8cc34ac085 100644 --- a/packages/rs-drive/src/drive/verify/voting/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/mod.rs @@ -1,3 +1,4 @@ +mod verify_contests_proof; mod verify_masternode_vote; mod verify_vote_poll_vote_state_proof; // mod verify_start_at_contender_in_proof; diff --git a/packages/rs-drive/src/drive/verify/voting/verify_contests_proof/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_contests_proof/mod.rs new file mode 100644 index 0000000000..6bd83475e1 --- /dev/null +++ b/packages/rs-drive/src/drive/verify/voting/verify_contests_proof/mod.rs @@ -0,0 +1,54 @@ +mod v0; + +use crate::drive::verify::RootHash; +use crate::error::drive::DriveError; +use dpp::platform_value::Value; + +use crate::error::Error; + +use crate::query::vote_polls_by_document_type_query::ResolvedVotePollsByDocumentTypeQuery; +use dpp::version::PlatformVersion; + +impl<'a> ResolvedVotePollsByDocumentTypeQuery<'a> { + /// Verifies a proof for the vote poll vote state proof. + /// + /// This function takes a byte slice representing the serialized proof, verifies it, and returns a tuple consisting of the root hash + /// and a vector of deserialized contenders. + /// + /// # Arguments + /// + /// * `proof` - A byte slice representing the proof to be verified. + /// * `platform_version` - The platform version against which to verify the proof. + /// + /// # Returns + /// + /// A `Result` containing: + /// * A tuple with the root hash and a vector of deserialized `Document`s if the proof is valid. + /// * An `Error` variant, in case the proof verification fails or a deserialization error occurs. + /// + /// # Errors + /// + /// This function will return an `Error` variant if: + /// 1. The proof verification fails. + /// 2. A deserialization error occurs when parsing the serialized document(s). + pub fn verify_contests_proof( + &self, + proof: &[u8], + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Vec), Error> { + match platform_version + .drive + .methods + .verify + .voting + .verify_contests_proof + { + 0 => self.verify_contests_proof_v0(proof, platform_version), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "verify_contests_proof".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/verify/voting/verify_contests_proof/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_contests_proof/v0/mod.rs new file mode 100644 index 0000000000..0776e7a956 --- /dev/null +++ b/packages/rs-drive/src/drive/verify/voting/verify_contests_proof/v0/mod.rs @@ -0,0 +1,88 @@ +use crate::drive::verify::RootHash; +use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; +use dpp::platform_value::Value; +use grovedb::GroveDb; + +use crate::error::Error; + +use crate::error::drive::DriveError; +use crate::query::vote_polls_by_document_type_query::ResolvedVotePollsByDocumentTypeQuery; +use dpp::version::PlatformVersion; + +impl<'a> ResolvedVotePollsByDocumentTypeQuery<'a> { + /// Verifies a proof for a collection of documents. + /// + /// This function takes a slice of bytes `proof` containing a serialized proof, + /// verifies it, and returns a tuple consisting of the root hash and a vector of deserialized documents. + /// + /// # Arguments + /// + /// * `proof` - A byte slice representing the proof to be verified. + /// * `drive_version` - The current active drive version + /// + /// # Returns + /// + /// A `Result` containing: + /// * A tuple with the root hash and a vector of deserialized `Document`s, if the proof is valid. + /// * An `Error` variant, in case the proof verification fails or deserialization error occurs. + /// + /// # Errors + /// + /// This function will return an `Error` variant if: + /// 1. The proof verification fails. + /// 2. There is a deserialization error when parsing the serialized document(s) into `Document` struct(s). + #[inline(always)] + pub(super) fn verify_contests_proof_v0( + &self, + proof: &[u8], + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Vec), Error> { + let index = self.index()?; + let path_query = self.construct_path_query_with_known_index(index, platform_version)?; + let (root_hash, proved_key_values) = GroveDb::verify_query(proof, &path_query)?; + + let result_is_in_key = self.result_is_in_key(); + let result_path_index = if result_is_in_key { + None + } else { + Some(self.result_path_index()) + }; + let document_type = self.document_type()?; + let property_name_being_searched = self.property_name_being_searched(index)?; + let values = proved_key_values + .into_iter() + .map(|(mut path, key, _)| { + if result_is_in_key { + // the result is in the key because we did not provide any end index values + // like this <------ start index values (path) ---> Key + // properties ------- --------- --------- ---------- ------- + document_type + .deserialize_value_for_key( + property_name_being_searched.name.as_str(), + key.as_slice(), + platform_version, + ) + .map_err(Error::Protocol) + } else if path.len() < result_path_index.unwrap() { + Err(Error::Drive(DriveError::CorruptedCodeExecution( + "the path length should always be bigger or equal to the result path index", + ))) + } else { + // the result is in the path because we did not provide any end index values + // like this <------ start index values (path) ---> Key + // properties ------- --------- --------- ---------- ------- + let inner_path_value_bytes = path.remove(result_path_index.unwrap()); + document_type + .deserialize_value_for_key( + property_name_being_searched.name.as_str(), + inner_path_value_bytes.as_slice(), + platform_version, + ) + .map_err(Error::Protocol) + } + }) + .collect::, Error>>()?; + + Ok((root_hash, values)) + } +} diff --git a/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs b/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs index c3eb31a0bc..c88c736b74 100644 --- a/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs +++ b/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs @@ -249,13 +249,13 @@ impl VotePollsByDocumentTypeQuery { } impl<'a> ResolvedVotePollsByDocumentTypeQuery<'a> { - fn document_type(&self) -> Result { + pub(crate) fn document_type(&self) -> Result { Ok(self .contract .as_ref() .document_type_for_name(self.document_type_name.as_str())?) } - fn index(&self) -> Result<&Index, Error> { + pub(crate) fn index(&self) -> Result<&Index, Error> { let index = self .contract .as_ref() @@ -318,7 +318,10 @@ impl<'a> ResolvedVotePollsByDocumentTypeQuery<'a> { Ok((start_values_vec, end_values_vec)) } - fn property_name_being_searched(&self, index: &'a Index) -> Result<&'a IndexProperty, Error> { + pub(crate) fn property_name_being_searched( + &self, + index: &'a Index, + ) -> Result<&'a IndexProperty, Error> { let offset = self.start_index_values.len(); index .properties @@ -330,12 +333,12 @@ impl<'a> ResolvedVotePollsByDocumentTypeQuery<'a> { )))) } - fn result_is_in_key(&self) -> bool { + pub(crate) fn result_is_in_key(&self) -> bool { // this means that the keys are the values that we are interested in self.end_index_values.is_empty() } - fn result_path_index(&self) -> usize { + pub(crate) fn result_path_index(&self) -> usize { // 5 because of: // voting sub tree (112) // contested ('c') @@ -346,13 +349,16 @@ impl<'a> ResolvedVotePollsByDocumentTypeQuery<'a> { } /// Operations to construct a path query. - fn construct_path_query(&self, platform_version: &PlatformVersion) -> Result { + pub(crate) fn construct_path_query( + &self, + platform_version: &PlatformVersion, + ) -> Result { let index = self.index()?; - self.construct_path_query_internal(index, platform_version) + self.construct_path_query_with_known_index(index, platform_version) } /// Operations to construct a path query. - fn construct_path_query_internal( + pub(crate) fn construct_path_query_with_known_index( &self, index: &Index, platform_version: &PlatformVersion, @@ -433,7 +439,7 @@ impl<'a> ResolvedVotePollsByDocumentTypeQuery<'a> { platform_version: &PlatformVersion, ) -> Result, Error> { let index = self.index()?; - let path_query = self.construct_path_query_internal(index, platform_version)?; + let path_query = self.construct_path_query_with_known_index(index, platform_version)?; let query_result = drive.grove_get_raw_path_query( &path_query, transaction, diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 140742002c..763147b536 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -114,6 +114,7 @@ pub struct DriveVerifyVoteMethodVersions { pub verify_masternode_vote: FeatureVersion, pub verify_start_at_contender_in_proof: FeatureVersion, pub verify_vote_poll_vote_state_proof: FeatureVersion, + pub verify_contests_proof: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 5285c5dec1..3a23c5515a 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -315,6 +315,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { verify_masternode_vote: 0, verify_start_at_contender_in_proof: 0, verify_vote_poll_vote_state_proof: 0, + verify_contests_proof: 0, }, state_transition: DriveVerifyStateTransitionMethodVersions { verify_state_transition_was_executed_with_proof: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 45274e3e5c..db625d0b31 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -323,6 +323,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { verify_masternode_vote: 0, verify_start_at_contender_in_proof: 0, verify_vote_poll_vote_state_proof: 0, + verify_contests_proof: 0, }, state_transition: DriveVerifyStateTransitionMethodVersions { verify_state_transition_was_executed_with_proof: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 96c26f96d2..a84e57f982 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -314,6 +314,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { verify_masternode_vote: 0, verify_start_at_contender_in_proof: 0, verify_vote_poll_vote_state_proof: 0, + verify_contests_proof: 0, }, state_transition: DriveVerifyStateTransitionMethodVersions { verify_state_transition_was_executed_with_proof: 0, From 96e9230dcb0a8d6b8f6f00bf1d81d3fb23d8f13c Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 29 May 2024 10:30:04 +0200 Subject: [PATCH 095/135] more work --- .../state_transitions/masternode_vote/mod.rs | 146 +++++++++++------- 1 file changed, 91 insertions(+), 55 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 978cc70193..6bcb01299d 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -92,7 +92,7 @@ mod tests { use dpp::data_contract::document_type::random_document::{ CreateRandomDocument, DocumentFieldFillSize, DocumentFieldFillType, }; - use dpp::document::{DocumentV0Getters, DocumentV0Setters}; + use dpp::document::{Document, DocumentV0Getters, DocumentV0Setters}; use dpp::identity::accessors::IdentityGettersV0; use dpp::platform_value::{Bytes32, Value}; use dpp::serialization::PlatformSerializable; @@ -101,6 +101,24 @@ mod tests { use platform_version::version::PlatformVersion; use rand::prelude::StdRng; use rand::SeedableRng; + use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, get_contested_vote_polls_by_end_date_request, get_contested_vote_polls_by_end_date_response, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetContestedVotePollsByEndDateRequest, GetContestedVotePollsByEndDateResponse}; + use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0::ResultType; + use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::GetContestedResourceVoteStateRequestV0; + use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; + use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_request::GetContestedVotePollsByEndDateRequestV0; + use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_response::{get_contested_vote_polls_by_end_date_response_v0, GetContestedVotePollsByEndDateResponseV0}; + use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_response::get_contested_vote_polls_by_end_date_response_v0::SerializedContestedVotePollsByTimestamp; + use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; + use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice::TowardsIdentity; + use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; + use dpp::voting::vote_polls::VotePoll; + use dpp::voting::votes::resource_vote::ResourceVote; + use dpp::voting::votes::resource_vote::v0::ResourceVoteV0; + use dpp::voting::votes::Vote; + use drive::drive::object_size_info::DataContractResolvedInfo; + use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; + use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; + use drive::query::vote_poll_vote_state_query::ResolvedContestedDocumentVotePollDriveQuery; mod vote_tests { use std::collections::BTreeMap; @@ -807,7 +825,7 @@ mod tests { } #[test] - fn test_masternode_voting() { + fn test_masternode_voting_and_vote_state_request() { let platform_version = PlatformVersion::latest(); let mut platform = TestPlatformBuilder::new() .build_with_mock_rpc() @@ -1074,62 +1092,80 @@ mod tests { assert_eq!(first_contender.vote_tally, Some(1)); assert_eq!(second_contender.vote_tally, Some(0)); + } - let GetContestedVotePollsByEndDateResponse { version } = platform - .query_contested_vote_polls_by_end_date_query( - GetContestedVotePollsByEndDateRequest { - version: Some(get_contested_vote_polls_by_end_date_request::Version::V0( - GetContestedVotePollsByEndDateRequestV0 { - start_time_info: None, - end_time_info: None, - limit: None, - offset: None, - ascending: false, - prove: false, - }, - )), - }, - &platform_state, - platform_version, - ) - .expect("expected to execute query") - .into_data() - .expect("expected query to be valid"); - - let get_contested_vote_polls_by_end_date_response::Version::V0( - GetContestedVotePollsByEndDateResponseV0 { - metadata: _, - result, + #[test] + fn test_end_date_query_request() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = crate::execution::validation::state_transition::state_transitions::masternode_vote::tests::vote_tests::create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + let GetContestedVotePollsByEndDateResponse { version } = platform + .query_contested_vote_polls_by_end_date_query( + GetContestedVotePollsByEndDateRequest { + version: Some(get_contested_vote_polls_by_end_date_request::Version::V0( + GetContestedVotePollsByEndDateRequestV0 { + start_time_info: None, + end_time_info: None, + limit: None, + offset: None, + ascending: false, + prove: false, + }, + )), }, - ) = version.expect("expected a version"); + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); - let Some( - get_contested_vote_polls_by_end_date_response_v0::Result::ContestedVotePollsByTimestamps( - get_contested_vote_polls_by_end_date_response_v0::SerializedContestedVotePollsByTimestamps { - contested_vote_polls_by_timestamps, finished_results - }, - ), - ) = result - else { - panic!("expected contenders") - }; + let get_contested_vote_polls_by_end_date_response::Version::V0( + GetContestedVotePollsByEndDateResponseV0 { + metadata: _, + result, + }, + ) = version.expect("expected a version"); - assert!(finished_results); - - // The timestamp is 0 because there were no blocks - assert_eq!( - contested_vote_polls_by_timestamps, - vec![SerializedContestedVotePollsByTimestamp { - timestamp: 1_209_600_000, // in ms, 2 weeks after Jan 1 1970 - serialized_contested_vote_polls: vec![vec![ - 0, 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, 6, - 100, 111, 109, 97, 105, 110, 18, 112, 97, 114, 101, 110, 116, 78, 97, 109, - 101, 65, 110, 100, 76, 97, 98, 101, 108, 2, 18, 4, 100, 97, 115, 104, 18, - 7, 113, 117, 97, 110, 116, 117, 109 - ]] - }] - ); - } + let Some( + get_contested_vote_polls_by_end_date_response_v0::Result::ContestedVotePollsByTimestamps( + get_contested_vote_polls_by_end_date_response_v0::SerializedContestedVotePollsByTimestamps { + contested_vote_polls_by_timestamps, finished_results + }, + ), + ) = result + else { + panic!("expected contenders") + }; + + assert!(finished_results); + + // The timestamp is 0 because there were no blocks + assert_eq!( + contested_vote_polls_by_timestamps, + vec![SerializedContestedVotePollsByTimestamp { + timestamp: 1_209_600_000, // in ms, 2 weeks after Jan 1 1970 + serialized_contested_vote_polls: vec![vec![ + 0, 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, 6, + 100, 111, 109, 97, 105, 110, 18, 112, 97, 114, 101, 110, 116, 78, 97, 109, + 101, 65, 110, 100, 76, 97, 98, 101, 108, 2, 18, 4, 100, 97, 115, 104, 18, + 7, 113, 117, 97, 110, 116, 117, 109 + ]] + }] + ); } } +} From c70799329fbeffe3fe4eed11ea85ed74e14f4786 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 29 May 2024 13:20:45 +0200 Subject: [PATCH 096/135] more fixes --- packages/dapi-grpc/build.rs | 4 +- .../protos/platform/v0/platform.proto | 24 +- .../state_transitions/masternode_vote/mod.rs | 277 +++++++++++++----- packages/rs-drive-abci/src/query/service.rs | 41 ++- .../rs-drive-abci/src/query/voting/mod.rs | 2 +- .../mod.rs | 28 +- .../v0/mod.rs | 42 ++- .../rs-drive/src/drive/verify/voting/mod.rs | 1 + .../verify_vote_polls_end_date_query/mod.rs | 58 ++++ .../v0/mod.rs | 77 +++++ .../src/version/drive_abci_versions.rs | 2 +- .../src/version/drive_versions.rs | 1 + .../src/version/mocks/v2_test.rs | 3 +- .../src/version/mocks/v3_test.rs | 3 +- .../rs-platform-version/src/version/v1.rs | 3 +- 15 files changed, 411 insertions(+), 155 deletions(-) rename packages/rs-drive-abci/src/query/voting/{contested_vote_polls_by_end_date_query => vote_polls_by_end_date_query}/mod.rs (63%) rename packages/rs-drive-abci/src/query/voting/{contested_vote_polls_by_end_date_query => vote_polls_by_end_date_query}/v0/mod.rs (76%) create mode 100644 packages/rs-drive/src/drive/verify/voting/verify_vote_polls_end_date_query/mod.rs create mode 100644 packages/rs-drive/src/drive/verify/voting/verify_vote_polls_end_date_query/v0/mod.rs diff --git a/packages/dapi-grpc/build.rs b/packages/dapi-grpc/build.rs index 6f32c5fb79..11c43f2863 100644 --- a/packages/dapi-grpc/build.rs +++ b/packages/dapi-grpc/build.rs @@ -71,7 +71,7 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig { "GetContestedResourceVoteStateRequest", "GetContestedResourceVotersForIdentityRequest", "GetContestedResourceIdentityVoteStatusRequest", - "GetContestedVotePollsByEndDateRequest", + "GetVotePollsByEndDateRequest", ]; // "GetConsensusParamsResponse" is excluded as this message does not support proofs @@ -101,7 +101,7 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig { "GetContestedResourceVoteStateResponse", "GetContestedResourceVotersForIdentityResponse", "GetContestedResourceIdentityVoteStatusResponse", - "GetContestedVotePollsByEndDateResponse", + "GetVotePollsByEndDateResponse", ]; // Derive VersionedGrpcMessage on requests diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index dcb66be31c..73a59f1a4a 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -43,7 +43,7 @@ service Platform { // How did an identity vote? rpc getContestedResourceIdentityVoteStatus(GetContestedResourceIdentityVoteStatusRequest) returns (GetContestedResourceIdentityVoteStatusResponse); // What vote polls will end soon? - rpc getContestedVotePollsByEndDate(GetContestedVotePollsByEndDateRequest) returns (GetContestedVotePollsByEndDateResponse); + rpc getVotePollsByEndDate(GetVotePollsByEndDateRequest) returns (GetVotePollsByEndDateResponse); rpc getPrefundedSpecializedBalance(GetPrefundedSpecializedBalanceRequest) returns (GetPrefundedSpecializedBalanceResponse); rpc getPathElements(GetPathElementsRequest) returns (GetPathElementsResponse); } @@ -678,8 +678,8 @@ message GetContestedResourcesResponse { } } -message GetContestedVotePollsByEndDateRequest { - message GetContestedVotePollsByEndDateRequestV0 { +message GetVotePollsByEndDateRequest { + message GetVotePollsByEndDateRequestV0 { message StartAtTimeInfo { uint64 start_time_ms = 1; bool start_time_included = 2; @@ -697,31 +697,31 @@ message GetContestedVotePollsByEndDateRequest { } oneof version { - GetContestedVotePollsByEndDateRequestV0 v0 = 1; + GetVotePollsByEndDateRequestV0 v0 = 1; } } -message GetContestedVotePollsByEndDateResponse { - message GetContestedVotePollsByEndDateResponseV0 { - message SerializedContestedVotePollsByTimestamp { +message GetVotePollsByEndDateResponse { + message GetVotePollsByEndDateResponseV0 { + message SerializedVotePollsByTimestamp { uint64 timestamp = 1; - repeated bytes serialized_contested_vote_polls = 2; + repeated bytes serialized_vote_polls = 2; } - message SerializedContestedVotePollsByTimestamps { - repeated SerializedContestedVotePollsByTimestamp contested_vote_polls_by_timestamps = 1; + message SerializedVotePollsByTimestamps { + repeated SerializedVotePollsByTimestamp vote_polls_by_timestamps = 1; bool finished_results = 2; } oneof result { - SerializedContestedVotePollsByTimestamps contested_vote_polls_by_timestamps = 1; + SerializedVotePollsByTimestamps vote_polls_by_timestamps = 1; Proof proof = 2; } ResponseMetadata metadata = 3; } oneof version { - GetContestedVotePollsByEndDateResponseV0 v0 = 1; + GetVotePollsByEndDateResponseV0 v0 = 1; } } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 6bcb01299d..828ba5f1ca 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -101,13 +101,13 @@ mod tests { use platform_version::version::PlatformVersion; use rand::prelude::StdRng; use rand::SeedableRng; - use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, get_contested_vote_polls_by_end_date_request, get_contested_vote_polls_by_end_date_response, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetContestedVotePollsByEndDateRequest, GetContestedVotePollsByEndDateResponse}; + use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, get_vote_polls_by_end_date_request, get_vote_polls_by_end_date_response, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetVotePollsByEndDateRequest, GetVotePollsByEndDateResponse}; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0::ResultType; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::GetContestedResourceVoteStateRequestV0; use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; - use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_request::GetContestedVotePollsByEndDateRequestV0; - use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_response::{get_contested_vote_polls_by_end_date_response_v0, GetContestedVotePollsByEndDateResponseV0}; - use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_response::get_contested_vote_polls_by_end_date_response_v0::SerializedContestedVotePollsByTimestamp; + use dapi_grpc::platform::v0::get_vote_polls_by_end_date_request::GetVotePollsByEndDateRequestV0; + use dapi_grpc::platform::v0::get_vote_polls_by_end_date_response::{get_vote_polls_by_end_date_response_v0, GetVotePollsByEndDateResponseV0}; + use dapi_grpc::platform::v0::get_vote_polls_by_end_date_response::get_vote_polls_by_end_date_response_v0::SerializedVotePollsByTimestamp; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice::TowardsIdentity; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; @@ -125,15 +125,15 @@ mod tests { use std::sync::Arc; use arc_swap::Guard; use rand::Rng; - use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, get_contested_resources_request, get_contested_resources_response, get_contested_vote_polls_by_end_date_request, get_contested_vote_polls_by_end_date_response, GetContestedResourcesRequest, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetContestedVotePollsByEndDateRequest, GetContestedVotePollsByEndDateResponse}; + use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, get_contested_resources_request, get_contested_resources_response, get_vote_polls_by_end_date_request, get_vote_polls_by_end_date_response, GetContestedResourcesRequest, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetVotePollsByEndDateRequest, GetVotePollsByEndDateResponse}; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0::ResultType; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::GetContestedResourceVoteStateRequestV0; use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; use dapi_grpc::platform::v0::get_contested_resources_request::GetContestedResourcesRequestV0; use dapi_grpc::platform::v0::get_contested_resources_response::{get_contested_resources_response_v0, GetContestedResourcesResponseV0}; - use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_request::GetContestedVotePollsByEndDateRequestV0; - use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_response::{get_contested_vote_polls_by_end_date_response_v0, GetContestedVotePollsByEndDateResponseV0}; - use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_response::get_contested_vote_polls_by_end_date_response_v0::SerializedContestedVotePollsByTimestamp; + use dapi_grpc::platform::v0::get_vote_polls_by_end_date_request::GetVotePollsByEndDateRequestV0; + use dapi_grpc::platform::v0::get_vote_polls_by_end_date_response::{get_vote_polls_by_end_date_response_v0, GetVotePollsByEndDateResponseV0}; + use dapi_grpc::platform::v0::get_vote_polls_by_end_date_response::get_vote_polls_by_end_date_response_v0::SerializedVotePollsByTimestamp; use super::*; use dpp::document::Document; use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; @@ -159,6 +159,8 @@ mod tests { use crate::platform_types::platform_state::PlatformState; use crate::rpc::core::MockCoreRPCLike; use crate::test::helpers::setup::TempPlatform; + use dpp::serialization::PlatformDeserializable; + use drive::query::VotePollsByEndDateDriveQuery; fn setup_masternode_identity( platform: &mut TempPlatform, @@ -1094,78 +1096,199 @@ mod tests { assert_eq!(second_contender.vote_tally, Some(0)); } - #[test] - fn test_end_date_query_request() { - let platform_version = PlatformVersion::latest(); - let mut platform = TestPlatformBuilder::new() - .build_with_mock_rpc() - .set_genesis_state(); - - let platform_state = platform.state.load(); - - let (contender_1, contender_2, dpns_contract) = crate::execution::validation::state_transition::state_transitions::masternode_vote::tests::vote_tests::create_dpns_name_contest( - &mut platform, - &platform_state, - 7, - "quantum", - platform_version, - ); - - let GetContestedVotePollsByEndDateResponse { version } = platform - .query_contested_vote_polls_by_end_date_query( - GetContestedVotePollsByEndDateRequest { - version: Some(get_contested_vote_polls_by_end_date_request::Version::V0( - GetContestedVotePollsByEndDateRequestV0 { - start_time_info: None, - end_time_info: None, - limit: None, - offset: None, - ascending: false, - prove: false, + mod end_date_query { + use super::*; + use dpp::platform_value::IdentifierBytes32; + use dpp::platform_value::Value::Text; + + #[test] + fn test_not_proved_end_date_query_request() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + let GetVotePollsByEndDateResponse { version } = platform + .query_vote_polls_by_end_date_query( + GetVotePollsByEndDateRequest { + version: Some(get_vote_polls_by_end_date_request::Version::V0( + GetVotePollsByEndDateRequestV0 { + start_time_info: None, + end_time_info: None, + limit: None, + offset: None, + ascending: false, + prove: false, + }, + )), }, - )), - }, - &platform_state, - platform_version, - ) - .expect("expected to execute query") - .into_data() - .expect("expected query to be valid"); + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_vote_polls_by_end_date_response::Version::V0( + GetVotePollsByEndDateResponseV0 { + metadata: _, + result, + }, + ) = version.expect("expected a version"); - let get_contested_vote_polls_by_end_date_response::Version::V0( - GetContestedVotePollsByEndDateResponseV0 { - metadata: _, - result, - }, - ) = version.expect("expected a version"); + let Some(get_vote_polls_by_end_date_response_v0::Result::VotePollsByTimestamps( + get_vote_polls_by_end_date_response_v0::SerializedVotePollsByTimestamps { + vote_polls_by_timestamps, + finished_results, + }, + )) = result + else { + panic!("expected contenders") + }; - let Some( - get_contested_vote_polls_by_end_date_response_v0::Result::ContestedVotePollsByTimestamps( - get_contested_vote_polls_by_end_date_response_v0::SerializedContestedVotePollsByTimestamps { - contested_vote_polls_by_timestamps, finished_results - }, - ), - ) = result - else { - panic!("expected contenders") - }; + assert!(finished_results); + + let serialized_contested_vote_poll_bytes = vec![ + 0, 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, 6, 100, + 111, 109, 97, 105, 110, 18, 112, 97, 114, 101, 110, 116, 78, 97, 109, 101, 65, + 110, 100, 76, 97, 98, 101, 108, 2, 18, 4, 100, 97, 115, 104, 18, 7, 113, 117, + 97, 110, 116, 117, 109, + ]; + + // The timestamp is 0 because there were no blocks + assert_eq!( + vote_polls_by_timestamps, + vec![SerializedVotePollsByTimestamp { + timestamp: 1_209_600_000, // in ms, 2 weeks after Jan 1 1970 + serialized_vote_polls: vec![serialized_contested_vote_poll_bytes.clone()] + }] + ); + + // Let's try deserializing + + let vote_poll = VotePoll::deserialize_from_bytes( + serialized_contested_vote_poll_bytes.as_slice(), + ) + .expect("expected to deserialize"); + + assert_eq!( + vote_poll, + VotePoll::ContestedDocumentResourceVotePoll( + ContestedDocumentResourceVotePoll { + contract_id: Identifier(IdentifierBytes32([ + 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 + ])), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![ + Text("dash".to_string()), + Text("quantum".to_string()) + ] + } + ) + ); + } + + #[test] + fn test_proved_end_date_query_request() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + let GetVotePollsByEndDateResponse { version } = platform + .query_vote_polls_by_end_date_query( + GetVotePollsByEndDateRequest { + version: Some(get_vote_polls_by_end_date_request::Version::V0( + GetVotePollsByEndDateRequestV0 { + start_time_info: None, + end_time_info: None, + limit: None, + offset: None, + ascending: false, + prove: true, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_vote_polls_by_end_date_response::Version::V0( + GetVotePollsByEndDateResponseV0 { + metadata: _, + result, + }, + ) = version.expect("expected a version"); + + let Some(get_vote_polls_by_end_date_response_v0::Result::Proof(proof)) = result + else { + panic!("expected contenders") + }; - assert!(finished_results); - - // The timestamp is 0 because there were no blocks - assert_eq!( - contested_vote_polls_by_timestamps, - vec![SerializedContestedVotePollsByTimestamp { - timestamp: 1_209_600_000, // in ms, 2 weeks after Jan 1 1970 - serialized_contested_vote_polls: vec![vec![ - 0, 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, 6, - 100, 111, 109, 97, 105, 110, 18, 112, 97, 114, 101, 110, 116, 78, 97, 109, - 101, 65, 110, 100, 76, 97, 98, 101, 108, 2, 18, 4, 100, 97, 115, 104, 18, - 7, 113, 117, 97, 110, 116, 117, 109 - ]] - }] - ); + let vote_poll_by_end_date_query = VotePollsByEndDateDriveQuery { + start_time: None, + end_time: None, + offset: None, + limit: None, + order_ascending: true, + }; + + let (_, vote_polls_by_timestamps) = vote_poll_by_end_date_query + .verify_vote_polls_by_end_date_proof( + proof.grovedb_proof.as_ref(), + platform_version, + ) + .expect("expected to verify proof"); + + assert_eq!( + vote_polls_by_timestamps, + BTreeMap::from([( + 1209600000, + vec![VotePoll::ContestedDocumentResourceVotePoll( + ContestedDocumentResourceVotePoll { + contract_id: Identifier(IdentifierBytes32([ + 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 + ])), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![ + Text("dash".to_string()), + Text("quantum".to_string()) + ] + } + )] + )]) + ); + } + } } } -} diff --git a/packages/rs-drive-abci/src/query/service.rs b/packages/rs-drive-abci/src/query/service.rs index 9981e2013b..a2c4525016 100644 --- a/packages/rs-drive-abci/src/query/service.rs +++ b/packages/rs-drive-abci/src/query/service.rs @@ -15,22 +15,21 @@ use dapi_grpc::platform::v0::{ GetContestedResourceIdentityVoteStatusResponse, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse, GetContestedResourcesRequest, - GetContestedResourcesResponse, GetContestedVotePollsByEndDateRequest, - GetContestedVotePollsByEndDateResponse, GetDataContractHistoryRequest, - GetDataContractHistoryResponse, GetDataContractRequest, GetDataContractResponse, - GetDataContractsRequest, GetDataContractsResponse, GetDocumentsRequest, GetDocumentsResponse, - GetEpochsInfoRequest, GetEpochsInfoResponse, GetIdentitiesContractKeysRequest, - GetIdentitiesContractKeysResponse, GetIdentityBalanceAndRevisionRequest, - GetIdentityBalanceAndRevisionResponse, GetIdentityBalanceRequest, GetIdentityBalanceResponse, - GetIdentityByPublicKeyHashRequest, GetIdentityByPublicKeyHashResponse, - GetIdentityContractNonceRequest, GetIdentityContractNonceResponse, GetIdentityKeysRequest, - GetIdentityKeysResponse, GetIdentityNonceRequest, GetIdentityNonceResponse, GetIdentityRequest, - GetIdentityResponse, GetPathElementsRequest, GetPathElementsResponse, - GetPrefundedSpecializedBalanceRequest, GetPrefundedSpecializedBalanceResponse, - GetProofsRequest, GetProofsResponse, GetProtocolVersionUpgradeStateRequest, - GetProtocolVersionUpgradeStateResponse, GetProtocolVersionUpgradeVoteStatusRequest, - GetProtocolVersionUpgradeVoteStatusResponse, WaitForStateTransitionResultRequest, - WaitForStateTransitionResultResponse, + GetContestedResourcesResponse, GetDataContractHistoryRequest, GetDataContractHistoryResponse, + GetDataContractRequest, GetDataContractResponse, GetDataContractsRequest, + GetDataContractsResponse, GetDocumentsRequest, GetDocumentsResponse, GetEpochsInfoRequest, + GetEpochsInfoResponse, GetIdentitiesContractKeysRequest, GetIdentitiesContractKeysResponse, + GetIdentityBalanceAndRevisionRequest, GetIdentityBalanceAndRevisionResponse, + GetIdentityBalanceRequest, GetIdentityBalanceResponse, GetIdentityByPublicKeyHashRequest, + GetIdentityByPublicKeyHashResponse, GetIdentityContractNonceRequest, + GetIdentityContractNonceResponse, GetIdentityKeysRequest, GetIdentityKeysResponse, + GetIdentityNonceRequest, GetIdentityNonceResponse, GetIdentityRequest, GetIdentityResponse, + GetPathElementsRequest, GetPathElementsResponse, GetPrefundedSpecializedBalanceRequest, + GetPrefundedSpecializedBalanceResponse, GetProofsRequest, GetProofsResponse, + GetProtocolVersionUpgradeStateRequest, GetProtocolVersionUpgradeStateResponse, + GetProtocolVersionUpgradeVoteStatusRequest, GetProtocolVersionUpgradeVoteStatusResponse, + GetVotePollsByEndDateRequest, GetVotePollsByEndDateResponse, + WaitForStateTransitionResultRequest, WaitForStateTransitionResultResponse, }; use dapi_grpc::tonic::{Code, Request, Response, Status}; use dpp::version::PlatformVersion; @@ -510,14 +509,14 @@ impl PlatformService for QueryService { .await } - async fn get_contested_vote_polls_by_end_date( + async fn get_vote_polls_by_end_date( &self, - request: Request, - ) -> Result, Status> { + request: Request, + ) -> Result, Status> { self.handle_blocking_query( request, - Platform::::query_contested_vote_polls_by_end_date_query, - "get_contested_vote_polls_by_end_date", + Platform::::query_vote_polls_by_end_date_query, + "get_vote_polls_by_end_date", ) .await } diff --git a/packages/rs-drive-abci/src/query/voting/mod.rs b/packages/rs-drive-abci/src/query/voting/mod.rs index 25c34322d0..af89d57a8c 100644 --- a/packages/rs-drive-abci/src/query/voting/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/mod.rs @@ -2,4 +2,4 @@ mod contested_resource_identity_vote_status; mod contested_resource_vote_state; mod contested_resource_voters_for_identity; mod contested_resources; -mod contested_vote_polls_by_end_date_query; +mod vote_polls_by_end_date_query; diff --git a/packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/mod.rs b/packages/rs-drive-abci/src/query/voting/vote_polls_by_end_date_query/mod.rs similarity index 63% rename from packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/mod.rs rename to packages/rs-drive-abci/src/query/voting/vote_polls_by_end_date_query/mod.rs index 4bee34c7f6..08672504ea 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/vote_polls_by_end_date_query/mod.rs @@ -3,11 +3,9 @@ use crate::error::Error; use crate::platform_types::platform::Platform; use crate::platform_types::platform_state::PlatformState; use crate::query::QueryValidationResult; -use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_request::Version as RequestVersion; -use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_response::Version as ResponseVersion; -use dapi_grpc::platform::v0::{ - GetContestedVotePollsByEndDateRequest, GetContestedVotePollsByEndDateResponse, -}; +use dapi_grpc::platform::v0::get_vote_polls_by_end_date_request::Version as RequestVersion; +use dapi_grpc::platform::v0::get_vote_polls_by_end_date_response::Version as ResponseVersion; +use dapi_grpc::platform::v0::{GetVotePollsByEndDateRequest, GetVotePollsByEndDateResponse}; use dpp::version::PlatformVersion; mod v0; @@ -15,12 +13,12 @@ mod v0; impl Platform { /// Querying of the contested vote polls by a query targeting the end date /// This is for querying what votes are ending soon, but can be for other time based queries - pub fn query_contested_vote_polls_by_end_date_query( + pub fn query_vote_polls_by_end_date_query( &self, - GetContestedVotePollsByEndDateRequest { version }: GetContestedVotePollsByEndDateRequest, + GetVotePollsByEndDateRequest { version }: GetVotePollsByEndDateRequest, platform_state: &PlatformState, platform_version: &PlatformVersion, - ) -> Result, Error> { + ) -> Result, Error> { let Some(version) = version else { return Ok(QueryValidationResult::new_with_error( QueryError::DecodingError( @@ -33,7 +31,7 @@ impl Platform { .drive_abci .query .voting_based_queries - .contested_vote_polls_by_end_date_query; + .vote_polls_by_end_date_query; let feature_version = match &version { RequestVersion::V0(_) => 0, @@ -41,7 +39,7 @@ impl Platform { if !feature_version_bounds.check_version(feature_version) { return Ok(QueryValidationResult::new_with_error( QueryError::UnsupportedQueryVersion( - "contested_vote_polls_by_end_date_query".to_string(), + "vote_polls_by_end_date_query".to_string(), feature_version_bounds.min_version, feature_version_bounds.max_version, platform_version.protocol_version, @@ -51,17 +49,15 @@ impl Platform { } match version { RequestVersion::V0(request_v0) => { - let result = self.query_contested_vote_polls_by_end_date_query_v0( + let result = self.query_vote_polls_by_end_date_query_v0( request_v0, platform_state, platform_version, )?; - Ok( - result.map(|response_v0| GetContestedVotePollsByEndDateResponse { - version: Some(ResponseVersion::V0(response_v0)), - }), - ) + Ok(result.map(|response_v0| GetVotePollsByEndDateResponse { + version: Some(ResponseVersion::V0(response_v0)), + })) } } } diff --git a/packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/vote_polls_by_end_date_query/v0/mod.rs similarity index 76% rename from packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/v0/mod.rs rename to packages/rs-drive-abci/src/query/voting/vote_polls_by_end_date_query/v0/mod.rs index 4e0564b24c..aaca8cc135 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_vote_polls_by_end_date_query/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/vote_polls_by_end_date_query/v0/mod.rs @@ -3,9 +3,9 @@ use crate::error::Error; use crate::platform_types::platform::Platform; use crate::platform_types::platform_state::PlatformState; use crate::query::QueryValidationResult; -use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_request::GetContestedVotePollsByEndDateRequestV0; -use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_response::{get_contested_vote_polls_by_end_date_response_v0, GetContestedVotePollsByEndDateResponseV0}; -use dapi_grpc::platform::v0::get_contested_vote_polls_by_end_date_response::get_contested_vote_polls_by_end_date_response_v0::SerializedContestedVotePollsByTimestamp; +use dapi_grpc::platform::v0::get_vote_polls_by_end_date_request::GetVotePollsByEndDateRequestV0; +use dapi_grpc::platform::v0::get_vote_polls_by_end_date_response::{get_vote_polls_by_end_date_response_v0, GetVotePollsByEndDateResponseV0}; +use dapi_grpc::platform::v0::get_vote_polls_by_end_date_response::get_vote_polls_by_end_date_response_v0::SerializedVotePollsByTimestamp; use dpp::check_validation_result_with_data; use dpp::version::PlatformVersion; use dpp::validation::ValidationResult; @@ -14,19 +14,19 @@ use drive::error::query::QuerySyntaxError; use drive::query::VotePollsByEndDateDriveQuery; impl Platform { - pub(super) fn query_contested_vote_polls_by_end_date_query_v0( + pub(super) fn query_vote_polls_by_end_date_query_v0( &self, - GetContestedVotePollsByEndDateRequestV0 { + GetVotePollsByEndDateRequestV0 { start_time_info, end_time_info, limit, offset, ascending, prove, - }: GetContestedVotePollsByEndDateRequestV0, + }: GetVotePollsByEndDateRequestV0, platform_state: &PlatformState, platform_version: &PlatformVersion, - ) -> Result, Error> { + ) -> Result, Error> { let config = &self.config.drive; let start_time = start_time_info.map(|start_time_info| { @@ -90,12 +90,10 @@ impl Platform { Err(e) => return Err(e.into()), }; - GetContestedVotePollsByEndDateResponseV0 { - result: Some( - get_contested_vote_polls_by_end_date_response_v0::Result::Proof( - self.response_proof_v0(platform_state, proof), - ), - ), + GetVotePollsByEndDateResponseV0 { + result: Some(get_vote_polls_by_end_date_response_v0::Result::Proof( + self.response_proof_v0(platform_state, proof), + )), metadata: Some(self.response_metadata_v0(platform_state)), } } else { @@ -114,17 +112,17 @@ impl Platform { Err(e) => return Err(e.into()), }; - let (contested_vote_polls_by_timestamps, counts): ( - Vec, + let (vote_polls_by_timestamps, counts): ( + Vec, Vec, ) = results .into_iter() .map(|(timestamp, contested_document_resource_vote_polls)| { let len = contested_document_resource_vote_polls.len(); ( - SerializedContestedVotePollsByTimestamp { + SerializedVotePollsByTimestamp { timestamp, - serialized_contested_vote_polls: contested_document_resource_vote_polls, + serialized_vote_polls: contested_document_resource_vote_polls, }, len, ) @@ -134,7 +132,7 @@ impl Platform { let count: usize = counts.into_iter().sum(); let finished_results = if count as u16 == limit { - let last = contested_vote_polls_by_timestamps + let last = vote_polls_by_timestamps .last() .expect("there should be a last one if count exists"); let next_query = VotePollsByEndDateDriveQuery { @@ -164,11 +162,11 @@ impl Platform { true }; - GetContestedVotePollsByEndDateResponseV0 { + GetVotePollsByEndDateResponseV0 { result: Some( - get_contested_vote_polls_by_end_date_response_v0::Result::ContestedVotePollsByTimestamps( - get_contested_vote_polls_by_end_date_response_v0::SerializedContestedVotePollsByTimestamps { - contested_vote_polls_by_timestamps, + get_vote_polls_by_end_date_response_v0::Result::VotePollsByTimestamps( + get_vote_polls_by_end_date_response_v0::SerializedVotePollsByTimestamps { + vote_polls_by_timestamps, finished_results, }, ), diff --git a/packages/rs-drive/src/drive/verify/voting/mod.rs b/packages/rs-drive/src/drive/verify/voting/mod.rs index 8cc34ac085..ea26ef8061 100644 --- a/packages/rs-drive/src/drive/verify/voting/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/mod.rs @@ -1,4 +1,5 @@ mod verify_contests_proof; mod verify_masternode_vote; mod verify_vote_poll_vote_state_proof; +mod verify_vote_polls_end_date_query; // mod verify_start_at_contender_in_proof; diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_polls_end_date_query/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_polls_end_date_query/mod.rs new file mode 100644 index 0000000000..fb8e2ca916 --- /dev/null +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_polls_end_date_query/mod.rs @@ -0,0 +1,58 @@ +mod v0; + +use crate::drive::verify::RootHash; +use crate::error::drive::DriveError; +use dpp::prelude::TimestampMillis; +use std::collections::BTreeMap; + +use crate::error::Error; + +use crate::query::VotePollsByEndDateDriveQuery; +use dpp::version::PlatformVersion; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::voting::vote_polls::VotePoll; + +impl VotePollsByEndDateDriveQuery { + /// Verifies the serialized proof for a vote poll based on the end date. + /// + /// This function analyzes a byte slice which contains the serialized proof, performs verification, and returns + /// the results, which include the root hash of the proof and a structured map of the contests. + /// + /// # Arguments + /// + /// * `proof` - A byte slice of the serialized proof that needs to be verified. + /// * `platform_version` - The version of the platform which defines how the proof should be verified. + /// + /// # Returns + /// + /// A `Result` which is either: + /// * `Ok((RootHash, BTreeMap))` if the proof is verified successfully. + /// * `Err(Error)` if there is a failure in proof verification or during the deserialization of documents. + /// + /// # Errors + /// + /// Returns an `Error` if: + /// 1. Proof verification fails due to invalid data or signature issues. + /// 2. Deserialization error occurs due to malformed data or incompatible types in the document(s). + /// + pub fn verify_vote_polls_by_end_date_proof( + &self, + proof: &[u8], + platform_version: &PlatformVersion, + ) -> Result<(RootHash, BTreeMap>), Error> { + match platform_version + .drive + .methods + .verify + .voting + .verify_vote_polls_by_end_date_proof + { + 0 => self.verify_vote_polls_by_end_date_proof_v0(proof), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "verify_vote_polls_by_end_date_proof".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_polls_end_date_query/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_polls_end_date_query/v0/mod.rs new file mode 100644 index 0000000000..76355770bd --- /dev/null +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_polls_end_date_query/v0/mod.rs @@ -0,0 +1,77 @@ +use crate::drive::verify::RootHash; +use dpp::prelude::TimestampMillis; +use dpp::serialization::PlatformDeserializable; +use grovedb::GroveDb; +use std::collections::BTreeMap; + +use crate::error::Error; + +use crate::common::encode::decode_u64; +use crate::error::drive::DriveError; +use crate::query::VotePollsByEndDateDriveQuery; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::voting::vote_polls::VotePoll; + +impl VotePollsByEndDateDriveQuery { + /// Verifies a proof and extracts voting poll documents based on their end date. + /// + /// This function takes a slice of bytes `proof` containing a serialized proof, + /// verifies the proof against a constructed path query, and deserializes the documents associated + /// with each proof into `ContestedDocumentResourceVotePoll` instances organized by their + /// timestamps. + /// + /// # Arguments + /// + /// * `proof` - A byte slice representing the serialized proof to be verified. + /// + /// # Returns + /// + /// A `Result` containing: + /// * A tuple with a root hash and a `BTreeMap` where the keys are timestamps (in milliseconds since + /// the epoch) and the values are vectors of `ContestedDocumentResourceVotePoll` objects, + /// representing voting polls ending at those times. The map entries are sorted by the timestamps. + /// * An `Error` variant, in case the proof verification fails or if there are deserialization + /// errors while parsing the documents. + /// + /// # Errors + /// + /// This function may return an `Error` if: + /// 1. The proof verification against the constructed path query fails. + /// 2. There is an error in deserializing the byte slices into `ContestedDocumentResourceVotePoll` + /// instances. + /// 3. A required path component (timestamp) is missing in any of the paths returned in the proof, + /// indicating a potentially corrupted state. + #[inline(always)] + pub(super) fn verify_vote_polls_by_end_date_proof_v0( + &self, + proof: &[u8], + ) -> Result<(RootHash, BTreeMap>), Error> { + let path_query = self.construct_path_query(); + let (root_hash, proved_key_values) = GroveDb::verify_query(proof, &path_query)?; + let vote_polls_by_end_date = proved_key_values + .into_iter() + .filter_map(|(path, _, element)| Some((path, element?))) + .map(|(path, element)| { + let Some(last_path_component) = path.last() else { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "we should always have a path not be null".to_string(), + ))); + }; + let timestamp = decode_u64(last_path_component).map_err(Error::from)?; + let vote_poll_bytes = element.into_item_bytes().map_err(Error::from)?; + let vote_poll = VotePoll::deserialize_from_bytes(&vote_poll_bytes)?; + Ok((timestamp, vote_poll)) + }) + .collect::, Error>>()? + .into_iter() + .fold( + BTreeMap::new(), + |mut acc: BTreeMap>, (timestamp, vote_poll)| { + acc.entry(timestamp).or_default().push(vote_poll); + acc + }, + ); + + Ok((root_hash, vote_polls_by_end_date)) + } +} diff --git a/packages/rs-platform-version/src/version/drive_abci_versions.rs b/packages/rs-platform-version/src/version/drive_abci_versions.rs index 2133ca715e..d14665cf09 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions.rs @@ -40,7 +40,7 @@ pub struct DriveAbciQueryIdentityVersions { #[derive(Clone, Debug, Default)] pub struct DriveAbciQueryVotingVersions { - pub contested_vote_polls_by_end_date_query: FeatureVersionBounds, + pub vote_polls_by_end_date_query: FeatureVersionBounds, pub contested_resource_vote_state: FeatureVersionBounds, pub contested_resource_voters_for_identity: FeatureVersionBounds, pub contested_resource_identity_vote_status: FeatureVersionBounds, diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 763147b536..fae65e432c 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -115,6 +115,7 @@ pub struct DriveVerifyVoteMethodVersions { pub verify_start_at_contender_in_proof: FeatureVersion, pub verify_vote_poll_vote_state_proof: FeatureVersion, pub verify_contests_proof: FeatureVersion, + pub verify_vote_polls_by_end_date_proof: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 3a23c5515a..7fe2e777a6 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -316,6 +316,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { verify_start_at_contender_in_proof: 0, verify_vote_poll_vote_state_proof: 0, verify_contests_proof: 0, + verify_vote_polls_by_end_date_proof: 0, }, state_transition: DriveVerifyStateTransitionMethodVersions { verify_state_transition_was_executed_with_proof: 0, @@ -876,7 +877,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { }, }, voting_based_queries: DriveAbciQueryVotingVersions { - contested_vote_polls_by_end_date_query: FeatureVersionBounds { + vote_polls_by_end_date_query: FeatureVersionBounds { min_version: 0, max_version: 0, default_current_version: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index db625d0b31..04fcb5ccaf 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -324,6 +324,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { verify_start_at_contender_in_proof: 0, verify_vote_poll_vote_state_proof: 0, verify_contests_proof: 0, + verify_vote_polls_by_end_date_proof: 0, }, state_transition: DriveVerifyStateTransitionMethodVersions { verify_state_transition_was_executed_with_proof: 0, @@ -876,7 +877,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { }, }, voting_based_queries: DriveAbciQueryVotingVersions { - contested_vote_polls_by_end_date_query: FeatureVersionBounds { + vote_polls_by_end_date_query: FeatureVersionBounds { min_version: 0, max_version: 0, default_current_version: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index a84e57f982..0c45caffb1 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -315,6 +315,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { verify_start_at_contender_in_proof: 0, verify_vote_poll_vote_state_proof: 0, verify_contests_proof: 0, + verify_vote_polls_by_end_date_proof: 0, }, state_transition: DriveVerifyStateTransitionMethodVersions { verify_state_transition_was_executed_with_proof: 0, @@ -875,7 +876,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { }, }, voting_based_queries: DriveAbciQueryVotingVersions { - contested_vote_polls_by_end_date_query: FeatureVersionBounds { + vote_polls_by_end_date_query: FeatureVersionBounds { min_version: 0, max_version: 0, default_current_version: 0, From 9a836284bc39cd75018bef042b4549927623c57f Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 29 May 2024 16:21:07 +0200 Subject: [PATCH 097/135] a lot more end date queries and tests --- packages/rs-dpp/src/block/block_info/mod.rs | 22 +- .../state_transitions/masternode_vote/mod.rs | 1383 +++++++++++++++-- .../vote_polls_by_end_date_query/v0/mod.rs | 61 +- .../v0/mod.rs | 28 +- .../mod.rs | 3 +- .../v0/mod.rs | 18 +- .../mod.rs | 1 + 7 files changed, 1340 insertions(+), 176 deletions(-) diff --git a/packages/rs-dpp/src/block/block_info/mod.rs b/packages/rs-dpp/src/block/block_info/mod.rs index 6f43eefc1b..62992d2845 100644 --- a/packages/rs-dpp/src/block/block_info/mod.rs +++ b/packages/rs-dpp/src/block/block_info/mod.rs @@ -37,13 +37,33 @@ impl BlockInfo { } /// Create default block with specified time - pub fn default_with_time(time_ms: u64) -> BlockInfo { + pub fn default_with_time(time_ms: TimestampMillis) -> BlockInfo { BlockInfo { time_ms, ..Default::default() } } + /// Create default block with specified height + pub fn default_with_height(height: BlockHeight) -> BlockInfo { + BlockInfo { + height, + ..Default::default() + } + } + + /// Create default block with specified height and time + pub fn default_with_height_and_time( + height: BlockHeight, + time_ms: TimestampMillis, + ) -> BlockInfo { + BlockInfo { + height, + time_ms, + ..Default::default() + } + } + /// Create default block with specified fee epoch pub fn default_with_epoch(epoch: Epoch) -> BlockInfo { BlockInfo { diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 828ba5f1ca..e422a50af0 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -161,6 +161,10 @@ mod tests { use crate::test::helpers::setup::TempPlatform; use dpp::serialization::PlatformDeserializable; use drive::query::VotePollsByEndDateDriveQuery; + use crate::platform_types::platform_state::v0::PlatformStateV0Methods; + use dpp::block::extended_block_info::v0::ExtendedBlockInfoV0; + use dpp::platform_value::IdentifierBytes32; + use dpp::platform_value::Value::Text; fn setup_masternode_identity( platform: &mut TempPlatform, @@ -204,7 +208,7 @@ mod tests { fn create_dpns_name_contest( platform: &mut TempPlatform, - platform_state: &Guard>, + platform_state: &PlatformState, seed: u64, name: &str, platform_version: &PlatformVersion, @@ -427,7 +431,12 @@ mod tests { documents_batch_create_serialized_preorder_transition_2.clone(), ], platform_state, - &BlockInfo::default(), + &BlockInfo::default_with_time( + platform_state + .last_committed_block_time_ms() + .unwrap_or_default() + + 3000, + ), &transaction, platform_version, ) @@ -452,7 +461,12 @@ mod tests { documents_batch_create_serialized_transition_2.clone(), ], platform_state, - &BlockInfo::default(), + &BlockInfo::default_with_time( + platform_state + .last_committed_block_time_ms() + .unwrap_or_default() + + 3000, + ), &transaction, platform_version, ) @@ -674,156 +688,163 @@ mod tests { assert_eq!(second_contender.vote_tally, Some(0)); } - #[test] - fn test_contests_request() { - let platform_version = PlatformVersion::latest(); - let mut platform = TestPlatformBuilder::new() - .build_with_mock_rpc() - .set_genesis_state(); - - let platform_state = platform.state.load(); - - let (identity_1, identity_2, dpns_contract) = create_dpns_name_contest( - &mut platform, - &platform_state, - 7, - "quantum", - platform_version, - ); - - verify_dpns_name_contest( - &mut platform, - &platform_state, - dpns_contract.as_ref(), - &identity_1, - &identity_2, - "quantum", - platform_version, - ); - - let (identity_3, identity_4, dpns_contract) = create_dpns_name_contest( - &mut platform, - &platform_state, - 8, - "cooldog", - platform_version, - ); - - verify_dpns_name_contest( - &mut platform, - &platform_state, - dpns_contract.as_ref(), - &identity_3, - &identity_4, - "cooldog", - platform_version, - ); - - let domain = dpns_contract - .document_type_for_name("domain") - .expect("expected a profile document type"); + mod contests_requests { + use super::*; + #[test] + fn test_contests_request() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); - let index_name = "parentNameAndLabel".to_string(); + let platform_state = platform.state.load(); - let config = bincode::config::standard() - .with_big_endian() - .with_no_limit(); + let (identity_1, identity_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); - let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) - .expect("expected to encode value"); + verify_dpns_name_contest( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + &identity_1, + &identity_2, + "quantum", + platform_version, + ); - let query_validation_result = platform - .query_contested_resources( - GetContestedResourcesRequest { - version: Some(get_contested_resources_request::Version::V0( - GetContestedResourcesRequestV0 { - contract_id: dpns_contract.id().to_vec(), - document_type_name: domain.name().clone(), - index_name: index_name.clone(), - start_index_values: vec![dash_encoded.clone()], - end_index_values: vec![], - start_at_value_info: None, - count: None, - order_ascending: true, - prove: false, - }, - )), - }, + let (identity_3, identity_4, dpns_contract) = create_dpns_name_contest( + &mut platform, &platform_state, + 8, + "cooldog", platform_version, - ) - .expect("expected to execute query") - .into_data() - .expect("expected query to be valid"); + ); - let get_contested_resources_response::Version::V0(GetContestedResourcesResponseV0 { - metadata: _, - result, - }) = query_validation_result.version.expect("expected a version"); + verify_dpns_name_contest( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + &identity_3, + &identity_4, + "cooldog", + platform_version, + ); - let Some(get_contested_resources_response_v0::Result::ContestedResourceValues( - get_contested_resources_response_v0::ContestedResourceValues { - contested_resource_values, - }, - )) = result - else { - panic!("expected contested resources") - }; + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); + + let index_name = "parentNameAndLabel".to_string(); + + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + + let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) + .expect("expected to encode value"); + + let query_validation_result = platform + .query_contested_resources( + GetContestedResourcesRequest { + version: Some(get_contested_resources_request::Version::V0( + GetContestedResourcesRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + start_index_values: vec![dash_encoded.clone()], + end_index_values: vec![], + start_at_value_info: None, + count: None, + order_ascending: true, + prove: false, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); - assert_eq!(contested_resource_values.len(), 2); + let get_contested_resources_response::Version::V0( + GetContestedResourcesResponseV0 { + metadata: _, + result, + }, + ) = query_validation_result.version.expect("expected a version"); - let query_validation_result = platform - .query_contested_resources( - GetContestedResourcesRequest { - version: Some(get_contested_resources_request::Version::V0( - GetContestedResourcesRequestV0 { - contract_id: dpns_contract.id().to_vec(), - document_type_name: domain.name().clone(), - index_name: index_name.clone(), - start_index_values: vec![dash_encoded], - end_index_values: vec![], - start_at_value_info: None, - count: None, - order_ascending: true, - prove: true, - }, - )), + let Some(get_contested_resources_response_v0::Result::ContestedResourceValues( + get_contested_resources_response_v0::ContestedResourceValues { + contested_resource_values, }, - &platform_state, - platform_version, - ) - .expect("expected to execute query") - .into_data() - .expect("expected query to be valid"); + )) = result + else { + panic!("expected contested resources") + }; - let get_contested_resources_response::Version::V0(GetContestedResourcesResponseV0 { - metadata: _, - result, - }) = query_validation_result.version.expect("expected a version"); + assert_eq!(contested_resource_values.len(), 2); + + let query_validation_result = platform + .query_contested_resources( + GetContestedResourcesRequest { + version: Some(get_contested_resources_request::Version::V0( + GetContestedResourcesRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + start_index_values: vec![dash_encoded], + end_index_values: vec![], + start_at_value_info: None, + count: None, + order_ascending: true, + prove: true, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); - let Some(get_contested_resources_response_v0::Result::Proof(proof)) = result else { - panic!("expected proof") - }; + let get_contested_resources_response::Version::V0( + GetContestedResourcesResponseV0 { + metadata: _, + result, + }, + ) = query_validation_result.version.expect("expected a version"); - let resolved_contested_document_vote_poll_drive_query = - ResolvedVotePollsByDocumentTypeQuery { - contract: DataContractResolvedInfo::BorrowedDataContract( - dpns_contract.as_ref(), - ), - document_type_name: domain.name(), - index_name: &index_name, - start_index_values: &vec!["dash".into()], - end_index_values: &vec![], - limit: None, - order_ascending: true, - start_at_value: &None, + let Some(get_contested_resources_response_v0::Result::Proof(proof)) = result else { + panic!("expected proof") }; - let (_, contests) = resolved_contested_document_vote_poll_drive_query - .verify_contests_proof(proof.grovedb_proof.as_ref(), platform_version) - .expect("expected to verify proof"); + let resolved_contested_document_vote_poll_drive_query = + ResolvedVotePollsByDocumentTypeQuery { + contract: DataContractResolvedInfo::BorrowedDataContract( + dpns_contract.as_ref(), + ), + document_type_name: domain.name(), + index_name: &index_name, + start_index_values: &vec!["dash".into()], + end_index_values: &vec![], + limit: None, + order_ascending: true, + start_at_value: &None, + }; + + let (_, contests) = resolved_contested_document_vote_poll_drive_query + .verify_contests_proof(proof.grovedb_proof.as_ref(), platform_version) + .expect("expected to verify proof"); - assert_eq!(contests.len(), 2); + assert_eq!(contests.len(), 2); + } } #[test] @@ -1098,8 +1119,7 @@ mod tests { mod end_date_query { use super::*; - use dpp::platform_value::IdentifierBytes32; - use dpp::platform_value::Value::Text; + use dapi_grpc::platform::v0::get_vote_polls_by_end_date_request::get_vote_polls_by_end_date_request_v0; #[test] fn test_not_proved_end_date_query_request() { @@ -1110,7 +1130,7 @@ mod tests { let platform_state = platform.state.load(); - let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + create_dpns_name_contest( &mut platform, &platform_state, 7, @@ -1127,7 +1147,7 @@ mod tests { end_time_info: None, limit: None, offset: None, - ascending: false, + ascending: true, prove: false, }, )), @@ -1170,7 +1190,7 @@ mod tests { assert_eq!( vote_polls_by_timestamps, vec![SerializedVotePollsByTimestamp { - timestamp: 1_209_600_000, // in ms, 2 weeks after Jan 1 1970 + timestamp: 1_209_603_000, // in ms, 2 weeks after Jan 1 1970 serialized_vote_polls: vec![serialized_contested_vote_poll_bytes.clone()] }] ); @@ -1211,7 +1231,7 @@ mod tests { let platform_state = platform.state.load(); - let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + create_dpns_name_contest( &mut platform, &platform_state, 7, @@ -1228,7 +1248,7 @@ mod tests { end_time_info: None, limit: None, offset: None, - ascending: false, + ascending: true, prove: true, }, )), @@ -1270,7 +1290,7 @@ mod tests { assert_eq!( vote_polls_by_timestamps, BTreeMap::from([( - 1209600000, + 1_209_603_000, vec![VotePoll::ContestedDocumentResourceVotePoll( ContestedDocumentResourceVotePoll { contract_id: Identifier(IdentifierBytes32([ @@ -1289,6 +1309,1081 @@ mod tests { )]) ); } + + #[test] + fn test_not_proved_end_date_query_multiple_contests() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + let mut platform_state = (**platform_state).clone(); + + create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + platform_state.set_last_committed_block_info(Some( + ExtendedBlockInfoV0 { + basic_info: BlockInfo { + time_ms: 500000, + height: 100, + core_height: 42, + epoch: Default::default(), + }, + app_hash: platform.drive.grove.root_hash(None).unwrap().unwrap(), + quorum_hash: [0u8; 32], + block_id_hash: [0u8; 32], + signature: [0u8; 96], + round: 0, + } + .into(), + )); + + // we create two new contenders, but we are on the same contest + create_dpns_name_contest( + &mut platform, + &platform_state, + 8, + "quantum", + platform_version, + ); + + // we create a new contest + create_dpns_name_contest( + &mut platform, + &platform_state, + 9, + "coolio", + platform_version, + ); + + let GetVotePollsByEndDateResponse { version } = platform + .query_vote_polls_by_end_date_query( + GetVotePollsByEndDateRequest { + version: Some(get_vote_polls_by_end_date_request::Version::V0( + GetVotePollsByEndDateRequestV0 { + start_time_info: None, + end_time_info: None, + limit: None, + offset: None, + ascending: true, + prove: false, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_vote_polls_by_end_date_response::Version::V0( + GetVotePollsByEndDateResponseV0 { + metadata: _, + result, + }, + ) = version.expect("expected a version"); + + let Some(get_vote_polls_by_end_date_response_v0::Result::VotePollsByTimestamps( + get_vote_polls_by_end_date_response_v0::SerializedVotePollsByTimestamps { + vote_polls_by_timestamps, + finished_results, + }, + )) = result + else { + panic!("expected contenders") + }; + + assert!(finished_results); + + let serialized_contested_vote_poll_bytes_1 = vec![ + 0, 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, 6, 100, + 111, 109, 97, 105, 110, 18, 112, 97, 114, 101, 110, 116, 78, 97, 109, 101, 65, + 110, 100, 76, 97, 98, 101, 108, 2, 18, 4, 100, 97, 115, 104, 18, 7, 113, 117, + 97, 110, 116, 117, 109, + ]; + + let serialized_contested_vote_poll_bytes_2 = vec![ + 0, 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, 6, 100, + 111, 109, 97, 105, 110, 18, 112, 97, 114, 101, 110, 116, 78, 97, 109, 101, 65, + 110, 100, 76, 97, 98, 101, 108, 2, 18, 4, 100, 97, 115, 104, 18, 6, 99, 48, 48, + 49, 49, 48, + ]; + + // The timestamp is 0 because there were no blocks + assert_eq!( + vote_polls_by_timestamps, + vec![ + SerializedVotePollsByTimestamp { + timestamp: 1_209_603_000, // in ms, 2 weeks after Jan 1 1970 + 3 seconds (chosen block time in test) + serialized_vote_polls: vec![ + serialized_contested_vote_poll_bytes_1.clone() + ] + }, + SerializedVotePollsByTimestamp { + timestamp: 1_210_103_000, // in ms, 500 s after Jan 1 1970 + 3 seconds (chosen block time in test) + serialized_vote_polls: vec![ + serialized_contested_vote_poll_bytes_2.clone() + ] + }, + ] + ); + + // Let's try deserializing + + let vote_poll_1 = VotePoll::deserialize_from_bytes( + serialized_contested_vote_poll_bytes_1.as_slice(), + ) + .expect("expected to deserialize"); + + assert_eq!( + vote_poll_1, + VotePoll::ContestedDocumentResourceVotePoll( + ContestedDocumentResourceVotePoll { + contract_id: Identifier(IdentifierBytes32([ + 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 + ])), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![ + Text("dash".to_string()), + Text("quantum".to_string()) + ] + } + ) + ); + + // Let's try deserializing + + let vote_poll_2 = VotePoll::deserialize_from_bytes( + serialized_contested_vote_poll_bytes_2.as_slice(), + ) + .expect("expected to deserialize"); + + assert_eq!( + vote_poll_2, + VotePoll::ContestedDocumentResourceVotePoll( + ContestedDocumentResourceVotePoll { + contract_id: Identifier(IdentifierBytes32([ + 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 + ])), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![ + Text("dash".to_string()), + Text("c00110".to_string()) + ] + } + ) + ); + } + + #[test] + fn test_proved_end_date_query_multiple_contests() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + let mut platform_state = (**platform_state).clone(); + + create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + platform_state.set_last_committed_block_info(Some( + ExtendedBlockInfoV0 { + basic_info: BlockInfo { + time_ms: 500000, + height: 100, + core_height: 42, + epoch: Default::default(), + }, + app_hash: platform.drive.grove.root_hash(None).unwrap().unwrap(), + quorum_hash: [0u8; 32], + block_id_hash: [0u8; 32], + signature: [0u8; 96], + round: 0, + } + .into(), + )); + + // we create two new contenders, but we are on the same contest + create_dpns_name_contest( + &mut platform, + &platform_state, + 8, + "quantum", + platform_version, + ); + + // we create a new contest + create_dpns_name_contest( + &mut platform, + &platform_state, + 9, + "coolio", + platform_version, + ); + + let GetVotePollsByEndDateResponse { version } = platform + .query_vote_polls_by_end_date_query( + GetVotePollsByEndDateRequest { + version: Some(get_vote_polls_by_end_date_request::Version::V0( + GetVotePollsByEndDateRequestV0 { + start_time_info: None, + end_time_info: None, + limit: None, + offset: None, + ascending: true, + prove: true, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_vote_polls_by_end_date_response::Version::V0( + GetVotePollsByEndDateResponseV0 { + metadata: _, + result, + }, + ) = version.expect("expected a version"); + + let Some(get_vote_polls_by_end_date_response_v0::Result::Proof(proof)) = result + else { + panic!("expected contenders") + }; + + let vote_poll_by_end_date_query = VotePollsByEndDateDriveQuery { + start_time: None, + end_time: None, + offset: None, + limit: None, + order_ascending: true, + }; + + let (_, vote_polls_by_timestamps) = vote_poll_by_end_date_query + .verify_vote_polls_by_end_date_proof( + proof.grovedb_proof.as_ref(), + platform_version, + ) + .expect("expected to verify proof"); + + assert_eq!( + vote_polls_by_timestamps, + BTreeMap::from([ + ( + 1_209_603_000, + vec![VotePoll::ContestedDocumentResourceVotePoll( + ContestedDocumentResourceVotePoll { + contract_id: Identifier(IdentifierBytes32([ + 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 + ])), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![ + Text("dash".to_string()), + Text("quantum".to_string()) + ] + } + )] + ), + ( + 1_210_103_000, + vec![VotePoll::ContestedDocumentResourceVotePoll( + ContestedDocumentResourceVotePoll { + contract_id: Identifier(IdentifierBytes32([ + 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 + ])), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![ + Text("dash".to_string()), + Text("c00110".to_string()) + ] + } + )] + ) + ]) + ); + } + + #[test] + fn test_not_proved_end_date_query_multiple_contests_with_start_at() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + let mut platform_state = (**platform_state).clone(); + + create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + platform_state.set_last_committed_block_info(Some( + ExtendedBlockInfoV0 { + basic_info: BlockInfo { + time_ms: 500000, + height: 100, + core_height: 42, + epoch: Default::default(), + }, + app_hash: platform.drive.grove.root_hash(None).unwrap().unwrap(), + quorum_hash: [0u8; 32], + block_id_hash: [0u8; 32], + signature: [0u8; 96], + round: 0, + } + .into(), + )); + + // we create two new contenders, but we are on the same contest + create_dpns_name_contest( + &mut platform, + &platform_state, + 8, + "quantum", + platform_version, + ); + + // we create a new contest + create_dpns_name_contest( + &mut platform, + &platform_state, + 9, + "coolio", + platform_version, + ); + + platform_state.set_last_committed_block_info(Some( + ExtendedBlockInfoV0 { + basic_info: BlockInfo { + time_ms: 900000, + height: 150, + core_height: 45, + epoch: Default::default(), + }, + app_hash: platform.drive.grove.root_hash(None).unwrap().unwrap(), + quorum_hash: [0u8; 32], + block_id_hash: [0u8; 32], + signature: [0u8; 96], + round: 0, + } + .into(), + )); + + // we create a new contest + create_dpns_name_contest( + &mut platform, + &platform_state, + 10, + "crazyman", + platform_version, + ); + + let GetVotePollsByEndDateResponse { version } = platform + .query_vote_polls_by_end_date_query( + GetVotePollsByEndDateRequest { + version: Some(get_vote_polls_by_end_date_request::Version::V0( + GetVotePollsByEndDateRequestV0 { + start_time_info: Some( + get_vote_polls_by_end_date_request_v0::StartAtTimeInfo { + start_time_ms: 1_209_603_000, + start_time_included: false, + }, + ), + end_time_info: None, + limit: None, + offset: None, + ascending: true, + prove: false, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_vote_polls_by_end_date_response::Version::V0( + GetVotePollsByEndDateResponseV0 { + metadata: _, + result, + }, + ) = version.expect("expected a version"); + + let Some(get_vote_polls_by_end_date_response_v0::Result::VotePollsByTimestamps( + get_vote_polls_by_end_date_response_v0::SerializedVotePollsByTimestamps { + vote_polls_by_timestamps, + finished_results, + }, + )) = result + else { + panic!("expected contenders") + }; + + assert!(finished_results); + + let serialized_contested_vote_poll_bytes_2 = vec![ + 0, 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, 6, 100, + 111, 109, 97, 105, 110, 18, 112, 97, 114, 101, 110, 116, 78, 97, 109, 101, 65, + 110, 100, 76, 97, 98, 101, 108, 2, 18, 4, 100, 97, 115, 104, 18, 6, 99, 48, 48, + 49, 49, 48, + ]; + + let serialized_contested_vote_poll_bytes_3 = vec![ + 0, 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, 6, 100, + 111, 109, 97, 105, 110, 18, 112, 97, 114, 101, 110, 116, 78, 97, 109, 101, 65, + 110, 100, 76, 97, 98, 101, 108, 2, 18, 4, 100, 97, 115, 104, 18, 8, 99, 114, + 97, 122, 121, 109, 97, 110, + ]; + + assert_eq!( + vote_polls_by_timestamps, + vec![ + SerializedVotePollsByTimestamp { + timestamp: 1_210_103_000, // in ms, 500 s after Jan 1 1970 + 3 seconds (chosen block time in test) + serialized_vote_polls: vec![ + serialized_contested_vote_poll_bytes_2.clone() + ] + }, + SerializedVotePollsByTimestamp { + timestamp: 1_210_503_000, // in ms, 900 s after Jan 1 1970 + 3 seconds (chosen block time in test) + serialized_vote_polls: vec![ + serialized_contested_vote_poll_bytes_3.clone() + ] + }, + ] + ); + } + + #[test] + fn test_not_proved_end_date_query_multiple_contests_with_end_at() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + let mut platform_state = (**platform_state).clone(); + + create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + platform_state.set_last_committed_block_info(Some( + ExtendedBlockInfoV0 { + basic_info: BlockInfo { + time_ms: 500000, + height: 100, + core_height: 42, + epoch: Default::default(), + }, + app_hash: platform.drive.grove.root_hash(None).unwrap().unwrap(), + quorum_hash: [0u8; 32], + block_id_hash: [0u8; 32], + signature: [0u8; 96], + round: 0, + } + .into(), + )); + + // we create two new contenders, but we are on the same contest + create_dpns_name_contest( + &mut platform, + &platform_state, + 8, + "quantum", + platform_version, + ); + + // we create a new contest + create_dpns_name_contest( + &mut platform, + &platform_state, + 9, + "coolio", + platform_version, + ); + + platform_state.set_last_committed_block_info(Some( + ExtendedBlockInfoV0 { + basic_info: BlockInfo { + time_ms: 900000, + height: 150, + core_height: 45, + epoch: Default::default(), + }, + app_hash: platform.drive.grove.root_hash(None).unwrap().unwrap(), + quorum_hash: [0u8; 32], + block_id_hash: [0u8; 32], + signature: [0u8; 96], + round: 0, + } + .into(), + )); + + // we create a new contest + create_dpns_name_contest( + &mut platform, + &platform_state, + 10, + "crazyman", + platform_version, + ); + + let GetVotePollsByEndDateResponse { version } = platform + .query_vote_polls_by_end_date_query( + GetVotePollsByEndDateRequest { + version: Some(get_vote_polls_by_end_date_request::Version::V0( + GetVotePollsByEndDateRequestV0 { + start_time_info: Some( + get_vote_polls_by_end_date_request_v0::StartAtTimeInfo { + start_time_ms: 1_209_603_000, + start_time_included: false, + }, + ), + end_time_info: Some( + get_vote_polls_by_end_date_request_v0::EndAtTimeInfo { + end_time_ms: 1_210_500_000, + end_time_included: true, + }, + ), + limit: None, + offset: None, + ascending: true, + prove: false, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_vote_polls_by_end_date_response::Version::V0( + GetVotePollsByEndDateResponseV0 { + metadata: _, + result, + }, + ) = version.expect("expected a version"); + + let Some(get_vote_polls_by_end_date_response_v0::Result::VotePollsByTimestamps( + get_vote_polls_by_end_date_response_v0::SerializedVotePollsByTimestamps { + vote_polls_by_timestamps, + finished_results, + }, + )) = result + else { + panic!("expected contenders") + }; + + assert!(finished_results); + + let serialized_contested_vote_poll_bytes_2 = vec![ + 0, 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, 6, 100, + 111, 109, 97, 105, 110, 18, 112, 97, 114, 101, 110, 116, 78, 97, 109, 101, 65, + 110, 100, 76, 97, 98, 101, 108, 2, 18, 4, 100, 97, 115, 104, 18, 6, 99, 48, 48, + 49, 49, 48, + ]; + + assert_eq!( + vote_polls_by_timestamps, + vec![SerializedVotePollsByTimestamp { + timestamp: 1_210_103_000, // in ms, 500 s after Jan 1 1970 + 3 seconds (chosen block time in test) + serialized_vote_polls: vec![serialized_contested_vote_poll_bytes_2.clone()] + },] + ); + } + + #[test] + fn test_not_proved_end_date_query_multiple_contests_with_end_at_before_start_at() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + let mut platform_state = (**platform_state).clone(); + + create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + platform_state.set_last_committed_block_info(Some( + ExtendedBlockInfoV0 { + basic_info: BlockInfo { + time_ms: 500000, + height: 100, + core_height: 42, + epoch: Default::default(), + }, + app_hash: platform.drive.grove.root_hash(None).unwrap().unwrap(), + quorum_hash: [0u8; 32], + block_id_hash: [0u8; 32], + signature: [0u8; 96], + round: 0, + } + .into(), + )); + + // we create two new contenders, but we are on the same contest + create_dpns_name_contest( + &mut platform, + &platform_state, + 8, + "quantum", + platform_version, + ); + + // we create a new contest + create_dpns_name_contest( + &mut platform, + &platform_state, + 9, + "coolio", + platform_version, + ); + + platform_state.set_last_committed_block_info(Some( + ExtendedBlockInfoV0 { + basic_info: BlockInfo { + time_ms: 900000, + height: 150, + core_height: 45, + epoch: Default::default(), + }, + app_hash: platform.drive.grove.root_hash(None).unwrap().unwrap(), + quorum_hash: [0u8; 32], + block_id_hash: [0u8; 32], + signature: [0u8; 96], + round: 0, + } + .into(), + )); + + // we create a new contest + create_dpns_name_contest( + &mut platform, + &platform_state, + 10, + "crazyman", + platform_version, + ); + + platform + .query_vote_polls_by_end_date_query( + GetVotePollsByEndDateRequest { + version: Some(get_vote_polls_by_end_date_request::Version::V0( + GetVotePollsByEndDateRequestV0 { + start_time_info: Some( + get_vote_polls_by_end_date_request_v0::StartAtTimeInfo { + start_time_ms: 1_209_603_000, + start_time_included: true, + }, + ), + end_time_info: Some( + get_vote_polls_by_end_date_request_v0::EndAtTimeInfo { + end_time_ms: 1_209_601_000, + end_time_included: true, + }, + ), + limit: None, + offset: None, + ascending: true, + prove: false, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect_err("expected query to be invalid"); + + platform + .query_vote_polls_by_end_date_query( + GetVotePollsByEndDateRequest { + version: Some(get_vote_polls_by_end_date_request::Version::V0( + GetVotePollsByEndDateRequestV0 { + start_time_info: Some( + get_vote_polls_by_end_date_request_v0::StartAtTimeInfo { + start_time_ms: 1_209_603_000, + start_time_included: true, + }, + ), + end_time_info: Some( + get_vote_polls_by_end_date_request_v0::EndAtTimeInfo { + end_time_ms: 1_209_603_000, + end_time_included: false, + }, + ), + limit: None, + offset: None, + ascending: true, + prove: false, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect_err("expected query to be invalid"); + } + + #[test] + fn test_not_proved_end_date_query_multiple_contests_with_start_at_ascending_false() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + let mut platform_state = (**platform_state).clone(); + + create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + platform_state.set_last_committed_block_info(Some( + ExtendedBlockInfoV0 { + basic_info: BlockInfo { + time_ms: 500000, + height: 100, + core_height: 42, + epoch: Default::default(), + }, + app_hash: platform.drive.grove.root_hash(None).unwrap().unwrap(), + quorum_hash: [0u8; 32], + block_id_hash: [0u8; 32], + signature: [0u8; 96], + round: 0, + } + .into(), + )); + + // we create two new contenders, but we are on the same contest + create_dpns_name_contest( + &mut platform, + &platform_state, + 8, + "quantum", + platform_version, + ); + + // we create a new contest + create_dpns_name_contest( + &mut platform, + &platform_state, + 9, + "coolio", + platform_version, + ); + + platform_state.set_last_committed_block_info(Some( + ExtendedBlockInfoV0 { + basic_info: BlockInfo { + time_ms: 900000, + height: 150, + core_height: 45, + epoch: Default::default(), + }, + app_hash: platform.drive.grove.root_hash(None).unwrap().unwrap(), + quorum_hash: [0u8; 32], + block_id_hash: [0u8; 32], + signature: [0u8; 96], + round: 0, + } + .into(), + )); + + // we create a new contest + create_dpns_name_contest( + &mut platform, + &platform_state, + 10, + "crazyman", + platform_version, + ); + + let GetVotePollsByEndDateResponse { version } = platform + .query_vote_polls_by_end_date_query( + GetVotePollsByEndDateRequest { + version: Some(get_vote_polls_by_end_date_request::Version::V0( + GetVotePollsByEndDateRequestV0 { + start_time_info: Some( + get_vote_polls_by_end_date_request_v0::StartAtTimeInfo { + start_time_ms: 1_209_603_000, + start_time_included: false, + }, + ), + end_time_info: None, + limit: None, + offset: None, + ascending: false, + prove: false, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_vote_polls_by_end_date_response::Version::V0( + GetVotePollsByEndDateResponseV0 { + metadata: _, + result, + }, + ) = version.expect("expected a version"); + + let Some(get_vote_polls_by_end_date_response_v0::Result::VotePollsByTimestamps( + get_vote_polls_by_end_date_response_v0::SerializedVotePollsByTimestamps { + vote_polls_by_timestamps, + finished_results, + }, + )) = result + else { + panic!("expected contenders") + }; + + assert!(finished_results); + + let serialized_contested_vote_poll_bytes_2 = vec![ + 0, 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, 6, 100, + 111, 109, 97, 105, 110, 18, 112, 97, 114, 101, 110, 116, 78, 97, 109, 101, 65, + 110, 100, 76, 97, 98, 101, 108, 2, 18, 4, 100, 97, 115, 104, 18, 6, 99, 48, 48, + 49, 49, 48, + ]; + + let serialized_contested_vote_poll_bytes_3 = vec![ + 0, 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, 6, 100, + 111, 109, 97, 105, 110, 18, 112, 97, 114, 101, 110, 116, 78, 97, 109, 101, 65, + 110, 100, 76, 97, 98, 101, 108, 2, 18, 4, 100, 97, 115, 104, 18, 8, 99, 114, + 97, 122, 121, 109, 97, 110, + ]; + + assert_eq!( + vote_polls_by_timestamps, + vec![ + SerializedVotePollsByTimestamp { + timestamp: 1_210_503_000, // in ms, 900 s after Jan 1 1970 + 3 seconds (chosen block time in test) + serialized_vote_polls: vec![ + serialized_contested_vote_poll_bytes_3.clone() + ] + }, + SerializedVotePollsByTimestamp { + timestamp: 1_210_103_000, // in ms, 500 s after Jan 1 1970 + 3 seconds (chosen block time in test) + serialized_vote_polls: vec![ + serialized_contested_vote_poll_bytes_2.clone() + ] + }, + ] + ); + } + + #[test] + fn test_proved_end_date_query_multiple_contests_with_start_at() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + let mut platform_state = (**platform_state).clone(); + + create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + platform_state.set_last_committed_block_info(Some( + ExtendedBlockInfoV0 { + basic_info: BlockInfo { + time_ms: 500000, + height: 100, + core_height: 42, + epoch: Default::default(), + }, + app_hash: platform.drive.grove.root_hash(None).unwrap().unwrap(), + quorum_hash: [0u8; 32], + block_id_hash: [0u8; 32], + signature: [0u8; 96], + round: 0, + } + .into(), + )); + + // we create two new contenders, but we are on the same contest + create_dpns_name_contest( + &mut platform, + &platform_state, + 8, + "quantum", + platform_version, + ); + + // we create a new contest + create_dpns_name_contest( + &mut platform, + &platform_state, + 9, + "coolio", + platform_version, + ); + + let GetVotePollsByEndDateResponse { version } = platform + .query_vote_polls_by_end_date_query( + GetVotePollsByEndDateRequest { + version: Some(get_vote_polls_by_end_date_request::Version::V0( + GetVotePollsByEndDateRequestV0 { + start_time_info: None, + end_time_info: None, + limit: None, + offset: None, + ascending: true, + prove: true, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_vote_polls_by_end_date_response::Version::V0( + GetVotePollsByEndDateResponseV0 { + metadata: _, + result, + }, + ) = version.expect("expected a version"); + + let Some(get_vote_polls_by_end_date_response_v0::Result::Proof(proof)) = result + else { + panic!("expected contenders") + }; + + let vote_poll_by_end_date_query = VotePollsByEndDateDriveQuery { + start_time: None, + end_time: None, + offset: None, + limit: None, + order_ascending: true, + }; + + let (_, vote_polls_by_timestamps) = vote_poll_by_end_date_query + .verify_vote_polls_by_end_date_proof( + proof.grovedb_proof.as_ref(), + platform_version, + ) + .expect("expected to verify proof"); + + assert_eq!( + vote_polls_by_timestamps, + BTreeMap::from([ + ( + 1_209_603_000, + vec![VotePoll::ContestedDocumentResourceVotePoll( + ContestedDocumentResourceVotePoll { + contract_id: Identifier(IdentifierBytes32([ + 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 + ])), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![ + Text("dash".to_string()), + Text("quantum".to_string()) + ] + } + )] + ), + ( + 1_210_103_000, + vec![VotePoll::ContestedDocumentResourceVotePoll( + ContestedDocumentResourceVotePoll { + contract_id: Identifier(IdentifierBytes32([ + 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 + ])), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![ + Text("dash".to_string()), + Text("c00110".to_string()) + ] + } + )] + ) + ]) + ); + } } } } diff --git a/packages/rs-drive-abci/src/query/voting/vote_polls_by_end_date_query/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/vote_polls_by_end_date_query/v0/mod.rs index aaca8cc135..b7f034533c 100644 --- a/packages/rs-drive-abci/src/query/voting/vote_polls_by_end_date_query/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/vote_polls_by_end_date_query/v0/mod.rs @@ -39,6 +39,24 @@ impl Platform { let end_time = end_time_info .map(|end_time_info| (end_time_info.end_time_ms, end_time_info.end_time_included)); + if let ( + Some((start_time_ms, start_time_included)), + Some((end_time_ms, end_time_included)), + ) = (start_time, end_time) + { + if start_time_ms > end_time_ms { + return Ok(QueryValidationResult::new_with_error( + QueryError::InvalidArgument(format!( + "start time {} must be before end time {}", + start_time_ms, end_time_ms + )), + )); + } + if start_time_ms == end_time_ms && (!start_time_included || !end_time_included) { + return Ok(QueryValidationResult::new_with_error(QueryError::InvalidArgument("if start time is equal to end time the start and end times must be included".to_string()))); + } + }; + let limit = check_validation_result_with_data!(limit.map_or( Ok(config.default_query_limit), |limit| { @@ -115,19 +133,36 @@ impl Platform { let (vote_polls_by_timestamps, counts): ( Vec, Vec, - ) = results - .into_iter() - .map(|(timestamp, contested_document_resource_vote_polls)| { - let len = contested_document_resource_vote_polls.len(); - ( - SerializedVotePollsByTimestamp { - timestamp, - serialized_vote_polls: contested_document_resource_vote_polls, - }, - len, - ) - }) - .unzip(); + ) = if query.order_ascending { + results + .into_iter() + .map(|(timestamp, contested_document_resource_vote_polls)| { + let len = contested_document_resource_vote_polls.len(); + ( + SerializedVotePollsByTimestamp { + timestamp, + serialized_vote_polls: contested_document_resource_vote_polls, + }, + len, + ) + }) + .unzip() + } else { + results + .into_iter() + .rev() + .map(|(timestamp, contested_document_resource_vote_polls)| { + let len = contested_document_resource_vote_polls.len(); + ( + SerializedVotePollsByTimestamp { + timestamp, + serialized_vote_polls: contested_document_resource_vote_polls, + }, + len, + ) + }) + .unzip() + }; let count: usize = counts.into_iter().sum(); diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs index 49e0a63715..1956e72d2b 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs @@ -55,19 +55,7 @@ impl Drive { .default_vote_poll_time_duration_ms, ); - self.add_vote_poll_end_date_query_operations( - document_and_contract_info.owned_document_info.owner_id, - VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll), - end_date, - block_info, - estimated_costs_only_with_layer_info, - previous_batch_operations, - &mut batch_operations, - transaction, - platform_version, - )?; - - self.add_contested_indices_for_contract_operations( + let contest_already_existed = self.add_contested_indices_for_contract_operations( &document_and_contract_info, previous_batch_operations, estimated_costs_only_with_layer_info, @@ -76,6 +64,20 @@ impl Drive { platform_version, )?; + if !contest_already_existed { + self.add_vote_poll_end_date_query_operations( + document_and_contract_info.owned_document_info.owner_id, + VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll), + end_date, + block_info, + estimated_costs_only_with_layer_info, + previous_batch_operations, + &mut batch_operations, + transaction, + platform_version, + )?; + } + Ok(batch_operations) } } diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/mod.rs index 161038e7d9..8e30acede3 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/mod.rs @@ -12,6 +12,7 @@ mod v0; impl Drive { /// Adds indices for an index level and recurses. + /// Will return true if the contest already existed pub(crate) fn add_contested_indices_for_contract_operations( &self, document_and_contract_info: &DocumentAndContractInfo, @@ -22,7 +23,7 @@ impl Drive { transaction: TransactionArg, batch_operations: &mut Vec, platform_version: &PlatformVersion, - ) -> Result<(), Error> { + ) -> Result { match platform_version .drive .methods diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs index 6700e4d2c3..16aa6000cb 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs @@ -24,7 +24,8 @@ use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; impl Drive { - /// Adds indices for the top index level and calls for lower levels. + /// Adds contested indices for the contract operations + /// Will return true if the contest already existed pub(crate) fn add_contested_indices_for_contract_operations_v0( &self, document_and_contract_info: &DocumentAndContractInfo, @@ -35,7 +36,7 @@ impl Drive { transaction: TransactionArg, batch_operations: &mut Vec, platform_version: &PlatformVersion, - ) -> Result<(), Error> { + ) -> Result { let drive_version = &platform_version.drive; let owner_id = document_and_contract_info .owned_document_info @@ -94,6 +95,8 @@ impl Drive { PathInfo::PathAsVec::<0>(index_path) }; + let mut contest_already_existed = true; + // next we need to store a reference to the document for each index for IndexProperty { name, .. } in &contested_index.properties { // We on purpose do not want to put index names @@ -143,7 +146,7 @@ impl Drive { .unwrap_or_default(); // here we are inserting an empty tree that will have a subtree of all other index properties - self.batch_insert_empty_tree_if_not_exists( + let inserted = self.batch_insert_empty_tree_if_not_exists( document_top_field .clone() .add_path_info(index_path_info.clone()), @@ -156,6 +159,11 @@ impl Drive { drive_version, )?; + // if we insert anything, that means that the contest didn't already exist + if contest_already_existed { + contest_already_existed &= !inserted; + } + index_path_info.push(document_top_field)?; } @@ -217,6 +225,8 @@ impl Drive { transaction, batch_operations, drive_version, - ) + )?; + + Ok(contest_already_existed) } } diff --git a/packages/rs-drive/src/drive/grove_operations/batch_insert_empty_tree_if_not_exists/mod.rs b/packages/rs-drive/src/drive/grove_operations/batch_insert_empty_tree_if_not_exists/mod.rs index e4de42378b..34d327d856 100644 --- a/packages/rs-drive/src/drive/grove_operations/batch_insert_empty_tree_if_not_exists/mod.rs +++ b/packages/rs-drive/src/drive/grove_operations/batch_insert_empty_tree_if_not_exists/mod.rs @@ -15,6 +15,7 @@ use grovedb::TransactionArg; impl Drive { /// Pushes an "insert empty tree where path key does not yet exist" operation to `drive_operations`. /// Will also check the current drive operations + /// Returns true if we inserted pub fn batch_insert_empty_tree_if_not_exists( &self, path_key_info: PathKeyInfo, From 36fb18cffdc2331aa8a9db10a7e7cafd21a505f7 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 29 May 2024 16:49:16 +0200 Subject: [PATCH 098/135] more query tests --- .../state_transitions/masternode_vote/mod.rs | 846 +++++++++++++----- .../v0/mod.rs | 6 +- 2 files changed, 632 insertions(+), 220 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index e422a50af0..5fae8d2b01 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -688,6 +688,72 @@ mod tests { assert_eq!(second_contender.vote_tally, Some(0)); } + fn perform_vote( + platform: &mut TempPlatform, + platform_state: &Guard>, + dpns_contract: &DataContract, + towards_identity_id: Identifier, + name: &str, + signer: &SimpleSigner, + masternode_id: Identifier, + voting_key: &IdentityPublicKey, + platform_version: &PlatformVersion, + ) { + // Let's vote for contender 1 + + let vote = Vote::ResourceVote(ResourceVote::V0(ResourceVoteV0 { + vote_poll: VotePoll::ContestedDocumentResourceVotePoll( + ContestedDocumentResourceVotePoll { + contract_id: dpns_contract.id(), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![ + Value::Text("dash".to_string()), + Value::Text(convert_to_homograph_safe_chars(name)), + ], + }, + ), + resource_vote_choice: TowardsIdentity(towards_identity_id), + })); + + let masternode_vote_transition = MasternodeVoteTransition::try_from_vote_with_signer( + vote, + signer, + masternode_id, + voting_key, + 1, + platform_version, + None, + ) + .expect("expected to make transition vote"); + + let masternode_vote_serialized_transition = masternode_vote_transition + .serialize_to_bytes() + .expect("expected documents batch serialized state transition"); + + let transaction = platform.drive.grove.start_transaction(); + + let processing_result = platform + .platform + .process_raw_state_transitions( + &vec![masternode_vote_serialized_transition.clone()], + platform_state, + &BlockInfo::default(), + &transaction, + platform_version, + ) + .expect("expected to process state transition"); + + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit transaction"); + + assert_eq!(processing_result.valid_count(), 1); + } + mod contests_requests { use super::*; #[test] @@ -847,274 +913,622 @@ mod tests { } } - #[test] - fn test_masternode_voting_and_vote_state_request() { - let platform_version = PlatformVersion::latest(); - let mut platform = TestPlatformBuilder::new() - .build_with_mock_rpc() - .set_genesis_state(); - - let platform_state = platform.state.load(); + mod vote_state_query { + use super::*; + #[test] + fn test_not_proved_vote_state_query_request_after_vote() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); - let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( - &mut platform, - &platform_state, - 7, - "quantum", - platform_version, - ); + let platform_state = platform.state.load(); - let (masternode_1, signer_1, voting_key_1) = - setup_masternode_identity(&mut platform, 29, platform_version); + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); - // Let's vote for contender 1 + let (masternode_1, signer_1, voting_key_1) = + setup_masternode_identity(&mut platform, 29, platform_version); - let vote = Vote::ResourceVote(ResourceVote::V0(ResourceVoteV0 { - vote_poll: VotePoll::ContestedDocumentResourceVotePoll( - ContestedDocumentResourceVotePoll { - contract_id: dpns_contract.id(), - document_type_name: "domain".to_string(), - index_name: "parentNameAndLabel".to_string(), - index_values: vec![ - Value::Text("dash".to_string()), - Value::Text("quantum".to_string()), - ], - }, - ), - resource_vote_choice: TowardsIdentity(contender_1.id()), - })); + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + contender_1.id(), + "quantum", + &signer_1, + masternode_1.id(), + &voting_key_1, + platform_version, + ); - let masternode_vote_transition = MasternodeVoteTransition::try_from_vote_with_signer( - vote, - &signer_1, - masternode_1.id(), - &voting_key_1, - 1, - platform_version, - None, - ) - .expect("expected to make transition vote"); + // Now let's run a query for the vote totals - let masternode_vote_serialized_transition = masternode_vote_transition - .serialize_to_bytes() - .expect("expected documents batch serialized state transition"); + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); - let transaction = platform.drive.grove.start_transaction(); + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); - let processing_result = platform - .platform - .process_raw_state_transitions( - &vec![masternode_vote_serialized_transition.clone()], - &platform_state, - &BlockInfo::default(), - &transaction, - platform_version, - ) - .expect("expected to process state transition"); + let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) + .expect("expected to encode the word dash"); - platform - .drive - .grove - .commit_transaction(transaction) - .unwrap() - .expect("expected to commit transaction"); + let quantum_encoded = + bincode::encode_to_vec(Value::Text("quantum".to_string()), config) + .expect("expected to encode the word quantum"); - assert_eq!(processing_result.valid_count(), 1); + let index_name = "parentNameAndLabel".to_string(); - // Now let's run a query for the vote totals + let query_validation_result = platform + .query_contested_resource_vote_state( + GetContestedResourceVoteStateRequest { + version: Some(get_contested_resource_vote_state_request::Version::V0( + GetContestedResourceVoteStateRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![ + dash_encoded.clone(), + quantum_encoded.clone(), + ], + result_type: ResultType::DocumentsAndVoteTally as i32, + start_at_identifier_info: None, + count: None, + order_ascending: true, + prove: false, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); - let domain = dpns_contract - .document_type_for_name("domain") - .expect("expected a profile document type"); + let get_contested_resource_vote_state_response::Version::V0( + GetContestedResourceVoteStateResponseV0 { + metadata: _, + result, + }, + ) = query_validation_result.version.expect("expected a version"); - let config = bincode::config::standard() - .with_big_endian() - .with_no_limit(); + let Some( + get_contested_resource_vote_state_response_v0::Result::ContestedResourceContenders( + get_contested_resource_vote_state_response_v0::ContestedResourceContenders { + contenders, + }, + ), + ) = result + else { + panic!("expected contenders") + }; - let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) - .expect("expected to encode the word dash"); + assert_eq!(contenders.len(), 2); - let quantum_encoded = - bincode::encode_to_vec(Value::Text("quantum".to_string()), config) - .expect("expected to encode the word quantum"); + let first_contender = contenders.first().unwrap(); - let index_name = "parentNameAndLabel".to_string(); + let second_contender = contenders.last().unwrap(); - let query_validation_result = platform - .query_contested_resource_vote_state( - GetContestedResourceVoteStateRequest { - version: Some(get_contested_resource_vote_state_request::Version::V0( - GetContestedResourceVoteStateRequestV0 { - contract_id: dpns_contract.id().to_vec(), - document_type_name: domain.name().clone(), - index_name: index_name.clone(), - index_values: vec![dash_encoded.clone(), quantum_encoded.clone()], - result_type: ResultType::DocumentsAndVoteTally as i32, - start_at_identifier_info: None, - count: None, - order_ascending: true, - prove: false, - }, - )), - }, - &platform_state, + let first_contender_document = Document::from_bytes( + first_contender + .document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, platform_version, ) - .expect("expected to execute query") - .into_data() - .expect("expected query to be valid"); + .expect("expected to get document"); + + let second_contender_document = Document::from_bytes( + second_contender + .document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); - let get_contested_resource_vote_state_response::Version::V0( - GetContestedResourceVoteStateResponseV0 { - metadata: _, - result, - }, - ) = query_validation_result.version.expect("expected a version"); + assert_ne!(first_contender_document, second_contender_document); - let Some( - get_contested_resource_vote_state_response_v0::Result::ContestedResourceContenders( - get_contested_resource_vote_state_response_v0::ContestedResourceContenders { - contenders, - }, - ), - ) = result - else { - panic!("expected contenders") - }; + assert_eq!(first_contender.identifier, contender_1.id().to_vec()); - assert_eq!(contenders.len(), 2); + assert_eq!(second_contender.identifier, contender_2.id().to_vec()); - let first_contender = contenders.first().unwrap(); + assert_eq!(first_contender.vote_count, Some(1)); - let second_contender = contenders.last().unwrap(); + assert_eq!(second_contender.vote_count, Some(0)); + } - let first_contender_document = Document::from_bytes( - first_contender - .document - .as_ref() - .expect("expected a document") - .as_slice(), - domain, - platform_version, - ) - .expect("expected to get document"); + #[test] + fn test_proved_vote_state_query_request_after_vote() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); - let second_contender_document = Document::from_bytes( - second_contender - .document - .as_ref() - .expect("expected a document") - .as_slice(), - domain, - platform_version, - ) - .expect("expected to get document"); + let platform_state = platform.state.load(); - assert_ne!(first_contender_document, second_contender_document); + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); - assert_eq!(first_contender.identifier, contender_1.id().to_vec()); + let (masternode_1, signer_1, voting_key_1) = + setup_masternode_identity(&mut platform, 29, platform_version); - assert_eq!(second_contender.identifier, contender_2.id().to_vec()); + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + contender_1.id(), + "quantum", + &signer_1, + masternode_1.id(), + &voting_key_1, + platform_version, + ); - assert_eq!(first_contender.vote_count, Some(1)); + // Now let's run a query for the vote totals - assert_eq!(second_contender.vote_count, Some(0)); + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); - let GetContestedResourceVoteStateResponse { version } = platform - .query_contested_resource_vote_state( - GetContestedResourceVoteStateRequest { - version: Some(get_contested_resource_vote_state_request::Version::V0( - GetContestedResourceVoteStateRequestV0 { - contract_id: dpns_contract.id().to_vec(), - document_type_name: domain.name().clone(), - index_name: "parentNameAndLabel".to_string(), - index_values: vec![dash_encoded, quantum_encoded], - result_type: ResultType::DocumentsAndVoteTally as i32, - start_at_identifier_info: None, - count: None, - order_ascending: true, - prove: true, - }, - )), + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + + let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) + .expect("expected to encode the word dash"); + + let quantum_encoded = + bincode::encode_to_vec(Value::Text("quantum".to_string()), config) + .expect("expected to encode the word quantum"); + + let index_name = "parentNameAndLabel".to_string(); + + let GetContestedResourceVoteStateResponse { version } = platform + .query_contested_resource_vote_state( + GetContestedResourceVoteStateRequest { + version: Some(get_contested_resource_vote_state_request::Version::V0( + GetContestedResourceVoteStateRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![dash_encoded, quantum_encoded], + result_type: ResultType::DocumentsAndVoteTally as i32, + start_at_identifier_info: None, + count: None, + order_ascending: true, + prove: true, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_vote_state_response::Version::V0( + GetContestedResourceVoteStateResponseV0 { + metadata: _, + result, }, + ) = version.expect("expected a version"); + + let Some(get_contested_resource_vote_state_response_v0::Result::Proof(proof)) = + result + else { + panic!("expected contenders") + }; + + let resolved_contested_document_vote_poll_drive_query = + ResolvedContestedDocumentVotePollDriveQuery { + vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { + contract: DataContractResolvedInfo::BorrowedDataContract( + &dpns_contract, + ), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![ + Value::Text("dash".to_string()), + Value::Text("quantum".to_string()), + ], + }, + result_type: DocumentsAndVoteTally, + offset: None, + limit: None, + start_at: None, + order_ascending: true, + }; + + let (_, contenders) = resolved_contested_document_vote_poll_drive_query + .verify_vote_poll_vote_state_proof( + proof.grovedb_proof.as_ref(), + platform_version, + ) + .expect("expected to verify proof"); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + let first_contender_document = Document::from_bytes( + first_contender + .serialized_document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); + + let second_contender_document = Document::from_bytes( + second_contender + .serialized_document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); + + assert_ne!(first_contender_document, second_contender_document); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(1)); + + assert_eq!(second_contender.vote_tally, Some(0)); + } + + #[test] + fn test_not_proved_vote_state_query_request_after_many_votes() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, &platform_state, + 7, + "quantum", + platform_version, + ); + + for i in 0..50 { + let (masternode, signer, voting_key) = + setup_masternode_identity(&mut platform, 10 + i, platform_version); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + contender_1.id(), + "quantum", + &signer, + masternode.id(), + &voting_key, + platform_version, + ); + } + + for i in 0..5 { + let (masternode, signer, voting_key) = + setup_masternode_identity(&mut platform, 100 + i, platform_version); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + contender_2.id(), + "quantum", + &signer, + masternode.id(), + &voting_key, + platform_version, + ); + } + + // Now let's run a query for the vote totals + + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); + + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + + let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) + .expect("expected to encode the word dash"); + + let quantum_encoded = + bincode::encode_to_vec(Value::Text("quantum".to_string()), config) + .expect("expected to encode the word quantum"); + + let index_name = "parentNameAndLabel".to_string(); + + let query_validation_result = platform + .query_contested_resource_vote_state( + GetContestedResourceVoteStateRequest { + version: Some(get_contested_resource_vote_state_request::Version::V0( + GetContestedResourceVoteStateRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![ + dash_encoded.clone(), + quantum_encoded.clone(), + ], + result_type: ResultType::DocumentsAndVoteTally as i32, + start_at_identifier_info: None, + count: None, + order_ascending: true, + prove: false, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_vote_state_response::Version::V0( + GetContestedResourceVoteStateResponseV0 { + metadata: _, + result, + }, + ) = query_validation_result.version.expect("expected a version"); + + let Some( + get_contested_resource_vote_state_response_v0::Result::ContestedResourceContenders( + get_contested_resource_vote_state_response_v0::ContestedResourceContenders { + contenders, + }, + ), + ) = result + else { + panic!("expected contenders") + }; + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + let first_contender_document = Document::from_bytes( + first_contender + .document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, platform_version, ) - .expect("expected to execute query") - .into_data() - .expect("expected query to be valid"); + .expect("expected to get document"); + + let second_contender_document = Document::from_bytes( + second_contender + .document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); - let get_contested_resource_vote_state_response::Version::V0( - GetContestedResourceVoteStateResponseV0 { - metadata: _, - result, - }, - ) = version.expect("expected a version"); + assert_ne!(first_contender_document, second_contender_document); - let Some(get_contested_resource_vote_state_response_v0::Result::Proof(proof)) = result - else { - panic!("expected contenders") - }; + assert_eq!(first_contender.identifier, contender_1.id().to_vec()); - let resolved_contested_document_vote_poll_drive_query = - ResolvedContestedDocumentVotePollDriveQuery { - vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { - contract: DataContractResolvedInfo::BorrowedDataContract(&dpns_contract), - document_type_name: domain.name().clone(), - index_name: index_name.clone(), - index_values: vec![ - Value::Text("dash".to_string()), - Value::Text("quantum".to_string()), - ], + assert_eq!(second_contender.identifier, contender_2.id().to_vec()); + + assert_eq!(first_contender.vote_count, Some(50)); + + assert_eq!(second_contender.vote_count, Some(5)); + } + + #[test] + fn test_proved_vote_state_query_request_after_many_votes() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + for i in 0..50 { + let (masternode, signer, voting_key) = + setup_masternode_identity(&mut platform, 10 + i, platform_version); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + contender_1.id(), + "quantum", + &signer, + masternode.id(), + &voting_key, + platform_version, + ); + } + + for i in 0..5 { + let (masternode, signer, voting_key) = + setup_masternode_identity(&mut platform, 100 + i, platform_version); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + contender_2.id(), + "quantum", + &signer, + masternode.id(), + &voting_key, + platform_version, + ); + } + // Now let's run a query for the vote totals + + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); + + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + + let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) + .expect("expected to encode the word dash"); + + let quantum_encoded = + bincode::encode_to_vec(Value::Text("quantum".to_string()), config) + .expect("expected to encode the word quantum"); + + let index_name = "parentNameAndLabel".to_string(); + + let GetContestedResourceVoteStateResponse { version } = platform + .query_contested_resource_vote_state( + GetContestedResourceVoteStateRequest { + version: Some(get_contested_resource_vote_state_request::Version::V0( + GetContestedResourceVoteStateRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![dash_encoded, quantum_encoded], + result_type: ResultType::DocumentsAndVoteTally as i32, + start_at_identifier_info: None, + count: None, + order_ascending: true, + prove: true, + }, + )), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_vote_state_response::Version::V0( + GetContestedResourceVoteStateResponseV0 { + metadata: _, + result, }, - result_type: DocumentsAndVoteTally, - offset: None, - limit: None, - start_at: None, - order_ascending: true, + ) = version.expect("expected a version"); + + let Some(get_contested_resource_vote_state_response_v0::Result::Proof(proof)) = + result + else { + panic!("expected contenders") }; - let (_, contenders) = resolved_contested_document_vote_poll_drive_query - .verify_vote_poll_vote_state_proof(proof.grovedb_proof.as_ref(), platform_version) - .expect("expected to verify proof"); + let resolved_contested_document_vote_poll_drive_query = + ResolvedContestedDocumentVotePollDriveQuery { + vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { + contract: DataContractResolvedInfo::BorrowedDataContract( + &dpns_contract, + ), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![ + Value::Text("dash".to_string()), + Value::Text("quantum".to_string()), + ], + }, + result_type: DocumentsAndVoteTally, + offset: None, + limit: None, + start_at: None, + order_ascending: true, + }; - assert_eq!(contenders.len(), 2); + let (_, contenders) = resolved_contested_document_vote_poll_drive_query + .verify_vote_poll_vote_state_proof( + proof.grovedb_proof.as_ref(), + platform_version, + ) + .expect("expected to verify proof"); - let first_contender = contenders.first().unwrap(); + assert_eq!(contenders.len(), 2); - let second_contender = contenders.last().unwrap(); + let first_contender = contenders.first().unwrap(); - let first_contender_document = Document::from_bytes( - first_contender - .serialized_document - .as_ref() - .expect("expected a document") - .as_slice(), - domain, - platform_version, - ) - .expect("expected to get document"); + let second_contender = contenders.last().unwrap(); - let second_contender_document = Document::from_bytes( - second_contender - .serialized_document - .as_ref() - .expect("expected a document") - .as_slice(), - domain, - platform_version, - ) - .expect("expected to get document"); + let first_contender_document = Document::from_bytes( + first_contender + .serialized_document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); + + let second_contender_document = Document::from_bytes( + second_contender + .serialized_document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); - assert_ne!(first_contender_document, second_contender_document); + assert_ne!(first_contender_document, second_contender_document); - assert_eq!(first_contender.identity_id, contender_1.id()); + assert_eq!(first_contender.identity_id, contender_1.id()); - assert_eq!(second_contender.identity_id, contender_2.id()); + assert_eq!(second_contender.identity_id, contender_2.id()); - assert_eq!(first_contender.vote_tally, Some(1)); + assert_eq!(first_contender.vote_tally, Some(50)); - assert_eq!(second_contender.vote_tally, Some(0)); + assert_eq!(second_contender.vote_tally, Some(5)); + } } mod end_date_query { diff --git a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/v0/mod.rs b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/v0/mod.rs index 9fb4489608..16b98d8b61 100644 --- a/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance_operations/v0/mod.rs @@ -12,9 +12,7 @@ use crate::drive::prefunded_specialized_balances::{ use dpp::identifier::Identifier; use dpp::version::PlatformVersion; use grovedb::batch::{GroveDbOp, KeyInfoPath}; -use grovedb::Element::Item; -use grovedb::{EstimatedLayerInformation, TransactionArg}; -use integer_encoding::VarInt; +use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; impl Drive { @@ -65,7 +63,7 @@ impl Drive { let replace_op = GroveDbOp::replace_op( path_holding_total_credits_vec, specialized_balance_id.to_vec(), - Item(new_total.encode_var_vec(), None), + Element::new_sum_item(new_total as i64), ); drive_operations.push(GroveOperation(replace_op)); Ok(drive_operations) From fbc47852a63bd727b0c490f05c98b4e2fafe54e2 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 29 May 2024 17:59:44 +0200 Subject: [PATCH 099/135] added more tests --- .../v0/mod.rs | 2 +- .../state_transitions/masternode_vote/mod.rs | 400 ++++++++++++++++-- .../identity/masternode_vote_transition.rs | 7 +- .../rs-drive/src/drive/verify/voting/mod.rs | 1 + .../voting/verify_specialized_balance/mod.rs | 62 +++ .../verify_specialized_balance/v0/mod.rs | 84 ++++ .../src/version/drive_versions.rs | 1 + .../fee/vote_resolution_fund_fees/mod.rs | 4 +- .../fee/vote_resolution_fund_fees/v1.rs | 3 +- .../src/version/mocks/v2_test.rs | 1 + .../src/version/mocks/v3_test.rs | 1 + .../rs-platform-version/src/version/v1.rs | 1 + 12 files changed, 518 insertions(+), 49 deletions(-) create mode 100644 packages/rs-drive/src/drive/verify/voting/verify_specialized_balance/mod.rs create mode 100644 packages/rs-drive/src/drive/verify/voting/verify_specialized_balance/v0/mod.rs diff --git a/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/v0/mod.rs b/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/v0/mod.rs index f89a96efb7..afffeb1a68 100644 --- a/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/v0/mod.rs +++ b/packages/rs-dpp/src/data_contract/document_type/methods/prefunded_voting_balances_for_document/v0/mod.rs @@ -35,7 +35,7 @@ impl DocumentTypeV0 { platform_version .fee_version .vote_resolution_fund_fees - .conflicting_vote_resolution_fund_required_amount, + .contested_document_vote_resolution_fund_required_amount, ) }) } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 5fae8d2b01..d6f28abff0 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -101,7 +101,7 @@ mod tests { use platform_version::version::PlatformVersion; use rand::prelude::StdRng; use rand::SeedableRng; - use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, get_vote_polls_by_end_date_request, get_vote_polls_by_end_date_response, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetVotePollsByEndDateRequest, GetVotePollsByEndDateResponse}; + use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, get_contested_resources_request, get_contested_resources_response, get_vote_polls_by_end_date_request, get_vote_polls_by_end_date_response, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetVotePollsByEndDateRequest, GetContestedResourcesRequest, GetVotePollsByEndDateResponse}; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0::ResultType; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::GetContestedResourceVoteStateRequestV0; use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; @@ -119,52 +119,36 @@ mod tests { use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; use drive::query::vote_poll_vote_state_query::ResolvedContestedDocumentVotePollDriveQuery; + use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; + use dpp::identifier::Identifier; + use dpp::identity::{IdentityPublicKey, IdentityV0}; + use dpp::prelude::{DataContract, Identity}; + use dpp::state_transition::masternode_vote_transition::methods::MasternodeVoteTransitionMethodsV0; + use dpp::util::hash::hash_double; + use dpp::util::strings::convert_to_homograph_safe_chars; + use drive::query::vote_polls_by_document_type_query::ResolvedVotePollsByDocumentTypeQuery; + use simple_signer::signer::SimpleSigner; + use crate::platform_types::platform_state::PlatformState; + use crate::rpc::core::MockCoreRPCLike; + use crate::test::helpers::setup::TempPlatform; + use dpp::serialization::PlatformDeserializable; + use drive::query::VotePollsByEndDateDriveQuery; + use crate::platform_types::platform_state::v0::PlatformStateV0Methods; + use dpp::block::extended_block_info::v0::ExtendedBlockInfoV0; + use dpp::platform_value::IdentifierBytes32; + use dpp::platform_value::Value::Text; + use dapi_grpc::platform::v0::{get_prefunded_specialized_balance_request, GetPrefundedSpecializedBalanceRequest}; + use dapi_grpc::platform::v0::get_prefunded_specialized_balance_request::GetPrefundedSpecializedBalanceRequestV0; + use std::collections::BTreeMap; + use std::sync::Arc; + use arc_swap::Guard; + use rand::Rng; + use dapi_grpc::platform::v0::get_contested_resources_request::GetContestedResourcesRequestV0; + use dapi_grpc::platform::v0::get_contested_resources_response::{get_contested_resources_response_v0, GetContestedResourcesResponseV0}; mod vote_tests { - use std::collections::BTreeMap; - use std::sync::Arc; - use arc_swap::Guard; - use rand::Rng; - use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, get_contested_resources_request, get_contested_resources_response, get_vote_polls_by_end_date_request, get_vote_polls_by_end_date_response, GetContestedResourcesRequest, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetVotePollsByEndDateRequest, GetVotePollsByEndDateResponse}; - use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0::ResultType; - use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::GetContestedResourceVoteStateRequestV0; - use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; - use dapi_grpc::platform::v0::get_contested_resources_request::GetContestedResourcesRequestV0; - use dapi_grpc::platform::v0::get_contested_resources_response::{get_contested_resources_response_v0, GetContestedResourcesResponseV0}; - use dapi_grpc::platform::v0::get_vote_polls_by_end_date_request::GetVotePollsByEndDateRequestV0; - use dapi_grpc::platform::v0::get_vote_polls_by_end_date_response::{get_vote_polls_by_end_date_response_v0, GetVotePollsByEndDateResponseV0}; - use dapi_grpc::platform::v0::get_vote_polls_by_end_date_response::get_vote_polls_by_end_date_response_v0::SerializedVotePollsByTimestamp; + use super::*; - use dpp::document::Document; - use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; - use dpp::identifier::Identifier; - use dpp::identity::{IdentityPublicKey, IdentityV0}; - use dpp::prelude::{DataContract, Identity}; - use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; - use dpp::state_transition::masternode_vote_transition::methods::MasternodeVoteTransitionMethodsV0; - use dpp::util::hash::hash_double; - use dpp::util::strings::convert_to_homograph_safe_chars; - use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice::TowardsIdentity; - use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; - use dpp::voting::vote_polls::VotePoll; - use dpp::voting::votes::resource_vote::ResourceVote; - use dpp::voting::votes::resource_vote::v0::ResourceVoteV0; - use dpp::voting::votes::Vote; - use drive::drive::object_size_info::DataContractResolvedInfo; - use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; - use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; - use drive::query::vote_poll_vote_state_query::ResolvedContestedDocumentVotePollDriveQuery; - use drive::query::vote_polls_by_document_type_query::ResolvedVotePollsByDocumentTypeQuery; - use simple_signer::signer::SimpleSigner; - use crate::platform_types::platform_state::PlatformState; - use crate::rpc::core::MockCoreRPCLike; - use crate::test::helpers::setup::TempPlatform; - use dpp::serialization::PlatformDeserializable; - use drive::query::VotePollsByEndDateDriveQuery; - use crate::platform_types::platform_state::v0::PlatformStateV0Methods; - use dpp::block::extended_block_info::v0::ExtendedBlockInfoV0; - use dpp::platform_value::IdentifierBytes32; - use dpp::platform_value::Value::Text; fn setup_masternode_identity( platform: &mut TempPlatform, @@ -2799,5 +2783,333 @@ mod tests { ); } } + + mod prefunded_specialized_balance { + use super::*; + use dapi_grpc::platform::v0::get_prefunded_specialized_balance_response; + use dapi_grpc::platform::v0::get_prefunded_specialized_balance_response::{ + get_prefunded_specialized_balance_response_v0, + GetPrefundedSpecializedBalanceResponseV0, + }; + use dpp::fee::Credits; + use drive::drive::Drive; + + fn get_specialized_balance( + platform: &TempPlatform, + platform_state: &PlatformState, + dpns_contract: &DataContract, + name: &str, + platform_version: &PlatformVersion, + ) -> Credits { + let vote_poll = ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { + contract: DataContractResolvedInfo::BorrowedDataContract(dpns_contract), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![ + Value::Text("dash".to_string()), + Value::Text(convert_to_homograph_safe_chars(name)), + ], + }; + + let specialized_balance_response = platform + .query_prefunded_specialized_balance( + GetPrefundedSpecializedBalanceRequest { + version: Some(get_prefunded_specialized_balance_request::Version::V0( + GetPrefundedSpecializedBalanceRequestV0 { + id: vote_poll + .specialized_balance_id() + .expect("expected a specialized balance id") + .to_vec(), + prove: false, + }, + )), + }, + platform_state, + platform_version, + ) + .expect("expected to be able to query specialized balance") + .into_data() + .expect("expected that the query would execute successfully"); + + let get_prefunded_specialized_balance_response::Version::V0( + GetPrefundedSpecializedBalanceResponseV0 { + metadata: _, + result, + }, + ) = specialized_balance_response + .version + .expect("expected a version"); + + let Some(get_prefunded_specialized_balance_response_v0::Result::Balance(balance)) = + result + else { + panic!("expected balance") + }; + balance + } + + fn get_proved_specialized_balance( + platform: &TempPlatform, + platform_state: &PlatformState, + dpns_contract: &DataContract, + name: &str, + platform_version: &PlatformVersion, + ) -> Credits { + let vote_poll = ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { + contract: DataContractResolvedInfo::BorrowedDataContract(dpns_contract), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![ + Value::Text("dash".to_string()), + Value::Text(convert_to_homograph_safe_chars(name)), + ], + }; + + let balance_id = vote_poll + .specialized_balance_id() + .expect("expected a specialized balance id"); + + let specialized_balance_response = platform + .query_prefunded_specialized_balance( + GetPrefundedSpecializedBalanceRequest { + version: Some(get_prefunded_specialized_balance_request::Version::V0( + GetPrefundedSpecializedBalanceRequestV0 { + id: balance_id.to_vec(), + prove: true, + }, + )), + }, + platform_state, + platform_version, + ) + .expect("expected to be able to query specialized balance") + .into_data() + .expect("expected that the query would execute successfully"); + + let get_prefunded_specialized_balance_response::Version::V0( + GetPrefundedSpecializedBalanceResponseV0 { + metadata: _, + result, + }, + ) = specialized_balance_response + .version + .expect("expected a version"); + + let Some(get_prefunded_specialized_balance_response_v0::Result::Proof(proof)) = + result + else { + panic!("expected balance") + }; + + Drive::verify_specialized_balance( + proof.grovedb_proof.as_slice(), + balance_id.to_buffer(), + false, + platform_version, + ) + .expect("expected to verify balance") + .1 + .expect("expected balance to exist") + } + + #[test] + fn test_non_proved_prefunded_specialized_balance_request_after_many_votes() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + let start_balance = get_specialized_balance( + &platform, + &platform_state, + dpns_contract.as_ref(), + "quantum", + platform_version, + ); + + assert_eq!(start_balance, dash_to_credits!(0.4)); + + let (contender_3, contender_4, _) = create_dpns_name_contest( + &mut platform, + &platform_state, + 9, + "quantum", + platform_version, + ); + + let start_balance_after_more_contenders = get_specialized_balance( + &platform, + &platform_state, + dpns_contract.as_ref(), + "quantum", + platform_version, + ); + + assert_eq!(start_balance_after_more_contenders, dash_to_credits!(0.8)); + + for i in 0..50 { + let (masternode, signer, voting_key) = + setup_masternode_identity(&mut platform, 10 + i, platform_version); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + contender_1.id(), + "quantum", + &signer, + masternode.id(), + &voting_key, + platform_version, + ); + } + + let balance_after_50_votes = get_specialized_balance( + &platform, + &platform_state, + dpns_contract.as_ref(), + "quantum", + platform_version, + ); + + assert_eq!(balance_after_50_votes, dash_to_credits!(0.795)); + + for i in 0..5 { + let (masternode, signer, voting_key) = + setup_masternode_identity(&mut platform, 100 + i, platform_version); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + contender_2.id(), + "quantum", + &signer, + masternode.id(), + &voting_key, + platform_version, + ); + } + + let balance_after_55_votes = get_specialized_balance( + &platform, + &platform_state, + dpns_contract.as_ref(), + "quantum", + platform_version, + ); + + assert_eq!(balance_after_55_votes, dash_to_credits!(0.7945)); + } + #[test] + fn test_proved_prefunded_specialized_balance_request_after_many_votes() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + let start_balance = get_proved_specialized_balance( + &platform, + &platform_state, + dpns_contract.as_ref(), + "quantum", + platform_version, + ); + + assert_eq!(start_balance, dash_to_credits!(0.4)); + + let (contender_3, contender_4, _) = create_dpns_name_contest( + &mut platform, + &platform_state, + 9, + "quantum", + platform_version, + ); + + let start_balance_after_more_contenders = get_proved_specialized_balance( + &platform, + &platform_state, + dpns_contract.as_ref(), + "quantum", + platform_version, + ); + + assert_eq!(start_balance_after_more_contenders, dash_to_credits!(0.8)); + + for i in 0..50 { + let (masternode, signer, voting_key) = + setup_masternode_identity(&mut platform, 10 + i, platform_version); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + contender_1.id(), + "quantum", + &signer, + masternode.id(), + &voting_key, + platform_version, + ); + } + + let balance_after_50_votes = get_proved_specialized_balance( + &platform, + &platform_state, + dpns_contract.as_ref(), + "quantum", + platform_version, + ); + + assert_eq!(balance_after_50_votes, dash_to_credits!(0.795)); + + for i in 0..5 { + let (masternode, signer, voting_key) = + setup_masternode_identity(&mut platform, 100 + i, platform_version); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + contender_2.id(), + "quantum", + &signer, + masternode.id(), + &voting_key, + platform_version, + ); + } + + let balance_after_55_votes = get_proved_specialized_balance( + &platform, + &platform_state, + dpns_contract.as_ref(), + "quantum", + platform_version, + ); + + assert_eq!(balance_after_55_votes, dash_to_credits!(0.7945)); + } + } } } diff --git a/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs b/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs index a935ebce7a..148ecc5381 100644 --- a/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs +++ b/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs @@ -15,7 +15,7 @@ impl DriveHighLevelOperationConverter for MasternodeVoteTransitionAction { fn into_high_level_drive_operations<'a>( self, _epoch: &Epoch, - _platform_version: &PlatformVersion, + platform_version: &PlatformVersion, ) -> Result>, Error> { let pro_tx_hash = self.pro_tx_hash(); let nonce = self.nonce(); @@ -35,7 +35,10 @@ impl DriveHighLevelOperationConverter for MasternodeVoteTransitionAction { PrefundedSpecializedBalanceOperation( PrefundedSpecializedBalanceOperationType::DeductFromPrefundedBalance { prefunded_specialized_balance_id, - remove_balance: 0, + remove_balance: platform_version + .fee_version + .vote_resolution_fund_fees + .contested_document_single_vote_cost, }, ), ]; diff --git a/packages/rs-drive/src/drive/verify/voting/mod.rs b/packages/rs-drive/src/drive/verify/voting/mod.rs index ea26ef8061..aeac87e832 100644 --- a/packages/rs-drive/src/drive/verify/voting/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/mod.rs @@ -1,5 +1,6 @@ mod verify_contests_proof; mod verify_masternode_vote; +mod verify_specialized_balance; mod verify_vote_poll_vote_state_proof; mod verify_vote_polls_end_date_query; // mod verify_start_at_contender_in_proof; diff --git a/packages/rs-drive/src/drive/verify/voting/verify_specialized_balance/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_specialized_balance/mod.rs new file mode 100644 index 0000000000..5cf1908498 --- /dev/null +++ b/packages/rs-drive/src/drive/verify/voting/verify_specialized_balance/mod.rs @@ -0,0 +1,62 @@ +mod v0; + +use crate::drive::Drive; + +use crate::error::drive::DriveError; + +use crate::error::Error; + +use crate::drive::verify::RootHash; + +use dpp::version::PlatformVersion; + +impl Drive { + /// Verifies the balance of an specialized balance. + /// + /// # Parameters + /// + /// - `proof`: A byte slice representing the proof of authentication from the user. + /// - `specialized_balance_id`: A 32-byte array representing the specialized balance. A method for getting this exists on vote polls. + /// - `verify_subset_of_proof`: A boolean indicating whether we are verifying a subset of a larger proof. + /// - `platform_version`: The platform version against which to verify the identity balance. + /// + /// # Returns + /// + /// If the verification is successful, it returns a `Result` with a tuple of `RootHash` and + /// an `Option`. The `RootHash` represents the root hash of GroveDB, and the + /// `Option` represents the balance of the user's identity if it exists. + /// + /// # Errors + /// + /// Returns an `Error` if: + /// + /// - The proof of authentication is not valid. + /// - The identity ID does not correspond to a valid balance. + /// - An unknown or unsupported platform version is provided. + /// + pub fn verify_specialized_balance( + proof: &[u8], + specialized_balance_id: [u8; 32], + verify_subset_of_proof: bool, + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Option), Error> { + match platform_version + .drive + .methods + .verify + .voting + .verify_specialized_balance + { + 0 => Self::verify_specialized_balance_v0( + proof, + specialized_balance_id, + verify_subset_of_proof, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "verify_specialized_balance".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/verify/voting/verify_specialized_balance/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_specialized_balance/v0/mod.rs new file mode 100644 index 0000000000..d72996c318 --- /dev/null +++ b/packages/rs-drive/src/drive/verify/voting/verify_specialized_balance/v0/mod.rs @@ -0,0 +1,84 @@ +use crate::drive::Drive; + +use crate::error::proof::ProofError; +use crate::error::Error; + +use crate::drive::verify::RootHash; + +use crate::drive::prefunded_specialized_balances::prefunded_specialized_balances_for_voting_path_vec; +use grovedb::{GroveDb, PathQuery}; + +impl Drive { + /// Verifies the balance of an identity by their identity ID. + /// + /// `verify_subset_of_proof` is used to indicate if we want to verify a subset of a bigger proof. + /// For example, if the proof can prove the balance and the revision, but here we are only interested + /// in verifying the balance. + /// + /// # Parameters + /// + /// - `proof`: A byte slice representing the proof of authentication from the user. + /// - `identity_id`: A 32-byte array representing the identity ID of the user. + /// - `verify_subset_of_proof`: A boolean indicating whether we are verifying a subset of a larger proof. + /// + /// # Returns + /// + /// If the verification is successful, it returns a `Result` with a tuple of `RootHash` and + /// an `Option`. The `RootHash` represents the root hash of GroveDB, and the + /// `Option` represents the balance of the user's identity if it exists. + /// + /// # Errors + /// + /// Returns an `Error` if: + /// + /// - The proof of authentication is not valid. + /// - The identity ID does not correspond to a valid balance. + /// - The proved key value is not for the correct path or key in balances. + /// - More than one balance is found. + /// + pub(super) fn verify_specialized_balance_v0( + proof: &[u8], + balance_id: [u8; 32], + verify_subset_of_proof: bool, + ) -> Result<(RootHash, Option), Error> { + let balance_path = prefunded_specialized_balances_for_voting_path_vec(); + let mut path_query = PathQuery::new_single_key(balance_path.clone(), balance_id.to_vec()); + path_query.query.limit = Some(1); + let (root_hash, mut proved_key_values) = if verify_subset_of_proof { + GroveDb::verify_subset_query_with_absence_proof(proof, &path_query)? + } else { + GroveDb::verify_query_with_absence_proof(proof, &path_query)? + }; + if proved_key_values.len() == 1 { + let (path, key, maybe_element) = &proved_key_values.remove(0); + if path != &balance_path { + return Err(Error::Proof(ProofError::CorruptedProof( + "we did not get back an element for the correct path in balances".to_string(), + ))); + } + if key != &balance_id { + return Err(Error::Proof(ProofError::CorruptedProof( + "we did not get back an element for the correct key in balances".to_string(), + ))); + } + + let signed_balance = maybe_element + .as_ref() + .map(|element| { + element + .as_sum_item_value() + .map_err(Error::GroveDB)? + .try_into() + .map_err(|_| { + Error::Proof(ProofError::IncorrectValueSize("value size is incorrect")) + }) + }) + .transpose()?; + Ok((root_hash, signed_balance)) + } else { + Err(Error::Proof(ProofError::TooManyElements( + "expected one specialized balance", + ))) + } + } +} diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index fae65e432c..38960515ec 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -116,6 +116,7 @@ pub struct DriveVerifyVoteMethodVersions { pub verify_vote_poll_vote_state_proof: FeatureVersion, pub verify_contests_proof: FeatureVersion, pub verify_vote_polls_by_end_date_proof: FeatureVersion, + pub verify_specialized_balance: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/mod.rs b/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/mod.rs index 67ec4225a9..37009a7acc 100644 --- a/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/mod.rs +++ b/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/mod.rs @@ -2,5 +2,7 @@ pub mod v1; #[derive(Clone, Debug, Default)] pub struct VoteResolutionFundFees { /// This is the amount that will be deducted from an identity and used to pay for voting - pub conflicting_vote_resolution_fund_required_amount: u64, + pub contested_document_vote_resolution_fund_required_amount: u64, + /// This is the amount that a single vote will cost + pub contested_document_single_vote_cost: u64, } diff --git a/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs b/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs index 02c7e8b3c0..afb8230a89 100644 --- a/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs +++ b/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs @@ -1,5 +1,6 @@ use crate::version::fee::vote_resolution_fund_fees::VoteResolutionFundFees; pub const VOTE_RESOLUTION_FUND_FEES_VERSION1: VoteResolutionFundFees = VoteResolutionFundFees { - conflicting_vote_resolution_fund_required_amount: 20000000000, // 0.2 Dash + contested_document_vote_resolution_fund_required_amount: 20000000000, // 0.2 Dash + contested_document_single_vote_cost: 10000000, // 0.0001 Dash }; diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 7fe2e777a6..52c79ede15 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -317,6 +317,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { verify_vote_poll_vote_state_proof: 0, verify_contests_proof: 0, verify_vote_polls_by_end_date_proof: 0, + verify_specialized_balance: 0, }, state_transition: DriveVerifyStateTransitionMethodVersions { verify_state_transition_was_executed_with_proof: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 04fcb5ccaf..658f6ebabc 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -325,6 +325,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { verify_vote_poll_vote_state_proof: 0, verify_contests_proof: 0, verify_vote_polls_by_end_date_proof: 0, + verify_specialized_balance: 0, }, state_transition: DriveVerifyStateTransitionMethodVersions { verify_state_transition_was_executed_with_proof: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 0c45caffb1..899231d0d1 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -316,6 +316,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { verify_vote_poll_vote_state_proof: 0, verify_contests_proof: 0, verify_vote_polls_by_end_date_proof: 0, + verify_specialized_balance: 0, }, state_transition: DriveVerifyStateTransitionMethodVersions { verify_state_transition_was_executed_with_proof: 0, From 7d77413086794b4cc85be6cdcb0cc9fc460bc024 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Thu, 30 May 2024 02:34:15 +0200 Subject: [PATCH 100/135] query contender votes --- .../state_transitions/masternode_vote/mod.rs | 364 +++++++++++++++++- .../rs-drive/src/drive/verify/voting/mod.rs | 1 + .../verify_vote_poll_votes_proof/mod.rs | 55 +++ .../verify_vote_poll_votes_proof/v0/mod.rs | 48 +++ .../query/vote_poll_contestant_votes_query.rs | 2 +- .../src/version/drive_versions.rs | 1 + .../src/version/mocks/v2_test.rs | 1 + .../src/version/mocks/v3_test.rs | 1 + .../rs-platform-version/src/version/v1.rs | 1 + 9 files changed, 472 insertions(+), 2 deletions(-) create mode 100644 packages/rs-drive/src/drive/verify/voting/verify_vote_poll_votes_proof/mod.rs create mode 100644 packages/rs-drive/src/drive/verify/voting/verify_vote_poll_votes_proof/v0/mod.rs diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index d6f28abff0..6a56cc8dbb 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -741,7 +741,7 @@ mod tests { mod contests_requests { use super::*; #[test] - fn test_contests_request() { + fn test_not_proved_contests_request() { let platform_version = PlatformVersion::latest(); let mut platform = TestPlatformBuilder::new() .build_with_mock_rpc() @@ -839,6 +839,45 @@ mod tests { }; assert_eq!(contested_resource_values.len(), 2); + } + + #[test] + fn test_proved_contests_request() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (identity_1, identity_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + let (identity_3, identity_4, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 8, + "cooldog", + platform_version, + ); + + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); + + let index_name = "parentNameAndLabel".to_string(); + + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + + let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) + .expect("expected to encode value"); let query_validation_result = platform .query_contested_resources( @@ -1515,6 +1554,329 @@ mod tests { } } + mod contestant_votes_query { + use super::*; + use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_request::GetContestedResourceVotersForIdentityRequestV0; + use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_response::{ + get_contested_resource_voters_for_identity_response_v0, + GetContestedResourceVotersForIdentityResponseV0, + }; + use dapi_grpc::platform::v0::{ + get_contested_resource_voters_for_identity_request, + get_contested_resource_voters_for_identity_response, + GetContestedResourceVotersForIdentityRequest, + }; + use drive::query::vote_poll_contestant_votes_query::ResolvedContestedDocumentVotePollVotesDriveQuery; + #[test] + fn test_non_proved_contestant_votes_query_request() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + let (contender_3, _, _) = create_dpns_name_contest( + &mut platform, + &platform_state, + 9, + "quantum", + platform_version, + ); + + for i in 0..50 { + let (masternode, signer, voting_key) = + setup_masternode_identity(&mut platform, 10 + i, platform_version); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + contender_1.id(), + "quantum", + &signer, + masternode.id(), + &voting_key, + platform_version, + ); + } + + for i in 0..5 { + let (masternode, signer, voting_key) = + setup_masternode_identity(&mut platform, 100 + i, platform_version); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + contender_2.id(), + "quantum", + &signer, + masternode.id(), + &voting_key, + platform_version, + ); + } + + for i in 0..8 { + let (masternode, signer, voting_key) = + setup_masternode_identity(&mut platform, 200 + i, platform_version); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + contender_3.id(), + "quantum", + &signer, + masternode.id(), + &voting_key, + platform_version, + ); + } + + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); + + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + + let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) + .expect("expected to encode the word dash"); + + let quantum_encoded = + bincode::encode_to_vec(Value::Text("quantum".to_string()), config) + .expect("expected to encode the word quantum"); + + let index_name = "parentNameAndLabel".to_string(); + + let query_validation_result = platform + .query_contested_resource_voters_for_identity( + GetContestedResourceVotersForIdentityRequest { + version: Some( + get_contested_resource_voters_for_identity_request::Version::V0( + GetContestedResourceVotersForIdentityRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![ + dash_encoded.clone(), + quantum_encoded.clone(), + ], + contestant_id: contender_1.id().to_vec(), + start_at_identifier_info: None, + count: None, + order_ascending: true, + prove: false, + }, + ), + ), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_voters_for_identity_response::Version::V0( + GetContestedResourceVotersForIdentityResponseV0 { + metadata: _, + result, + }, + ) = query_validation_result.version.expect("expected a version"); + + let Some( + get_contested_resource_voters_for_identity_response_v0::Result::ContestedResourceVoters( + get_contested_resource_voters_for_identity_response_v0::ContestedResourceVoters { + voters, + finished_results, + }, + ), + ) = result + else { + panic!("expected contenders") + }; + + assert!(finished_results); + + assert_eq!(voters.len(), 50); + } + + #[test] + fn test_proved_contestant_votes_query_request() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + let (contender_3, _, _) = create_dpns_name_contest( + &mut platform, + &platform_state, + 9, + "quantum", + platform_version, + ); + + for i in 0..50 { + let (masternode, signer, voting_key) = + setup_masternode_identity(&mut platform, 10 + i, platform_version); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + contender_1.id(), + "quantum", + &signer, + masternode.id(), + &voting_key, + platform_version, + ); + } + + for i in 0..5 { + let (masternode, signer, voting_key) = + setup_masternode_identity(&mut platform, 100 + i, platform_version); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + contender_2.id(), + "quantum", + &signer, + masternode.id(), + &voting_key, + platform_version, + ); + } + + for i in 0..8 { + let (masternode, signer, voting_key) = + setup_masternode_identity(&mut platform, 200 + i, platform_version); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + contender_3.id(), + "quantum", + &signer, + masternode.id(), + &voting_key, + platform_version, + ); + } + + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); + + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + + let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) + .expect("expected to encode the word dash"); + + let quantum_encoded = + bincode::encode_to_vec(Value::Text("quantum".to_string()), config) + .expect("expected to encode the word quantum"); + + let index_name = "parentNameAndLabel".to_string(); + + let query_validation_result = platform + .query_contested_resource_voters_for_identity( + GetContestedResourceVotersForIdentityRequest { + version: Some( + get_contested_resource_voters_for_identity_request::Version::V0( + GetContestedResourceVotersForIdentityRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![ + dash_encoded.clone(), + quantum_encoded.clone(), + ], + contestant_id: contender_1.id().to_vec(), + start_at_identifier_info: None, + count: None, + order_ascending: true, + prove: true, + }, + ), + ), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_voters_for_identity_response::Version::V0( + GetContestedResourceVotersForIdentityResponseV0 { + metadata: _, + result, + }, + ) = query_validation_result.version.expect("expected a version"); + + let Some(get_contested_resource_voters_for_identity_response_v0::Result::Proof( + proof, + )) = result + else { + panic!("expected contenders") + }; + + let resolved_contested_document_vote_poll_drive_query = + ResolvedContestedDocumentVotePollVotesDriveQuery { + vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { + contract: DataContractResolvedInfo::BorrowedDataContract( + &dpns_contract, + ), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![ + Value::Text("dash".to_string()), + Value::Text("quantum".to_string()), + ], + }, + contestant_id: contender_1.id(), + offset: None, + limit: None, + start_at: None, + order_ascending: true, + }; + + let (_, voters) = resolved_contested_document_vote_poll_drive_query + .verify_vote_poll_votes_proof(proof.grovedb_proof.as_ref(), platform_version) + .expect("expected to verify proof"); + + assert_eq!(voters.len(), 50); + } + } + mod end_date_query { use super::*; use dapi_grpc::platform::v0::get_vote_polls_by_end_date_request::get_vote_polls_by_end_date_request_v0; diff --git a/packages/rs-drive/src/drive/verify/voting/mod.rs b/packages/rs-drive/src/drive/verify/voting/mod.rs index aeac87e832..892827e80f 100644 --- a/packages/rs-drive/src/drive/verify/voting/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/mod.rs @@ -2,5 +2,6 @@ mod verify_contests_proof; mod verify_masternode_vote; mod verify_specialized_balance; mod verify_vote_poll_vote_state_proof; +mod verify_vote_poll_votes_proof; mod verify_vote_polls_end_date_query; // mod verify_start_at_contender_in_proof; diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_votes_proof/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_votes_proof/mod.rs new file mode 100644 index 0000000000..92b153cfb0 --- /dev/null +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_votes_proof/mod.rs @@ -0,0 +1,55 @@ +mod v0; + +use crate::drive::verify::RootHash; +use crate::error::drive::DriveError; +use dpp::identifier::Identifier; + +use crate::error::Error; + +use crate::query::vote_poll_contestant_votes_query::ResolvedContestedDocumentVotePollVotesDriveQuery; +use crate::query::vote_poll_vote_state_query::ContenderWithSerializedDocument; +use dpp::version::PlatformVersion; + +impl<'a> ResolvedContestedDocumentVotePollVotesDriveQuery<'a> { + /// Verifies a proof for the vote poll vote state proof. + /// + /// This function takes a byte slice representing the serialized proof, verifies it, and returns a tuple consisting of the root hash + /// and a vector of deserialized contenders. + /// + /// # Arguments + /// + /// * `proof` - A byte slice representing the proof to be verified. + /// * `platform_version` - The platform version against which to verify the proof. + /// + /// # Returns + /// + /// A `Result` containing: + /// * A tuple with the root hash and a vector of deserialized `Document`s if the proof is valid. + /// * An `Error` variant, in case the proof verification fails or a deserialization error occurs. + /// + /// # Errors + /// + /// This function will return an `Error` variant if: + /// 1. The proof verification fails. + /// 2. A deserialization error occurs when parsing the serialized document(s). + pub fn verify_vote_poll_votes_proof( + &self, + proof: &[u8], + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Vec), Error> { + match platform_version + .drive + .methods + .verify + .voting + .verify_vote_poll_votes_proof + { + 0 => self.verify_vote_poll_votes_proof_v0(proof, platform_version), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "verify_vote_poll_votes_proof".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_votes_proof/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_votes_proof/v0/mod.rs new file mode 100644 index 0000000000..f446d66b27 --- /dev/null +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_votes_proof/v0/mod.rs @@ -0,0 +1,48 @@ +use crate::drive::verify::RootHash; +use dpp::identifier::Identifier; +use dpp::platform_value; +use grovedb::{Element, GroveDb}; + +use crate::error::Error; + +use crate::query::vote_poll_contestant_votes_query::ResolvedContestedDocumentVotePollVotesDriveQuery; +use dpp::version::PlatformVersion; + +impl<'a> ResolvedContestedDocumentVotePollVotesDriveQuery<'a> { + /// Verifies a proof for a collection of documents. + /// + /// This function takes a slice of bytes `proof` containing a serialized proof, + /// verifies it, and returns a tuple consisting of the root hash and a vector of deserialized documents. + /// + /// # Arguments + /// + /// * `proof` - A byte slice representing the proof to be verified. + /// * `drive_version` - The current active drive version + /// + /// # Returns + /// + /// A `Result` containing: + /// * A tuple with the root hash and a vector of deserialized `Document`s, if the proof is valid. + /// * An `Error` variant, in case the proof verification fails or deserialization error occurs. + /// + /// # Errors + /// + /// This function will return an `Error` variant if: + /// 1. The proof verification fails. + /// 2. There is a deserialization error when parsing the serialized document(s) into `Document` struct(s). + #[inline(always)] + pub(super) fn verify_vote_poll_votes_proof_v0( + &self, + proof: &[u8], + platform_version: &PlatformVersion, + ) -> Result<(RootHash, Vec), Error> { + let path_query = self.construct_path_query(platform_version)?; + let (root_hash, proved_key_values) = GroveDb::verify_query(proof, &path_query)?; + let voters = proved_key_values + .into_iter() + .map(|(_, voter_id, _)| Identifier::try_from(voter_id)) + .collect::, platform_value::Error>>()?; + + Ok((root_hash, voters)) + } +} diff --git a/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs b/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs index 5f28e42ab7..6d04885222 100644 --- a/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs +++ b/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs @@ -259,7 +259,7 @@ impl<'a> ResolvedContestedDocumentVotePollVotesDriveQuery<'a> { &self, platform_version: &PlatformVersion, ) -> Result { - let mut path = self + let path = self .vote_poll .contender_voting_path(TowardsIdentity(self.contestant_id), platform_version)?; diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 38960515ec..8b7d45eacf 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -113,6 +113,7 @@ pub struct DriveVerifyIdentityMethodVersions { pub struct DriveVerifyVoteMethodVersions { pub verify_masternode_vote: FeatureVersion, pub verify_start_at_contender_in_proof: FeatureVersion, + pub verify_vote_poll_votes_proof: FeatureVersion, pub verify_vote_poll_vote_state_proof: FeatureVersion, pub verify_contests_proof: FeatureVersion, pub verify_vote_polls_by_end_date_proof: FeatureVersion, diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 52c79ede15..f5843437b7 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -314,6 +314,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { voting: DriveVerifyVoteMethodVersions { verify_masternode_vote: 0, verify_start_at_contender_in_proof: 0, + verify_vote_poll_votes_proof: 0, verify_vote_poll_vote_state_proof: 0, verify_contests_proof: 0, verify_vote_polls_by_end_date_proof: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 658f6ebabc..a2af0c0966 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -322,6 +322,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { voting: DriveVerifyVoteMethodVersions { verify_masternode_vote: 0, verify_start_at_contender_in_proof: 0, + verify_vote_poll_votes_proof: 0, verify_vote_poll_vote_state_proof: 0, verify_contests_proof: 0, verify_vote_polls_by_end_date_proof: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 899231d0d1..7b00f2f613 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -313,6 +313,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { voting: DriveVerifyVoteMethodVersions { verify_masternode_vote: 0, verify_start_at_contender_in_proof: 0, + verify_vote_poll_votes_proof: 0, verify_vote_poll_vote_state_proof: 0, verify_contests_proof: 0, verify_vote_polls_by_end_date_proof: 0, From 795e67dc2bee6499cf5ce720b4464135ecef5639 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Thu, 30 May 2024 12:11:57 +0200 Subject: [PATCH 101/135] query contender votes (better) --- .../state_transitions/masternode_vote/mod.rs | 511 +++++++++++++----- 1 file changed, 365 insertions(+), 146 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 6a56cc8dbb..38686e4e92 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -145,6 +145,17 @@ mod tests { use rand::Rng; use dapi_grpc::platform::v0::get_contested_resources_request::GetContestedResourcesRequestV0; use dapi_grpc::platform::v0::get_contested_resources_response::{get_contested_resources_response_v0, GetContestedResourcesResponseV0}; + use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_request::GetContestedResourceVotersForIdentityRequestV0; + use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_response::{ + get_contested_resource_voters_for_identity_response_v0, + GetContestedResourceVotersForIdentityResponseV0, + }; + use dapi_grpc::platform::v0::{ + get_contested_resource_voters_for_identity_request, + get_contested_resource_voters_for_identity_response, + GetContestedResourceVotersForIdentityRequest, + }; + use drive::query::vote_poll_contestant_votes_query::ResolvedContestedDocumentVotePollVotesDriveQuery; mod vote_tests { @@ -1555,18 +1566,199 @@ mod tests { } mod contestant_votes_query { + use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_request::get_contested_resource_voters_for_identity_request_v0; + use dpp::platform_value; use super::*; - use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_request::GetContestedResourceVotersForIdentityRequestV0; - use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_response::{ - get_contested_resource_voters_for_identity_response_v0, - GetContestedResourceVotersForIdentityResponseV0, - }; - use dapi_grpc::platform::v0::{ - get_contested_resource_voters_for_identity_request, - get_contested_resource_voters_for_identity_response, - GetContestedResourceVotersForIdentityRequest, - }; - use drive::query::vote_poll_contestant_votes_query::ResolvedContestedDocumentVotePollVotesDriveQuery; + + fn get_contestant_votes( + platform: &TempPlatform, + platform_state: &PlatformState, + dpns_contract: &DataContract, + contender_id: Identifier, + name: &str, + count: Option, + order_ascending: bool, + start_at_identifier_info: Option< + get_contested_resource_voters_for_identity_request_v0::StartAtIdentifierInfo, + >, + should_be_finished: bool, + platform_version: &PlatformVersion, + ) -> Vec { + + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); + + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + + let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) + .expect("expected to encode the word dash"); + + let quantum_encoded = + bincode::encode_to_vec(Value::Text(convert_to_homograph_safe_chars(name)), config) + .expect("expected to encode the word quantum"); + + let index_name = "parentNameAndLabel".to_string(); + + let query_validation_result = platform + .query_contested_resource_voters_for_identity( + GetContestedResourceVotersForIdentityRequest { + version: Some( + get_contested_resource_voters_for_identity_request::Version::V0( + GetContestedResourceVotersForIdentityRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![ + dash_encoded.clone(), + quantum_encoded.clone(), + ], + contestant_id: contender_id.to_vec(), + start_at_identifier_info, + count, + order_ascending, + prove: false, + }, + ), + ), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_voters_for_identity_response::Version::V0( + GetContestedResourceVotersForIdentityResponseV0 { + metadata: _, + result, + }, + ) = query_validation_result.version.expect("expected a version"); + + let Some( + get_contested_resource_voters_for_identity_response_v0::Result::ContestedResourceVoters( + get_contested_resource_voters_for_identity_response_v0::ContestedResourceVoters { + voters, + finished_results, + }, + ), + ) = result + else { + panic!("expected contenders") + }; + if should_be_finished { + assert!(finished_results); + } + + voters.into_iter().map(Identifier::from_vec).collect::, platform_value::Error>>().expect("expected all voters to be identifiers") + } + + fn get_proved_contestant_votes( + platform: &TempPlatform, + platform_state: &PlatformState, + dpns_contract: &DataContract, + contender_id: Identifier, + name: &str, + count: Option, + order_ascending: bool, + start_at_identifier_info: Option< + get_contested_resource_voters_for_identity_request_v0::StartAtIdentifierInfo, + >, + platform_version: &PlatformVersion, + ) -> Vec { + + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); + + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + + let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) + .expect("expected to encode the word dash"); + + let quantum_encoded = + bincode::encode_to_vec(Value::Text(convert_to_homograph_safe_chars(name)), config) + .expect("expected to encode the word quantum"); + + let index_name = "parentNameAndLabel".to_string(); + + let query_validation_result = platform + .query_contested_resource_voters_for_identity( + GetContestedResourceVotersForIdentityRequest { + version: Some( + get_contested_resource_voters_for_identity_request::Version::V0( + GetContestedResourceVotersForIdentityRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![ + dash_encoded.clone(), + quantum_encoded.clone(), + ], + contestant_id: contender_id.to_vec(), + start_at_identifier_info, + count, + order_ascending, + prove: true, + }, + ), + ), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_voters_for_identity_response::Version::V0( + GetContestedResourceVotersForIdentityResponseV0 { + metadata: _, + result, + }, + ) = query_validation_result.version.expect("expected a version"); + + let Some(get_contested_resource_voters_for_identity_response_v0::Result::Proof( + proof, + )) = result + else { + panic!("expected contenders") + }; + + let resolved_contested_document_vote_poll_drive_query = + ResolvedContestedDocumentVotePollVotesDriveQuery { + vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { + contract: DataContractResolvedInfo::BorrowedDataContract( + &dpns_contract, + ), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![ + Value::Text("dash".to_string()), + Value::Text("quantum".to_string()), + ], + }, + contestant_id: contender_id, + offset: None, + limit: None, + start_at: None, + order_ascending: true, + }; + + let (_, voters) = resolved_contested_document_vote_poll_drive_query + .verify_vote_poll_votes_proof(proof.grovedb_proof.as_ref(), platform_version) + .expect("expected to verify proof"); + + voters + } + + + #[test] fn test_non_proved_contestant_votes_query_request() { let platform_version = PlatformVersion::latest(); @@ -1642,75 +1834,130 @@ mod tests { platform_version, ); } + let voters = get_contestant_votes( + &platform, + &platform_state, + dpns_contract.as_ref(), + contender_1.id(), + "quantum", + None, + true, + None, + true, + platform_version, + ); + assert_eq!(voters.len(), 50); - let domain = dpns_contract - .document_type_for_name("domain") - .expect("expected a profile document type"); + let voters_2 = get_contestant_votes( + &platform, + &platform_state, + dpns_contract.as_ref(), + contender_2.id(), + "quantum", + None, + true, + None, + true, + platform_version, + ); - let config = bincode::config::standard() - .with_big_endian() - .with_no_limit(); + assert_eq!(voters_2.len(), 5); - let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) - .expect("expected to encode the word dash"); + let voters_3 = get_contestant_votes( + &platform, + &platform_state, + dpns_contract.as_ref(), + contender_3.id(), + "quantum", + None, + true, + None, + true, + platform_version, + ); - let quantum_encoded = - bincode::encode_to_vec(Value::Text("quantum".to_string()), config) - .expect("expected to encode the word quantum"); + let mut voters_3_desc = get_contestant_votes( + &platform, + &platform_state, + dpns_contract.as_ref(), + contender_3.id(), + "quantum", + None, + false, + None, + true, + platform_version, + ); - let index_name = "parentNameAndLabel".to_string(); + voters_3_desc.reverse(); - let query_validation_result = platform - .query_contested_resource_voters_for_identity( - GetContestedResourceVotersForIdentityRequest { - version: Some( - get_contested_resource_voters_for_identity_request::Version::V0( - GetContestedResourceVotersForIdentityRequestV0 { - contract_id: dpns_contract.id().to_vec(), - document_type_name: domain.name().clone(), - index_name: index_name.clone(), - index_values: vec![ - dash_encoded.clone(), - quantum_encoded.clone(), - ], - contestant_id: contender_1.id().to_vec(), - start_at_identifier_info: None, - count: None, - order_ascending: true, - prove: false, - }, - ), - ), - }, + assert_eq!(voters_3, voters_3_desc); + + assert_eq!(voters_3.len(), 8); + + // let's add another 50 votes + for i in 0..50 { + let (masternode, signer, voting_key) = + setup_masternode_identity(&mut platform, 400 + i, platform_version); + + perform_vote( + &mut platform, &platform_state, + dpns_contract.as_ref(), + contender_1.id(), + "quantum", + &signer, + masternode.id(), + &voting_key, platform_version, - ) - .expect("expected to execute query") - .into_data() - .expect("expected query to be valid"); + ); + } - let get_contested_resource_voters_for_identity_response::Version::V0( - GetContestedResourceVotersForIdentityResponseV0 { - metadata: _, - result, - }, - ) = query_validation_result.version.expect("expected a version"); + let voters = get_contestant_votes( + &platform, + &platform_state, + dpns_contract.as_ref(), + contender_1.id(), + "quantum", + None, + true, + None, + true, + platform_version, + ); + assert_eq!(voters.len(), 100); - let Some( - get_contested_resource_voters_for_identity_response_v0::Result::ContestedResourceVoters( - get_contested_resource_voters_for_identity_response_v0::ContestedResourceVoters { - voters, - finished_results, - }, - ), - ) = result - else { - panic!("expected contenders") - }; + // let's add another vote + for i in 0..1 { + let (masternode, signer, voting_key) = + setup_masternode_identity(&mut platform, 500 + i, platform_version); - assert!(finished_results); + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + contender_1.id(), + "quantum", + &signer, + masternode.id(), + &voting_key, + platform_version, + ); + } - assert_eq!(voters.len(), 50); + let voters = get_contestant_votes( + &platform, + &platform_state, + dpns_contract.as_ref(), + contender_1.id(), + "quantum", + None, + true, + None, + false, + platform_version, + ); + assert_eq!(voters.len(), 100); } #[test] @@ -1789,91 +2036,63 @@ mod tests { ); } - let domain = dpns_contract - .document_type_for_name("domain") - .expect("expected a profile document type"); - - let config = bincode::config::standard() - .with_big_endian() - .with_no_limit(); - - let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) - .expect("expected to encode the word dash"); - - let quantum_encoded = - bincode::encode_to_vec(Value::Text("quantum".to_string()), config) - .expect("expected to encode the word quantum"); + let voters_1 = get_proved_contestant_votes( + &platform, + &platform_state, + dpns_contract.as_ref(), + contender_1.id(), + "quantum", + None, + true, + None, + platform_version, + ); - let index_name = "parentNameAndLabel".to_string(); + assert_eq!(voters_1.len(), 50); - let query_validation_result = platform - .query_contested_resource_voters_for_identity( - GetContestedResourceVotersForIdentityRequest { - version: Some( - get_contested_resource_voters_for_identity_request::Version::V0( - GetContestedResourceVotersForIdentityRequestV0 { - contract_id: dpns_contract.id().to_vec(), - document_type_name: domain.name().clone(), - index_name: index_name.clone(), - index_values: vec![ - dash_encoded.clone(), - quantum_encoded.clone(), - ], - contestant_id: contender_1.id().to_vec(), - start_at_identifier_info: None, - count: None, - order_ascending: true, - prove: true, - }, - ), - ), - }, - &platform_state, - platform_version, - ) - .expect("expected to execute query") - .into_data() - .expect("expected query to be valid"); + let voters_2 = get_proved_contestant_votes( + &platform, + &platform_state, + dpns_contract.as_ref(), + contender_2.id(), + "quantum", + None, + true, + None, + platform_version, + ); - let get_contested_resource_voters_for_identity_response::Version::V0( - GetContestedResourceVotersForIdentityResponseV0 { - metadata: _, - result, - }, - ) = query_validation_result.version.expect("expected a version"); + assert_eq!(voters_2.len(), 5); - let Some(get_contested_resource_voters_for_identity_response_v0::Result::Proof( - proof, - )) = result - else { - panic!("expected contenders") - }; + let voters_3 = get_proved_contestant_votes( + &platform, + &platform_state, + dpns_contract.as_ref(), + contender_3.id(), + "quantum", + None, + true, + None, + platform_version, + ); - let resolved_contested_document_vote_poll_drive_query = - ResolvedContestedDocumentVotePollVotesDriveQuery { - vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { - contract: DataContractResolvedInfo::BorrowedDataContract( - &dpns_contract, - ), - document_type_name: domain.name().clone(), - index_name: index_name.clone(), - index_values: vec![ - Value::Text("dash".to_string()), - Value::Text("quantum".to_string()), - ], - }, - contestant_id: contender_1.id(), - offset: None, - limit: None, - start_at: None, - order_ascending: true, - }; + let mut voters_3_desc = get_proved_contestant_votes( + &platform, + &platform_state, + dpns_contract.as_ref(), + contender_3.id(), + "quantum", + None, + false, + None, + platform_version, + ); - let (_, voters) = resolved_contested_document_vote_poll_drive_query - .verify_vote_poll_votes_proof(proof.grovedb_proof.as_ref(), platform_version) - .expect("expected to verify proof"); + voters_3_desc.reverse(); + + assert_eq!(voters_3, voters_3_desc); - assert_eq!(voters.len(), 50); + assert_eq!(voters_3.len(), 8); } } From 03f8ae798dcf638c26e5511e47dfbf6512e23f36 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 31 May 2024 04:35:31 +0200 Subject: [PATCH 102/135] added lock and abstain tree and did more work on identity votes query --- Cargo.lock | 90 ++--- packages/dapi-grpc/build.rs | 4 +- .../protos/platform/v0/platform.proto | 41 ++- packages/rs-dpp/src/errors/protocol_error.rs | 3 + .../vote_choices/resource_vote_choice/mod.rs | 16 +- .../state_transitions/masternode_vote/mod.rs | 314 +++++++++++++++--- packages/rs-drive-abci/src/query/service.rs | 14 +- .../v0/mod.rs | 208 ------------ .../mod.rs | 24 +- .../v0/mod.rs | 181 ++++++++++ .../v0/mod.rs | 3 +- .../rs-drive-abci/src/query/voting/mod.rs | 2 +- packages/rs-drive/src/drive/defaults.rs | 3 + .../v0/mod.rs | 65 +++- .../mod.rs | 0 .../v0/mod.rs | 0 .../mod.rs | 51 +++ .../v0/mod.rs | 124 +++++++ .../drive/document/insert_contested/mod.rs | 5 +- packages/rs-drive/src/drive/votes/mod.rs | 170 ++++++++++ packages/rs-drive/src/drive/votes/paths.rs | 7 + ..._resource_votes_given_by_identity_query.rs | 235 +++++++++++++ packages/rs-drive/src/query/mod.rs | 4 + .../src/version/drive_versions.rs | 1 + .../src/version/mocks/v2_test.rs | 1 + .../src/version/mocks/v3_test.rs | 1 + .../rs-platform-version/src/version/v1.rs | 1 + packages/rs-sdk/src/platform/fetch.rs | 2 +- 28 files changed, 1217 insertions(+), 353 deletions(-) delete mode 100644 packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/v0/mod.rs rename packages/rs-drive-abci/src/query/voting/{contested_resource_identity_vote_status => contested_resource_identity_votes}/mod.rs (75%) create mode 100644 packages/rs-drive-abci/src/query/voting/contested_resource_identity_votes/v0/mod.rs rename packages/rs-drive/src/drive/document/insert_contested/{add_contested_reference_for_index_level_for_contract_operations => add_contested_reference_and_vote_subtree_to_document_operations}/mod.rs (100%) rename packages/rs-drive/src/drive/document/insert_contested/{add_contested_reference_for_index_level_for_contract_operations => add_contested_reference_and_vote_subtree_to_document_operations}/v0/mod.rs (100%) create mode 100644 packages/rs-drive/src/drive/document/insert_contested/add_contested_vote_subtrees_for_non_identities_operations/mod.rs create mode 100644 packages/rs-drive/src/drive/document/insert_contested/add_contested_vote_subtrees_for_non_identities_operations/v0/mod.rs create mode 100644 packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs diff --git a/Cargo.lock b/Cargo.lock index 14c30bf1f9..d74de63da0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,11 +4,11 @@ version = 3 [[package]] name = "addr2line" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ - "gimli", + "gimli 0.29.0", ] [[package]] @@ -307,16 +307,16 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.71" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11" dependencies = [ "addr2line", "cc", "cfg-if", "libc", "miniz_oxide", - "object", + "object 0.35.0", "rustc-demangle", ] @@ -809,9 +809,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.8.0" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a483f3cbf7cec2e153d424d0e92329d816becc6421389bd494375c6065921b9b" +checksum = "f803f94ecf597339c7a34eed2036ef83f86aaba937f001f7c5b5e251f043f1f9" dependencies = [ "glob", "libc", @@ -996,7 +996,7 @@ dependencies = [ "cranelift-control", "cranelift-entity", "cranelift-isle", - "gimli", + "gimli 0.28.1", "hashbrown 0.14.5", "log", "regalloc2", @@ -2174,6 +2174,12 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "gimli" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" + [[package]] name = "glob" version = "0.3.1" @@ -2183,7 +2189,7 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "grovedb" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#2c0712b89eb9e13b70c2772f941832f061d54ac7" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#17e9193b20d4c319b00beea1ae860b2a0c587faa" dependencies = [ "bincode 2.0.0-rc.3", "bitvec", @@ -2206,7 +2212,7 @@ dependencies = [ [[package]] name = "grovedb-costs" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#2c0712b89eb9e13b70c2772f941832f061d54ac7" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#17e9193b20d4c319b00beea1ae860b2a0c587faa" dependencies = [ "integer-encoding", "intmap", @@ -2216,7 +2222,7 @@ dependencies = [ [[package]] name = "grovedb-merk" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#2c0712b89eb9e13b70c2772f941832f061d54ac7" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#17e9193b20d4c319b00beea1ae860b2a0c587faa" dependencies = [ "blake3", "byteorder", @@ -2239,12 +2245,12 @@ dependencies = [ [[package]] name = "grovedb-path" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#2c0712b89eb9e13b70c2772f941832f061d54ac7" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#17e9193b20d4c319b00beea1ae860b2a0c587faa" [[package]] name = "grovedb-storage" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#2c0712b89eb9e13b70c2772f941832f061d54ac7" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#17e9193b20d4c319b00beea1ae860b2a0c587faa" dependencies = [ "blake3", "grovedb-costs", @@ -2263,7 +2269,7 @@ dependencies = [ [[package]] name = "grovedb-visualize" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#2c0712b89eb9e13b70c2772f941832f061d54ac7" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#17e9193b20d4c319b00beea1ae860b2a0c587faa" dependencies = [ "hex", "itertools 0.12.1", @@ -2554,9 +2560,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d8d52be92d09acc2e01dddb7fde3ad983fc6489c7db4837e605bc3fca4cb63e" +checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" dependencies = [ "bytes", "futures-channel", @@ -3196,11 +3202,10 @@ checksum = "9252111cf132ba0929b6f8e030cac2a24b507f3a4d6db6fb2896f27b354c714b" [[package]] name = "native-tls" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" dependencies = [ - "lazy_static", "libc", "log", "openssl", @@ -3383,6 +3388,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "object" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.19.0" @@ -5152,9 +5166,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.37.0" +version = "1.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" dependencies = [ "backtrace", "bytes", @@ -5182,9 +5196,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", @@ -5302,7 +5316,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.8", + "winnow 0.6.9", ] [[package]] @@ -5502,9 +5516,9 @@ checksum = "e2ce481b2b7c2534fe7b5242cccebf37f9084392665c6a3783c414a1bada5432" [[package]] name = "triomphe" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3" +checksum = "1b2cb4fbb9995eeb36ac86fadf24031ccd58f99d6b4b2d7b911db70bddb80d90" [[package]] name = "try-lock" @@ -5846,7 +5860,7 @@ dependencies = [ "indexmap 2.2.6", "libc", "log", - "object", + "object 0.32.2", "once_cell", "paste", "serde", @@ -5884,9 +5898,9 @@ dependencies = [ "cranelift-frontend", "cranelift-native", "cranelift-wasm", - "gimli", + "gimli 0.28.1", "log", - "object", + "object 0.32.2", "target-lexicon", "thiserror", "wasmparser", @@ -5905,8 +5919,8 @@ dependencies = [ "cranelift-codegen", "cranelift-control", "cranelift-native", - "gimli", - "object", + "gimli 0.28.1", + "object 0.32.2", "target-lexicon", "wasmtime-environ", ] @@ -5919,10 +5933,10 @@ checksum = "61eb64fb3e0da883e2df4a13a81d6282e072336e6cb6295021d0f7ab2e352754" dependencies = [ "anyhow", "cranelift-entity", - "gimli", + "gimli 0.28.1", "indexmap 2.2.6", "log", - "object", + "object 0.32.2", "serde", "serde_derive", "target-lexicon", @@ -5940,9 +5954,9 @@ dependencies = [ "anyhow", "bincode 1.3.3", "cfg-if", - "gimli", + "gimli 0.28.1", "log", - "object", + "object 0.32.2", "rustix 0.38.34", "serde", "serde_derive", @@ -6313,9 +6327,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.8" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" +checksum = "86c949fede1d13936a99f14fafd3e76fd642b556dd2ce96287fbe2e0151bfac6" dependencies = [ "memchr", ] diff --git a/packages/dapi-grpc/build.rs b/packages/dapi-grpc/build.rs index 11c43f2863..4ca7d670d7 100644 --- a/packages/dapi-grpc/build.rs +++ b/packages/dapi-grpc/build.rs @@ -70,7 +70,7 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig { "GetContestedResourcesRequest", "GetContestedResourceVoteStateRequest", "GetContestedResourceVotersForIdentityRequest", - "GetContestedResourceIdentityVoteStatusRequest", + "GetContestedResourceIdentityVotesRequest", "GetVotePollsByEndDateRequest", ]; @@ -100,7 +100,7 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig { "GetContestedResourcesResponse", "GetContestedResourceVoteStateResponse", "GetContestedResourceVotersForIdentityResponse", - "GetContestedResourceIdentityVoteStatusResponse", + "GetContestedResourceIdentityVotesResponse", "GetVotePollsByEndDateResponse", ]; diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index 73a59f1a4a..8b8dc9b614 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -41,7 +41,7 @@ service Platform { // Who voted for a contested resource to go to a specific identity? rpc getContestedResourceVotersForIdentity(GetContestedResourceVotersForIdentityRequest) returns (GetContestedResourceVotersForIdentityResponse); // How did an identity vote? - rpc getContestedResourceIdentityVoteStatus(GetContestedResourceIdentityVoteStatusRequest) returns (GetContestedResourceIdentityVoteStatusResponse); + rpc getContestedResourceIdentityVotes(GetContestedResourceIdentityVotesRequest) returns (GetContestedResourceIdentityVotesResponse); // What vote polls will end soon? rpc getVotePollsByEndDate(GetVotePollsByEndDateRequest) returns (GetVotePollsByEndDateResponse); rpc getPrefundedSpecializedBalance(GetPrefundedSpecializedBalanceRequest) returns (GetPrefundedSpecializedBalanceResponse); @@ -822,41 +822,46 @@ message GetContestedResourceVotersForIdentityResponse { } // How did an identity vote? -message GetContestedResourceIdentityVoteStatusRequest { - message GetContestedResourceIdentityVoteStatusRequestV0 { - bool prove = 1; - repeated bytes resource_path = 2; - bytes resource_identifier = 3; - optional bytes voter_identifier = 4; - optional uint32 count = 5; - optional bool ascending = 6; +message GetContestedResourceIdentityVotesRequest { + message GetContestedResourceIdentityVotesRequestV0 { + message StartAtVotePollIdInfo { + bytes start_at_poll_identifier = 1; + bool start_poll_identifier_included = 2; + } + bytes identity_id = 1; + google.protobuf.UInt32Value limit = 2; + google.protobuf.UInt32Value offset = 3; + bool order_ascending = 4; + optional StartAtVotePollIdInfo start_at_vote_poll_id_info = 5; + bool prove = 6; } oneof version { - GetContestedResourceIdentityVoteStatusRequestV0 v0 = 1; + GetContestedResourceIdentityVotesRequestV0 v0 = 1; } } -message GetContestedResourceIdentityVoteStatusResponse { - message GetContestedResourceIdentityVoteStatusResponseV0 { - message ContestedResourceVoters { - repeated Voter voters = 1; +message GetContestedResourceIdentityVotesResponse { + message GetContestedResourceIdentityVotesResponseV0 { + message Votes { + repeated Vote votes = 1; bool finished_results = 2; } - message Voter { - bytes identifier = 1; + message Vote { + // We return a serialized vote + bytes contested_resource_serialized_vote = 1; } oneof result { - ContestedResourceVoters contested_resource_voters = 1; + Votes votes = 1; Proof proof = 2; } ResponseMetadata metadata = 3; } oneof version { - GetContestedResourceIdentityVoteStatusResponseV0 v0 = 1; + GetContestedResourceIdentityVotesResponseV0 v0 = 1; } } diff --git a/packages/rs-dpp/src/errors/protocol_error.rs b/packages/rs-dpp/src/errors/protocol_error.rs index 0c702402b1..2164b339f1 100644 --- a/packages/rs-dpp/src/errors/protocol_error.rs +++ b/packages/rs-dpp/src/errors/protocol_error.rs @@ -137,6 +137,9 @@ pub enum ProtocolError { #[error("Generic Error: {0}")] Generic(String), + #[error("Not supported Error: {0}")] + NotSupported(String), + #[cfg(feature = "message-signing")] #[error("Invalid signing type error: {0}")] InvalidSigningKeyTypeError(String), diff --git a/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs b/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs index d05e5ca9c5..cb397a1c60 100644 --- a/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs +++ b/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs @@ -5,8 +5,8 @@ use serde::{Deserialize, Serialize}; /// A resource votes is a votes determining what we should do with a contested resource. /// For example Alice and Bob both want the username "Malaka" -/// Some would votes for Alice to get it by putting in her Identifier. -/// Some would votes for Bob to get it by putting in Bob's Identifier. +/// Some would vote for Alice to get it by putting in her Identifier. +/// Some would vote for Bob to get it by putting in Bob's Identifier. /// Let's say someone voted, but is now not quite sure of their votes, they can abstain. /// Lock is there to signal that the shared resource should be given to no one. /// In this case Malaka might have a bad connotation in Greek, hence some might votes to Lock @@ -22,17 +22,5 @@ pub enum ResourceVoteChoice { TowardsIdentity(Identifier), #[default] Abstain, - Defer, Lock, } - -impl ResourceVoteChoice { - pub fn to_key(&self) -> Vec { - match self { - ResourceVoteChoice::TowardsIdentity(identity_id) => identity_id.to_vec(), - ResourceVoteChoice::Abstain => vec![128], - ResourceVoteChoice::Defer => vec![129], - ResourceVoteChoice::Lock => vec![130], - } - } -} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 38686e4e92..d4a6869a1c 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -156,10 +156,13 @@ mod tests { GetContestedResourceVotersForIdentityRequest, }; use drive::query::vote_poll_contestant_votes_query::ResolvedContestedDocumentVotePollVotesDriveQuery; + use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_request::get_contested_resource_voters_for_identity_request_v0; + use dpp::platform_value; mod vote_tests { - use super::*; + use dpp::prelude::IdentityNonce; + use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; fn setup_masternode_identity( platform: &mut TempPlatform, @@ -687,11 +690,12 @@ mod tests { platform: &mut TempPlatform, platform_state: &Guard>, dpns_contract: &DataContract, - towards_identity_id: Identifier, + resource_vote_choice: ResourceVoteChoice, name: &str, signer: &SimpleSigner, masternode_id: Identifier, voting_key: &IdentityPublicKey, + nonce: IdentityNonce, platform_version: &PlatformVersion, ) { // Let's vote for contender 1 @@ -708,7 +712,7 @@ mod tests { ], }, ), - resource_vote_choice: TowardsIdentity(towards_identity_id), + resource_vote_choice, })); let masternode_vote_transition = MasternodeVoteTransition::try_from_vote_with_signer( @@ -716,7 +720,7 @@ mod tests { signer, masternode_id, voting_key, - 1, + nonce, platform_version, None, ) @@ -973,11 +977,12 @@ mod tests { &mut platform, &platform_state, dpns_contract.as_ref(), - contender_1.id(), + TowardsIdentity(contender_1.id()), "quantum", &signer_1, masternode_1.id(), &voting_key_1, + 1, platform_version, ); @@ -1108,11 +1113,12 @@ mod tests { &mut platform, &platform_state, dpns_contract.as_ref(), - contender_1.id(), + TowardsIdentity(contender_1.id()), "quantum", &signer_1, masternode_1.id(), &voting_key_1, + 1, platform_version, ); @@ -1263,11 +1269,12 @@ mod tests { &mut platform, &platform_state, dpns_contract.as_ref(), - contender_1.id(), + TowardsIdentity(contender_1.id()), "quantum", &signer, masternode.id(), &voting_key, + 1, platform_version, ); } @@ -1280,11 +1287,12 @@ mod tests { &mut platform, &platform_state, dpns_contract.as_ref(), - contender_2.id(), + TowardsIdentity(contender_2.id()), "quantum", &signer, masternode.id(), &voting_key, + 1, platform_version, ); } @@ -1417,11 +1425,12 @@ mod tests { &mut platform, &platform_state, dpns_contract.as_ref(), - contender_1.id(), + TowardsIdentity(contender_1.id()), "quantum", &signer, masternode.id(), &voting_key, + 1, platform_version, ); } @@ -1434,11 +1443,12 @@ mod tests { &mut platform, &platform_state, dpns_contract.as_ref(), - contender_2.id(), + TowardsIdentity(contender_2.id()), "quantum", &signer, masternode.id(), &voting_key, + 1, platform_version, ); } @@ -1565,11 +1575,9 @@ mod tests { } } - mod contestant_votes_query { - use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_request::get_contested_resource_voters_for_identity_request_v0; - use dpp::platform_value; + mod contestant_received_votes_query { use super::*; - + fn get_contestant_votes( platform: &TempPlatform, platform_state: &PlatformState, @@ -1584,7 +1592,6 @@ mod tests { should_be_finished: bool, platform_version: &PlatformVersion, ) -> Vec { - let domain = dpns_contract .document_type_for_name("domain") .expect("expected a profile document type"); @@ -1596,12 +1603,14 @@ mod tests { let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) .expect("expected to encode the word dash"); - let quantum_encoded = - bincode::encode_to_vec(Value::Text(convert_to_homograph_safe_chars(name)), config) - .expect("expected to encode the word quantum"); + let quantum_encoded = bincode::encode_to_vec( + Value::Text(convert_to_homograph_safe_chars(name)), + config, + ) + .expect("expected to encode the word quantum"); let index_name = "parentNameAndLabel".to_string(); - + let query_validation_result = platform .query_contested_resource_voters_for_identity( GetContestedResourceVotersForIdentityRequest { @@ -1652,8 +1661,12 @@ mod tests { if should_be_finished { assert!(finished_results); } - - voters.into_iter().map(Identifier::from_vec).collect::, platform_value::Error>>().expect("expected all voters to be identifiers") + + voters + .into_iter() + .map(Identifier::from_vec) + .collect::, platform_value::Error>>() + .expect("expected all voters to be identifiers") } fn get_proved_contestant_votes( @@ -1669,7 +1682,6 @@ mod tests { >, platform_version: &PlatformVersion, ) -> Vec { - let domain = dpns_contract .document_type_for_name("domain") .expect("expected a profile document type"); @@ -1681,9 +1693,11 @@ mod tests { let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) .expect("expected to encode the word dash"); - let quantum_encoded = - bincode::encode_to_vec(Value::Text(convert_to_homograph_safe_chars(name)), config) - .expect("expected to encode the word quantum"); + let quantum_encoded = bincode::encode_to_vec( + Value::Text(convert_to_homograph_safe_chars(name)), + config, + ) + .expect("expected to encode the word quantum"); let index_name = "parentNameAndLabel".to_string(); @@ -1724,11 +1738,11 @@ mod tests { ) = query_validation_result.version.expect("expected a version"); let Some(get_contested_resource_voters_for_identity_response_v0::Result::Proof( - proof, - )) = result - else { - panic!("expected contenders") - }; + proof, + )) = result + else { + panic!("expected contenders") + }; let resolved_contested_document_vote_poll_drive_query = ResolvedContestedDocumentVotePollVotesDriveQuery { @@ -1757,8 +1771,6 @@ mod tests { voters } - - #[test] fn test_non_proved_contestant_votes_query_request() { let platform_version = PlatformVersion::latest(); @@ -1792,11 +1804,12 @@ mod tests { &mut platform, &platform_state, dpns_contract.as_ref(), - contender_1.id(), + TowardsIdentity(contender_1.id()), "quantum", &signer, masternode.id(), &voting_key, + 1, platform_version, ); } @@ -1809,11 +1822,12 @@ mod tests { &mut platform, &platform_state, dpns_contract.as_ref(), - contender_2.id(), + TowardsIdentity(contender_2.id()), "quantum", &signer, masternode.id(), &voting_key, + 1, platform_version, ); } @@ -1826,11 +1840,12 @@ mod tests { &mut platform, &platform_state, dpns_contract.as_ref(), - contender_3.id(), + TowardsIdentity(contender_3.id()), "quantum", &signer, masternode.id(), &voting_key, + 1, platform_version, ); } @@ -1904,11 +1919,12 @@ mod tests { &mut platform, &platform_state, dpns_contract.as_ref(), - contender_1.id(), + TowardsIdentity(contender_1.id()), "quantum", &signer, masternode.id(), &voting_key, + 1, platform_version, ); } @@ -1936,11 +1952,12 @@ mod tests { &mut platform, &platform_state, dpns_contract.as_ref(), - contender_1.id(), + TowardsIdentity(contender_1.id()), "quantum", &signer, masternode.id(), &voting_key, + 1, platform_version, ); } @@ -1958,6 +1975,28 @@ mod tests { platform_version, ); assert_eq!(voters.len(), 100); + + let voters_reversed_30 = get_contestant_votes( + &platform, + &platform_state, + dpns_contract.as_ref(), + contender_1.id(), + "quantum", + Some(30), + false, + Some(get_contested_resource_voters_for_identity_request_v0::StartAtIdentifierInfo { + start_identifier: voters.last().expect("expected a last voter").to_vec(), + start_identifier_included: true, + }), + false, + platform_version, + ); + assert_eq!(voters_reversed_30.len(), 30); + + let reversed_last_30_from_100_query: Vec<_> = + voters.split_at(70).1.iter().rev().cloned().collect(); + + assert_eq!(voters_reversed_30, reversed_last_30_from_100_query); } #[test] @@ -1993,11 +2032,12 @@ mod tests { &mut platform, &platform_state, dpns_contract.as_ref(), - contender_1.id(), + TowardsIdentity(contender_1.id()), "quantum", &signer, masternode.id(), &voting_key, + 1, platform_version, ); } @@ -2010,11 +2050,12 @@ mod tests { &mut platform, &platform_state, dpns_contract.as_ref(), - contender_2.id(), + TowardsIdentity(contender_2.id()), "quantum", &signer, masternode.id(), &voting_key, + 1, platform_version, ); } @@ -2027,11 +2068,12 @@ mod tests { &mut platform, &platform_state, dpns_contract.as_ref(), - contender_3.id(), + TowardsIdentity(contender_3.id()), "quantum", &signer, masternode.id(), &voting_key, + 1, platform_version, ); } @@ -2089,13 +2131,191 @@ mod tests { ); voters_3_desc.reverse(); - + assert_eq!(voters_3, voters_3_desc); assert_eq!(voters_3.len(), 8); } } + mod identity_given_votes_query { + use super::*; + use dapi_grpc::platform::v0::get_contested_resource_identity_votes_request::{ + get_contested_resource_identity_votes_request_v0, + GetContestedResourceIdentityVotesRequestV0, + }; + use dapi_grpc::platform::v0::get_contested_resource_identity_votes_response::{ + get_contested_resource_identity_votes_response_v0, + GetContestedResourceIdentityVotesResponseV0, + }; + use dapi_grpc::platform::v0::{ + get_contested_resource_identity_votes_request, + get_contested_resource_identity_votes_response, + GetContestedResourceIdentityVotesRequest, + }; + use dpp::ProtocolError; + + fn get_identity_given_votes( + platform: &TempPlatform, + platform_state: &PlatformState, + identity_id: Identifier, + count: Option, + order_ascending: bool, + start_at_vote_poll_id_info: Option< + get_contested_resource_identity_votes_request_v0::StartAtVotePollIdInfo, + >, + should_be_finished: bool, + platform_version: &PlatformVersion, + ) -> Vec { + let query_validation_result = platform + .query_contested_resource_identity_votes( + GetContestedResourceIdentityVotesRequest { + version: Some( + get_contested_resource_identity_votes_request::Version::V0( + GetContestedResourceIdentityVotesRequestV0 { + identity_id: identity_id.to_vec(), + limit: count, + offset: None, + order_ascending, + start_at_vote_poll_id_info, + prove: false, + }, + ), + ), + }, + &platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_identity_votes_response::Version::V0( + GetContestedResourceIdentityVotesResponseV0 { + metadata: _, + result, + }, + ) = query_validation_result.version.expect("expected a version"); + + let Some(get_contested_resource_identity_votes_response_v0::Result::Votes( + get_contested_resource_identity_votes_response_v0::Votes { + votes, + finished_results, + }, + )) = result + else { + panic!("expected contenders") + }; + if should_be_finished { + assert!(finished_results); + } + + votes + .iter() + .map(|vote| { + ResourceVote::deserialize_from_bytes( + vote.contested_resource_serialized_vote.as_slice(), + ) + }) + .collect::, ProtocolError>>() + .expect("expected all voters to be identifiers") + } + + #[test] + fn test_not_proved_identity_given_votes_query_request() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1_quantum, contender_2_quantum, dpns_contract) = + create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + let (contender_1_cooldog, contender_2_cooldog, dpns_contract) = + create_dpns_name_contest( + &mut platform, + &platform_state, + 8, + "cooldog", + platform_version, + ); + + let (contender_1_superman, contender_2_superman, dpns_contract) = + create_dpns_name_contest( + &mut platform, + &platform_state, + 9, + "superman", + platform_version, + ); + + let (masternode, signer, voting_key) = + setup_masternode_identity(&mut platform, 10, platform_version); + + // Now let's perform a few votes + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + TowardsIdentity(contender_1_quantum.id()), + "quantum", + &signer, + masternode.id(), + &voting_key, + 1, + platform_version, + ); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + TowardsIdentity(contender_2_cooldog.id()), + "cooldog", + &signer, + masternode.id(), + &voting_key, + 2, + platform_version, + ); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + ResourceVoteChoice::Lock, + "superman", + &signer, + masternode.id(), + &voting_key, + 3, + platform_version, + ); + + let votes = get_identity_given_votes( + &platform, + &platform_state, + masternode.id(), + None, + true, + None, + true, + platform_version, + ); + + assert_eq!(votes.len(), 3) + } + } + mod end_date_query { use super::*; use dapi_grpc::platform::v0::get_vote_polls_by_end_date_request::get_vote_polls_by_end_date_request_v0; @@ -3546,11 +3766,12 @@ mod tests { &mut platform, &platform_state, dpns_contract.as_ref(), - contender_1.id(), + TowardsIdentity(contender_1.id()), "quantum", &signer, masternode.id(), &voting_key, + 1, platform_version, ); } @@ -3573,11 +3794,12 @@ mod tests { &mut platform, &platform_state, dpns_contract.as_ref(), - contender_2.id(), + TowardsIdentity(contender_2.id()), "quantum", &signer, masternode.id(), &voting_key, + 1, platform_version, ); } @@ -3645,11 +3867,12 @@ mod tests { &mut platform, &platform_state, dpns_contract.as_ref(), - contender_1.id(), + TowardsIdentity(contender_1.id()), "quantum", &signer, masternode.id(), &voting_key, + 1, platform_version, ); } @@ -3672,11 +3895,12 @@ mod tests { &mut platform, &platform_state, dpns_contract.as_ref(), - contender_2.id(), + TowardsIdentity(contender_2.id()), "quantum", &signer, masternode.id(), &voting_key, + 1, platform_version, ); } diff --git a/packages/rs-drive-abci/src/query/service.rs b/packages/rs-drive-abci/src/query/service.rs index a2c4525016..3c7b147ea0 100644 --- a/packages/rs-drive-abci/src/query/service.rs +++ b/packages/rs-drive-abci/src/query/service.rs @@ -11,8 +11,8 @@ use async_trait::async_trait; use dapi_grpc::platform::v0::platform_server::Platform as PlatformService; use dapi_grpc::platform::v0::{ BroadcastStateTransitionRequest, BroadcastStateTransitionResponse, GetConsensusParamsRequest, - GetConsensusParamsResponse, GetContestedResourceIdentityVoteStatusRequest, - GetContestedResourceIdentityVoteStatusResponse, GetContestedResourceVoteStateRequest, + GetConsensusParamsResponse, GetContestedResourceIdentityVotesRequest, + GetContestedResourceIdentityVotesResponse, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetContestedResourceVotersForIdentityRequest, GetContestedResourceVotersForIdentityResponse, GetContestedResourcesRequest, GetContestedResourcesResponse, GetDataContractHistoryRequest, GetDataContractHistoryResponse, @@ -497,14 +497,14 @@ impl PlatformService for QueryService { .await } - async fn get_contested_resource_identity_vote_status( + async fn get_contested_resource_identity_votes( &self, - request: Request, - ) -> Result, Status> { + request: Request, + ) -> Result, Status> { self.handle_blocking_query( request, - Platform::::query_contested_resource_identity_vote_status, - "get_contested_resource_identity_vote_status", + Platform::::query_contested_resource_identity_votes, + "get_contested_resource_identity_votes", ) .await } diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/v0/mod.rs deleted file mode 100644 index 22b867fc6e..0000000000 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/v0/mod.rs +++ /dev/null @@ -1,208 +0,0 @@ -use crate::error::query::QueryError; -use crate::error::Error; -use crate::platform_types::platform::Platform; -use crate::platform_types::platform_state::PlatformState; -use crate::query::QueryValidationResult; -use dapi_grpc::platform::v0::get_contested_resource_identity_vote_status_request::GetContestedResourceIdentityVoteStatusRequestV0; -use dapi_grpc::platform::v0::get_contested_resource_identity_vote_status_response::{ - get_contested_resource_identity_vote_status_response_v0, - GetContestedResourceIdentityVoteStatusResponseV0, -}; -use dpp::data_contract::accessors::v0::DataContractV0Getters; -use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; -use dpp::identifier::Identifier; -use dpp::validation::ValidationResult; -use dpp::version::PlatformVersion; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; -use dpp::{check_validation_result_with_data, platform_value}; -use drive::error::query::QuerySyntaxError; - -impl Platform { - pub(super) fn query_contested_resource_identity_vote_status_v0( - &self, - GetContestedResourceIdentityVoteStatusRequestV0 { - prove, - resource_path, - resource_identifier, - voter_identifier, - count, - ascending, - }: GetContestedResourceIdentityVoteStatusRequestV0, - platform_state: &PlatformState, - platform_version: &PlatformVersion, - ) -> Result, Error> - { - todo!() - // let config = &self.config.drive; - // let contract_id: Identifier = - // check_validation_result_with_data!(contract_id.try_into().map_err(|_| { - // QueryError::InvalidArgument( - // "contract_id must be a valid identifier (32 bytes long)".to_string(), - // ) - // })); - // - // let (_, contract) = self.drive.get_contract_with_fetch_info_and_fee( - // contract_id.to_buffer(), - // None, - // true, - // None, - // platform_version, - // )?; - // - // let contract = check_validation_result_with_data!(contract.ok_or(QueryError::Query( - // QuerySyntaxError::DataContractNotFound( - // "contract not found when querying from value with contract info", - // ) - // ))); - // - // let contract_ref = &contract.contract; - // - // let document_type = check_validation_result_with_data!(contract_ref - // .document_type_for_name(document_type_name.as_str()) - // .map_err(|_| QueryError::InvalidArgument(format!( - // "document type {} not found for contract {}", - // document_type_name, contract_id - // )))); - // - // let index = check_validation_result_with_data!(document_type.find_contested_index().ok_or( - // QueryError::InvalidArgument(format!( - // "document type {} does not have a contested index", - // document_type_name - // )) - // )); - // - // if &index.name != &index_name { - // return Ok(QueryValidationResult::new_with_error(QueryError::InvalidArgument(format!( - // "index with name {} is not the contested index on the document type {}, {} is the name of the only contested index", - // index_name, document_type_name, index.name - // )))); - // } - // - // let index_values = match index_values - // .into_iter() - // .enumerate() - // .map(|(pos, serialized_value)| { - // Ok(bincode::decode_from_slice( - // serialized_value.as_slice(), - // bincode::config::standard() - // .with_big_endian() - // .with_no_limit(), - // ) - // .map_err(|_| { - // QueryError::InvalidArgument(format!( - // "could not convert {:?} to a value in the index values at position {}", - // serialized_value, pos - // )) - // })? - // .0) - // }) - // .collect::, QueryError>>() - // { - // Ok(index_values) => index_values, - // Err(e) => return Ok(QueryValidationResult::new_with_error(e)), - // }; - // - // let vote_poll = ContestedDocumentResourceVotePoll { - // contract_id, - // document_type_name, - // index_name, - // index_values, - // } - // .into(); - // - // let limit = count - // .map_or(Some(config.default_query_limit), |limit_value| { - // if limit_value == 0 - // || limit_value > u16::MAX as u32 - // || limit_value as u16 > config.default_query_limit - // { - // None - // } else { - // Some(limit_value as u16) - // } - // }) - // .ok_or(drive::error::Error::Query(QuerySyntaxError::InvalidLimit( - // format!("limit greater than max limit {}", config.max_query_limit), - // )))?; - // - // let query = ContestedDocumentVotePollDriveQuery { - // vote_poll, - // result_type: result_type.try_into()?, - // offset: None, - // limit: Some(limit), - // start_at: start_at_identifier_info - // .map(|start_at_identifier_info| { - // Ok::<([u8; 32], bool), platform_value::Error>(( - // Identifier::from_vec(start_at_identifier_info.start_identifier)? - // .to_buffer(), - // start_at_identifier_info.start_identifier_included, - // )) - // }) - // .transpose()?, - // order_ascending, - // }; - // - // let response = if prove { - // let proof = match query.execute_with_proof(&self.drive, None, None, platform_version) { - // Ok(result) => result.0, - // Err(drive::error::Error::Query(query_error)) => { - // return Ok(QueryValidationResult::new_with_error(QueryError::Query( - // query_error, - // ))); - // } - // Err(e) => return Err(e.into()), - // }; - // - // GetContestedResourceIdentityVoteStatusResponseV0 { - // result: Some( - // get_contested_resource_identity_vote_status_response_v0::Result::Proof( - // self.response_proof_v0(platform_state, proof), - // ), - // ), - // metadata: Some(self.response_metadata_v0(platform_state)), - // } - // } else { - // let results = - // match query.execute_no_proof(&self.drive, None, &mut vec![], platform_version) { - // Ok(result) => result, - // Err(drive::error::Error::Query(query_error)) => { - // return Ok(QueryValidationResult::new_with_error(QueryError::Query( - // query_error, - // ))); - // } - // Err(e) => return Err(e.into()), - // }; - // - // let contenders = results - // .contenders - // .into_iter() - // .map( - // |Contender { - // identity_id, - // serialized_document, - // vote_tally, - // }| { - // get_contested_resource_identity_vote_status_response_v0::Contender { - // identifier: identity_id.to_vec(), - // vote_count: vote_tally, - // document: serialized_document, - // } - // }, - // ) - // .collect(); - // - // GetContestedResourceIdentityVoteStatusResponseV0 { - // result: Some( - // get_contested_resource_identity_vote_status_response_v0::Result::ContestedResourceContenders( - // get_contested_resource_identity_vote_status_response_v0::ContestedResourceContenders { - // contenders - // }, - // ), - // ), - // metadata: Some(self.response_metadata_v0(platform_state)), - // } - // }; - // - // Ok(QueryValidationResult::new_with_data(response)) - } -} diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_votes/mod.rs similarity index 75% rename from packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/mod.rs rename to packages/rs-drive-abci/src/query/voting/contested_resource_identity_votes/mod.rs index 21ae44f78d..d5d8f68792 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_identity_vote_status/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_votes/mod.rs @@ -3,10 +3,10 @@ use crate::error::Error; use crate::platform_types::platform::Platform; use crate::platform_types::platform_state::PlatformState; use crate::query::QueryValidationResult; -use dapi_grpc::platform::v0::get_contested_resource_identity_vote_status_request::Version as RequestVersion; -use dapi_grpc::platform::v0::get_contested_resource_identity_vote_status_response::Version as ResponseVersion; +use dapi_grpc::platform::v0::get_contested_resource_identity_votes_request::Version as RequestVersion; +use dapi_grpc::platform::v0::get_contested_resource_identity_votes_response::Version as ResponseVersion; use dapi_grpc::platform::v0::{ - GetContestedResourceIdentityVoteStatusRequest, GetContestedResourceIdentityVoteStatusResponse, + GetContestedResourceIdentityVotesRequest, GetContestedResourceIdentityVotesResponse, }; use dpp::version::PlatformVersion; @@ -14,12 +14,12 @@ mod v0; impl Platform { /// Querying of a how an identity voted for a specific contested resource - pub fn query_contested_resource_identity_vote_status( + pub fn query_contested_resource_identity_votes( &self, - GetContestedResourceIdentityVoteStatusRequest { version }: GetContestedResourceIdentityVoteStatusRequest, + GetContestedResourceIdentityVotesRequest { version }: GetContestedResourceIdentityVotesRequest, platform_state: &PlatformState, platform_version: &PlatformVersion, - ) -> Result, Error> { + ) -> Result, Error> { let Some(version) = version else { return Ok(QueryValidationResult::new_with_error( QueryError::DecodingError( @@ -40,7 +40,7 @@ impl Platform { if !feature_version_bounds.check_version(feature_version) { return Ok(QueryValidationResult::new_with_error( QueryError::UnsupportedQueryVersion( - "query_contested_resource_identity_vote_status".to_string(), + "query_contested_resource_identity_votes".to_string(), feature_version_bounds.min_version, feature_version_bounds.max_version, platform_version.protocol_version, @@ -50,17 +50,17 @@ impl Platform { } match version { RequestVersion::V0(request_v0) => { - let result = self.query_contested_resource_identity_vote_status_v0( + let result = self.query_contested_resource_identity_votes_v0( request_v0, platform_state, platform_version, )?; - Ok(result.map( - |response_v0| GetContestedResourceIdentityVoteStatusResponse { + Ok( + result.map(|response_v0| GetContestedResourceIdentityVotesResponse { version: Some(ResponseVersion::V0(response_v0)), - }, - )) + }), + ) } } } diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_identity_votes/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_votes/v0/mod.rs new file mode 100644 index 0000000000..f7f1ad388a --- /dev/null +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_votes/v0/mod.rs @@ -0,0 +1,181 @@ +use crate::error::query::QueryError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::platform_types::platform_state::PlatformState; +use crate::query::QueryValidationResult; +use dapi_grpc::platform::v0::get_contested_resource_identity_votes_request::GetContestedResourceIdentityVotesRequestV0; +use dapi_grpc::platform::v0::get_contested_resource_identity_votes_response::{ + get_contested_resource_identity_votes_response_v0, GetContestedResourceIdentityVotesResponseV0, +}; +use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_response::{ + get_contested_resource_voters_for_identity_response_v0, + GetContestedResourceVotersForIdentityResponseV0, +}; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::identifier::Identifier; +use dpp::serialization::PlatformSerializable; +use dpp::validation::ValidationResult; +use dpp::version::PlatformVersion; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::{check_validation_result_with_data, platform_value, ProtocolError}; +use drive::error::query::QuerySyntaxError; +use drive::query::contested_resource_votes_given_by_identity_query::ContestedResourceVotesGivenByIdentityQuery; +use drive::query::vote_poll_contestant_votes_query::ContestedDocumentVotePollVotesDriveQuery; + +impl Platform { + pub(super) fn query_contested_resource_identity_votes_v0( + &self, + GetContestedResourceIdentityVotesRequestV0 { + identity_id, + limit, + offset, + order_ascending, + start_at_vote_poll_id_info, + prove, + }: GetContestedResourceIdentityVotesRequestV0, + platform_state: &PlatformState, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let config = &self.config.drive; + let identity_id: Identifier = + check_validation_result_with_data!(identity_id.try_into().map_err(|_| { + QueryError::InvalidArgument( + "identity_id must be a valid identifier (32 bytes long)".to_string(), + ) + })); + + let limit = limit + .map_or(Some(config.default_query_limit), |limit_value| { + if limit_value == 0 + || limit_value > u16::MAX as u32 + || limit_value as u16 > config.default_query_limit + { + None + } else { + Some(limit_value as u16) + } + }) + .ok_or(drive::error::Error::Query(QuerySyntaxError::InvalidLimit( + format!("limit greater than max limit {}", config.max_query_limit), + )))?; + + let offset = check_validation_result_with_data!(offset + .map(|offset| { + u16::try_from(offset) + .map_err(|_| QueryError::InvalidArgument("offset out of bounds".to_string())) + }) + .transpose()); + + let query = ContestedResourceVotesGivenByIdentityQuery { + identity_id, + offset, + limit: Some(limit), + start_at: start_at_vote_poll_id_info + .map(|start_at_vote_poll_id_info| { + Ok::<([u8; 32], bool), platform_value::Error>(( + Identifier::from_vec(start_at_vote_poll_id_info.start_at_poll_identifier)? + .to_buffer(), + start_at_vote_poll_id_info.start_poll_identifier_included, + )) + }) + .transpose()?, + order_ascending, + }; + + let response = if prove { + let proof = match query.execute_with_proof(&self.drive, None, None, platform_version) { + Ok(result) => result.0, + Err(drive::error::Error::Query(query_error)) => { + return Ok(QueryValidationResult::new_with_error(QueryError::Query( + query_error, + ))); + } + Err(e) => return Err(e.into()), + }; + + GetContestedResourceIdentityVotesResponseV0 { + result: Some( + get_contested_resource_identity_votes_response_v0::Result::Proof( + self.response_proof_v0(platform_state, proof), + ), + ), + metadata: Some(self.response_metadata_v0(platform_state)), + } + } else { + let votes = + match query.execute_no_proof(&self.drive, None, &mut vec![], platform_version) { + Ok(result) => result, + Err(drive::error::Error::Query(query_error)) => { + return Ok(QueryValidationResult::new_with_error(QueryError::Query( + query_error, + ))); + } + Err(e) => return Err(e.into()), + }; + + let finished_results = if votes.len() == limit as usize && limit > 0 { + let start_at = if order_ascending { + votes + .iter() + .rev() + .next() + .map(|(id, _)| (id.to_buffer(), false)) + } else { + votes.iter().next().map(|(id, _)| (id.to_buffer(), false)) + }; + let extra_query = ContestedResourceVotesGivenByIdentityQuery { + identity_id, + offset: None, + limit: Some(1), + start_at, + order_ascending, + }; + let another_result = match extra_query.execute_no_proof( + &self.drive, + None, + &mut vec![], + platform_version, + ) { + Ok(result) => result, + Err(drive::error::Error::Query(query_error)) => { + return Ok(QueryValidationResult::new_with_error(QueryError::Query( + query_error, + ))); + } + Err(e) => return Err(e.into()), + }; + another_result.is_empty() + } else { + true + }; + + let votes = votes + .into_values() + .map(|resource_vote| { + Ok(get_contested_resource_identity_votes_response_v0::Vote { + contested_resource_serialized_vote: resource_vote + .serialize_consume_to_bytes()?, + }) + }) + .collect::, + ProtocolError, + >>()?; + + GetContestedResourceIdentityVotesResponseV0 { + result: Some( + get_contested_resource_identity_votes_response_v0::Result::Votes( + get_contested_resource_identity_votes_response_v0::Votes { + votes, + finished_results, + }, + ), + ), + metadata: Some(self.response_metadata_v0(platform_state)), + } + }; + + Ok(QueryValidationResult::new_with_data(response)) + } +} diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/v0/mod.rs index ef10ae68ac..2df1abc67c 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_voters_for_identity/v0/mod.rs @@ -116,8 +116,7 @@ impl Platform { document_type_name, index_name, index_values, - } - .into(); + }; let limit = count .map_or(Some(config.default_query_limit), |limit_value| { diff --git a/packages/rs-drive-abci/src/query/voting/mod.rs b/packages/rs-drive-abci/src/query/voting/mod.rs index af89d57a8c..e0beb4cb74 100644 --- a/packages/rs-drive-abci/src/query/voting/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/mod.rs @@ -1,4 +1,4 @@ -mod contested_resource_identity_vote_status; +mod contested_resource_identity_votes; mod contested_resource_vote_state; mod contested_resource_voters_for_identity; mod contested_resources; diff --git a/packages/rs-drive/src/drive/defaults.rs b/packages/rs-drive/src/drive/defaults.rs index 0e2e35992e..1f9fa648b8 100644 --- a/packages/rs-drive/src/drive/defaults.rs +++ b/packages/rs-drive/src/drive/defaults.rs @@ -50,6 +50,9 @@ pub const BASE_CONTRACT_DOCUMENTS_PATH: u32 = 34; pub const BASE_CONTRACT_DOCUMENTS_PRIMARY_KEY_PATH: u32 = 35; /// Default hash size pub const DEFAULT_HASH_SIZE: u32 = 32; + +/// Default hash size +pub const DEFAULT_HASH_SIZE_USIZE: usize = 32; /// Default hash 160 size as u8 pub const DEFAULT_HASH_160_SIZE_U8: u8 = 20; /// Default hash size as u8 diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs index 16aa6000cb..0c4c4cb542 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_indices_for_contract_operations/v0/mod.rs @@ -12,7 +12,10 @@ use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use crate::drive::defaults::DEFAULT_HASH_SIZE_U8; -use crate::drive::votes::paths::vote_contested_resource_active_polls_contract_document_tree_path_vec; +use crate::drive::votes::paths::{ + vote_contested_resource_active_polls_contract_document_tree_path_vec, + RESOURCE_ABSTAIN_VOTE_TREE_KEY, RESOURCE_LOCK_VOTE_TREE_KEY, +}; use crate::error::drive::DriveError; use dpp::data_contract::document_type::IndexProperty; use dpp::version::PlatformVersion; @@ -206,7 +209,32 @@ impl Drive { drive_version, )?; - index_path_info.push(DriveKeyInfo::Key(owner_id.to_vec()))?; + let inserted_abstain = self.batch_insert_empty_tree_if_not_exists( + DriveKeyInfo::Key(vec![RESOURCE_ABSTAIN_VOTE_TREE_KEY as u8]) + .add_path_info(index_path_info.clone()), + false, + storage_flags, + apply_type, + transaction, + previous_batch_operations, + batch_operations, + drive_version, + )?; + + let inserted_lock = self.batch_insert_empty_tree_if_not_exists( + DriveKeyInfo::Key(vec![RESOURCE_LOCK_VOTE_TREE_KEY as u8]) + .add_path_info(index_path_info.clone()), + false, + storage_flags, + apply_type, + transaction, + previous_batch_operations, + batch_operations, + drive_version, + )?; + + let mut towards_identity_index_path_info = index_path_info.clone(); + towards_identity_index_path_info.push(DriveKeyInfo::Key(owner_id.to_vec()))?; // Inter-wizard championship (event type) // | @@ -219,7 +247,7 @@ impl Drive { self.add_contested_reference_and_vote_subtree_to_document_operations( document_and_contract_info, - index_path_info, + towards_identity_index_path_info, storage_flags, estimated_costs_only_with_layer_info, transaction, @@ -227,6 +255,37 @@ impl Drive { drive_version, )?; + if inserted_abstain { + let mut towards_abstain_index_path_info = index_path_info.clone(); + towards_abstain_index_path_info.push(DriveKeyInfo::Key(vec![ + RESOURCE_ABSTAIN_VOTE_TREE_KEY as u8, + ]))?; + + self.add_contested_vote_subtree_operations( + towards_abstain_index_path_info, + storage_flags, + estimated_costs_only_with_layer_info, + transaction, + batch_operations, + drive_version, + )?; + } + + if inserted_lock { + let mut towards_lock_index_path_info = index_path_info; + towards_lock_index_path_info + .push(DriveKeyInfo::Key(vec![RESOURCE_LOCK_VOTE_TREE_KEY as u8]))?; + + self.add_contested_vote_subtree_operations( + towards_lock_index_path_info, + storage_flags, + estimated_costs_only_with_layer_info, + transaction, + batch_operations, + drive_version, + )?; + } + Ok(contest_already_existed) } } diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_and_vote_subtree_to_document_operations/mod.rs similarity index 100% rename from packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/mod.rs rename to packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_and_vote_subtree_to_document_operations/mod.rs diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_and_vote_subtree_to_document_operations/v0/mod.rs similarity index 100% rename from packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_for_index_level_for_contract_operations/v0/mod.rs rename to packages/rs-drive/src/drive/document/insert_contested/add_contested_reference_and_vote_subtree_to_document_operations/v0/mod.rs diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_vote_subtrees_for_non_identities_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_vote_subtrees_for_non_identities_operations/mod.rs new file mode 100644 index 0000000000..229a0386d1 --- /dev/null +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_vote_subtrees_for_non_identities_operations/mod.rs @@ -0,0 +1,51 @@ +mod v0; + +use crate::drive::flags::StorageFlags; + +use crate::drive::object_size_info::{DocumentAndContractInfo, PathInfo}; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use dpp::version::drive_versions::DriveVersion; + +use grovedb::batch::KeyInfoPath; + +use grovedb::{EstimatedLayerInformation, TransactionArg}; +use std::collections::HashMap; + +impl Drive { + /// Adds the contested vote subtree + pub fn add_contested_vote_subtree_operations( + &self, + index_path_info: PathInfo<0>, + storage_flags: Option<&StorageFlags>, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + transaction: TransactionArg, + batch_operations: &mut Vec, + drive_version: &DriveVersion, + ) -> Result<(), Error> { + match drive_version + .methods + .document + .insert_contested + .add_contested_vote_subtree_for_non_identities_operations + { + 0 => self.add_contested_vote_subtree_operations_v0( + index_path_info, + storage_flags, + estimated_costs_only_with_layer_info, + transaction, + batch_operations, + drive_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "add_contested_vote_subtree_operations".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_vote_subtrees_for_non_identities_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_vote_subtrees_for_non_identities_operations/v0/mod.rs new file mode 100644 index 0000000000..43e279b08e --- /dev/null +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_vote_subtrees_for_non_identities_operations/v0/mod.rs @@ -0,0 +1,124 @@ +use crate::drive::defaults::{ + CONTESTED_DOCUMENT_REFERENCE_SIZE, DEFAULT_HASH_SIZE_U8, STORAGE_FLAGS_SIZE, U8_SIZE_U32, + U8_SIZE_U8, +}; +use crate::drive::document::make_document_contested_reference; +use crate::drive::flags::StorageFlags; +use crate::drive::grove_operations::BatchInsertTreeApplyType; +use crate::drive::object_size_info::DocumentInfo::{ + DocumentAndSerialization, DocumentEstimatedAverageSize, DocumentOwnedInfo, + DocumentRefAndSerialization, DocumentRefInfo, +}; +use crate::drive::object_size_info::DriveKeyInfo::KeyRef; +use crate::drive::object_size_info::KeyElementInfo::{KeyElement, KeyUnknownElementSize}; +use crate::drive::object_size_info::{DocumentAndContractInfo, PathInfo, PathKeyElementInfo}; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; +use dpp::version::drive_versions::DriveVersion; +use grovedb::batch::key_info::KeyInfo; +use grovedb::batch::KeyInfoPath; +use grovedb::EstimatedLayerCount::{ApproximateElements, PotentiallyAtMaxElements}; +use grovedb::EstimatedLayerSizes::{AllItems, Mix}; +use grovedb::EstimatedSumTrees::AllSumTrees; +use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; +use std::collections::HashMap; + +impl Drive { + /// Adds the contested vote subtree + #[inline(always)] + pub(super) fn add_contested_vote_subtree_operations_v0( + &self, + index_path_info: PathInfo<0>, + storage_flags: Option<&StorageFlags>, + estimated_costs_only_with_layer_info: &mut Option< + HashMap, + >, + transaction: TransactionArg, + batch_operations: &mut Vec, + drive_version: &DriveVersion, + ) -> Result<(), Error> { + // Inter-wizard championship (event type) + // | + // Goblet of Fire (event name) + // / \ + // Lock Abstain + // \ \ + // 1 (sum tree) 1 (sum tree) <---- We now need to insert at this level + // + + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { + // On this level we will have all the identities + estimated_costs_only_with_layer_info.insert( + index_path_info.clone().convert_to_key_info_path(), + EstimatedLayerInformation { + is_sum_tree: false, + estimated_layer_count: ApproximateElements(1), + estimated_layer_sizes: Mix { + // The votes don't have storage flags + subtrees_size: Some(( + U8_SIZE_U8, + AllSumTrees, // There is 1 tree that is a sum tree, so all are sum trees + None, + 1, + )), + items_size: None, + references_size: None, + }, + }, + ); + } + + // Let's insert the voting tree + + let votes_key_path_info = KeyRef(&[1]); + + let votes_path_key_info = votes_key_path_info.add_path_info(index_path_info.clone()); + + if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { + // On this level we will have a 0 and all the top index paths + estimated_costs_only_with_layer_info.insert( + votes_path_key_info.clone().convert_to_key_info_path()?, + EstimatedLayerInformation { + is_sum_tree: true, + estimated_layer_count: PotentiallyAtMaxElements, + estimated_layer_sizes: AllItems(DEFAULT_HASH_SIZE_U8, U8_SIZE_U32, None), + }, + ); + } + + let apply_type = if estimated_costs_only_with_layer_info.is_none() { + BatchInsertTreeApplyType::StatefulBatchInsertTree + } else { + BatchInsertTreeApplyType::StatelessBatchInsertTree { + in_tree_using_sums: false, + is_sum_tree: true, + flags_len: storage_flags + .map(|s| s.serialized_size()) + .unwrap_or_default(), + } + }; + + // here we are the tree that will contain the voting tree + let inserted = self.batch_insert_empty_tree_if_not_exists( + votes_path_key_info, + true, + storage_flags, + apply_type, + transaction, + &mut None, + batch_operations, + drive_version, + )?; + + if !inserted { + return Err(Error::Drive(DriveError::CorruptedContractIndexes( + "contested votes tree already exists", + ))); + } + + Ok(()) + } +} diff --git a/packages/rs-drive/src/drive/document/insert_contested/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/mod.rs index bc0801d3c3..d08f604170 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/mod.rs @@ -31,9 +31,10 @@ mod add_contested_document_to_primary_storage; // This module contains functionality for adding indices for the top index level for contract operations mod add_contested_indices_for_contract_operations; -// Module: add_contested_reference_for_index_level_for_contract_operations +// Module: add_contested_reference_and_vote_subtree_to_document_operations // This module contains functionality for adding a reference for an index level for contract operations -mod add_contested_reference_for_index_level_for_contract_operations; +mod add_contested_reference_and_vote_subtree_to_document_operations; +mod add_contested_vote_subtrees_for_non_identities_operations; #[cfg(all( feature = "fixtures-and-mocks", diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 7b39cb62b7..607bd31495 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -1,9 +1,19 @@ +use crate::drive::defaults::{DEFAULT_HASH_SIZE, DEFAULT_HASH_SIZE_USIZE}; use crate::drive::document::paths::contract_document_type_path; +use crate::drive::votes::paths::{ + ACTIVE_POLLS_TREE_KEY, CONTESTED_RESOURCE_TREE_KEY, RESOURCE_ABSTAIN_VOTE_TREE_KEY, + RESOURCE_LOCK_VOTE_TREE_KEY, VOTE_DECISIONS_TREE_KEY, +}; +use crate::drive::RootTree::Votes; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::DataContract; +use dpp::identifier::Identifier; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::voting::vote_polls::VotePoll; use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; +use dpp::voting::votes::resource_vote::v0::ResourceVoteV0; use dpp::voting::votes::resource_vote::ResourceVote; use dpp::voting::votes::Vote; use dpp::ProtocolError; @@ -29,6 +39,11 @@ pub mod resolved; pub trait TreePath { /// The tree path function fn tree_path<'a>(&'a self, contract: &'a DataContract) -> Result, ProtocolError>; + + /// Construction of the resource vote from the tree oath + fn try_from_tree_path(path: Vec>) -> Result + where + Self: Sized; } impl TreePath for Vote { @@ -37,9 +52,148 @@ impl TreePath for Vote { Vote::ResourceVote(resource_vote) => resource_vote.tree_path(contract), } } + + fn try_from_tree_path(path: Vec>) -> Result + where + Self: Sized, + { + if path.len() < 3 { + return Err(ProtocolError::VoteError(format!( + "path {} is not long enough to construct vote information", + path.into_iter() + .map(hex::encode) + .collect::>() + .join("/") + ))); + } + let key_0 = path.get(0).unwrap(); + let key_1 = path.get(1).unwrap(); + + let Some(key_0_byte) = key_0.get(0) else { + return Err(ProtocolError::VoteError(format!( + "path {} first element must be a byte", + path.into_iter() + .map(hex::encode) + .collect::>() + .join("/") + ))); + }; + + if *key_0_byte != Votes as u8 { + return Err(ProtocolError::VoteError(format!( + "path {} first element must be a byte for voting {}, got {}", + path.iter().map(hex::encode).collect::>().join("/"), + Votes as u8, + *key_0_byte + ))); + }; + + let Some(key_1_byte) = key_1.get(0) else { + return Err(ProtocolError::VoteError(format!( + "path {} second element must be a byte", + path.into_iter() + .map(hex::encode) + .collect::>() + .join("/") + ))); + }; + + match *key_1_byte as char { + CONTESTED_RESOURCE_TREE_KEY => { + Ok(Vote::ResourceVote(ResourceVote::try_from_tree_path(path)?)) + } + VOTE_DECISIONS_TREE_KEY => Err(ProtocolError::NotSupported( + "decision votes not supported yet".to_string(), + )), + _ => Err(ProtocolError::VoteError(format!( + "path {} second element must be a byte for CONTESTED_RESOURCE_TREE_KEY {}, got {}", + path.iter().map(hex::encode).collect::>().join("/"), + CONTESTED_RESOURCE_TREE_KEY as u8, + *key_1_byte + ))), + } + } } impl TreePath for ResourceVote { + fn try_from_tree_path(path: Vec>) -> Result + where + Self: Sized, + { + if path.len() < 8 { + return Err(ProtocolError::VoteError(format!( + "path {} is not long enough to construct vote information", + path.into_iter() + .map(hex::encode) + .collect::>() + .join("/") + ))); + } + + let key_2 = path.get(2).unwrap(); // active_vote_polls + let key_contract_id = path.get(3).unwrap(); // contract_id + let key_document_type_name = path.get(4).unwrap(); // document_type_name + let key_vote_choice = path.get(path.len() - 2).unwrap(); // this is the vote choice + + let Some(key_2_byte) = key_2.get(0) else { + return Err(ProtocolError::VoteError(format!( + "path {} third element must be a byte", + path.into_iter() + .map(hex::encode) + .collect::>() + .join("/") + ))); + }; + + if *key_2_byte != ACTIVE_POLLS_TREE_KEY as u8 { + return Err(ProtocolError::VoteError(format!( + "path {} third element must be a byte for ACTIVE_POLLS_TREE_KEY {}, got {}", + path.iter().map(hex::encode).collect::>().join("/"), + ACTIVE_POLLS_TREE_KEY as u8, + *key_2_byte + ))); + }; + + if key_contract_id.len() != DEFAULT_HASH_SIZE_USIZE { + return Err(ProtocolError::VoteError(format!( + "path {} fourth element must be a contract id but isn't 32 bytes long", + path.into_iter() + .map(hex::encode) + .collect::>() + .join("/") + ))); + } + + let contract_id = Identifier::from_vec(key_contract_id.clone())?; + + let document_type_name = String::from_utf8(key_document_type_name.clone()).map_err(|_| ProtocolError::VoteError(format!("path {} fifth element must be a document type name but couldn't be converted to a string", path.iter().map(hex::encode).collect::>().join("/"))))?; + + let resource_vote_choice = if key_vote_choice.len() == 32 { + ResourceVoteChoice::TowardsIdentity(Identifier::from_vec(key_vote_choice.clone())?) + } else if key_vote_choice.len() == 1 { + let char = (*key_vote_choice.first().unwrap()) as char; + match char { + RESOURCE_ABSTAIN_VOTE_TREE_KEY => ResourceVoteChoice::Abstain, + RESOURCE_LOCK_VOTE_TREE_KEY => ResourceVoteChoice::Lock, + _ => return Err(ProtocolError::VoteError(format!("path {} before last element must be an identifier or RESOURCE_ABSTAIN_VOTE_TREE_KEY/RESOURCE_LOCK_VOTE_TREE_KEY", path.into_iter().map(hex::encode).collect::>().join("/")))), + } + } else { + return Err(ProtocolError::VoteError(format!("path {} before last element must be an identifier or RESOURCE_ABSTAIN_VOTE_TREE_KEY/RESOURCE_LOCK_VOTE_TREE_KEY", path.into_iter().map(hex::encode).collect::>().join("/")))); + }; + + let vote_poll = + VotePoll::ContestedDocumentResourceVotePoll(ContestedDocumentResourceVotePoll { + contract_id, + document_type_name, + index_name: "".to_string(), + index_values: vec![], + }); + + Ok(ResourceVote::V0(ResourceVoteV0 { + vote_poll, + resource_vote_choice, + })) + } fn tree_path<'a>(&'a self, contract: &'a DataContract) -> Result, ProtocolError> { let vote_poll = self.vote_poll(); @@ -82,3 +236,19 @@ impl TreePath for ResourceVote { } } } + +/// A helper trait to get the key for a resource vote +pub trait ResourceVoteChoiceToKeyTrait { + /// A helper function to get the key for a resource vote + fn to_key(&self) -> Vec; +} + +impl ResourceVoteChoiceToKeyTrait for ResourceVoteChoice { + fn to_key(&self) -> Vec { + match self { + ResourceVoteChoice::TowardsIdentity(identity_id) => identity_id.to_vec(), + ResourceVoteChoice::Abstain => vec![RESOURCE_ABSTAIN_VOTE_TREE_KEY as u8], + ResourceVoteChoice::Lock => vec![RESOURCE_LOCK_VOTE_TREE_KEY as u8], + } + } +} diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index a5d59d7368..4832b72feb 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -3,6 +3,7 @@ use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_ ContestedDocumentResourceVotePollWithContractInfo, ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed, }; +use crate::drive::votes::ResourceVoteChoiceToKeyTrait; use crate::drive::RootTree; use crate::error::Error; use dpp::data_contract::accessors::v0::DataContractV0Getters; @@ -40,6 +41,12 @@ pub const ACTIVE_POLLS_TREE_KEY: char = 'p'; /// A subtree made for being able to query votes that an identity has made pub const IDENTITY_VOTES_TREE_KEY: char = 'i'; +/// In the active vote poll this will contain votes for locking the contested resource +pub const RESOURCE_LOCK_VOTE_TREE_KEY: char = 'l'; + +/// In the active vote poll this will contain votes for abstaining on the vote for the contested resource +pub const RESOURCE_ABSTAIN_VOTE_TREE_KEY: char = 'a'; + /// Convenience methods to be easily able to get a path when we know the vote poll pub trait VotePollPaths { /// The root path, under this there should be the documents area and the contract itself diff --git a/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs b/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs new file mode 100644 index 0000000000..894a28f920 --- /dev/null +++ b/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs @@ -0,0 +1,235 @@ +use crate::drive::votes::paths::{ + vote_contested_resource_identity_votes_tree_path_for_identity, + vote_contested_resource_identity_votes_tree_path_for_identity_vec, VotePollPaths, +}; +#[cfg(feature = "server")] +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; +use crate::drive::votes::TreePath; +#[cfg(feature = "server")] +use crate::drive::Drive; +use crate::error::Error; +#[cfg(feature = "server")] +use crate::fee::op::LowLevelDriveOperation; +#[cfg(feature = "server")] +use crate::query::GroveError; +use crate::query::Query; +#[cfg(feature = "server")] +use dpp::block::block_info::BlockInfo; +use dpp::identifier::Identifier; +use dpp::voting::votes::resource_vote::ResourceVote; +#[cfg(feature = "server")] +use grovedb::query_result_type::{QueryResultElements, QueryResultType}; +#[cfg(feature = "server")] +use grovedb::TransactionArg; +use grovedb::{PathQuery, SizedQuery}; +use platform_version::version::PlatformVersion; +use std::collections::BTreeMap; + +/// Vote Poll Drive Query struct +#[derive(Debug, PartialEq, Clone)] +pub struct ContestedResourceVotesGivenByIdentityQuery { + /// Which contestant do we want to get the votes for + pub identity_id: Identifier, + /// Offset + pub offset: Option, + /// Limit + pub limit: Option, + /// Start at vote id + pub start_at: Option<([u8; 32], bool)>, + /// Ascending + pub order_ascending: bool, +} + +impl ContestedResourceVotesGivenByIdentityQuery { + #[cfg(feature = "server")] + /// Executes a query with proof and returns the items and fee. + pub fn execute_with_proof( + self, + drive: &Drive, + block_info: Option, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(Vec, u64), Error> { + let mut drive_operations = vec![]; + let items = self.execute_with_proof_internal( + drive, + transaction, + &mut drive_operations, + platform_version, + )?; + let cost = if let Some(block_info) = block_info { + let fee_result = Drive::calculate_fee( + None, + Some(drive_operations), + &block_info.epoch, + drive.config.epochs_per_era, + platform_version, + )?; + fee_result.processing_fee + } else { + 0 + }; + Ok((items, cost)) + } + + #[cfg(feature = "server")] + /// Executes an internal query with proof and returns the items. + pub(crate) fn execute_with_proof_internal( + self, + drive: &Drive, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let path_query = self.construct_path_query(platform_version)?; + drive.grove_get_proved_path_query( + &path_query, + false, + transaction, + drive_operations, + &platform_version.drive, + ) + } + + #[cfg(feature = "server")] + /// Executes a query with no proof and returns the items, skipped items, and fee. + pub fn execute_no_proof_with_cost( + &self, + drive: &Drive, + block_info: Option, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(BTreeMap, u64), Error> { + let mut drive_operations = vec![]; + let result = + self.execute_no_proof(drive, transaction, &mut drive_operations, platform_version)?; + let cost = if let Some(block_info) = block_info { + let fee_result = Drive::calculate_fee( + None, + Some(drive_operations), + &block_info.epoch, + drive.config.epochs_per_era, + platform_version, + )?; + fee_result.processing_fee + } else { + 0 + }; + Ok((result, cost)) + } + + #[cfg(feature = "server")] + /// Executes an internal query with no proof and returns the values and skipped items. + pub fn execute_no_proof( + &self, + drive: &Drive, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let path_query = self.construct_path_query(platform_version)?; + let query_result = drive.grove_get_raw_path_query( + &path_query, + transaction, + QueryResultType::QueryPathKeyElementTrioResultType, + drive_operations, + &platform_version.drive, + ); + match query_result { + Err(Error::GroveDB(GroveError::PathKeyNotFound(_))) + | Err(Error::GroveDB(GroveError::PathNotFound(_))) + | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok(BTreeMap::new()), + Err(e) => Err(e), + Ok((query_result_elements, skipped)) => { + let voters = query_result_elements + .to_path_key_elements() + .into_iter() + .map(|(path, key, element)| { + let reference = element.into_reference_path_type()?; + let absolute_path = + reference.absolute_path(path.as_slice(), Some(key.as_slice()))?; + let vote_id = Identifier::from_vec(key)?; + Ok((vote_id, ResourceVote::try_from_tree_path(absolute_path)?)) + }) + .collect::, Error>>()?; + + Ok(voters) + } + } + } + + #[cfg(feature = "server")] + #[allow(unused)] + /// Executes an internal query with no proof and returns the values and skipped items. + pub(crate) fn execute_no_proof_internal( + &self, + drive: &Drive, + result_type: QueryResultType, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result<(QueryResultElements, u16), Error> { + let path_query = self.construct_path_query(platform_version)?; + let query_result = drive.grove_get_path_query( + &path_query, + transaction, + result_type, + drive_operations, + &platform_version.drive, + ); + match query_result { + Err(Error::GroveDB(GroveError::PathKeyNotFound(_))) + | Err(Error::GroveDB(GroveError::PathNotFound(_))) + | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => { + Ok((QueryResultElements::new(), 0)) + } + _ => { + let (data, skipped) = query_result?; + { + Ok((data, skipped)) + } + } + } + } + /// Operations to construct a path query. + pub fn construct_path_query( + &self, + platform_version: &PlatformVersion, + ) -> Result { + let path = vote_contested_resource_identity_votes_tree_path_for_identity_vec( + self.identity_id.as_bytes(), + ); + + let mut query = Query::new_with_direction(self.order_ascending); + + // this is a range on all elements + match &self.start_at { + None => { + query.insert_all(); + } + Some((starts_at_key_bytes, start_at_included)) => { + let starts_at_key = starts_at_key_bytes.to_vec(); + match self.order_ascending { + true => match start_at_included { + true => query.insert_range_from(starts_at_key..), + false => query.insert_range_after(starts_at_key..), + }, + false => match start_at_included { + true => query.insert_range_to_inclusive(..=starts_at_key), + false => query.insert_range_to(..starts_at_key), + }, + } + } + } + + Ok(PathQuery { + path, + query: SizedQuery { + query, + limit: self.limit, + offset: self.offset, + }, + }) + } +} diff --git a/packages/rs-drive/src/query/mod.rs b/packages/rs-drive/src/query/mod.rs index a001297857..7da9335e9a 100644 --- a/packages/rs-drive/src/query/mod.rs +++ b/packages/rs-drive/src/query/mod.rs @@ -94,6 +94,10 @@ pub mod vote_polls_by_end_date_query; /// Vote polls by document type query pub mod vote_polls_by_document_type_query; +#[cfg(any(feature = "server", feature = "verify"))] +/// A query to get the votes given out by an identity +pub mod contested_resource_votes_given_by_identity_query; + #[cfg(any(feature = "server", feature = "verify"))] /// Internal clauses struct #[derive(Clone, Debug, PartialEq, Default)] diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 8b7d45eacf..952052c630 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -337,6 +337,7 @@ pub struct DriveDocumentInsertContestedMethodVersions { pub add_contested_document_to_primary_storage: FeatureVersion, pub add_contested_indices_for_contract_operations: FeatureVersion, pub add_contested_reference_and_vote_subtree_to_document_operations: FeatureVersion, + pub add_contested_vote_subtree_for_non_identities_operations: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index f5843437b7..b829125556 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -199,6 +199,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { add_contested_document_to_primary_storage: 0, add_contested_indices_for_contract_operations: 0, add_contested_reference_and_vote_subtree_to_document_operations: 0, + add_contested_vote_subtree_for_non_identities_operations: 0, }, update: DriveDocumentUpdateMethodVersions { add_update_multiple_documents_operations: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index a2af0c0966..527b9ea943 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -207,6 +207,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { add_contested_document_to_primary_storage: 0, add_contested_indices_for_contract_operations: 0, add_contested_reference_and_vote_subtree_to_document_operations: 0, + add_contested_vote_subtree_for_non_identities_operations: 0, }, update: DriveDocumentUpdateMethodVersions { add_update_multiple_documents_operations: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 7b00f2f613..3129597869 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -198,6 +198,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { add_contested_document_to_primary_storage: 0, add_contested_indices_for_contract_operations: 0, add_contested_reference_and_vote_subtree_to_document_operations: 0, + add_contested_vote_subtree_for_non_identities_operations: 0, }, update: DriveDocumentUpdateMethodVersions { add_update_multiple_documents_operations: 0, diff --git a/packages/rs-sdk/src/platform/fetch.rs b/packages/rs-sdk/src/platform/fetch.rs index 0ea7cb0b9a..793f44d10b 100644 --- a/packages/rs-sdk/src/platform/fetch.rs +++ b/packages/rs-sdk/src/platform/fetch.rs @@ -230,5 +230,5 @@ impl Fetch for ExtendedEpochInfo { } impl Fetch for ContestedVote { - type Request = platform_proto::GetContestedResourceIdentityVoteStatusRequest; + type Request = platform_proto::GetContestedResourceIdentityVotesRequest; } From dec5f815a3e08462629e6ec351f18e6fdd803d7f Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 31 May 2024 05:49:16 +0200 Subject: [PATCH 103/135] broke things --- packages/rs-dpp/src/errors/consensus/codes.rs | 3 + .../rs-dpp/src/errors/consensus/state/mod.rs | 1 + .../src/errors/consensus/state/state_error.rs | 4 + .../voting/masternode_not_found_error.rs | 37 ++++++++ .../src/errors/consensus/state/voting/mod.rs | 1 + .../state_transitions/masternode_vote/mod.rs | 89 ++++++++++++++++++- .../masternode_vote/state/v0/mod.rs | 22 +++++ .../v0/mod.rs | 3 +- .../drive/batch/drive_op_batch/identity.rs | 4 + .../identity/masternode_vote_transition.rs | 2 + .../mod.rs | 4 + .../v0/mod.rs | 5 ++ .../insert/register_identity_vote/mod.rs | 5 ++ .../insert/register_identity_vote/v0/mod.rs | 4 + ..._resource_votes_given_by_identity_query.rs | 2 +- .../identity/masternode_vote/mod.rs | 7 ++ .../identity/masternode_vote/transformer.rs | 6 ++ .../identity/masternode_vote/v0/mod.rs | 2 + .../masternode_vote/v0/transformer.rs | 4 + 19 files changed, 201 insertions(+), 4 deletions(-) create mode 100644 packages/rs-dpp/src/errors/consensus/state/voting/masternode_not_found_error.rs create mode 100644 packages/rs-dpp/src/errors/consensus/state/voting/mod.rs diff --git a/packages/rs-dpp/src/errors/consensus/codes.rs b/packages/rs-dpp/src/errors/consensus/codes.rs index 885786e0ec..fa93a008f1 100644 --- a/packages/rs-dpp/src/errors/consensus/codes.rs +++ b/packages/rs-dpp/src/errors/consensus/codes.rs @@ -223,6 +223,9 @@ impl ErrorWithCode for StateError { Self::DocumentTypeUpdateError(_) => 40212, Self::DataContractUpdatePermissionError(_) => 40213, + // Voting Errors: 40300-40399 + Self::MasternodeNotFoundError(_) => 40300, + // Prefunded specialized balances Errors: 40400-40499 Self::PrefundedSpecializedBalanceInsufficientError(_) => 40400, Self::PrefundedSpecializedBalanceNotFoundError(_) => 40401, diff --git a/packages/rs-dpp/src/errors/consensus/state/mod.rs b/packages/rs-dpp/src/errors/consensus/state/mod.rs index 9beb6b3b24..118ca4b10c 100644 --- a/packages/rs-dpp/src/errors/consensus/state/mod.rs +++ b/packages/rs-dpp/src/errors/consensus/state/mod.rs @@ -5,3 +5,4 @@ pub mod document; pub mod identity; pub mod prefunded_specialized_balances; pub mod state_error; +pub mod voting; diff --git a/packages/rs-dpp/src/errors/consensus/state/state_error.rs b/packages/rs-dpp/src/errors/consensus/state/state_error.rs index 1d43e38ddd..6443e404c2 100644 --- a/packages/rs-dpp/src/errors/consensus/state/state_error.rs +++ b/packages/rs-dpp/src/errors/consensus/state/state_error.rs @@ -35,6 +35,7 @@ use crate::consensus::state::identity::identity_public_key_already_exists_for_un use crate::consensus::state::identity::invalid_identity_contract_nonce_error::InvalidIdentityNonceError; use crate::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_insufficient_error::PrefundedSpecializedBalanceInsufficientError; use crate::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_not_found_error::PrefundedSpecializedBalanceNotFoundError; +use crate::consensus::state::voting::masternode_not_found_error::MasternodeNotFoundError; use super::document::document_timestamps_are_equal_error::DocumentTimestampsAreEqualError; @@ -139,6 +140,9 @@ pub enum StateError { #[error(transparent)] DataContractUpdatePermissionError(DataContractUpdatePermissionError), + + #[error(transparent)] + MasternodeNotFoundError(MasternodeNotFoundError), } impl From for ConsensusError { diff --git a/packages/rs-dpp/src/errors/consensus/state/voting/masternode_not_found_error.rs b/packages/rs-dpp/src/errors/consensus/state/voting/masternode_not_found_error.rs new file mode 100644 index 0000000000..9a99ec13c9 --- /dev/null +++ b/packages/rs-dpp/src/errors/consensus/state/voting/masternode_not_found_error.rs @@ -0,0 +1,37 @@ +use crate::consensus::state::state_error::StateError; +use crate::consensus::ConsensusError; +use crate::errors::ProtocolError; +use bincode::{Decode, Encode}; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +use platform_value::Identifier; +use thiserror::Error; + +#[derive( + Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] +#[error("Masternode {pro_tx_hash:?} not found")] +#[platform_serialize(unversioned)] +pub struct MasternodeNotFoundError { + /* + + DO NOT CHANGE ORDER OF FIELDS WITHOUT INTRODUCING OF NEW VERSION + + */ + pro_tx_hash: Identifier, +} + +impl MasternodeNotFoundError { + pub fn new(pro_tx_hash: Identifier) -> Self { + Self { pro_tx_hash } + } + + pub fn pro_tx_hash(&self) -> Identifier { + self.pro_tx_hash + } +} + +impl From for ConsensusError { + fn from(err: MasternodeNotFoundError) -> Self { + Self::StateError(StateError::MasternodeNotFoundError(err)) + } +} diff --git a/packages/rs-dpp/src/errors/consensus/state/voting/mod.rs b/packages/rs-dpp/src/errors/consensus/state/voting/mod.rs new file mode 100644 index 0000000000..fc8ba5f1d3 --- /dev/null +++ b/packages/rs-dpp/src/errors/consensus/state/voting/mod.rs @@ -0,0 +1 @@ +pub mod masternode_not_found_error; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index d4a6869a1c..cd4119d094 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -161,8 +161,13 @@ mod tests { mod vote_tests { use super::*; + use dashcore_rpc::dashcore_rpc_json::{DMNState, MasternodeListItem, MasternodeType}; + use dpp::dashcore::hashes::Hash; + use dpp::dashcore::{ProTxHash, Txid}; use dpp::prelude::IdentityNonce; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; + use std::net::{IpAddr, Ipv4Addr, SocketAddr}; + use std::ops::Deref; fn setup_masternode_identity( platform: &mut TempPlatform, @@ -201,6 +206,46 @@ mod tests { ) .expect("expected to add a new identity"); + let mut platform_state = platform.state.load().clone().deref().clone(); + + let pro_tx_hash = ProTxHash::from_byte_array(identity.id().to_buffer()); + + let random_ip = Ipv4Addr::new( + rng.gen_range(0..255), + rng.gen_range(0..255), + rng.gen_range(0..255), + rng.gen_range(0..255), + ); + + platform_state.full_masternode_list_mut().insert( + pro_tx_hash, + MasternodeListItem { + node_type: MasternodeType::Regular, + pro_tx_hash, + collateral_hash: Txid::from_byte_array(rng.gen()), + collateral_index: 0, + collateral_address: rng.gen(), + operator_reward: 0.0, + state: DMNState { + service: SocketAddr::new(IpAddr::V4(random_ip), 19999), + registered_height: 0, + pose_revived_height: None, + pose_ban_height: None, + revocation_reason: 0, + owner_address: rng.gen(), + voting_address: rng.gen(), + payout_address: rng.gen(), + pub_key_operator: vec![], + operator_payout_address: None, + platform_node_id: None, + platform_p2p_port: None, + platform_http_port: None, + }, + }, + ); + + platform.state.store(Arc::new(platform_state)); + (identity, signer, voting_key) } @@ -973,6 +1018,8 @@ mod tests { let (masternode_1, signer_1, voting_key_1) = setup_masternode_identity(&mut platform, 29, platform_version); + let platform_state = platform.state.load(); + perform_vote( &mut platform, &platform_state, @@ -1109,6 +1156,8 @@ mod tests { let (masternode_1, signer_1, voting_key_1) = setup_masternode_identity(&mut platform, 29, platform_version); + let platform_state = platform.state.load(); + perform_vote( &mut platform, &platform_state, @@ -1265,6 +1314,8 @@ mod tests { let (masternode, signer, voting_key) = setup_masternode_identity(&mut platform, 10 + i, platform_version); + let platform_state = platform.state.load(); + perform_vote( &mut platform, &platform_state, @@ -1283,6 +1334,8 @@ mod tests { let (masternode, signer, voting_key) = setup_masternode_identity(&mut platform, 100 + i, platform_version); + let platform_state = platform.state.load(); + perform_vote( &mut platform, &platform_state, @@ -1421,6 +1474,8 @@ mod tests { let (masternode, signer, voting_key) = setup_masternode_identity(&mut platform, 10 + i, platform_version); + let platform_state = platform.state.load(); + perform_vote( &mut platform, &platform_state, @@ -1439,6 +1494,8 @@ mod tests { let (masternode, signer, voting_key) = setup_masternode_identity(&mut platform, 100 + i, platform_version); + let platform_state = platform.state.load(); + perform_vote( &mut platform, &platform_state, @@ -1800,6 +1857,8 @@ mod tests { let (masternode, signer, voting_key) = setup_masternode_identity(&mut platform, 10 + i, platform_version); + let platform_state = platform.state.load(); + perform_vote( &mut platform, &platform_state, @@ -1818,6 +1877,8 @@ mod tests { let (masternode, signer, voting_key) = setup_masternode_identity(&mut platform, 100 + i, platform_version); + let platform_state = platform.state.load(); + perform_vote( &mut platform, &platform_state, @@ -1836,6 +1897,8 @@ mod tests { let (masternode, signer, voting_key) = setup_masternode_identity(&mut platform, 200 + i, platform_version); + let platform_state = platform.state.load(); + perform_vote( &mut platform, &platform_state, @@ -1915,6 +1978,8 @@ mod tests { let (masternode, signer, voting_key) = setup_masternode_identity(&mut platform, 400 + i, platform_version); + let platform_state = platform.state.load(); + perform_vote( &mut platform, &platform_state, @@ -1948,6 +2013,8 @@ mod tests { let (masternode, signer, voting_key) = setup_masternode_identity(&mut platform, 500 + i, platform_version); + let platform_state = platform.state.load(); + perform_vote( &mut platform, &platform_state, @@ -2028,6 +2095,8 @@ mod tests { let (masternode, signer, voting_key) = setup_masternode_identity(&mut platform, 10 + i, platform_version); + let platform_state = platform.state.load(); + perform_vote( &mut platform, &platform_state, @@ -2046,6 +2115,8 @@ mod tests { let (masternode, signer, voting_key) = setup_masternode_identity(&mut platform, 100 + i, platform_version); + let platform_state = platform.state.load(); + perform_vote( &mut platform, &platform_state, @@ -2064,6 +2135,8 @@ mod tests { let (masternode, signer, voting_key) = setup_masternode_identity(&mut platform, 200 + i, platform_version); + let platform_state = platform.state.load(); + perform_vote( &mut platform, &platform_state, @@ -2183,7 +2256,7 @@ mod tests { ), ), }, - &platform_state, + platform_state, platform_version, ) .expect("expected to execute query") @@ -2262,6 +2335,8 @@ mod tests { // Now let's perform a few votes + let platform_state = platform.state.load(); + perform_vote( &mut platform, &platform_state, @@ -2275,6 +2350,8 @@ mod tests { platform_version, ); + let platform_state = platform.state.load(); + perform_vote( &mut platform, &platform_state, @@ -2288,6 +2365,8 @@ mod tests { platform_version, ); + let platform_state = platform.state.load(); + perform_vote( &mut platform, &platform_state, @@ -3762,6 +3841,8 @@ mod tests { let (masternode, signer, voting_key) = setup_masternode_identity(&mut platform, 10 + i, platform_version); + let platform_state = platform.state.load(); + perform_vote( &mut platform, &platform_state, @@ -3790,6 +3871,8 @@ mod tests { let (masternode, signer, voting_key) = setup_masternode_identity(&mut platform, 100 + i, platform_version); + let platform_state = platform.state.load(); + perform_vote( &mut platform, &platform_state, @@ -3863,6 +3946,8 @@ mod tests { let (masternode, signer, voting_key) = setup_masternode_identity(&mut platform, 10 + i, platform_version); + let platform_state = platform.state.load(); + perform_vote( &mut platform, &platform_state, @@ -3891,6 +3976,8 @@ mod tests { let (masternode, signer, voting_key) = setup_masternode_identity(&mut platform, 100 + i, platform_version); + let platform_state = platform.state.load(); + perform_vote( &mut platform, &platform_state, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs index 4945c0515b..4fc31c387f 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs @@ -1,10 +1,16 @@ use crate::error::Error; use crate::platform_types::platform::PlatformRef; +use dashcore_rpc::dashcore_rpc_json::MasternodeType; +use dpp::consensus::state::voting::masternode_not_found_error::MasternodeNotFoundError; +use dpp::dashcore::hashes::Hash; +use dpp::dashcore::ProTxHash; use dpp::prelude::ConsensusValidationResult; +use dpp::state_transition::masternode_vote_transition::accessors::MasternodeVoteTransitionAccessorsV0; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; use drive::state_transition_action::identity::masternode_vote::MasternodeVoteTransitionAction; +use crate::platform_types::platform_state::v0::PlatformStateV0Methods; use dpp::version::PlatformVersion; use drive::grovedb::TransactionArg; use drive::state_transition_action::StateTransitionAction; @@ -42,9 +48,25 @@ impl MasternodeVoteStateTransitionStateValidationV0 for MasternodeVoteTransition tx: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { + let Some(masternode) = platform + .state + .full_masternode_list() + .get(&ProTxHash::from_byte_array(self.pro_tx_hash().to_buffer())) + else { + return Ok(ConsensusValidationResult::new_with_error( + MasternodeNotFoundError::new(self.pro_tx_hash()).into(), + )); + }; + + let strength = match masternode.node_type { + MasternodeType::Regular => 1, + MasternodeType::Evo => 4, + }; + Ok(ConsensusValidationResult::new_with_data( MasternodeVoteTransitionAction::transform_from_transition( self, + strength, platform.drive, tx, platform_version, diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_identity_votes/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_votes/v0/mod.rs index f7f1ad388a..720add6915 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_identity_votes/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_votes/v0/mod.rs @@ -118,8 +118,7 @@ impl Platform { let start_at = if order_ascending { votes .iter() - .rev() - .next() + .next_back() .map(|(id, _)| (id.to_buffer(), false)) } else { votes.iter().next().map(|(id, _)| (id.to_buffer(), false)) diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs index a71e8d5e4d..c7d8992711 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs @@ -79,6 +79,8 @@ pub enum IdentityOperationType { MasternodeCastVote { /// The pro tx hash of the masternode doing the voting voter_pro_tx_hash: [u8; 32], + /// The strength of the vote, masternodes have 1, evonodes have 4, + strength: u8, /// Contested Vote type vote: ResolvedVote, }, @@ -191,9 +193,11 @@ impl DriveLowLevelOperationConverter for IdentityOperationType { )?]), IdentityOperationType::MasternodeCastVote { voter_pro_tx_hash, + strength, vote, } => drive.register_identity_vote_operations( voter_pro_tx_hash, + strength, vote, block_info, estimated_costs_only_with_layer_info, diff --git a/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs b/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs index 148ecc5381..ed7c78279f 100644 --- a/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs +++ b/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs @@ -19,6 +19,7 @@ impl DriveHighLevelOperationConverter for MasternodeVoteTransitionAction { ) -> Result>, Error> { let pro_tx_hash = self.pro_tx_hash(); let nonce = self.nonce(); + let strength = self.vote_strength(); let vote = self.vote_owned(); let prefunded_specialized_balance_id = vote.specialized_balance_id()?.ok_or(Error::Protocol(ProtocolError::VoteError("vote does not have a specialized balance from where it can use to pay for processing (this should have been caught during validation)".to_string())))?; @@ -29,6 +30,7 @@ impl DriveHighLevelOperationConverter for MasternodeVoteTransitionAction { }), IdentityOperation(IdentityOperationType::MasternodeCastVote { voter_pro_tx_hash: pro_tx_hash.to_buffer(), + strength, vote, }), // Casting a vote has a fixed cost diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs index 3009e41169..58c5fe0ca3 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs @@ -46,6 +46,7 @@ impl Drive { pub fn register_contested_resource_identity_vote( &self, voter_pro_tx_hash: [u8; 32], + strength: u8, vote_poll: ContestedDocumentResourceVotePollWithContractInfo, vote_choice: ResourceVoteChoice, block_info: &BlockInfo, @@ -62,6 +63,7 @@ impl Drive { { 0 => self.register_contested_resource_identity_vote_v0( voter_pro_tx_hash, + strength, vote_poll, vote_choice, block_info, @@ -106,6 +108,7 @@ impl Drive { pub fn register_contested_resource_identity_vote_operations( &self, voter_pro_tx_hash: [u8; 32], + strength: u8, vote_poll: ContestedDocumentResourceVotePollWithContractInfo, vote_choice: ResourceVoteChoice, block_info: &BlockInfo, @@ -124,6 +127,7 @@ impl Drive { { 0 => self.register_contested_resource_identity_vote_operations_v0( voter_pro_tx_hash, + strength, vote_poll, vote_choice, block_info, diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index 4f5c24b891..5c7a820c06 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -16,6 +16,7 @@ impl Drive { pub(super) fn register_contested_resource_identity_vote_v0( &self, voter_pro_tx_hash: [u8; 32], + strength: u8, vote_poll: ContestedDocumentResourceVotePollWithContractInfo, vote_choice: ResourceVoteChoice, block_info: &BlockInfo, @@ -31,6 +32,7 @@ impl Drive { let batch_operations = self.register_contested_resource_identity_vote_operations_v0( voter_pro_tx_hash, + strength, vote_poll, vote_choice, block_info, @@ -61,6 +63,7 @@ impl Drive { pub(super) fn register_contested_resource_identity_vote_operations_v0( &self, voter_pro_tx_hash: [u8; 32], + strength: u8, vote_poll: ContestedDocumentResourceVotePollWithContractInfo, vote_choice: ResourceVoteChoice, block_info: &BlockInfo, @@ -75,6 +78,8 @@ impl Drive { // The vote at this point will have been verified as valid by rs-drive-abci + // We start by inserting the main vote as a value of 1 + let voting_path = vote_poll.contender_voting_path(vote_choice, platform_version)?; self.batch_insert::<0>( diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs index 97e743ba42..e5b8c8139f 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs @@ -22,6 +22,7 @@ impl Drive { /// # Parameters /// /// - `voter_pro_tx_hash`: A 32-byte array representing the ProRegTx hash of the voter. + /// - `strength`: the strength of the vote, masternodes have 1, evonodes have 4 /// - `vote`: The vote to be registered, encapsulating the decision made by the voter. /// - `block_info`: Reference to the block information at the time of the vote. /// - `apply`: A boolean flag indicating whether the vote should be immediately applied to the state. @@ -42,6 +43,7 @@ impl Drive { pub fn register_identity_vote( &self, voter_pro_tx_hash: [u8; 32], + strength: u8, vote: ResolvedVote, block_info: &BlockInfo, apply: bool, @@ -57,6 +59,7 @@ impl Drive { { 0 => self.register_identity_vote_v0( voter_pro_tx_hash, + strength, vote, block_info, apply, @@ -99,6 +102,7 @@ impl Drive { pub fn register_identity_vote_operations( &self, voter_pro_tx_hash: [u8; 32], + strength: u8, vote: ResolvedVote, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< @@ -116,6 +120,7 @@ impl Drive { { 0 => self.register_identity_vote_operations_v0( voter_pro_tx_hash, + strength, vote, block_info, estimated_costs_only_with_layer_info, diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs index 2a6287937e..d9e99c2b79 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs @@ -15,6 +15,7 @@ impl Drive { pub(super) fn register_identity_vote_v0( &self, voter_pro_tx_hash: [u8; 32], + strength: u8, vote: ResolvedVote, block_info: &BlockInfo, apply: bool, @@ -29,6 +30,7 @@ impl Drive { contested_document_resource_vote_poll, ) => self.register_contested_resource_identity_vote( voter_pro_tx_hash, + strength, contested_document_resource_vote_poll, vote_choice, block_info, @@ -44,6 +46,7 @@ impl Drive { pub(super) fn register_identity_vote_operations_v0( &self, voter_pro_tx_hash: [u8; 32], + strength: u8, vote: ResolvedVote, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< @@ -60,6 +63,7 @@ impl Drive { contested_document_resource_vote_poll, ) => self.register_contested_resource_identity_vote_operations( voter_pro_tx_hash, + strength, contested_document_resource_vote_poll, vote_choice, block_info, diff --git a/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs b/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs index 894a28f920..a27d9d4944 100644 --- a/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs +++ b/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs @@ -141,7 +141,7 @@ impl ContestedResourceVotesGivenByIdentityQuery { | Err(Error::GroveDB(GroveError::PathNotFound(_))) | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok(BTreeMap::new()), Err(e) => Err(e), - Ok((query_result_elements, skipped)) => { + Ok((query_result_elements, _)) => { let voters = query_result_elements .to_path_key_elements() .into_iter() diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs index b729ec3669..848ddcb175 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs @@ -44,4 +44,11 @@ impl MasternodeVoteTransitionAction { MasternodeVoteTransitionAction::V0(transition) => transition.nonce, } } + + /// Vote strength + pub fn vote_strength(&self) -> u8 { + match self { + MasternodeVoteTransitionAction::V0(transition) => transition.vote_strength, + } + } } diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs index bfca654d83..61d9733d77 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs @@ -12,6 +12,7 @@ impl MasternodeVoteTransitionAction { /// # Parameters /// /// - `value`: The owned `MasternodeVoteTransition` to transform. + /// - `masternode_strength`: The strength of the masternode, normal ones have 1, evonodes have 4 /// - `drive`: A reference to the `Drive` instance. /// - `transaction`: The transaction argument. /// - `platform_version`: A reference to the platform version. @@ -21,6 +22,7 @@ impl MasternodeVoteTransitionAction { /// A `Result` containing the transformed `MasternodeVoteTransitionAction`, or an `Error` if the transformation fails. pub fn transform_from_owned_transition( value: MasternodeVoteTransition, + masternode_strength: u8, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -29,6 +31,7 @@ impl MasternodeVoteTransitionAction { MasternodeVoteTransition::V0(v0) => Ok( MasternodeVoteTransitionActionV0::transform_from_owned_transition( v0, + masternode_strength, drive, transaction, platform_version, @@ -43,6 +46,7 @@ impl MasternodeVoteTransitionAction { /// # Parameters /// /// - `value`: A reference to the `MasternodeVoteTransition` to transform. + /// - `masternode_strength`: The strength of the masternode, normal ones have 1, evonodes have 4 /// - `drive`: A reference to the `Drive` instance. /// - `transaction`: The transaction argument. /// - `platform_version`: A reference to the platform version. @@ -52,6 +56,7 @@ impl MasternodeVoteTransitionAction { /// A `Result` containing the transformed `MasternodeVoteTransitionAction`, or an `Error` if the transformation fails. pub fn transform_from_transition( value: &MasternodeVoteTransition, + masternode_strength: u8, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -60,6 +65,7 @@ impl MasternodeVoteTransitionAction { MasternodeVoteTransition::V0(v0) => { Ok(MasternodeVoteTransitionActionV0::transform_from_transition( v0, + masternode_strength, drive, transaction, platform_version, diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs index 196073ea4e..5cba194606 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs @@ -9,6 +9,8 @@ use dpp::prelude::IdentityNonce; pub struct MasternodeVoteTransitionActionV0 { /// the pro tx hash identifier of the masternode pub pro_tx_hash: Identifier, + /// masternode type vote strength, masternodes have 1, evonodes have 4 + pub vote_strength: u8, /// the resource votes pub vote: ResolvedVote, /// nonce diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs index fe3473ed65..dcdb99b372 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs @@ -9,6 +9,7 @@ use platform_version::version::PlatformVersion; impl MasternodeVoteTransitionActionV0 { pub(crate) fn transform_from_owned_transition( value: MasternodeVoteTransitionV0, + masternode_strength: u8, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -22,6 +23,7 @@ impl MasternodeVoteTransitionActionV0 { let resolved_vote = vote.resolve_owned(drive, transaction, platform_version)?; Ok(MasternodeVoteTransitionActionV0 { pro_tx_hash, + vote_strength: masternode_strength, vote: resolved_vote, nonce, }) @@ -29,6 +31,7 @@ impl MasternodeVoteTransitionActionV0 { pub(crate) fn transform_from_transition( value: &MasternodeVoteTransitionV0, + masternode_strength: u8, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -42,6 +45,7 @@ impl MasternodeVoteTransitionActionV0 { let resolved_vote = vote.resolve(drive, transaction, platform_version)?; Ok(MasternodeVoteTransitionActionV0 { pro_tx_hash: *pro_tx_hash, + vote_strength: masternode_strength, vote: resolved_vote, nonce: *nonce, }) From eddf4878308bcd4199e10059b8f79bda96b67e3a Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 31 May 2024 09:19:42 +0200 Subject: [PATCH 104/135] repaired some requests --- Cargo.lock | 16 +- .../protos/platform/v0/platform.proto | 9 +- .../v0/mod.rs | 3 +- .../mod.rs | 7 +- .../v0/mod.rs | 17 +- .../state_transitions/documents_batch/mod.rs | 3 + .../state_transitions/masternode_vote/mod.rs | 9 + .../contested_resource_vote_state/v0/mod.rs | 2 + .../tests/strategy_tests/voting_tests.rs | 2 + .../v0/mod.rs | 55 ++- packages/rs-drive/src/drive/votes/mod.rs | 6 +- packages/rs-drive/src/drive/votes/paths.rs | 6 + .../src/query/vote_poll_vote_state_query.rs | 420 +++++++++++++++--- 13 files changed, 468 insertions(+), 87 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d74de63da0..3f94adc7ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -809,9 +809,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.8.2" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f803f94ecf597339c7a34eed2036ef83f86aaba937f001f7c5b5e251f043f1f9" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" dependencies = [ "glob", "libc", @@ -2189,7 +2189,7 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "grovedb" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#17e9193b20d4c319b00beea1ae860b2a0c587faa" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#229b7f26b4195b145a9f2621defc58ddaca913ce" dependencies = [ "bincode 2.0.0-rc.3", "bitvec", @@ -2212,7 +2212,7 @@ dependencies = [ [[package]] name = "grovedb-costs" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#17e9193b20d4c319b00beea1ae860b2a0c587faa" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#229b7f26b4195b145a9f2621defc58ddaca913ce" dependencies = [ "integer-encoding", "intmap", @@ -2222,7 +2222,7 @@ dependencies = [ [[package]] name = "grovedb-merk" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#17e9193b20d4c319b00beea1ae860b2a0c587faa" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#229b7f26b4195b145a9f2621defc58ddaca913ce" dependencies = [ "blake3", "byteorder", @@ -2245,12 +2245,12 @@ dependencies = [ [[package]] name = "grovedb-path" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#17e9193b20d4c319b00beea1ae860b2a0c587faa" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#229b7f26b4195b145a9f2621defc58ddaca913ce" [[package]] name = "grovedb-storage" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#17e9193b20d4c319b00beea1ae860b2a0c587faa" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#229b7f26b4195b145a9f2621defc58ddaca913ce" dependencies = [ "blake3", "grovedb-costs", @@ -2269,7 +2269,7 @@ dependencies = [ [[package]] name = "grovedb-visualize" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#17e9193b20d4c319b00beea1ae860b2a0c587faa" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#229b7f26b4195b145a9f2621defc58ddaca913ce" dependencies = [ "hex", "itertools 0.12.1", diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index 8b8dc9b614..87875bb036 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -744,10 +744,11 @@ message GetContestedResourceVoteStateRequest { string index_name = 3; repeated bytes index_values = 4; ResultType result_type = 5; - optional StartAtIdentifierInfo start_at_identifier_info = 6; - optional uint32 count = 7; - bool order_ascending = 8; - bool prove = 9; + bool allow_include_locked_and_abstaining_vote_tally = 6; + optional StartAtIdentifierInfo start_at_identifier_info = 7; + optional uint32 count = 8; + bool order_ascending = 9; + bool prove = 10; } oneof version { diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs index e00994f9eb..c77fcb8857 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs @@ -42,11 +42,12 @@ where vote_poll.resolve(&self.drive, transaction, platform_version)?; let document_type = resolved_vote_poll.document_type()?; // let's see who actually won - let contenders = self.tally_votes_for_contested_document_resource_vote_poll( + let result = self.tally_votes_for_contested_document_resource_vote_poll( vote_poll, transaction, platform_version, )?; + let contenders = result.contenders; let max_vote_tally = contenders.iter().map(|c| c.final_vote_tally).max(); if let Some(max_tally) = max_vote_tally { diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/mod.rs index d4176cbe27..0f781dc339 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/mod.rs @@ -5,7 +5,10 @@ use crate::rpc::core::CoreRPCLike; use dpp::version::PlatformVersion; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use drive::grovedb::TransactionArg; -use drive::query::vote_poll_vote_state_query::FinalizedContenderWithSerializedDocument; +use drive::query::vote_poll_vote_state_query::{ + FinalizedContenderWithSerializedDocument, + FinalizedContestedDocumentVotePollDriveQueryExecutionResult, +}; mod v0; @@ -19,7 +22,7 @@ where contested_document_resource_vote_poll: &ContestedDocumentResourceVotePoll, transaction: TransactionArg, platform_version: &PlatformVersion, - ) -> Result, Error> { + ) -> Result { match platform_version .drive_abci .methods diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/v0/mod.rs index 92f326c0a3..9b2367d5cf 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/v0/mod.rs @@ -7,6 +7,7 @@ use drive::grovedb::TransactionArg; use drive::query::vote_poll_vote_state_query::{ ContestedDocumentVotePollDriveQuery, ContestedDocumentVotePollDriveQueryResultType, FinalizedContenderWithSerializedDocument, + FinalizedContestedDocumentVotePollDriveQueryExecutionResult, }; impl Platform @@ -19,7 +20,7 @@ where contested_document_resource_vote_poll: &ContestedDocumentResourceVotePoll, transaction: TransactionArg, platform_version: &PlatformVersion, - ) -> Result, Error> { + ) -> Result { //todo: try to figure out how to do this without a clone //we start by only requesting the vote tally because we don't want to load all the documents let query = ContestedDocumentVotePollDriveQuery { @@ -35,16 +36,12 @@ where ), start_at: None, order_ascending: true, + allow_include_locked_and_abstaining_vote_tally: true, }; - query - .execute_no_proof(&self.drive, transaction, &mut vec![], platform_version)? - .contenders - .into_iter() - .map(|contender| { - let finalized: FinalizedContenderWithSerializedDocument = contender.try_into()?; - Ok(finalized) - }) - .collect::, Error>>() + let query_result = + query.execute_no_proof(&self.drive, transaction, &mut vec![], platform_version)?; + + Ok(query_result.try_into()?) } } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs index e20cfb1244..1030218bbb 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs @@ -644,6 +644,7 @@ mod tests { index_name: index_name.clone(), index_values: vec![dash_encoded.clone(), quantum_encoded.clone()], result_type: ResultType::DocumentsAndVoteTally as i32, + allow_include_locked_and_abstaining_vote_tally: false, start_at_identifier_info: None, count: None, order_ascending: true, @@ -724,6 +725,7 @@ mod tests { index_name: "parentNameAndLabel".to_string(), index_values: vec![dash_encoded, quantum_encoded], result_type: ResultType::DocumentsAndVoteTally as i32, + allow_include_locked_and_abstaining_vote_tally: false, start_at_identifier_info: None, count: None, order_ascending: true, @@ -766,6 +768,7 @@ mod tests { limit: None, start_at: None, order_ascending: true, + allow_include_locked_and_abstaining_vote_tally: true, }; let (root_hash, contenders) = resolved_contested_document_vote_poll_drive_query diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index cd4119d094..3983906a6e 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -564,6 +564,7 @@ mod tests { index_name: index_name.clone(), index_values: vec![dash_encoded.clone(), quantum_encoded.clone()], result_type: ResultType::DocumentsAndVoteTally as i32, + allow_include_locked_and_abstaining_vote_tally: true, start_at_identifier_info: None, count: None, order_ascending: true, @@ -644,6 +645,7 @@ mod tests { index_name: "parentNameAndLabel".to_string(), index_values: vec![dash_encoded, quantum_encoded], result_type: ResultType::DocumentsAndVoteTally as i32, + allow_include_locked_and_abstaining_vote_tally: true, start_at_identifier_info: None, count: None, order_ascending: true, @@ -686,6 +688,7 @@ mod tests { limit: None, start_at: None, order_ascending: true, + allow_include_locked_and_abstaining_vote_tally: true, }; let (_, contenders) = resolved_contested_document_vote_poll_drive_query @@ -1065,6 +1068,7 @@ mod tests { quantum_encoded.clone(), ], result_type: ResultType::DocumentsAndVoteTally as i32, + allow_include_locked_and_abstaining_vote_tally: true, start_at_identifier_info: None, count: None, order_ascending: true, @@ -1200,6 +1204,7 @@ mod tests { index_name: "parentNameAndLabel".to_string(), index_values: vec![dash_encoded, quantum_encoded], result_type: ResultType::DocumentsAndVoteTally as i32, + allow_include_locked_and_abstaining_vote_tally: true, start_at_identifier_info: None, count: None, order_ascending: true, @@ -1245,6 +1250,7 @@ mod tests { limit: None, start_at: None, order_ascending: true, + allow_include_locked_and_abstaining_vote_tally: true, }; let (_, contenders) = resolved_contested_document_vote_poll_drive_query @@ -1382,6 +1388,7 @@ mod tests { quantum_encoded.clone(), ], result_type: ResultType::DocumentsAndVoteTally as i32, + allow_include_locked_and_abstaining_vote_tally: true, start_at_identifier_info: None, count: None, order_ascending: true, @@ -1538,6 +1545,7 @@ mod tests { index_name: "parentNameAndLabel".to_string(), index_values: vec![dash_encoded, quantum_encoded], result_type: ResultType::DocumentsAndVoteTally as i32, + allow_include_locked_and_abstaining_vote_tally: true, start_at_identifier_info: None, count: None, order_ascending: true, @@ -1583,6 +1591,7 @@ mod tests { limit: None, start_at: None, order_ascending: true, + allow_include_locked_and_abstaining_vote_tally: true, }; let (_, contenders) = resolved_contested_document_vote_poll_drive_query diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs index 73248c1588..16f33b475c 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs @@ -28,6 +28,7 @@ impl Platform { index_name, index_values, result_type, + allow_include_locked_and_abstaining_vote_tally, start_at_identifier_info, count, order_ascending, @@ -142,6 +143,7 @@ impl Platform { }) .transpose()?, order_ascending, + allow_include_locked_and_abstaining_vote_tally, }; let response = if prove { diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index aabbd98e17..d2d75dbee9 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -240,6 +240,7 @@ mod tests { index_name: index_name.clone(), index_values: vec![dash_encoded.clone(), quantum_encoded.clone()], result_type: ResultType::DocumentsAndVoteTally as i32, + allow_include_locked_and_abstaining_vote_tally: false, start_at_identifier_info: None, count: None, order_ascending: true, @@ -320,6 +321,7 @@ mod tests { index_name: "parentNameAndLabel".to_string(), index_values: vec![dash_encoded, quantum_encoded], result_type: ResultType::DocumentsAndVoteTally as i32, + allow_include_locked_and_abstaining_vote_tally: false, start_at_identifier_info: None, count: None, order_ascending: true, diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index 5c7a820c06..2f3deedb70 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -1,5 +1,13 @@ -use crate::drive::object_size_info::PathKeyElementInfo::PathKeyElement; -use crate::drive::votes::paths::VotePollPaths; +use crate::drive::grove_operations::BatchInsertTreeApplyType; +use crate::drive::object_size_info::PathKeyElementInfo::{ + PathFixedSizeKeyRefElement, PathKeyElement, +}; +use crate::drive::object_size_info::PathKeyInfo; +use crate::drive::votes::paths::{ + vote_contested_resource_identity_votes_tree_path, + vote_contested_resource_identity_votes_tree_path_for_identity_vec, + vote_contested_resource_identity_votes_tree_path_vec, VotePollPaths, +}; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use crate::drive::Drive; use crate::error::Error; @@ -8,6 +16,7 @@ use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use grovedb::batch::KeyInfoPath; +use grovedb::reference_path::ReferencePathType; use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; use platform_version::version::PlatformVersion; use std::collections::HashMap; @@ -73,20 +82,54 @@ impl Drive { transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { + //todo estimated costs // let's start by creating a batch of operations let mut drive_operations: Vec = vec![]; // The vote at this point will have been verified as valid by rs-drive-abci - // We start by inserting the main vote as a value of 1 + // We start by inserting the main vote as a value of 1 or 4 depending on the strength - let voting_path = vote_poll.contender_voting_path(vote_choice, platform_version)?; + let mut voting_path = vote_poll.contender_voting_path(vote_choice, platform_version)?; self.batch_insert::<0>( PathKeyElement(( - voting_path, + voting_path.clone(), voter_pro_tx_hash.to_vec(), - Element::new_sum_item(1), + Element::new_sum_item(strength as i64), + )), + &mut drive_operations, + &platform_version.drive, + )?; + + let votes_identities_path = vote_contested_resource_identity_votes_tree_path_vec(); + + self.batch_insert_empty_tree_if_not_exists( + PathKeyInfo::PathKey::<0>((votes_identities_path, voter_pro_tx_hash.to_vec())), + false, + None, + BatchInsertTreeApplyType::StatefulBatchInsertTree, //todo this shouldn't always be stateful + transaction, + &mut None, //we shouldn't have more than one document here + &mut drive_operations, + &platform_version.drive, + )?; + + // Now we create the vote reference + + let path = + vote_contested_resource_identity_votes_tree_path_for_identity_vec(&voter_pro_tx_hash); + + voting_path.remove(0); // we remove the top (root tree vote key) + voting_path.remove(0); // contested resource + + let reference = + ReferencePathType::UpstreamRootHeightWithParentPathAdditionReference(2, voting_path); + self.batch_insert::<0>( + PathKeyElement(( + path, + vote_poll.unique_id()?.to_vec(), + Element::new_reference_with_hops(reference, Some(1)), )), &mut drive_operations, &platform_version.drive, diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 607bd31495..10c0ca3d41 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -133,7 +133,7 @@ impl TreePath for ResourceVote { let key_2 = path.get(2).unwrap(); // active_vote_polls let key_contract_id = path.get(3).unwrap(); // contract_id let key_document_type_name = path.get(4).unwrap(); // document_type_name - let key_vote_choice = path.get(path.len() - 2).unwrap(); // this is the vote choice + let key_vote_choice = path.get(path.len() - 3).unwrap(); // this is the vote choice let Some(key_2_byte) = key_2.get(0) else { return Err(ProtocolError::VoteError(format!( @@ -175,10 +175,10 @@ impl TreePath for ResourceVote { match char { RESOURCE_ABSTAIN_VOTE_TREE_KEY => ResourceVoteChoice::Abstain, RESOURCE_LOCK_VOTE_TREE_KEY => ResourceVoteChoice::Lock, - _ => return Err(ProtocolError::VoteError(format!("path {} before last element must be an identifier or RESOURCE_ABSTAIN_VOTE_TREE_KEY/RESOURCE_LOCK_VOTE_TREE_KEY", path.into_iter().map(hex::encode).collect::>().join("/")))), + _ => return Err(ProtocolError::VoteError(format!("path {} 2 before last element must be an identifier or RESOURCE_ABSTAIN_VOTE_TREE_KEY/RESOURCE_LOCK_VOTE_TREE_KEY", path.into_iter().map(hex::encode).collect::>().join("/")))), } } else { - return Err(ProtocolError::VoteError(format!("path {} before last element must be an identifier or RESOURCE_ABSTAIN_VOTE_TREE_KEY/RESOURCE_LOCK_VOTE_TREE_KEY", path.into_iter().map(hex::encode).collect::>().join("/")))); + return Err(ProtocolError::VoteError(format!("path {} 2 before last element must be an identifier or RESOURCE_ABSTAIN_VOTE_TREE_KEY/RESOURCE_LOCK_VOTE_TREE_KEY", path.into_iter().map(hex::encode).collect::>().join("/")))); }; let vote_poll = diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index 4832b72feb..c4b398c1ba 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -47,6 +47,12 @@ pub const RESOURCE_LOCK_VOTE_TREE_KEY: char = 'l'; /// In the active vote poll this will contain votes for abstaining on the vote for the contested resource pub const RESOURCE_ABSTAIN_VOTE_TREE_KEY: char = 'a'; +/// In the active vote poll this will contain votes for locking the contested resource +pub const RESOURCE_LOCK_VOTE_TREE_KEY_U8: u8 = 'l' as u8; + +/// In the active vote poll this will contain votes for abstaining on the vote for the contested resource +pub const RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8: u8 = 'a' as u8; + /// Convenience methods to be easily able to get a path when we know the vote poll pub trait VotePollPaths { /// The root path, under this there should be the documents area and the contract itself diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index f7717d5883..95016df3da 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -1,4 +1,7 @@ -use crate::drive::votes::paths::VotePollPaths; +use crate::drive::votes::paths::{ + VotePollPaths, RESOURCE_ABSTAIN_VOTE_TREE_KEY, RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8, + RESOURCE_LOCK_VOTE_TREE_KEY, RESOURCE_LOCK_VOTE_TREE_KEY_U8, +}; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; use crate::drive::Drive; @@ -21,7 +24,7 @@ use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDoc use grovedb::query_result_type::{QueryResultElements, QueryResultType}; #[cfg(feature = "server")] use grovedb::{Element, TransactionArg}; -use grovedb::{PathQuery, Query, SizedQuery}; +use grovedb::{PathQuery, Query, QueryItem, SizedQuery}; use platform_version::version::PlatformVersion; #[cfg(feature = "verify")] use std::sync::Arc; @@ -42,6 +45,28 @@ pub enum ContestedDocumentVotePollDriveQueryResultType { DocumentsAndVoteTally, } +impl ContestedDocumentVotePollDriveQueryResultType { + /// Helper method to say if this result type should return vote tally + pub fn has_vote_tally(&self) -> bool { + match self { + ContestedDocumentVotePollDriveQueryResultType::IdentityIdsOnly => false, + ContestedDocumentVotePollDriveQueryResultType::Documents => false, + ContestedDocumentVotePollDriveQueryResultType::VoteTally => true, + ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally => true, + } + } + + /// Helper method to say if this result type should return documents + pub fn has_documents(&self) -> bool { + match self { + ContestedDocumentVotePollDriveQueryResultType::IdentityIdsOnly => false, + ContestedDocumentVotePollDriveQueryResultType::Documents => true, + ContestedDocumentVotePollDriveQueryResultType::VoteTally => false, + ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally => true, + } + } +} + impl TryFrom for ContestedDocumentVotePollDriveQueryResultType { type Error = Error; @@ -74,6 +99,10 @@ pub struct ContestedDocumentVotePollDriveQuery { pub start_at: Option<([u8; 32], bool)>, /// Ascending pub order_ascending: bool, + /// Include locked and abstaining vote tally + /// This is not automatic, it will just be at the beginning if the order is ascending + /// If the order is descending, we will get a value if we finish the query + pub allow_include_locked_and_abstaining_vote_tally: bool, } /// Represents a contender in the contested document vote poll. @@ -189,10 +218,65 @@ pub struct Contender { pub struct ContestedDocumentVotePollDriveQueryExecutionResult { /// The list of contenders returned by the query. pub contenders: Vec, + /// Locked tally + pub locked_vote_tally: Option, + /// Abstaining tally + pub abstaining_vote_tally: Option, /// The number of skipped items when an offset is given. pub skipped: u16, } +/// Represents the result of executing a contested document vote poll drive query. +/// +/// This struct holds the list of contenders and the number of skipped items +/// when an offset is given. +#[derive(Debug, PartialEq, Eq, Clone, Default)] +pub struct FinalizedContestedDocumentVotePollDriveQueryExecutionResult { + /// The list of contenders returned by the query. + pub contenders: Vec, + /// Locked tally + pub locked_vote_tally: u32, + /// Abstaining tally + pub abstaining_vote_tally: u32, +} + +impl TryFrom + for FinalizedContestedDocumentVotePollDriveQueryExecutionResult +{ + type Error = Error; + + fn try_from( + value: ContestedDocumentVotePollDriveQueryExecutionResult, + ) -> Result { + let ContestedDocumentVotePollDriveQueryExecutionResult { + contenders, + locked_vote_tally, + abstaining_vote_tally, + skipped, + } = value; + + let finalized_contenders = contenders + .into_iter() + .map(|contender| { + let finalized: FinalizedContenderWithSerializedDocument = contender.try_into()?; + Ok(finalized) + }) + .collect::, Error>>()?; + + Ok( + FinalizedContestedDocumentVotePollDriveQueryExecutionResult { + contenders: finalized_contenders, + locked_vote_tally: locked_vote_tally.ok_or(Error::Drive( + DriveError::CorruptedCodeExecution("expected a locked tally"), + ))?, + abstaining_vote_tally: abstaining_vote_tally.ok_or(Error::Drive( + DriveError::CorruptedCodeExecution("expected an abstaining tally"), + ))?, + }, + ) + } +} + impl ContestedDocumentVotePollDriveQuery { #[cfg(feature = "server")] /// Resolves the contested document vote poll drive query. @@ -228,6 +312,7 @@ impl ContestedDocumentVotePollDriveQuery { limit, start_at, order_ascending, + allow_include_locked_and_abstaining_vote_tally, } = self; Ok(ResolvedContestedDocumentVotePollDriveQuery { vote_poll: vote_poll.resolve_allow_borrowed(drive, transaction, platform_version)?, @@ -236,6 +321,8 @@ impl ContestedDocumentVotePollDriveQuery { limit: *limit, start_at: *start_at, order_ascending: *order_ascending, + allow_include_locked_and_abstaining_vote_tally: + *allow_include_locked_and_abstaining_vote_tally, }) } @@ -252,6 +339,7 @@ impl ContestedDocumentVotePollDriveQuery { limit, start_at, order_ascending, + allow_include_locked_and_abstaining_vote_tally, } = self; Ok(ResolvedContestedDocumentVotePollDriveQuery { vote_poll: vote_poll @@ -261,6 +349,8 @@ impl ContestedDocumentVotePollDriveQuery { limit: *limit, start_at: *start_at, order_ascending: *order_ascending, + allow_include_locked_and_abstaining_vote_tally: + *allow_include_locked_and_abstaining_vote_tally, }) } @@ -277,6 +367,7 @@ impl ContestedDocumentVotePollDriveQuery { limit, start_at, order_ascending, + allow_include_locked_and_abstaining_vote_tally, } = self; Ok(ResolvedContestedDocumentVotePollDriveQuery { vote_poll: vote_poll.resolve_with_provided_borrowed_contract(data_contract)?, @@ -285,6 +376,8 @@ impl ContestedDocumentVotePollDriveQuery { limit: *limit, start_at: *start_at, order_ascending: *order_ascending, + allow_include_locked_and_abstaining_vote_tally: + *allow_include_locked_and_abstaining_vote_tally, }) } @@ -429,6 +522,7 @@ impl ContestedDocumentVotePollDriveQuery { ) -> Result { let resolved = self.resolve(drive, transaction, platform_version)?; let path_query = resolved.construct_path_query(platform_version)?; + let order_ascending = resolved.order_ascending; let query_result = drive.grove_get_path_query( &path_query, transaction, @@ -444,70 +538,251 @@ impl ContestedDocumentVotePollDriveQuery { } Err(e) => Err(e), Ok((query_result_elements, skipped)) => { - let contenders = match self.result_type { + match self.result_type { ContestedDocumentVotePollDriveQueryResultType::IdentityIdsOnly => { - query_result_elements.to_keys().into_iter().map(|identity_id| Ok(ContenderWithSerializedDocument { - identity_id: Identifier::try_from(identity_id)?, - serialized_document: None, - vote_tally: None, - })).collect::, Error>>() + // with identities only we don't need to work about lock and abstaining tree + let contenders = query_result_elements + .to_keys() + .into_iter() + .map(|identity_id| { + Ok(ContenderWithSerializedDocument { + identity_id: Identifier::try_from(identity_id)?, + serialized_document: None, + vote_tally: None, + }) + }) + .collect::, Error>>()?; + + Ok(ContestedDocumentVotePollDriveQueryExecutionResult { + contenders, + locked_vote_tally: None, + abstaining_vote_tally: None, + skipped, + }) } ContestedDocumentVotePollDriveQueryResultType::Documents => { - query_result_elements.to_key_elements().into_iter().map(|(identity_id, document)| { - Ok(ContenderWithSerializedDocument { - identity_id: Identifier::try_from(identity_id)?, - serialized_document: Some(document.into_item_bytes()?), - vote_tally: None, + // with documents only we don't need to work about lock and abstaining tree + let contenders = query_result_elements + .to_key_elements() + .into_iter() + .map(|(identity_id, document)| { + Ok(ContenderWithSerializedDocument { + identity_id: Identifier::try_from(identity_id)?, + serialized_document: Some(document.into_item_bytes()?), + vote_tally: None, + }) }) - }).collect::, Error>>() + .collect::, Error>>()?; + + Ok(ContestedDocumentVotePollDriveQueryExecutionResult { + contenders, + locked_vote_tally: None, + abstaining_vote_tally: None, + skipped, + }) } ContestedDocumentVotePollDriveQueryResultType::VoteTally => { - query_result_elements.to_key_elements().into_iter().map(|(identity_id, vote_tally)| { + let mut contenders = Vec::new(); + let mut locked_vote_tally: Option = None; + let mut abstaining_vote_tally: Option = None; + + for (key, vote_tally) in query_result_elements.to_key_elements().into_iter() + { let sum_tree_value = vote_tally.into_sum_tree_value()?; if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { - return Err(Error::Drive(DriveError::CorruptedDriveState(format!("sum tree value for vote tally must be between 0 and u32::Max, received {} from state", sum_tree_value)))); + return Err(Error::Drive(DriveError::CorruptedDriveState(format!( + "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", + sum_tree_value + )))); } - Ok(ContenderWithSerializedDocument { - identity_id: Identifier::try_from(identity_id)?, - serialized_document: None, - vote_tally: Some(sum_tree_value as u32), - }) - }).collect::, Error>>() + + match key.get(0) { + Some(key) if key == &RESOURCE_LOCK_VOTE_TREE_KEY_U8 => { + locked_vote_tally = Some(sum_tree_value as u32); + } + Some(key) => { + if key == &RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8 { + abstaining_vote_tally = Some(sum_tree_value as u32); + } + } + _ => { + let identity_id = Identifier::try_from(key)?; + contenders.push(ContenderWithSerializedDocument { + identity_id, + serialized_document: None, + vote_tally: Some(sum_tree_value as u32), + }); + } + } + } + Ok(ContestedDocumentVotePollDriveQueryExecutionResult { + contenders, + locked_vote_tally, + abstaining_vote_tally, + skipped, + }) } ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally => { - let mut elements_iter = query_result_elements.to_path_key_elements().into_iter(); - + let mut elements_iter = + query_result_elements.to_path_key_elements().into_iter(); let mut contenders = vec![]; - while let (Some((path_doc, _, Element::Item(serialized_document, _))), Some((path_tally, _, Element::SumTree(_, sum_tree_value, _)))) = (elements_iter.next(), elements_iter.next()) { - if path_doc != path_tally { - return Err(Error::Drive(DriveError::CorruptedDriveState("the two results in a chunk when requesting documents and vote tally should both have the same path".to_string()))); + let mut locked_vote_tally: Option = None; + let mut abstaining_vote_tally: Option = None; + + if order_ascending { + // Handle ascending order + while let Some((path, _, element)) = elements_iter.next() { + let Some(identity_bytes) = path.last() else { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "the path must have a last element".to_string(), + ))); + }; + + match element { + Element::SumTree(_, sum_tree_value, _) => { + if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!( + "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", + sum_tree_value + )))); + } + + match identity_bytes.get(0) { + Some(key) if key == &RESOURCE_LOCK_VOTE_TREE_KEY_U8 => { + locked_vote_tally = Some(sum_tree_value as u32); + } + Some(key) => { + if key == &RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8 { + abstaining_vote_tally = + Some(sum_tree_value as u32); + } + } + _ => { + return Err(Error::Drive( + DriveError::CorruptedDriveState( + "unexpected key for sum tree value" + .to_string(), + ), + )); + } + } + } + Element::Item(serialized_document, _) => { + // We should find a sum tree paired with this document + if let Some(( + path_tally, + _, + Element::SumTree(_, sum_tree_value, _), + )) = elements_iter.next() + { + if path != path_tally { + return Err(Error::Drive(DriveError::CorruptedDriveState("the two results in a chunk when requesting documents and vote tally should both have the same path".to_string()))); + } + + if sum_tree_value < 0 + || sum_tree_value > u32::MAX as i64 + { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!( + "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", + sum_tree_value + )))); + } + + let identity_id = + Identifier::from_bytes(identity_bytes)?; + let contender = ContenderWithSerializedDocument { + identity_id, + serialized_document: Some(serialized_document), + vote_tally: Some(sum_tree_value as u32), + }; + contenders.push(contender); + } else { + return Err(Error::Drive(DriveError::CorruptedDriveState("expected a sum tree element after item element".to_string()))); + } + } + _ => { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "unexpected element type in result".to_string(), + ))); + } + } } - let Some(identity_bytes) = path_doc.last() else { - return Err(Error::Drive(DriveError::CorruptedDriveState("the path must have a last element".to_string()))); - }; - - let identity_id = Identifier::from_bytes(identity_bytes)?; - - if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { - return Err(Error::Drive(DriveError::CorruptedDriveState(format!("sum tree value for vote tally must be between 0 and u32::Max, received {} from state", sum_tree_value)))); + } else { + // Handle descending order + let mut prev_element: Option<(Vec>, i64, Element)> = None; + + while let Some((path, _, element)) = elements_iter.next() { + let Some(identity_bytes) = path.last() else { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "the path must have a last element".to_string(), + ))); + }; + + match element { + Element::SumTree(_, sum_tree_value, _) => { + if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!( + "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", + sum_tree_value + )))); + } + + match identity_bytes.get(0) { + Some(key) if key == &RESOURCE_LOCK_VOTE_TREE_KEY_U8 => { + locked_vote_tally = Some(sum_tree_value as u32); + } + Some(key) => { + if key == &RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8 { + abstaining_vote_tally = + Some(sum_tree_value as u32); + } + } + _ => { + prev_element = + Some((path.clone(), sum_tree_value, element)); + } + } + } + Element::Item(serialized_document, _) => { + if let Some(( + prev_path, + sum_tree_value, + Element::SumTree(_, _, _), + )) = prev_element.take() + { + if prev_path != path { + return Err(Error::Drive(DriveError::CorruptedDriveState("the two results in a chunk when requesting documents and vote tally should both have the same path".to_string()))); + } + + let identity_id = + Identifier::from_bytes(identity_bytes)?; + let contender = ContenderWithSerializedDocument { + identity_id, + serialized_document: Some(serialized_document), + vote_tally: Some(sum_tree_value as u32), + }; + contenders.push(contender); + } else { + return Err(Error::Drive(DriveError::CorruptedDriveState("expected a sum tree element before item element".to_string()))); + } + } + _ => { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "unexpected element type in result".to_string(), + ))); + } + } } - - let contender = ContenderWithSerializedDocument { - identity_id, - serialized_document: Some(serialized_document), - vote_tally: Some(sum_tree_value as u32), - }; - - contenders.push(contender) } - Ok(contenders) - } - }?; - Ok(ContestedDocumentVotePollDriveQueryExecutionResult { - contenders, - skipped, - }) + Ok(ContestedDocumentVotePollDriveQueryExecutionResult { + contenders, + locked_vote_tally, + abstaining_vote_tally, + skipped, + }) + } + } } } } @@ -563,6 +838,8 @@ pub struct ResolvedContestedDocumentVotePollDriveQuery<'a> { pub start_at: Option<([u8; 32], bool)>, /// Ascending pub order_ascending: bool, + /// Include locked and abstaining vote tally + pub allow_include_locked_and_abstaining_vote_tally: bool, } impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { @@ -575,10 +852,18 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { let mut query = Query::new_with_direction(self.order_ascending); + let allow_include_locked_and_abstaining_vote_tally = self + .allow_include_locked_and_abstaining_vote_tally + && self.result_type.has_vote_tally(); + // this is a range on all elements match &self.start_at { None => { - query.insert_all(); + if allow_include_locked_and_abstaining_vote_tally { + query.insert_all() + } else { + query.insert_range_after(vec![RESOURCE_LOCK_VOTE_TREE_KEY as u8]..) + } } Some((starts_at_key_bytes, start_at_included)) => { let starts_at_key = starts_at_key_bytes.to_vec(); @@ -588,8 +873,24 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { false => query.insert_range_after(starts_at_key..), }, false => match start_at_included { - true => query.insert_range_to_inclusive(..=starts_at_key), - false => query.insert_range_to(..starts_at_key), + true => { + if allow_include_locked_and_abstaining_vote_tally { + query.insert_range_to_inclusive(..=starts_at_key) + } else { + query.insert_range_after_to_inclusive( + vec![RESOURCE_LOCK_VOTE_TREE_KEY as u8]..=starts_at_key, + ) + } + } + false => { + if allow_include_locked_and_abstaining_vote_tally { + query.insert_range_to(..starts_at_key) + } else { + query.insert_range_after_to( + vec![RESOURCE_LOCK_VOTE_TREE_KEY as u8]..starts_at_key, + ) + } + } }, } } @@ -609,6 +910,19 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { query.default_subquery_branch.subquery_path = subquery_path; query.default_subquery_branch.subquery = subquery; + if allow_include_locked_and_abstaining_vote_tally { + query.add_conditional_subquery( + QueryItem::Key(vec![RESOURCE_LOCK_VOTE_TREE_KEY as u8]), + Some(vec![vec![1]]), + None, + ); + query.add_conditional_subquery( + QueryItem::Key(vec![RESOURCE_ABSTAIN_VOTE_TREE_KEY as u8]), + Some(vec![vec![1]]), + None, + ); + } + Ok(PathQuery { path, query: SizedQuery { From c43f1ec6d45d4d550e21ad4d9d73f31c311d5057 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 31 May 2024 14:27:13 +0200 Subject: [PATCH 105/135] last test passed --- .../state_transitions/documents_batch/mod.rs | 3 +- .../state_transitions/masternode_vote/mod.rs | 12 +- .../verify_vote_poll_vote_state_proof/mod.rs | 5 +- .../v0/mod.rs | 287 +++++++++++++++--- .../src/query/vote_poll_vote_state_query.rs | 25 +- 5 files changed, 267 insertions(+), 65 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs index 1030218bbb..9afd3f28dc 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs @@ -771,10 +771,11 @@ mod tests { allow_include_locked_and_abstaining_vote_tally: true, }; - let (root_hash, contenders) = resolved_contested_document_vote_poll_drive_query + let (root_hash, result) = resolved_contested_document_vote_poll_drive_query .verify_vote_poll_vote_state_proof(proof.grovedb_proof.as_ref(), platform_version) .expect("expected to verify proof"); + let contenders = result.contenders; assert_eq!(contenders.len(), 2); let first_contender = contenders.first().unwrap(); diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 3983906a6e..8cacfb0c5e 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -691,10 +691,12 @@ mod tests { allow_include_locked_and_abstaining_vote_tally: true, }; - let (_, contenders) = resolved_contested_document_vote_poll_drive_query + let (_, result) = resolved_contested_document_vote_poll_drive_query .verify_vote_poll_vote_state_proof(proof.grovedb_proof.as_ref(), platform_version) .expect("expected to verify proof"); + let contenders = result.contenders; + assert_eq!(contenders.len(), 2); let first_contender = contenders.first().unwrap(); @@ -1253,13 +1255,15 @@ mod tests { allow_include_locked_and_abstaining_vote_tally: true, }; - let (_, contenders) = resolved_contested_document_vote_poll_drive_query + let (_, result) = resolved_contested_document_vote_poll_drive_query .verify_vote_poll_vote_state_proof( proof.grovedb_proof.as_ref(), platform_version, ) .expect("expected to verify proof"); + let contenders = result.contenders; + assert_eq!(contenders.len(), 2); let first_contender = contenders.first().unwrap(); @@ -1594,13 +1598,15 @@ mod tests { allow_include_locked_and_abstaining_vote_tally: true, }; - let (_, contenders) = resolved_contested_document_vote_poll_drive_query + let (_, result) = resolved_contested_document_vote_poll_drive_query .verify_vote_poll_vote_state_proof( proof.grovedb_proof.as_ref(), platform_version, ) .expect("expected to verify proof"); + let contenders = result.contenders; + assert_eq!(contenders.len(), 2); let first_contender = contenders.first().unwrap(); diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/mod.rs index ea03d1e5be..dffff4f323 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/mod.rs @@ -6,7 +6,8 @@ use crate::error::drive::DriveError; use crate::error::Error; use crate::query::vote_poll_vote_state_query::{ - ContenderWithSerializedDocument, ResolvedContestedDocumentVotePollDriveQuery, + ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQueryExecutionResult, + ResolvedContestedDocumentVotePollDriveQuery, }; use dpp::version::PlatformVersion; @@ -36,7 +37,7 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { &self, proof: &[u8], platform_version: &PlatformVersion, - ) -> Result<(RootHash, Vec), Error> { + ) -> Result<(RootHash, ContestedDocumentVotePollDriveQueryExecutionResult), Error> { match platform_version .drive .methods diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs index 27483b8072..8bf1e24d87 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs @@ -4,10 +4,13 @@ use grovedb::{Element, GroveDb}; use crate::error::Error; +use crate::drive::votes::paths::{ + RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8, RESOURCE_LOCK_VOTE_TREE_KEY_U8, +}; use crate::error::drive::DriveError; use crate::query::vote_poll_vote_state_query::{ - ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQueryResultType, - ResolvedContestedDocumentVotePollDriveQuery, + ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQueryExecutionResult, + ContestedDocumentVotePollDriveQueryResultType, ResolvedContestedDocumentVotePollDriveQuery, }; use dpp::version::PlatformVersion; @@ -38,70 +41,264 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { &self, proof: &[u8], platform_version: &PlatformVersion, - ) -> Result<(RootHash, Vec), Error> { + ) -> Result<(RootHash, ContestedDocumentVotePollDriveQueryExecutionResult), Error> { let path_query = self.construct_path_query(platform_version)?; let (root_hash, proved_key_values) = GroveDb::verify_query(proof, &path_query)?; - let contenders = match self.result_type { + match self.result_type { ContestedDocumentVotePollDriveQueryResultType::IdentityIdsOnly => { - proved_key_values.into_iter().map(|(_,identity_id, _)| Ok(ContenderWithSerializedDocument { - identity_id: Identifier::try_from(identity_id)?, - serialized_document: None, - vote_tally: None, - })).collect::, Error>>() + let contenders = proved_key_values + .into_iter() + .map(|(_, identity_id, _)| { + Ok(ContenderWithSerializedDocument { + identity_id: Identifier::try_from(identity_id)?, + serialized_document: None, + vote_tally: None, + }) + }) + .collect::, Error>>()?; + + Ok(( + root_hash, + ContestedDocumentVotePollDriveQueryExecutionResult { + contenders, + locked_vote_tally: None, + abstaining_vote_tally: None, + skipped: 0, + }, + )) } ContestedDocumentVotePollDriveQueryResultType::Documents => { - proved_key_values.into_iter().map(|(_, identity_id, document)| { - Ok(ContenderWithSerializedDocument { - identity_id: Identifier::try_from(identity_id)?, - serialized_document: document.map(|document| document.into_item_bytes()).transpose()?, - vote_tally: None, + let contenders = proved_key_values + .into_iter() + .map(|(_, identity_id, document)| { + Ok(ContenderWithSerializedDocument { + identity_id: Identifier::try_from(identity_id)?, + serialized_document: document + .map(|document| document.into_item_bytes()) + .transpose()?, + vote_tally: None, + }) }) - }).collect::, Error>>() + .collect::, Error>>()?; + + Ok(( + root_hash, + ContestedDocumentVotePollDriveQueryExecutionResult { + contenders, + locked_vote_tally: None, + abstaining_vote_tally: None, + skipped: 0, + }, + )) } ContestedDocumentVotePollDriveQueryResultType::VoteTally => { - proved_key_values.into_iter().map(|(_, identity_id, vote_tally)| { - let sum_tree_value = vote_tally.map(|vote_tally| vote_tally.into_sum_tree_value()).transpose()?.unwrap_or_default(); + let mut contenders = Vec::new(); + let mut locked_vote_tally: Option = None; + let mut abstaining_vote_tally: Option = None; + + for (_, key, vote_tally) in proved_key_values.into_iter() { + let Some(vote_tally) = vote_tally else { + continue; + }; + let sum_tree_value = vote_tally.into_sum_tree_value()?; if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { - return Err(Error::Drive(DriveError::CorruptedDriveState(format!("sum tree value for vote tally must be between 0 and u32::Max, received {} from state", sum_tree_value)))); + return Err(Error::Drive(DriveError::CorruptedDriveState(format!( + "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", + sum_tree_value + )))); } - Ok(ContenderWithSerializedDocument { - identity_id: Identifier::try_from(identity_id)?, - serialized_document: None, - vote_tally: Some(sum_tree_value as u32), - }) - }).collect::, Error>>() + + match key.get(0) { + Some(key) if key == &RESOURCE_LOCK_VOTE_TREE_KEY_U8 => { + locked_vote_tally = Some(sum_tree_value as u32); + } + Some(key) => { + if key == &RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8 { + abstaining_vote_tally = Some(sum_tree_value as u32); + } + } + _ => { + let identity_id = Identifier::try_from(key)?; + contenders.push(ContenderWithSerializedDocument { + identity_id, + serialized_document: None, + vote_tally: Some(sum_tree_value as u32), + }); + } + } + } + Ok(( + root_hash, + ContestedDocumentVotePollDriveQueryExecutionResult { + contenders, + locked_vote_tally, + abstaining_vote_tally, + skipped: 0, + }, + )) } ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally => { let mut elements_iter = proved_key_values.into_iter(); - let mut contenders = vec![]; - while let (Some((path_doc, _, Some(Element::Item(serialized_document, _)))), Some((path_tally, _, Some(Element::SumTree(_, sum_tree_value, _))))) = (elements_iter.next(), elements_iter.next()) { - if path_doc != path_tally { - return Err(Error::Drive(DriveError::CorruptedDriveState("the two results in a chunk when requesting documents and vote tally should both have the same path".to_string()))); - } - let Some(identity_bytes) = path_doc.last() else { - return Err(Error::Drive(DriveError::CorruptedDriveState("the path must have a last element".to_string()))); - }; + let mut locked_vote_tally: Option = None; + let mut abstaining_vote_tally: Option = None; - let identity_id = Identifier::from_bytes(identity_bytes)?; + if self.order_ascending { + // Handle ascending order + while let Some((path, _, element)) = elements_iter.next() { + let Some(element) = element else { + continue; + }; + let Some(identity_bytes) = path.last() else { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "the path must have a last element".to_string(), + ))); + }; - if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { - return Err(Error::Drive(DriveError::CorruptedDriveState(format!("sum tree value for vote tally must be between 0 and u32::Max, received {} from state", sum_tree_value)))); + match element { + Element::SumTree(_, sum_tree_value, _) => { + if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!( + "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", + sum_tree_value + )))); + } + + match identity_bytes.get(0) { + Some(key) if key == &RESOURCE_LOCK_VOTE_TREE_KEY_U8 => { + locked_vote_tally = Some(sum_tree_value as u32); + } + Some(key) if key == &RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8 => { + abstaining_vote_tally = Some(sum_tree_value as u32); + } + _ => { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "unexpected key for sum tree value".to_string(), + ))); + } + } + } + Element::Item(serialized_document, _) => { + // We should find a sum tree paired with this document + if let Some(( + path_tally, + _, + Some(Element::SumTree(_, sum_tree_value, _)), + )) = elements_iter.next() + { + if path != path_tally { + return Err(Error::Drive(DriveError::CorruptedDriveState("the two results in a chunk when requesting documents and vote tally should both have the same path".to_string()))); + } + + if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!( + "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", + sum_tree_value + )))); + } + + let identity_id = Identifier::from_bytes(identity_bytes)?; + let contender = ContenderWithSerializedDocument { + identity_id, + serialized_document: Some(serialized_document), + vote_tally: Some(sum_tree_value as u32), + }; + contenders.push(contender); + } else { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "expected a sum tree element after item element" + .to_string(), + ))); + } + } + _ => { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "unexpected element type in result".to_string(), + ))); + } + } } + } else { + // Handle descending order + let mut prev_element: Option<(Vec>, i64, Element)> = None; - let contender = ContenderWithSerializedDocument { - identity_id, - serialized_document: Some(serialized_document), - vote_tally: Some(sum_tree_value as u32), - }; + while let Some((path, _, element)) = elements_iter.next() { + let Some(element) = element else { + continue; + }; + let Some(identity_bytes) = path.last() else { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "the path must have a last element".to_string(), + ))); + }; - contenders.push(contender) + match element { + Element::SumTree(_, sum_tree_value, _) => { + if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!( + "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", + sum_tree_value + )))); + } + + match identity_bytes.get(0) { + Some(key) if key == &RESOURCE_LOCK_VOTE_TREE_KEY_U8 => { + locked_vote_tally = Some(sum_tree_value as u32); + } + Some(key) if key == &RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8 => { + abstaining_vote_tally = Some(sum_tree_value as u32); + } + _ => { + prev_element = + Some((path.clone(), sum_tree_value, element)); + } + } + } + Element::Item(serialized_document, _) => { + if let Some(( + prev_path, + sum_tree_value, + Element::SumTree(_, _, _), + )) = prev_element.take() + { + if prev_path != path { + return Err(Error::Drive(DriveError::CorruptedDriveState("the two results in a chunk when requesting documents and vote tally should both have the same path".to_string()))); + } + + let identity_id = Identifier::from_bytes(identity_bytes)?; + let contender = ContenderWithSerializedDocument { + identity_id, + serialized_document: Some(serialized_document), + vote_tally: Some(sum_tree_value as u32), + }; + contenders.push(contender); + } else { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "expected a sum tree element before item element" + .to_string(), + ))); + } + } + _ => { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "unexpected element type in result".to_string(), + ))); + } + } + } } - Ok(contenders) - } - }?; - Ok((root_hash, contenders)) + Ok(( + root_hash, + ContestedDocumentVotePollDriveQueryExecutionResult { + contenders, + locked_vote_tally, + abstaining_vote_tally, + skipped: 0, + }, + )) + } + } } } diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index 95016df3da..eb2272352a 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -600,11 +600,10 @@ impl ContestedDocumentVotePollDriveQuery { Some(key) if key == &RESOURCE_LOCK_VOTE_TREE_KEY_U8 => { locked_vote_tally = Some(sum_tree_value as u32); } - Some(key) => { - if key == &RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8 { - abstaining_vote_tally = Some(sum_tree_value as u32); - } + Some(key) if key == &RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8 => { + abstaining_vote_tally = Some(sum_tree_value as u32); } + _ => { let identity_id = Identifier::try_from(key)?; contenders.push(ContenderWithSerializedDocument { @@ -651,11 +650,10 @@ impl ContestedDocumentVotePollDriveQuery { Some(key) if key == &RESOURCE_LOCK_VOTE_TREE_KEY_U8 => { locked_vote_tally = Some(sum_tree_value as u32); } - Some(key) => { - if key == &RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8 { - abstaining_vote_tally = - Some(sum_tree_value as u32); - } + Some(key) + if key == &RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8 => + { + abstaining_vote_tally = Some(sum_tree_value as u32); } _ => { return Err(Error::Drive( @@ -731,11 +729,10 @@ impl ContestedDocumentVotePollDriveQuery { Some(key) if key == &RESOURCE_LOCK_VOTE_TREE_KEY_U8 => { locked_vote_tally = Some(sum_tree_value as u32); } - Some(key) => { - if key == &RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8 { - abstaining_vote_tally = - Some(sum_tree_value as u32); - } + Some(key) + if key == &RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8 => + { + abstaining_vote_tally = Some(sum_tree_value as u32); } _ => { prev_element = From 748e50dc8681ed0850596d80fd5d9db10f59fbde Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 31 May 2024 16:44:37 +0200 Subject: [PATCH 106/135] a lot of work --- .../protos/platform/v0/platform.proto | 24 ++- .../vote_choices/resource_vote_choice/mod.rs | 17 ++ .../state_transitions/masternode_vote/mod.rs | 133 ++++++++++--- .../v0/mod.rs | 48 +++-- packages/rs-drive/src/drive/votes/mod.rs | 150 +------------- .../mod.rs | 186 ++++++++++++++++++ .../src/drive/votes/storage_form/mod.rs | 5 + .../storage_form/vote_storage_form/mod.rs | 74 +++++++ .../src/drive/votes/tree_path_storage_form.rs | 9 + ..._resource_votes_given_by_identity_query.rs | 64 +++--- .../src/version/drive_versions.rs | 6 + .../src/version/mocks/v2_test.rs | 5 +- .../src/version/mocks/v3_test.rs | 5 +- .../rs-platform-version/src/version/v1.rs | 5 +- 14 files changed, 503 insertions(+), 228 deletions(-) create mode 100644 packages/rs-drive/src/drive/votes/storage_form/contested_document_resource_storage_form/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/storage_form/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/storage_form/vote_storage_form/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/tree_path_storage_form.rs diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index 87875bb036..b3b10be265 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -844,18 +844,30 @@ message GetContestedResourceIdentityVotesRequest { message GetContestedResourceIdentityVotesResponse { message GetContestedResourceIdentityVotesResponseV0 { - message Votes { - repeated Vote votes = 1; + message ContestedResourceIdentityVotes { + repeated ContestedResourceIdentityVote contested_resource_identity_votes = 1; bool finished_results = 2; } - message Vote { - // We return a serialized vote - bytes contested_resource_serialized_vote = 1; + message ResourceVoteChoice { + enum VoteChoiceType { + TOWARDS_IDENTITY = 0; + ABSTAIN = 1; + LOCK = 2; + } + VoteChoiceType vote_choice_type = 1; + optional bytes identity_id = 2; // Only used when vote_choice_type is TOWARDS_IDENTITY + } + + message ContestedResourceIdentityVote { + bytes contract_id = 1; + string document_type_name = 2; + repeated bytes serialized_index_storage_values = 3; + ResourceVoteChoice vote_choice = 4; } oneof result { - Votes votes = 1; + ContestedResourceIdentityVotes votes = 1; Proof proof = 2; } ResponseMetadata metadata = 3; diff --git a/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs b/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs index cb397a1c60..876289e664 100644 --- a/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs +++ b/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs @@ -1,3 +1,7 @@ +use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice::{ + Abstain, Lock, TowardsIdentity, +}; +use crate::ProtocolError; use bincode::{Decode, Encode}; use platform_value::Identifier; #[cfg(feature = "vote-serde-conversion")] @@ -24,3 +28,16 @@ pub enum ResourceVoteChoice { Abstain, Lock, } + +impl TryFrom<(i32, Option>)> for ResourceVoteChoice { + type Error = ProtocolError; + + fn try_from(value: (i32, Option>)) -> Result { + match value.0 { + 0 => Ok(TowardsIdentity(value.1.ok_or(ProtocolError::DecodingError("identifier needed when trying to cast from an i32 to a resource vote choice".to_string()))?.try_into()?)), + 1 => Ok(Abstain), + 2 => Ok(Lock), + n => Err(ProtocolError::DecodingError(format!("identifier must be 0, 1, or 2, got {}", n))) + } + } +} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 8cacfb0c5e..be0b257d1e 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -158,16 +158,32 @@ mod tests { use drive::query::vote_poll_contestant_votes_query::ResolvedContestedDocumentVotePollVotesDriveQuery; use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_request::get_contested_resource_voters_for_identity_request_v0; use dpp::platform_value; + use dapi_grpc::platform::v0::get_contested_resource_identity_votes_request::{ + get_contested_resource_identity_votes_request_v0, + GetContestedResourceIdentityVotesRequestV0, + }; + use dapi_grpc::platform::v0::get_contested_resource_identity_votes_response::{ + get_contested_resource_identity_votes_response_v0, + GetContestedResourceIdentityVotesResponseV0, + }; + use dapi_grpc::platform::v0::{ + get_contested_resource_identity_votes_request, + get_contested_resource_identity_votes_response, + GetContestedResourceIdentityVotesRequest, + }; + use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice::Lock; + use drive::drive::votes::storage_form::contested_document_resource_storage_form::ContestedDocumentResourceVoteStorageForm; + use crate::error::Error; + use dashcore_rpc::dashcore_rpc_json::{DMNState, MasternodeListItem, MasternodeType}; + use dpp::dashcore::hashes::Hash; + use dpp::dashcore::{ProTxHash, Txid}; + use dpp::prelude::IdentityNonce; + use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; + use std::net::{IpAddr, Ipv4Addr, SocketAddr}; + use std::ops::Deref; mod vote_tests { use super::*; - use dashcore_rpc::dashcore_rpc_json::{DMNState, MasternodeListItem, MasternodeType}; - use dpp::dashcore::hashes::Hash; - use dpp::dashcore::{ProTxHash, Txid}; - use dpp::prelude::IdentityNonce; - use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; - use std::net::{IpAddr, Ipv4Addr, SocketAddr}; - use std::ops::Deref; fn setup_masternode_identity( platform: &mut TempPlatform, @@ -2228,24 +2244,11 @@ mod tests { mod identity_given_votes_query { use super::*; - use dapi_grpc::platform::v0::get_contested_resource_identity_votes_request::{ - get_contested_resource_identity_votes_request_v0, - GetContestedResourceIdentityVotesRequestV0, - }; - use dapi_grpc::platform::v0::get_contested_resource_identity_votes_response::{ - get_contested_resource_identity_votes_response_v0, - GetContestedResourceIdentityVotesResponseV0, - }; - use dapi_grpc::platform::v0::{ - get_contested_resource_identity_votes_request, - get_contested_resource_identity_votes_response, - GetContestedResourceIdentityVotesRequest, - }; - use dpp::ProtocolError; fn get_identity_given_votes( platform: &TempPlatform, platform_state: &PlatformState, + contract: &DataContract, identity_id: Identifier, count: Option, order_ascending: bool, @@ -2286,9 +2289,8 @@ mod tests { ) = query_validation_result.version.expect("expected a version"); let Some(get_contested_resource_identity_votes_response_v0::Result::Votes( - get_contested_resource_identity_votes_response_v0::Votes { - votes, - finished_results, + get_contested_resource_identity_votes_response_v0::ContestedResourceIdentityVotes { + contested_resource_identity_votes, finished_results, }, )) = result else { @@ -2298,14 +2300,22 @@ mod tests { assert!(finished_results); } - votes - .iter() + contested_resource_identity_votes + .into_iter() .map(|vote| { - ResourceVote::deserialize_from_bytes( - vote.contested_resource_serialized_vote.as_slice(), - ) + let get_contested_resource_identity_votes_response_v0::ContestedResourceIdentityVote { + contract_id, document_type_name, serialized_index_storage_values, vote_choice + } = vote; + let vote_choice = vote_choice.expect("expected a vote choice"); + let storage_form = ContestedDocumentResourceVoteStorageForm { + contract_id: contract_id.try_into().expect("expected 32 bytes"), + document_type_name, + index_values: serialized_index_storage_values, + resource_vote_choice: (vote_choice.vote_choice_type, vote_choice.identity_id).try_into()?, + }; + Ok(storage_form.resolve_with_contract(contract, platform_version)?) }) - .collect::, ProtocolError>>() + .collect::, Error>>() .expect("expected all voters to be identifiers") } @@ -2395,9 +2405,10 @@ mod tests { platform_version, ); - let votes = get_identity_given_votes( + let mut votes = get_identity_given_votes( &platform, &platform_state, + &dpns_contract, masternode.id(), None, true, @@ -2406,7 +2417,65 @@ mod tests { platform_version, ); - assert_eq!(votes.len(), 3) + assert_eq!(votes.len(), 3); + + let vote_0 = votes.remove(0); + let vote_1 = votes.remove(0); + let vote_2 = votes.remove(0); + + assert_eq!( + vote_0, + ResourceVote::V0(ResourceVoteV0 { + vote_poll: VotePoll::ContestedDocumentResourceVotePoll( + ContestedDocumentResourceVotePoll { + contract_id: dpns_contract.id(), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![ + Text("dash".to_string()), + Text("c001d0g".to_string()) + ] + } + ), + resource_vote_choice: TowardsIdentity(contender_2_cooldog.id()) + }) + ); + + assert_eq!( + vote_1, + ResourceVote::V0(ResourceVoteV0 { + vote_poll: VotePoll::ContestedDocumentResourceVotePoll( + ContestedDocumentResourceVotePoll { + contract_id: dpns_contract.id(), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![ + Text("dash".to_string()), + Text("superman".to_string()) + ] + } + ), + resource_vote_choice: Lock + }) + ); + + assert_eq!( + vote_2, + ResourceVote::V0(ResourceVoteV0 { + vote_poll: VotePoll::ContestedDocumentResourceVotePoll( + ContestedDocumentResourceVotePoll { + contract_id: dpns_contract.id(), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![ + Text("dash".to_string()), + Text("quantum".to_string()) + ] + } + ), + resource_vote_choice: TowardsIdentity(contender_1_quantum.id()) + }) + ); } } diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_identity_votes/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_votes/v0/mod.rs index 720add6915..fba356cdb0 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_identity_votes/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_votes/v0/mod.rs @@ -7,21 +7,16 @@ use dapi_grpc::platform::v0::get_contested_resource_identity_votes_request::GetC use dapi_grpc::platform::v0::get_contested_resource_identity_votes_response::{ get_contested_resource_identity_votes_response_v0, GetContestedResourceIdentityVotesResponseV0, }; -use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_response::{ - get_contested_resource_voters_for_identity_response_v0, - GetContestedResourceVotersForIdentityResponseV0, -}; use dpp::data_contract::accessors::v0::DataContractV0Getters; -use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::identifier::Identifier; use dpp::serialization::PlatformSerializable; use dpp::validation::ValidationResult; use dpp::version::PlatformVersion; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use dpp::{check_validation_result_with_data, platform_value, ProtocolError}; +use drive::drive::votes::storage_form::contested_document_resource_storage_form::ContestedDocumentResourceVoteStorageForm; use drive::error::query::QuerySyntaxError; use drive::query::contested_resource_votes_given_by_identity_query::ContestedResourceVotesGivenByIdentityQuery; -use drive::query::vote_poll_contestant_votes_query::ContestedDocumentVotePollVotesDriveQuery; impl Platform { pub(super) fn query_contested_resource_identity_votes_v0( @@ -149,24 +144,49 @@ impl Platform { true }; - let votes = votes + let contested_resource_identity_votes = votes .into_values() .map(|resource_vote| { - Ok(get_contested_resource_identity_votes_response_v0::Vote { - contested_resource_serialized_vote: resource_vote - .serialize_consume_to_bytes()?, + let ContestedDocumentResourceVoteStorageForm { + contract_id, document_type_name, index_values, resource_vote_choice + } = resource_vote; + let vote_choice = match resource_vote_choice { + ResourceVoteChoice::TowardsIdentity(towards_identity) => { + get_contested_resource_identity_votes_response_v0::ResourceVoteChoice { + vote_choice_type: 0, + identity_id: Some(towards_identity.to_vec()), + } + } + ResourceVoteChoice::Abstain => { + get_contested_resource_identity_votes_response_v0::ResourceVoteChoice { + vote_choice_type: 1, + identity_id: None, + } + } + ResourceVoteChoice::Lock => { + get_contested_resource_identity_votes_response_v0::ResourceVoteChoice { + vote_choice_type: 2, + identity_id: None, + } + } + }; + Ok(get_contested_resource_identity_votes_response_v0::ContestedResourceIdentityVote { + contract_id: contract_id.to_vec(), + document_type_name, + serialized_index_storage_values: index_values, + vote_choice: Some(vote_choice), }) }) .collect::, + Vec, ProtocolError, >>()?; GetContestedResourceIdentityVotesResponseV0 { result: Some( get_contested_resource_identity_votes_response_v0::Result::Votes( - get_contested_resource_identity_votes_response_v0::Votes { - votes, + get_contested_resource_identity_votes_response_v0::ContestedResourceIdentityVotes { + contested_resource_identity_votes, finished_results, }, ), diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 10c0ca3d41..4f198ee94b 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -34,16 +34,17 @@ mod setup; #[cfg(any(feature = "server", feature = "verify"))] /// Resolve contested document resource vote poll module pub mod resolved; +#[cfg(feature = "server")] +/// Storage form +pub mod storage_form; +#[cfg(feature = "server")] +/// Tree path storage form +pub mod tree_path_storage_form; /// A trait to convert the vote to a tree path usable in grovedb pub trait TreePath { /// The tree path function fn tree_path<'a>(&'a self, contract: &'a DataContract) -> Result, ProtocolError>; - - /// Construction of the resource vote from the tree oath - fn try_from_tree_path(path: Vec>) -> Result - where - Self: Sized; } impl TreePath for Vote { @@ -52,148 +53,9 @@ impl TreePath for Vote { Vote::ResourceVote(resource_vote) => resource_vote.tree_path(contract), } } - - fn try_from_tree_path(path: Vec>) -> Result - where - Self: Sized, - { - if path.len() < 3 { - return Err(ProtocolError::VoteError(format!( - "path {} is not long enough to construct vote information", - path.into_iter() - .map(hex::encode) - .collect::>() - .join("/") - ))); - } - let key_0 = path.get(0).unwrap(); - let key_1 = path.get(1).unwrap(); - - let Some(key_0_byte) = key_0.get(0) else { - return Err(ProtocolError::VoteError(format!( - "path {} first element must be a byte", - path.into_iter() - .map(hex::encode) - .collect::>() - .join("/") - ))); - }; - - if *key_0_byte != Votes as u8 { - return Err(ProtocolError::VoteError(format!( - "path {} first element must be a byte for voting {}, got {}", - path.iter().map(hex::encode).collect::>().join("/"), - Votes as u8, - *key_0_byte - ))); - }; - - let Some(key_1_byte) = key_1.get(0) else { - return Err(ProtocolError::VoteError(format!( - "path {} second element must be a byte", - path.into_iter() - .map(hex::encode) - .collect::>() - .join("/") - ))); - }; - - match *key_1_byte as char { - CONTESTED_RESOURCE_TREE_KEY => { - Ok(Vote::ResourceVote(ResourceVote::try_from_tree_path(path)?)) - } - VOTE_DECISIONS_TREE_KEY => Err(ProtocolError::NotSupported( - "decision votes not supported yet".to_string(), - )), - _ => Err(ProtocolError::VoteError(format!( - "path {} second element must be a byte for CONTESTED_RESOURCE_TREE_KEY {}, got {}", - path.iter().map(hex::encode).collect::>().join("/"), - CONTESTED_RESOURCE_TREE_KEY as u8, - *key_1_byte - ))), - } - } } impl TreePath for ResourceVote { - fn try_from_tree_path(path: Vec>) -> Result - where - Self: Sized, - { - if path.len() < 8 { - return Err(ProtocolError::VoteError(format!( - "path {} is not long enough to construct vote information", - path.into_iter() - .map(hex::encode) - .collect::>() - .join("/") - ))); - } - - let key_2 = path.get(2).unwrap(); // active_vote_polls - let key_contract_id = path.get(3).unwrap(); // contract_id - let key_document_type_name = path.get(4).unwrap(); // document_type_name - let key_vote_choice = path.get(path.len() - 3).unwrap(); // this is the vote choice - - let Some(key_2_byte) = key_2.get(0) else { - return Err(ProtocolError::VoteError(format!( - "path {} third element must be a byte", - path.into_iter() - .map(hex::encode) - .collect::>() - .join("/") - ))); - }; - - if *key_2_byte != ACTIVE_POLLS_TREE_KEY as u8 { - return Err(ProtocolError::VoteError(format!( - "path {} third element must be a byte for ACTIVE_POLLS_TREE_KEY {}, got {}", - path.iter().map(hex::encode).collect::>().join("/"), - ACTIVE_POLLS_TREE_KEY as u8, - *key_2_byte - ))); - }; - - if key_contract_id.len() != DEFAULT_HASH_SIZE_USIZE { - return Err(ProtocolError::VoteError(format!( - "path {} fourth element must be a contract id but isn't 32 bytes long", - path.into_iter() - .map(hex::encode) - .collect::>() - .join("/") - ))); - } - - let contract_id = Identifier::from_vec(key_contract_id.clone())?; - - let document_type_name = String::from_utf8(key_document_type_name.clone()).map_err(|_| ProtocolError::VoteError(format!("path {} fifth element must be a document type name but couldn't be converted to a string", path.iter().map(hex::encode).collect::>().join("/"))))?; - - let resource_vote_choice = if key_vote_choice.len() == 32 { - ResourceVoteChoice::TowardsIdentity(Identifier::from_vec(key_vote_choice.clone())?) - } else if key_vote_choice.len() == 1 { - let char = (*key_vote_choice.first().unwrap()) as char; - match char { - RESOURCE_ABSTAIN_VOTE_TREE_KEY => ResourceVoteChoice::Abstain, - RESOURCE_LOCK_VOTE_TREE_KEY => ResourceVoteChoice::Lock, - _ => return Err(ProtocolError::VoteError(format!("path {} 2 before last element must be an identifier or RESOURCE_ABSTAIN_VOTE_TREE_KEY/RESOURCE_LOCK_VOTE_TREE_KEY", path.into_iter().map(hex::encode).collect::>().join("/")))), - } - } else { - return Err(ProtocolError::VoteError(format!("path {} 2 before last element must be an identifier or RESOURCE_ABSTAIN_VOTE_TREE_KEY/RESOURCE_LOCK_VOTE_TREE_KEY", path.into_iter().map(hex::encode).collect::>().join("/")))); - }; - - let vote_poll = - VotePoll::ContestedDocumentResourceVotePoll(ContestedDocumentResourceVotePoll { - contract_id, - document_type_name, - index_name: "".to_string(), - index_values: vec![], - }); - - Ok(ResourceVote::V0(ResourceVoteV0 { - vote_poll, - resource_vote_choice, - })) - } fn tree_path<'a>(&'a self, contract: &'a DataContract) -> Result, ProtocolError> { let vote_poll = self.vote_poll(); diff --git a/packages/rs-drive/src/drive/votes/storage_form/contested_document_resource_storage_form/mod.rs b/packages/rs-drive/src/drive/votes/storage_form/contested_document_resource_storage_form/mod.rs new file mode 100644 index 0000000000..167f88fd00 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/storage_form/contested_document_resource_storage_form/mod.rs @@ -0,0 +1,186 @@ +use crate::drive::defaults::DEFAULT_HASH_SIZE_USIZE; +use crate::drive::votes::paths::{ + ACTIVE_POLLS_TREE_KEY, RESOURCE_ABSTAIN_VOTE_TREE_KEY, RESOURCE_LOCK_VOTE_TREE_KEY, +}; +use crate::drive::votes::tree_path_storage_form::TreePathStorageForm; +use crate::error::contract::DataContractError::{CorruptedDataContract, ProvidedContractMismatch}; +use crate::error::drive::DriveError; +use crate::error::Error; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::identifier::Identifier; +use dpp::platform_value::Value; +use dpp::prelude::DataContract; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::voting::vote_polls::VotePoll; +use dpp::voting::votes::resource_vote::v0::ResourceVoteV0; +use dpp::voting::votes::resource_vote::ResourceVote; +use dpp::ProtocolError; +use platform_version::version::PlatformVersion; + +/// Represents the storage form of a contested document resource vote. +#[derive(Debug, Clone, PartialEq)] +pub struct ContestedDocumentResourceVoteStorageForm { + /// The identifier of the contract associated with the resource vote. + pub contract_id: Identifier, + + /// The name of the document type associated with the resource vote. + pub document_type_name: String, + + /// The index values associated with the resource vote, stored as a vector of byte vectors. + pub index_values: Vec>, + + /// The choice of the resource vote, represented by a `ResourceVoteChoice` enum. + pub resource_vote_choice: ResourceVoteChoice, +} + +impl ContestedDocumentResourceVoteStorageForm { + /// Resolves to a resource vote + pub fn resolve_with_contract( + self, + data_contract: &DataContract, + platform_version: &PlatformVersion, + ) -> Result { + match platform_version + .drive + .methods + .vote + .storage_form + .resolve_with_contract + { + 0 => self.resolve_with_contract_v0(data_contract), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "ContestedDocumentResourceVoteStorageForm::resolve_with_contract" + .to_string(), + known_versions: vec![0], + received: version, + })), + } + } + + fn resolve_with_contract_v0(self, data_contract: &DataContract) -> Result { + let ContestedDocumentResourceVoteStorageForm { + contract_id, + document_type_name, + index_values, + resource_vote_choice, + } = self; + + let document_type = data_contract.document_type_for_name(document_type_name.as_str())?; + + let index = document_type + .find_contested_index() + .ok_or(Error::DataContract(ProvidedContractMismatch( + "no contested index on provided contract".to_string(), + )))?; + + let resolved_index_values = index_values + .into_iter() + .zip(index.properties.iter()) + .map(|(serialized_index_value, property)| { + let document_property = document_type + .flattened_properties() + .get(property.name.as_str()) + .ok_or(Error::DataContract(CorruptedDataContract( + "document type does not have a property of its index".to_string(), + )))?; + let value = document_property + .property_type + .decode_value_for_tree_keys(serialized_index_value.as_slice())?; + Ok(value) + }) + .collect::, Error>>()?; + + let vote_poll = + VotePoll::ContestedDocumentResourceVotePoll(ContestedDocumentResourceVotePoll { + contract_id, + document_type_name, + index_name: index.name.clone(), + index_values: resolved_index_values, + }); + + Ok(ResourceVote::V0(ResourceVoteV0 { + vote_poll, + resource_vote_choice, + })) + } +} + +impl TreePathStorageForm for ContestedDocumentResourceVoteStorageForm { + fn try_from_tree_path(mut path: Vec>) -> Result + where + Self: Sized, + { + if path.len() < 9 { + return Err(ProtocolError::VoteError(format!( + "path {} is not long enough to construct vote information", + path.into_iter() + .map(hex::encode) + .collect::>() + .join("/") + ))); + } + + let key_2 = path.get(2).unwrap(); // active_vote_polls + let key_contract_id = path.get(3).unwrap(); // contract_id + let key_document_type_name = path.get(4).unwrap(); // document_type_name + let key_vote_choice = path.get(path.len() - 3).unwrap(); // this is the vote choice + + let Some(key_2_byte) = key_2.get(0) else { + return Err(ProtocolError::VoteError(format!( + "path {} third element must be a byte", + path.into_iter() + .map(hex::encode) + .collect::>() + .join("/") + ))); + }; + + if *key_2_byte != ACTIVE_POLLS_TREE_KEY as u8 { + return Err(ProtocolError::VoteError(format!( + "path {} third element must be a byte for ACTIVE_POLLS_TREE_KEY {}, got {}", + path.iter().map(hex::encode).collect::>().join("/"), + ACTIVE_POLLS_TREE_KEY as u8, + *key_2_byte + ))); + }; + + if key_contract_id.len() != DEFAULT_HASH_SIZE_USIZE { + return Err(ProtocolError::VoteError(format!( + "path {} fourth element must be a contract id but isn't 32 bytes long", + path.into_iter() + .map(hex::encode) + .collect::>() + .join("/") + ))); + } + + let contract_id = Identifier::from_vec(key_contract_id.clone())?; + + let document_type_name = String::from_utf8(key_document_type_name.clone()).map_err(|_| ProtocolError::VoteError(format!("path {} fifth element must be a document type name but couldn't be converted to a string", path.iter().map(hex::encode).collect::>().join("/"))))?; + + let resource_vote_choice = if key_vote_choice.len() == 32 { + ResourceVoteChoice::TowardsIdentity(Identifier::from_vec(key_vote_choice.clone())?) + } else if key_vote_choice.len() == 1 { + let char = (*key_vote_choice.first().unwrap()) as char; + match char { + RESOURCE_ABSTAIN_VOTE_TREE_KEY => ResourceVoteChoice::Abstain, + RESOURCE_LOCK_VOTE_TREE_KEY => ResourceVoteChoice::Lock, + _ => return Err(ProtocolError::VoteError(format!("path {} 2 before last element must be an identifier or RESOURCE_ABSTAIN_VOTE_TREE_KEY/RESOURCE_LOCK_VOTE_TREE_KEY", path.into_iter().map(hex::encode).collect::>().join("/")))), + } + } else { + return Err(ProtocolError::VoteError(format!("path {} 2 before last element must be an identifier or RESOURCE_ABSTAIN_VOTE_TREE_KEY/RESOURCE_LOCK_VOTE_TREE_KEY", path.into_iter().map(hex::encode).collect::>().join("/")))); + }; + + // 5 is the first index value, then we have 2 at the end that are not index values + let index_values = path.drain(5..path.len() - 3).collect::>(); + + Ok(ContestedDocumentResourceVoteStorageForm { + contract_id, + document_type_name, + index_values, + resource_vote_choice, + }) + } +} diff --git a/packages/rs-drive/src/drive/votes/storage_form/mod.rs b/packages/rs-drive/src/drive/votes/storage_form/mod.rs new file mode 100644 index 0000000000..cffe63448f --- /dev/null +++ b/packages/rs-drive/src/drive/votes/storage_form/mod.rs @@ -0,0 +1,5 @@ +/// Module for handling the storage form of contested document resources. +pub mod contested_document_resource_storage_form; + +/// Module for handling the storage form of votes. +pub mod vote_storage_form; diff --git a/packages/rs-drive/src/drive/votes/storage_form/vote_storage_form/mod.rs b/packages/rs-drive/src/drive/votes/storage_form/vote_storage_form/mod.rs new file mode 100644 index 0000000000..8bdcdfcb7e --- /dev/null +++ b/packages/rs-drive/src/drive/votes/storage_form/vote_storage_form/mod.rs @@ -0,0 +1,74 @@ +use crate::drive::votes::paths::{CONTESTED_RESOURCE_TREE_KEY, VOTE_DECISIONS_TREE_KEY}; +use crate::drive::votes::storage_form::contested_document_resource_storage_form::ContestedDocumentResourceVoteStorageForm; +use crate::drive::votes::tree_path_storage_form::TreePathStorageForm; +use crate::drive::RootTree::Votes; +use dpp::ProtocolError; + +/// Represents the various storage forms of votes. +pub enum VoteStorageForm { + /// Storage form for contested document resource votes. + ContestedDocumentResource(ContestedDocumentResourceVoteStorageForm), +} + +impl TreePathStorageForm for VoteStorageForm { + fn try_from_tree_path(path: Vec>) -> Result + where + Self: Sized, + { + if path.len() < 3 { + return Err(ProtocolError::VoteError(format!( + "path {} is not long enough to construct vote information", + path.into_iter() + .map(hex::encode) + .collect::>() + .join("/") + ))); + } + let key_0 = path.get(0).unwrap(); + let key_1 = path.get(1).unwrap(); + + let Some(key_0_byte) = key_0.get(0) else { + return Err(ProtocolError::VoteError(format!( + "path {} first element must be a byte", + path.into_iter() + .map(hex::encode) + .collect::>() + .join("/") + ))); + }; + + if *key_0_byte != Votes as u8 { + return Err(ProtocolError::VoteError(format!( + "path {} first element must be a byte for voting {}, got {}", + path.iter().map(hex::encode).collect::>().join("/"), + Votes as u8, + *key_0_byte + ))); + }; + + let Some(key_1_byte) = key_1.get(0) else { + return Err(ProtocolError::VoteError(format!( + "path {} second element must be a byte", + path.into_iter() + .map(hex::encode) + .collect::>() + .join("/") + ))); + }; + + match *key_1_byte as char { + CONTESTED_RESOURCE_TREE_KEY => Ok(VoteStorageForm::ContestedDocumentResource( + ContestedDocumentResourceVoteStorageForm::try_from_tree_path(path)?, + )), + VOTE_DECISIONS_TREE_KEY => Err(ProtocolError::NotSupported( + "decision votes not supported yet".to_string(), + )), + _ => Err(ProtocolError::VoteError(format!( + "path {} second element must be a byte for CONTESTED_RESOURCE_TREE_KEY {}, got {}", + path.iter().map(hex::encode).collect::>().join("/"), + CONTESTED_RESOURCE_TREE_KEY as u8, + *key_1_byte + ))), + } + } +} diff --git a/packages/rs-drive/src/drive/votes/tree_path_storage_form.rs b/packages/rs-drive/src/drive/votes/tree_path_storage_form.rs new file mode 100644 index 0000000000..5a22c12d1d --- /dev/null +++ b/packages/rs-drive/src/drive/votes/tree_path_storage_form.rs @@ -0,0 +1,9 @@ +use dpp::ProtocolError; + +/// A trait to figure out vote info from a tree path +pub trait TreePathStorageForm { + /// Construction of the resource vote from the tree oath + fn try_from_tree_path(path: Vec>) -> Result + where + Self: Sized; +} diff --git a/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs b/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs index a27d9d4944..498dc84504 100644 --- a/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs +++ b/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs @@ -1,11 +1,6 @@ -use crate::drive::votes::paths::{ - vote_contested_resource_identity_votes_tree_path_for_identity, - vote_contested_resource_identity_votes_tree_path_for_identity_vec, VotePollPaths, -}; -#[cfg(feature = "server")] -use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; -use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; -use crate::drive::votes::TreePath; +use crate::drive::votes::paths::vote_contested_resource_identity_votes_tree_path_for_identity_vec; +use crate::drive::votes::storage_form::contested_document_resource_storage_form::ContestedDocumentResourceVoteStorageForm; +use crate::drive::votes::tree_path_storage_form::TreePathStorageForm; #[cfg(feature = "server")] use crate::drive::Drive; use crate::error::Error; @@ -17,7 +12,6 @@ use crate::query::Query; #[cfg(feature = "server")] use dpp::block::block_info::BlockInfo; use dpp::identifier::Identifier; -use dpp::voting::votes::resource_vote::ResourceVote; #[cfg(feature = "server")] use grovedb::query_result_type::{QueryResultElements, QueryResultType}; #[cfg(feature = "server")] @@ -82,7 +76,7 @@ impl ContestedResourceVotesGivenByIdentityQuery { drive_operations: &mut Vec, platform_version: &PlatformVersion, ) -> Result, Error> { - let path_query = self.construct_path_query(platform_version)?; + let path_query = self.construct_path_query()?; drive.grove_get_proved_path_query( &path_query, false, @@ -100,7 +94,13 @@ impl ContestedResourceVotesGivenByIdentityQuery { block_info: Option, transaction: TransactionArg, platform_version: &PlatformVersion, - ) -> Result<(BTreeMap, u64), Error> { + ) -> Result< + ( + BTreeMap, + u64, + ), + Error, + > { let mut drive_operations = vec![]; let result = self.execute_no_proof(drive, transaction, &mut drive_operations, platform_version)?; @@ -127,8 +127,8 @@ impl ContestedResourceVotesGivenByIdentityQuery { transaction: TransactionArg, drive_operations: &mut Vec, platform_version: &PlatformVersion, - ) -> Result, Error> { - let path_query = self.construct_path_query(platform_version)?; + ) -> Result, Error> { + let path_query = self.construct_path_query()?; let query_result = drive.grove_get_raw_path_query( &path_query, transaction, @@ -142,17 +142,26 @@ impl ContestedResourceVotesGivenByIdentityQuery { | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok(BTreeMap::new()), Err(e) => Err(e), Ok((query_result_elements, _)) => { - let voters = query_result_elements - .to_path_key_elements() - .into_iter() - .map(|(path, key, element)| { - let reference = element.into_reference_path_type()?; - let absolute_path = - reference.absolute_path(path.as_slice(), Some(key.as_slice()))?; - let vote_id = Identifier::from_vec(key)?; - Ok((vote_id, ResourceVote::try_from_tree_path(absolute_path)?)) - }) - .collect::, Error>>()?; + let voters = + query_result_elements + .to_path_key_elements() + .into_iter() + .map(|(path, key, element)| { + let reference = element.into_reference_path_type()?; + let absolute_path = + reference.absolute_path(path.as_slice(), Some(key.as_slice()))?; + let vote_id = Identifier::from_vec(key)?; + Ok(( + vote_id, + ContestedDocumentResourceVoteStorageForm::try_from_tree_path( + absolute_path, + )?, + )) + }) + .collect::, + Error, + >>()?; Ok(voters) } @@ -170,7 +179,7 @@ impl ContestedResourceVotesGivenByIdentityQuery { drive_operations: &mut Vec, platform_version: &PlatformVersion, ) -> Result<(QueryResultElements, u16), Error> { - let path_query = self.construct_path_query(platform_version)?; + let path_query = self.construct_path_query()?; let query_result = drive.grove_get_path_query( &path_query, transaction, @@ -193,10 +202,7 @@ impl ContestedResourceVotesGivenByIdentityQuery { } } /// Operations to construct a path query. - pub fn construct_path_query( - &self, - platform_version: &PlatformVersion, - ) -> Result { + pub fn construct_path_query(&self) -> Result { let path = vote_contested_resource_identity_votes_tree_path_for_identity_vec( self.identity_id.as_bytes(), ); diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 952052c630..c89cfb3b59 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -268,6 +268,12 @@ pub struct DriveVoteMethodVersions { pub contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions, pub cleanup: DriveVoteCleanupMethodVersions, pub setup: DriveVoteSetupMethodVersions, + pub storage_form: DriveVoteStorageFormMethodVersions, +} + +#[derive(Clone, Debug, Default)] +pub struct DriveVoteStorageFormMethodVersions { + pub resolve_with_contract: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index b829125556..371c5cf85e 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -71,7 +71,7 @@ use crate::version::drive_versions::{ DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVerifyVoteMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, - DriveVoteMethodVersions, DriveVoteSetupMethodVersions, + DriveVoteMethodVersions, DriveVoteSetupMethodVersions, DriveVoteStorageFormMethodVersions, }; use crate::version::fee::v1::FEE_VERSION1; use crate::version::mocks::TEST_PROTOCOL_VERSION_SHIFT_BYTES; @@ -241,6 +241,9 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { setup: DriveVoteSetupMethodVersions { add_initial_vote_tree_main_structure_operations: 0, }, + storage_form: DriveVoteStorageFormMethodVersions { + resolve_with_contract: 0, + }, }, contract: DriveContractMethodVersions { prove: DriveContractProveMethodVersions { diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 527b9ea943..0d6c4b2d41 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -71,7 +71,7 @@ use crate::version::drive_versions::{ DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVerifyVoteMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, - DriveVoteMethodVersions, DriveVoteSetupMethodVersions, + DriveVoteMethodVersions, DriveVoteSetupMethodVersions, DriveVoteStorageFormMethodVersions, }; use crate::version::fee::v1::FEE_VERSION1; use crate::version::mocks::TEST_PROTOCOL_VERSION_SHIFT_BYTES; @@ -249,6 +249,9 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { setup: DriveVoteSetupMethodVersions { add_initial_vote_tree_main_structure_operations: 0, }, + storage_form: DriveVoteStorageFormMethodVersions { + resolve_with_contract: 0, + }, }, contract: DriveContractMethodVersions { prove: DriveContractProveMethodVersions { diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 3129597869..c0b87469e7 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -71,7 +71,7 @@ use crate::version::drive_versions::{ DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVerifyVoteMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, - DriveVoteMethodVersions, DriveVoteSetupMethodVersions, + DriveVoteMethodVersions, DriveVoteSetupMethodVersions, DriveVoteStorageFormMethodVersions, }; use crate::version::fee::v1::FEE_VERSION1; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; @@ -240,6 +240,9 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { setup: DriveVoteSetupMethodVersions { add_initial_vote_tree_main_structure_operations: 0, }, + storage_form: DriveVoteStorageFormMethodVersions { + resolve_with_contract: 0, + }, }, contract: DriveContractMethodVersions { prove: DriveContractProveMethodVersions { From f731520f8c211f499978bd19c4a7631c84e978eb Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 31 May 2024 18:16:22 +0200 Subject: [PATCH 107/135] last query done --- .../state_transitions/masternode_vote/mod.rs | 237 ++++++++++++++++++ .../contested_resource_vote_state/v0/mod.rs | 21 +- .../rs-drive/src/drive/verify/voting/mod.rs | 1 + .../verify_identity_votes_given_proof/mod.rs | 58 +++++ .../v0/mod.rs | 58 +++++ .../verify_vote_poll_votes_proof/mod.rs | 1 - .../v0/mod.rs | 15 +- ..._resource_votes_given_by_identity_query.rs | 18 +- .../src/version/drive_versions.rs | 1 + .../src/version/mocks/v2_test.rs | 1 + .../src/version/mocks/v3_test.rs | 1 + .../rs-platform-version/src/version/v1.rs | 1 + 12 files changed, 400 insertions(+), 13 deletions(-) create mode 100644 packages/rs-drive/src/drive/verify/voting/verify_identity_votes_given_proof/mod.rs create mode 100644 packages/rs-drive/src/drive/verify/voting/verify_identity_votes_given_proof/v0/mod.rs diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index be0b257d1e..802d93ec6d 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -2244,6 +2244,7 @@ mod tests { mod identity_given_votes_query { use super::*; + use drive::query::contested_resource_votes_given_by_identity_query::ContestedResourceVotesGivenByIdentityQuery; fn get_identity_given_votes( platform: &TempPlatform, @@ -2319,6 +2320,84 @@ mod tests { .expect("expected all voters to be identifiers") } + fn get_proved_identity_given_votes( + platform: &TempPlatform, + platform_state: &PlatformState, + contract: &DataContract, + identity_id: Identifier, + count: Option, + order_ascending: bool, + start_at_vote_poll_id_info: Option< + get_contested_resource_identity_votes_request_v0::StartAtVotePollIdInfo, + >, + platform_version: &PlatformVersion, + ) -> Vec { + let query_validation_result = platform + .query_contested_resource_identity_votes( + GetContestedResourceIdentityVotesRequest { + version: Some( + get_contested_resource_identity_votes_request::Version::V0( + GetContestedResourceIdentityVotesRequestV0 { + identity_id: identity_id.to_vec(), + limit: count.map(|limit| limit as u32), + offset: None, + order_ascending, + start_at_vote_poll_id_info: start_at_vote_poll_id_info + .clone(), + prove: true, + }, + ), + ), + }, + platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_identity_votes_response::Version::V0( + GetContestedResourceIdentityVotesResponseV0 { + metadata: _, + result, + }, + ) = query_validation_result.version.expect("expected a version"); + + let Some(get_contested_resource_identity_votes_response_v0::Result::Proof(proof)) = + result + else { + panic!("expected contenders") + }; + + let query = ContestedResourceVotesGivenByIdentityQuery { + identity_id, + offset: None, + limit: count, + start_at: start_at_vote_poll_id_info.map(|start_at_vote_poll_info| { + let included = start_at_vote_poll_info.start_poll_identifier_included; + ( + start_at_vote_poll_info + .start_at_poll_identifier + .try_into() + .expect("expected 32 bytes"), + included, + ) + }), + order_ascending, + }; + + query + .verify_identity_votes_given_proof( + proof.grovedb_proof.as_slice(), + contract, + platform_version, + ) + .expect("expected to verify proof") + .1 + .into_values() + .collect() + } + #[test] fn test_not_proved_identity_given_votes_query_request() { let platform_version = PlatformVersion::latest(); @@ -2477,6 +2556,164 @@ mod tests { }) ); } + + #[test] + fn test_proved_identity_given_votes_query_request() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1_quantum, contender_2_quantum, dpns_contract) = + create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + let (contender_1_cooldog, contender_2_cooldog, dpns_contract) = + create_dpns_name_contest( + &mut platform, + &platform_state, + 8, + "cooldog", + platform_version, + ); + + let (contender_1_superman, contender_2_superman, dpns_contract) = + create_dpns_name_contest( + &mut platform, + &platform_state, + 9, + "superman", + platform_version, + ); + + let (masternode, signer, voting_key) = + setup_masternode_identity(&mut platform, 10, platform_version); + + // Now let's perform a few votes + + let platform_state = platform.state.load(); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + TowardsIdentity(contender_1_quantum.id()), + "quantum", + &signer, + masternode.id(), + &voting_key, + 1, + platform_version, + ); + + let platform_state = platform.state.load(); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + TowardsIdentity(contender_2_cooldog.id()), + "cooldog", + &signer, + masternode.id(), + &voting_key, + 2, + platform_version, + ); + + let platform_state = platform.state.load(); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + ResourceVoteChoice::Lock, + "superman", + &signer, + masternode.id(), + &voting_key, + 3, + platform_version, + ); + + let mut votes = get_proved_identity_given_votes( + &platform, + &platform_state, + &dpns_contract, + masternode.id(), + None, + true, + None, + platform_version, + ); + + assert_eq!(votes.len(), 3); + + let vote_0 = votes.remove(0); + let vote_1 = votes.remove(0); + let vote_2 = votes.remove(0); + + assert_eq!( + vote_0, + ResourceVote::V0(ResourceVoteV0 { + vote_poll: VotePoll::ContestedDocumentResourceVotePoll( + ContestedDocumentResourceVotePoll { + contract_id: dpns_contract.id(), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![ + Text("dash".to_string()), + Text("c001d0g".to_string()) + ] + } + ), + resource_vote_choice: TowardsIdentity(contender_2_cooldog.id()) + }) + ); + + assert_eq!( + vote_1, + ResourceVote::V0(ResourceVoteV0 { + vote_poll: VotePoll::ContestedDocumentResourceVotePoll( + ContestedDocumentResourceVotePoll { + contract_id: dpns_contract.id(), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![ + Text("dash".to_string()), + Text("superman".to_string()) + ] + } + ), + resource_vote_choice: Lock + }) + ); + + assert_eq!( + vote_2, + ResourceVote::V0(ResourceVoteV0 { + vote_poll: VotePoll::ContestedDocumentResourceVotePoll( + ContestedDocumentResourceVotePoll { + contract_id: dpns_contract.id(), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![ + Text("dash".to_string()), + Text("quantum".to_string()) + ] + } + ), + resource_vote_choice: TowardsIdentity(contender_1_quantum.id()) + }) + ); + } } mod end_date_query { diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs index 16f33b475c..99ad0ebc5f 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs @@ -82,23 +82,24 @@ impl Platform { )))); } + let bincode_config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + let index_values = match index_values .into_iter() .enumerate() .map(|(pos, serialized_value)| { - Ok(bincode::decode_from_slice( - serialized_value.as_slice(), - bincode::config::standard() - .with_big_endian() - .with_no_limit(), - ) - .map_err(|_| { - QueryError::InvalidArgument(format!( + Ok( + bincode::decode_from_slice(serialized_value.as_slice(), bincode_config) + .map_err(|_| { + QueryError::InvalidArgument(format!( "could not convert {:?} to a value in the index values at position {}", serialized_value, pos )) - })? - .0) + })? + .0, + ) }) .collect::, QueryError>>() { diff --git a/packages/rs-drive/src/drive/verify/voting/mod.rs b/packages/rs-drive/src/drive/verify/voting/mod.rs index 892827e80f..540c8999f5 100644 --- a/packages/rs-drive/src/drive/verify/voting/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/mod.rs @@ -1,4 +1,5 @@ mod verify_contests_proof; +mod verify_identity_votes_given_proof; mod verify_masternode_vote; mod verify_specialized_balance; mod verify_vote_poll_vote_state_proof; diff --git a/packages/rs-drive/src/drive/verify/voting/verify_identity_votes_given_proof/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_identity_votes_given_proof/mod.rs new file mode 100644 index 0000000000..c4611d9d41 --- /dev/null +++ b/packages/rs-drive/src/drive/verify/voting/verify_identity_votes_given_proof/mod.rs @@ -0,0 +1,58 @@ +mod v0; + +use crate::drive::verify::RootHash; +use crate::error::drive::DriveError; +use dpp::identifier::Identifier; +use dpp::prelude::DataContract; +use std::collections::BTreeMap; + +use crate::error::Error; + +use crate::query::contested_resource_votes_given_by_identity_query::ContestedResourceVotesGivenByIdentityQuery; +use dpp::version::PlatformVersion; +use dpp::voting::votes::resource_vote::ResourceVote; + +impl ContestedResourceVotesGivenByIdentityQuery { + /// Verifies a proof for the vote poll vote state proof. + /// + /// This function verifies a given serialized proof and returns the root hash along with a vector of deserialized identifiers. + /// + /// # Arguments + /// + /// * `proof` - A byte slice representing the serialized proof to be verified. + /// * `data_contract` - A reference to the data contract relevant to the proof. + /// * `platform_version` - A reference to the platform version to be used for verification. + /// + /// # Returns + /// + /// A `Result` containing: + /// * A tuple with the root hash and a vector of deserialized `Identifier`s if the proof is valid. + /// * An `Error` variant if the proof verification fails or a deserialization error occurs. + /// + /// # Errors + /// + /// This function will return an `Error` if: + /// * The proof verification fails. + /// * A deserialization error occurs when parsing the serialized document(s). + pub fn verify_identity_votes_given_proof( + &self, + proof: &[u8], + data_contract: &DataContract, + platform_version: &PlatformVersion, + ) -> Result<(RootHash, BTreeMap), Error> { + match platform_version + .drive + .methods + .verify + .voting + .verify_identity_votes_given_proof + { + 0 => self.verify_identity_votes_given_proof_v0(proof, data_contract, platform_version), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "verify_identity_votes_given_proof".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/verify/voting/verify_identity_votes_given_proof/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_identity_votes_given_proof/v0/mod.rs new file mode 100644 index 0000000000..7850d5fda8 --- /dev/null +++ b/packages/rs-drive/src/drive/verify/voting/verify_identity_votes_given_proof/v0/mod.rs @@ -0,0 +1,58 @@ +use crate::drive::verify::RootHash; +use crate::drive::votes::storage_form::contested_document_resource_storage_form::ContestedDocumentResourceVoteStorageForm; +use crate::drive::votes::tree_path_storage_form::TreePathStorageForm; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::query::contested_resource_votes_given_by_identity_query::ContestedResourceVotesGivenByIdentityQuery; +use dpp::bincode; +use dpp::data_contract::DataContract; +use dpp::identifier::Identifier; +use dpp::voting::votes::resource_vote::ResourceVote; +use grovedb::reference_path::ReferencePathType; +use grovedb::GroveDb; +use platform_version::version::PlatformVersion; +use std::collections::BTreeMap; + +impl ContestedResourceVotesGivenByIdentityQuery { + #[inline(always)] + pub(super) fn verify_identity_votes_given_proof_v0( + &self, + proof: &[u8], + data_contract: &DataContract, + platform_version: &PlatformVersion, + ) -> Result<(RootHash, BTreeMap), Error> { + let path_query = self.construct_path_query()?; + let (root_hash, proved_key_values) = GroveDb::verify_query(proof, &path_query)?; + + let voters = proved_key_values + .into_iter() + .filter_map(|(path, key, element)| element.map(|element| (path, key, element))) + .map(|(path, key, element)| { + let serialized_reference = element.into_item_bytes()?; + let bincode_config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + let reference: ReferencePathType = + bincode::decode_from_slice(&serialized_reference, bincode_config) + .map_err(|e| { + Error::Drive(DriveError::CorruptedSerialization(format!( + "serialization of reference {} is corrupted: {}", + hex::encode(serialized_reference), + e + ))) + })? + .0; + let absolute_path = + reference.absolute_path(path.as_slice(), Some(key.as_slice()))?; + let vote_id = Identifier::from_vec(key)?; + let vote_storage_form = + ContestedDocumentResourceVoteStorageForm::try_from_tree_path(absolute_path)?; + let resource_vote = + vote_storage_form.resolve_with_contract(data_contract, platform_version)?; + Ok((vote_id, resource_vote)) + }) + .collect::, Error>>()?; + + Ok((root_hash, voters)) + } +} diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_votes_proof/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_votes_proof/mod.rs index 92b153cfb0..3adf7583dd 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_votes_proof/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_votes_proof/mod.rs @@ -7,7 +7,6 @@ use dpp::identifier::Identifier; use crate::error::Error; use crate::query::vote_poll_contestant_votes_query::ResolvedContestedDocumentVotePollVotesDriveQuery; -use crate::query::vote_poll_vote_state_query::ContenderWithSerializedDocument; use dpp::version::PlatformVersion; impl<'a> ResolvedContestedDocumentVotePollVotesDriveQuery<'a> { diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index 2f3deedb70..5e40fed7d6 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -15,6 +15,7 @@ use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use dpp::{bincode, ProtocolError}; use grovedb::batch::KeyInfoPath; use grovedb::reference_path::ReferencePathType; use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; @@ -125,11 +126,23 @@ impl Drive { let reference = ReferencePathType::UpstreamRootHeightWithParentPathAdditionReference(2, voting_path); + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + let encoded_reference = bincode::encode_to_vec(reference, config).map_err(|e| { + Error::Protocol(ProtocolError::CorruptedSerialization(format!( + "can not encode reference: {}", + e + ))) + })?; self.batch_insert::<0>( PathKeyElement(( path, vote_poll.unique_id()?.to_vec(), - Element::new_reference_with_hops(reference, Some(1)), + // We store the encoded reference as an item on purpose as we want the advantages of a resolvable + // reference, but at the same time, we don't want the proof to have the value of the followed + // reference, because here there is no point, it being 1 or 4. + Element::new_item(encoded_reference), )), &mut drive_operations, &platform_version.drive, diff --git a/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs b/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs index 498dc84504..b13c527293 100644 --- a/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs +++ b/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs @@ -3,17 +3,20 @@ use crate::drive::votes::storage_form::contested_document_resource_storage_form: use crate::drive::votes::tree_path_storage_form::TreePathStorageForm; #[cfg(feature = "server")] use crate::drive::Drive; +use crate::error::drive::DriveError; use crate::error::Error; #[cfg(feature = "server")] use crate::fee::op::LowLevelDriveOperation; #[cfg(feature = "server")] use crate::query::GroveError; use crate::query::Query; +use dpp::bincode; #[cfg(feature = "server")] use dpp::block::block_info::BlockInfo; use dpp::identifier::Identifier; #[cfg(feature = "server")] use grovedb::query_result_type::{QueryResultElements, QueryResultType}; +use grovedb::reference_path::ReferencePathType; #[cfg(feature = "server")] use grovedb::TransactionArg; use grovedb::{PathQuery, SizedQuery}; @@ -147,7 +150,20 @@ impl ContestedResourceVotesGivenByIdentityQuery { .to_path_key_elements() .into_iter() .map(|(path, key, element)| { - let reference = element.into_reference_path_type()?; + let serialized_reference = element.into_item_bytes()?; + let bincode_config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + let reference: ReferencePathType = + bincode::decode_from_slice(&serialized_reference, bincode_config) + .map_err(|e| { + Error::Drive(DriveError::CorruptedSerialization(format!( + "serialization of reference {} is corrupted: {}", + hex::encode(serialized_reference), + e + ))) + })? + .0; let absolute_path = reference.absolute_path(path.as_slice(), Some(key.as_slice()))?; let vote_id = Identifier::from_vec(key)?; diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index c89cfb3b59..65edf689e4 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -114,6 +114,7 @@ pub struct DriveVerifyVoteMethodVersions { pub verify_masternode_vote: FeatureVersion, pub verify_start_at_contender_in_proof: FeatureVersion, pub verify_vote_poll_votes_proof: FeatureVersion, + pub verify_identity_votes_given_proof: FeatureVersion, pub verify_vote_poll_vote_state_proof: FeatureVersion, pub verify_contests_proof: FeatureVersion, pub verify_vote_polls_by_end_date_proof: FeatureVersion, diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 371c5cf85e..a08f2583e7 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -319,6 +319,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { verify_masternode_vote: 0, verify_start_at_contender_in_proof: 0, verify_vote_poll_votes_proof: 0, + verify_identity_votes_given_proof: 0, verify_vote_poll_vote_state_proof: 0, verify_contests_proof: 0, verify_vote_polls_by_end_date_proof: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 0d6c4b2d41..555409b9a9 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -327,6 +327,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { verify_masternode_vote: 0, verify_start_at_contender_in_proof: 0, verify_vote_poll_votes_proof: 0, + verify_identity_votes_given_proof: 0, verify_vote_poll_vote_state_proof: 0, verify_contests_proof: 0, verify_vote_polls_by_end_date_proof: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index c0b87469e7..f0862bb88b 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -318,6 +318,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { verify_masternode_vote: 0, verify_start_at_contender_in_proof: 0, verify_vote_poll_votes_proof: 0, + verify_identity_votes_given_proof: 0, verify_vote_poll_vote_state_proof: 0, verify_contests_proof: 0, verify_vote_polls_by_end_date_proof: 0, From 635b535cc8d7617cbf8722d55d49d983c1671e96 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 31 May 2024 22:09:43 +0200 Subject: [PATCH 108/135] more work --- .../state_transitions/masternode_vote/mod.rs | 164 ++++++++++-------- .../tests/strategy_tests/voting_tests.rs | 13 +- .../src/query/vote_poll_vote_state_query.rs | 4 +- 3 files changed, 104 insertions(+), 77 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 802d93ec6d..6ca702d0c1 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -1019,41 +1019,22 @@ mod tests { mod vote_state_query { use super::*; - #[test] - fn test_not_proved_vote_state_query_request_after_vote() { - let platform_version = PlatformVersion::latest(); - let mut platform = TestPlatformBuilder::new() - .build_with_mock_rpc() - .set_genesis_state(); - - let platform_state = platform.state.load(); - - let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( - &mut platform, - &platform_state, - 7, - "quantum", - platform_version, - ); - - let (masternode_1, signer_1, voting_key_1) = - setup_masternode_identity(&mut platform, 29, platform_version); - - let platform_state = platform.state.load(); - - perform_vote( - &mut platform, - &platform_state, - dpns_contract.as_ref(), - TowardsIdentity(contender_1.id()), - "quantum", - &signer_1, - masternode_1.id(), - &voting_key_1, - 1, - platform_version, - ); - + use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0; + use drive::query::vote_poll_vote_state_query::Contender; + fn get_vote_states( + platform: &TempPlatform, + platform_state: &PlatformState, + dpns_contract: &DataContract, + name: &str, + count: Option, + order_ascending: bool, + allow_include_locked_and_abstaining_vote_tally: bool, + start_at_identifier_info: Option< + get_contested_resource_vote_state_request_v0::StartAtIdentifierInfo, + >, + result_type: ResultType, + platform_version: &PlatformVersion, + ) -> Vec { // Now let's run a query for the vote totals let domain = dpns_contract @@ -1067,9 +1048,11 @@ mod tests { let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) .expect("expected to encode the word dash"); - let quantum_encoded = - bincode::encode_to_vec(Value::Text("quantum".to_string()), config) - .expect("expected to encode the word quantum"); + let quantum_encoded = bincode::encode_to_vec( + Value::Text(convert_to_homograph_safe_chars(name)), + config, + ) + .expect("expected to encode the word quantum"); let index_name = "parentNameAndLabel".to_string(); @@ -1085,11 +1068,11 @@ mod tests { dash_encoded.clone(), quantum_encoded.clone(), ], - result_type: ResultType::DocumentsAndVoteTally as i32, - allow_include_locked_and_abstaining_vote_tally: true, - start_at_identifier_info: None, - count: None, - order_ascending: true, + result_type: result_type as i32, + allow_include_locked_and_abstaining_vote_tally, + start_at_identifier_info, + count, + order_ascending, prove: false, }, )), @@ -1118,44 +1101,87 @@ mod tests { else { panic!("expected contenders") }; + contenders + .into_iter() + .map(|contender| Contender { + identity_id: contender.identifier.try_into().expect("expected 32 bytes"), + document: contender.document.map(|document_bytes| { + Document::from_bytes( + document_bytes.as_slice(), + domain, + platform_version, + ) + .expect("expected to deserialize document") + }), + vote_tally: None, + }) + .collect() + } - assert_eq!(contenders.len(), 2); + #[test] + fn test_not_proved_vote_state_query_request_after_vote() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); - let first_contender = contenders.first().unwrap(); + let platform_state = platform.state.load(); - let second_contender = contenders.last().unwrap(); + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); - let first_contender_document = Document::from_bytes( - first_contender - .document - .as_ref() - .expect("expected a document") - .as_slice(), - domain, + let (masternode_1, signer_1, voting_key_1) = + setup_masternode_identity(&mut platform, 29, platform_version); + + let platform_state = platform.state.load(); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + TowardsIdentity(contender_1.id()), + "quantum", + &signer_1, + masternode_1.id(), + &voting_key_1, + 1, platform_version, - ) - .expect("expected to get document"); + ); - let second_contender_document = Document::from_bytes( - second_contender - .document - .as_ref() - .expect("expected a document") - .as_slice(), - domain, + let contenders = get_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + true, + None, + ResultType::DocumentsAndVoteTally, + true, platform_version, - ) - .expect("expected to get document"); + ); - assert_ne!(first_contender_document, second_contender_document); + assert_eq!(contenders.len(), 2); - assert_eq!(first_contender.identifier, contender_1.id().to_vec()); + let first_contender = contenders.first().unwrap(); - assert_eq!(second_contender.identifier, contender_2.id().to_vec()); + let second_contender = contenders.last().unwrap(); + + assert_ne!(first_contender.document, second_contender.document); + + assert_eq!(first_contender.identity_id, contender_1.id()); - assert_eq!(first_contender.vote_count, Some(1)); + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(1)); - assert_eq!(second_contender.vote_count, Some(0)); + assert_eq!(second_contender.vote_tally, Some(0)); } #[test] diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index d2d75dbee9..0996d9aa35 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -240,7 +240,7 @@ mod tests { index_name: index_name.clone(), index_values: vec![dash_encoded.clone(), quantum_encoded.clone()], result_type: ResultType::DocumentsAndVoteTally as i32, - allow_include_locked_and_abstaining_vote_tally: false, + allow_include_locked_and_abstaining_vote_tally: true, start_at_identifier_info: None, count: None, order_ascending: true, @@ -321,7 +321,7 @@ mod tests { index_name: "parentNameAndLabel".to_string(), index_values: vec![dash_encoded, quantum_encoded], result_type: ResultType::DocumentsAndVoteTally as i32, - allow_include_locked_and_abstaining_vote_tally: false, + allow_include_locked_and_abstaining_vote_tally: true, start_at_identifier_info: None, count: None, order_ascending: true, @@ -364,9 +364,10 @@ mod tests { limit: None, start_at: None, order_ascending: true, + allow_include_locked_and_abstaining_vote_tally: true, }; - let (root_hash, contenders) = resolved_contested_document_vote_poll_drive_query + let (root_hash, result) = resolved_contested_document_vote_poll_drive_query .verify_vote_poll_vote_state_proof(proof.grovedb_proof.as_ref(), platform_version) .expect("expected to verify proof"); @@ -377,11 +378,11 @@ mod tests { .expect("expected an app hash") ); - assert_eq!(contenders.len(), 2); + assert_eq!(result.contenders.len(), 2); - let first_contender = contenders.first().unwrap(); + let first_contender = result.contenders.first().unwrap(); - let second_contender = contenders.last().unwrap(); + let second_contender = result.contenders.last().unwrap(); let first_contender_document = Document::from_bytes( first_contender diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index eb2272352a..9b38b7ae38 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -204,8 +204,8 @@ impl TryFrom for FinalizedContenderWithSerializ pub struct Contender { /// The identity ID of the contender. pub identity_id: Identifier, - /// The serialized document associated with the contender. - pub serialized_document: Option, + /// The document associated with the contender. + pub document: Option, /// The vote tally for the contender. pub vote_tally: Option, } From 6912bec1775864aa16c0d0dd6802b5a504d29d37 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 2 Jun 2024 05:03:39 +0200 Subject: [PATCH 109/135] refactored vote tests --- .../protos/platform/v0/platform.proto | 2 + .../state_transitions/documents_batch/mod.rs | 2 + .../state_transitions/masternode_vote/mod.rs | 741 +++++++++--------- .../contested_resource_vote_state/v0/mod.rs | 7 +- 4 files changed, 371 insertions(+), 381 deletions(-) diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index b3b10be265..9a26645472 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -760,6 +760,8 @@ message GetContestedResourceVoteStateResponse { message GetContestedResourceVoteStateResponseV0 { message ContestedResourceContenders { repeated Contender contenders = 1; + optional uint32 abstain_vote_tally = 2; + optional uint32 lock_vote_tally = 3; } message Contender { diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs index 9afd3f28dc..1326b06bc5 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs @@ -670,6 +670,8 @@ mod tests { get_contested_resource_vote_state_response_v0::Result::ContestedResourceContenders( get_contested_resource_vote_state_response_v0::ContestedResourceContenders { contenders, + abstain_vote_tally, + lock_vote_tally, }, ), ) = result diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 6ca702d0c1..2429b34296 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -181,6 +181,8 @@ mod tests { use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::ops::Deref; + use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0; + use drive::query::vote_poll_vote_state_query::Contender; mod vote_tests { use super::*; @@ -606,6 +608,7 @@ mod tests { get_contested_resource_vote_state_response_v0::Result::ContestedResourceContenders( get_contested_resource_vote_state_response_v0::ContestedResourceContenders { contenders, + .. }, ), ) = result @@ -819,6 +822,36 @@ mod tests { assert_eq!(processing_result.valid_count(), 1); } + fn perform_votes( + platform: &mut TempPlatform, + dpns_contract: &DataContract, + resource_vote_choice: ResourceVoteChoice, + name: &str, + count: u64, + start_seed: u64, + platform_version: &PlatformVersion, + ) { + for i in 0..count { + let (masternode, signer, voting_key) = + setup_masternode_identity(platform, start_seed + i, platform_version); + + let platform_state = platform.state.load(); + + perform_vote( + platform, + &platform_state, + dpns_contract, + resource_vote_choice, + name, + &signer, + masternode.id(), + &voting_key, + 1, + platform_version, + ); + } + } + mod contests_requests { use super::*; #[test] @@ -1019,8 +1052,7 @@ mod tests { mod vote_state_query { use super::*; - use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0; - use drive::query::vote_poll_vote_state_query::Contender; + use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType; fn get_vote_states( platform: &TempPlatform, platform_state: &PlatformState, @@ -1034,7 +1066,7 @@ mod tests { >, result_type: ResultType, platform_version: &PlatformVersion, - ) -> Vec { + ) -> (Vec, Option, Option) { // Now let's run a query for the vote totals let domain = dpns_contract @@ -1077,7 +1109,7 @@ mod tests { }, )), }, - &platform_state, + platform_state, platform_version, ) .expect("expected to execute query") @@ -1094,28 +1126,165 @@ mod tests { let Some( get_contested_resource_vote_state_response_v0::Result::ContestedResourceContenders( get_contested_resource_vote_state_response_v0::ContestedResourceContenders { - contenders, + contenders, abstain_vote_tally, lock_vote_tally, }, ), ) = result else { panic!("expected contenders") }; - contenders - .into_iter() - .map(|contender| Contender { - identity_id: contender.identifier.try_into().expect("expected 32 bytes"), - document: contender.document.map(|document_bytes| { - Document::from_bytes( - document_bytes.as_slice(), - domain, - platform_version, - ) - .expect("expected to deserialize document") - }), - vote_tally: None, - }) - .collect() + ( + contenders + .into_iter() + .map(|contender| Contender { + identity_id: contender + .identifier + .try_into() + .expect("expected 32 bytes"), + document: contender.document.map(|document_bytes| { + Document::from_bytes( + document_bytes.as_slice(), + domain, + platform_version, + ) + .expect("expected to deserialize document") + }), + vote_tally: contender.vote_count, + }) + .collect(), + abstain_vote_tally, + lock_vote_tally, + ) + } + + fn get_proved_vote_states( + platform: &TempPlatform, + platform_state: &PlatformState, + dpns_contract: &DataContract, + name: &str, + count: Option, + order_ascending: bool, + allow_include_locked_and_abstaining_vote_tally: bool, + start_at_identifier_info: Option< + get_contested_resource_vote_state_request_v0::StartAtIdentifierInfo, + >, + result_type: ResultType, + platform_version: &PlatformVersion, + ) -> (Vec, Option, Option) { + // Now let's run a query for the vote totals + + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); + + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + + let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) + .expect("expected to encode the word dash"); + + let quantum_encoded = bincode::encode_to_vec( + Value::Text(convert_to_homograph_safe_chars(name)), + config, + ) + .expect("expected to encode the word quantum"); + + let index_name = "parentNameAndLabel".to_string(); + + let query_validation_result = platform + .query_contested_resource_vote_state( + GetContestedResourceVoteStateRequest { + version: Some(get_contested_resource_vote_state_request::Version::V0( + GetContestedResourceVoteStateRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![ + dash_encoded.clone(), + quantum_encoded.clone(), + ], + result_type: result_type as i32, + allow_include_locked_and_abstaining_vote_tally, + start_at_identifier_info, + count, + order_ascending, + prove: true, + }, + )), + }, + platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_vote_state_response::Version::V0( + GetContestedResourceVoteStateResponseV0 { + metadata: _, + result, + }, + ) = query_validation_result.version.expect("expected a version"); + + let Some(get_contested_resource_vote_state_response_v0::Result::Proof(proof)) = + result + else { + panic!("expected contenders") + }; + + let resolved_contested_document_vote_poll_drive_query = + ResolvedContestedDocumentVotePollDriveQuery { + vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { + contract: DataContractResolvedInfo::BorrowedDataContract(dpns_contract), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![ + Value::Text("dash".to_string()), + Value::Text("quantum".to_string()), + ], + }, + result_type: ContestedDocumentVotePollDriveQueryResultType::try_from( + result_type as i32, + ) + .expect("expected valid result type"), + offset: None, + limit: count.map(|a| a as u16), + start_at: None, + order_ascending, + allow_include_locked_and_abstaining_vote_tally, + }; + + let (_, result) = resolved_contested_document_vote_poll_drive_query + .verify_vote_poll_vote_state_proof( + proof.grovedb_proof.as_ref(), + platform_version, + ) + .expect("expected to verify proof"); + + let abstaining_vote_tally = result.abstaining_vote_tally; + let lock_vote_tally = result.locked_vote_tally; + + let contenders = result.contenders; + ( + contenders + .into_iter() + .map(|contender| Contender { + identity_id: contender.identity_id, + document: contender.serialized_document.map(|document_bytes| { + Document::from_bytes( + document_bytes.as_slice(), + domain, + platform_version, + ) + .expect("expected to deserialize document") + }), + vote_tally: contender.vote_tally, + }) + .collect(), + abstaining_vote_tally, + lock_vote_tally, + ) } #[test] @@ -1153,7 +1322,7 @@ mod tests { platform_version, ); - let contenders = get_vote_states( + let (contenders, abstaining, locking) = get_vote_states( &platform, &platform_state, &dpns_contract, @@ -1163,7 +1332,6 @@ mod tests { true, None, ResultType::DocumentsAndVoteTally, - true, platform_version, ); @@ -1219,92 +1387,18 @@ mod tests { platform_version, ); - // Now let's run a query for the vote totals - - let domain = dpns_contract - .document_type_for_name("domain") - .expect("expected a profile document type"); - - let config = bincode::config::standard() - .with_big_endian() - .with_no_limit(); - - let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) - .expect("expected to encode the word dash"); - - let quantum_encoded = - bincode::encode_to_vec(Value::Text("quantum".to_string()), config) - .expect("expected to encode the word quantum"); - - let index_name = "parentNameAndLabel".to_string(); - - let GetContestedResourceVoteStateResponse { version } = platform - .query_contested_resource_vote_state( - GetContestedResourceVoteStateRequest { - version: Some(get_contested_resource_vote_state_request::Version::V0( - GetContestedResourceVoteStateRequestV0 { - contract_id: dpns_contract.id().to_vec(), - document_type_name: domain.name().clone(), - index_name: "parentNameAndLabel".to_string(), - index_values: vec![dash_encoded, quantum_encoded], - result_type: ResultType::DocumentsAndVoteTally as i32, - allow_include_locked_and_abstaining_vote_tally: true, - start_at_identifier_info: None, - count: None, - order_ascending: true, - prove: true, - }, - )), - }, - &platform_state, - platform_version, - ) - .expect("expected to execute query") - .into_data() - .expect("expected query to be valid"); - - let get_contested_resource_vote_state_response::Version::V0( - GetContestedResourceVoteStateResponseV0 { - metadata: _, - result, - }, - ) = version.expect("expected a version"); - - let Some(get_contested_resource_vote_state_response_v0::Result::Proof(proof)) = - result - else { - panic!("expected contenders") - }; - - let resolved_contested_document_vote_poll_drive_query = - ResolvedContestedDocumentVotePollDriveQuery { - vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { - contract: DataContractResolvedInfo::BorrowedDataContract( - &dpns_contract, - ), - document_type_name: domain.name().clone(), - index_name: index_name.clone(), - index_values: vec![ - Value::Text("dash".to_string()), - Value::Text("quantum".to_string()), - ], - }, - result_type: DocumentsAndVoteTally, - offset: None, - limit: None, - start_at: None, - order_ascending: true, - allow_include_locked_and_abstaining_vote_tally: true, - }; - - let (_, result) = resolved_contested_document_vote_poll_drive_query - .verify_vote_poll_vote_state_proof( - proof.grovedb_proof.as_ref(), - platform_version, - ) - .expect("expected to verify proof"); - - let contenders = result.contenders; + let (contenders, abstaining, locking) = get_proved_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); assert_eq!(contenders.len(), 2); @@ -1312,29 +1406,7 @@ mod tests { let second_contender = contenders.last().unwrap(); - let first_contender_document = Document::from_bytes( - first_contender - .serialized_document - .as_ref() - .expect("expected a document") - .as_slice(), - domain, - platform_version, - ) - .expect("expected to get document"); - - let second_contender_document = Document::from_bytes( - second_contender - .serialized_document - .as_ref() - .expect("expected a document") - .as_slice(), - domain, - platform_version, - ) - .expect("expected to get document"); - - assert_ne!(first_contender_document, second_contender_document); + assert_ne!(first_contender.document, second_contender.document); assert_eq!(first_contender.identity_id, contender_1.id()); @@ -1362,110 +1434,93 @@ mod tests { platform_version, ); - for i in 0..50 { - let (masternode, signer, voting_key) = - setup_masternode_identity(&mut platform, 10 + i, platform_version); - - let platform_state = platform.state.load(); + perform_votes( + &mut platform, + dpns_contract.as_ref(), + TowardsIdentity(contender_1.id()), + "quantum", + 50, + 10, + platform_version, + ); - perform_vote( - &mut platform, - &platform_state, - dpns_contract.as_ref(), - TowardsIdentity(contender_1.id()), - "quantum", - &signer, - masternode.id(), - &voting_key, - 1, - platform_version, - ); - } + perform_votes( + &mut platform, + dpns_contract.as_ref(), + TowardsIdentity(contender_2.id()), + "quantum", + 5, + 100, + platform_version, + ); - for i in 0..5 { - let (masternode, signer, voting_key) = - setup_masternode_identity(&mut platform, 100 + i, platform_version); + perform_votes( + &mut platform, + dpns_contract.as_ref(), + ResourceVoteChoice::Abstain, + "quantum", + 10, + 200, + platform_version, + ); - let platform_state = platform.state.load(); + perform_votes( + &mut platform, + dpns_contract.as_ref(), + ResourceVoteChoice::Lock, + "quantum", + 3, + 300, + platform_version, + ); - perform_vote( - &mut platform, - &platform_state, - dpns_contract.as_ref(), - TowardsIdentity(contender_2.id()), - "quantum", - &signer, - masternode.id(), - &voting_key, - 1, - platform_version, - ); - } + let (contenders, abstaining, locking) = get_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); - // Now let's run a query for the vote totals + assert_eq!(contenders.len(), 2); - let domain = dpns_contract - .document_type_for_name("domain") - .expect("expected a profile document type"); + let first_contender = contenders.first().unwrap(); - let config = bincode::config::standard() - .with_big_endian() - .with_no_limit(); + let second_contender = contenders.last().unwrap(); - let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) - .expect("expected to encode the word dash"); + assert_ne!(first_contender.document, second_contender.document); - let quantum_encoded = - bincode::encode_to_vec(Value::Text("quantum".to_string()), config) - .expect("expected to encode the word quantum"); + assert_eq!(first_contender.identity_id, contender_1.id()); - let index_name = "parentNameAndLabel".to_string(); + assert_eq!(second_contender.identity_id, contender_2.id()); - let query_validation_result = platform - .query_contested_resource_vote_state( - GetContestedResourceVoteStateRequest { - version: Some(get_contested_resource_vote_state_request::Version::V0( - GetContestedResourceVoteStateRequestV0 { - contract_id: dpns_contract.id().to_vec(), - document_type_name: domain.name().clone(), - index_name: index_name.clone(), - index_values: vec![ - dash_encoded.clone(), - quantum_encoded.clone(), - ], - result_type: ResultType::DocumentsAndVoteTally as i32, - allow_include_locked_and_abstaining_vote_tally: true, - start_at_identifier_info: None, - count: None, - order_ascending: true, - prove: false, - }, - )), - }, - &platform_state, - platform_version, - ) - .expect("expected to execute query") - .into_data() - .expect("expected query to be valid"); + assert_eq!(first_contender.vote_tally, Some(50)); - let get_contested_resource_vote_state_response::Version::V0( - GetContestedResourceVoteStateResponseV0 { - metadata: _, - result, - }, - ) = query_validation_result.version.expect("expected a version"); + assert_eq!(second_contender.vote_tally, Some(5)); - let Some( - get_contested_resource_vote_state_response_v0::Result::ContestedResourceContenders( - get_contested_resource_vote_state_response_v0::ContestedResourceContenders { - contenders, - }, - ), - ) = result - else { - panic!("expected contenders") - }; + assert_eq!(abstaining, Some(10)); + + assert_eq!(locking, Some(3)); + + // Now let's not include locked and abstaining + + let (contenders, abstaining, locking) = get_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + false, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); assert_eq!(contenders.len(), 2); @@ -1473,37 +1528,19 @@ mod tests { let second_contender = contenders.last().unwrap(); - let first_contender_document = Document::from_bytes( - first_contender - .document - .as_ref() - .expect("expected a document") - .as_slice(), - domain, - platform_version, - ) - .expect("expected to get document"); - - let second_contender_document = Document::from_bytes( - second_contender - .document - .as_ref() - .expect("expected a document") - .as_slice(), - domain, - platform_version, - ) - .expect("expected to get document"); + assert_ne!(first_contender.document, second_contender.document); - assert_ne!(first_contender_document, second_contender_document); + assert_eq!(first_contender.identity_id, contender_1.id()); - assert_eq!(first_contender.identifier, contender_1.id().to_vec()); + assert_eq!(second_contender.identity_id, contender_2.id()); - assert_eq!(second_contender.identifier, contender_2.id().to_vec()); + assert_eq!(first_contender.vote_tally, Some(50)); - assert_eq!(first_contender.vote_count, Some(50)); + assert_eq!(second_contender.vote_tally, Some(5)); + + assert_eq!(abstaining, None); - assert_eq!(second_contender.vote_count, Some(5)); + assert_eq!(locking, None); } #[test] @@ -1523,131 +1560,93 @@ mod tests { platform_version, ); - for i in 0..50 { - let (masternode, signer, voting_key) = - setup_masternode_identity(&mut platform, 10 + i, platform_version); + perform_votes( + &mut platform, + dpns_contract.as_ref(), + TowardsIdentity(contender_1.id()), + "quantum", + 50, + 10, + platform_version, + ); - let platform_state = platform.state.load(); + perform_votes( + &mut platform, + dpns_contract.as_ref(), + TowardsIdentity(contender_2.id()), + "quantum", + 5, + 100, + platform_version, + ); - perform_vote( - &mut platform, - &platform_state, - dpns_contract.as_ref(), - TowardsIdentity(contender_1.id()), - "quantum", - &signer, - masternode.id(), - &voting_key, - 1, - platform_version, - ); - } + perform_votes( + &mut platform, + dpns_contract.as_ref(), + ResourceVoteChoice::Abstain, + "quantum", + 10, + 200, + platform_version, + ); - for i in 0..5 { - let (masternode, signer, voting_key) = - setup_masternode_identity(&mut platform, 100 + i, platform_version); + perform_votes( + &mut platform, + dpns_contract.as_ref(), + ResourceVoteChoice::Lock, + "quantum", + 3, + 300, + platform_version, + ); - let platform_state = platform.state.load(); + let (contenders, abstaining, locking) = get_proved_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); - perform_vote( - &mut platform, - &platform_state, - dpns_contract.as_ref(), - TowardsIdentity(contender_2.id()), - "quantum", - &signer, - masternode.id(), - &voting_key, - 1, - platform_version, - ); - } - // Now let's run a query for the vote totals + assert_eq!(contenders.len(), 2); - let domain = dpns_contract - .document_type_for_name("domain") - .expect("expected a profile document type"); + let first_contender = contenders.first().unwrap(); - let config = bincode::config::standard() - .with_big_endian() - .with_no_limit(); + let second_contender = contenders.last().unwrap(); - let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) - .expect("expected to encode the word dash"); + assert_ne!(first_contender.document, second_contender.document); - let quantum_encoded = - bincode::encode_to_vec(Value::Text("quantum".to_string()), config) - .expect("expected to encode the word quantum"); + assert_eq!(first_contender.identity_id, contender_1.id()); - let index_name = "parentNameAndLabel".to_string(); + assert_eq!(second_contender.identity_id, contender_2.id()); - let GetContestedResourceVoteStateResponse { version } = platform - .query_contested_resource_vote_state( - GetContestedResourceVoteStateRequest { - version: Some(get_contested_resource_vote_state_request::Version::V0( - GetContestedResourceVoteStateRequestV0 { - contract_id: dpns_contract.id().to_vec(), - document_type_name: domain.name().clone(), - index_name: "parentNameAndLabel".to_string(), - index_values: vec![dash_encoded, quantum_encoded], - result_type: ResultType::DocumentsAndVoteTally as i32, - allow_include_locked_and_abstaining_vote_tally: true, - start_at_identifier_info: None, - count: None, - order_ascending: true, - prove: true, - }, - )), - }, - &platform_state, - platform_version, - ) - .expect("expected to execute query") - .into_data() - .expect("expected query to be valid"); + assert_eq!(first_contender.vote_tally, Some(50)); - let get_contested_resource_vote_state_response::Version::V0( - GetContestedResourceVoteStateResponseV0 { - metadata: _, - result, - }, - ) = version.expect("expected a version"); + assert_eq!(second_contender.vote_tally, Some(5)); - let Some(get_contested_resource_vote_state_response_v0::Result::Proof(proof)) = - result - else { - panic!("expected contenders") - }; + assert_eq!(abstaining, Some(10)); - let resolved_contested_document_vote_poll_drive_query = - ResolvedContestedDocumentVotePollDriveQuery { - vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { - contract: DataContractResolvedInfo::BorrowedDataContract( - &dpns_contract, - ), - document_type_name: domain.name().clone(), - index_name: index_name.clone(), - index_values: vec![ - Value::Text("dash".to_string()), - Value::Text("quantum".to_string()), - ], - }, - result_type: DocumentsAndVoteTally, - offset: None, - limit: None, - start_at: None, - order_ascending: true, - allow_include_locked_and_abstaining_vote_tally: true, - }; + assert_eq!(locking, Some(3)); - let (_, result) = resolved_contested_document_vote_poll_drive_query - .verify_vote_poll_vote_state_proof( - proof.grovedb_proof.as_ref(), - platform_version, - ) - .expect("expected to verify proof"); + // Now let's not include locked and abstaining - let contenders = result.contenders; + let (contenders, abstaining, locking) = get_proved_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + false, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); assert_eq!(contenders.len(), 2); @@ -1655,29 +1654,7 @@ mod tests { let second_contender = contenders.last().unwrap(); - let first_contender_document = Document::from_bytes( - first_contender - .serialized_document - .as_ref() - .expect("expected a document") - .as_slice(), - domain, - platform_version, - ) - .expect("expected to get document"); - - let second_contender_document = Document::from_bytes( - second_contender - .serialized_document - .as_ref() - .expect("expected a document") - .as_slice(), - domain, - platform_version, - ) - .expect("expected to get document"); - - assert_ne!(first_contender_document, second_contender_document); + assert_ne!(first_contender.document, second_contender.document); assert_eq!(first_contender.identity_id, contender_1.id()); @@ -1686,6 +1663,10 @@ mod tests { assert_eq!(first_contender.vote_tally, Some(50)); assert_eq!(second_contender.vote_tally, Some(5)); + + assert_eq!(abstaining, None); + + assert_eq!(locking, None); } } diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs index 99ad0ebc5f..be713abbd9 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs @@ -178,6 +178,9 @@ impl Platform { Err(e) => return Err(e.into()), }; + let abstain_vote_tally = results.abstaining_vote_tally; + let lock_vote_tally = results.locked_vote_tally; + let contenders = results .contenders .into_iter() @@ -200,7 +203,9 @@ impl Platform { result: Some( get_contested_resource_vote_state_response_v0::Result::ContestedResourceContenders( get_contested_resource_vote_state_response_v0::ContestedResourceContenders { - contenders + contenders, + abstain_vote_tally, + lock_vote_tally, }, ), ), From ea57ccef1c5d642a326f0fcdf133fa13d54b621b Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 3 Jun 2024 11:39:38 +0200 Subject: [PATCH 110/135] a lot of fixes --- Cargo.lock | 37 +- .../src/data_contract/errors/contract.rs | 4 +- .../data_contract/errors/json_schema_error.rs | 4 +- .../src/errors/consensus/basic/basic_error.rs | 4 +- ...tract_immutable_properties_update_error.rs | 4 +- .../consensus/basic/decode/decoding_error.rs | 4 +- .../decode/protocol_version_parsing_error.rs | 4 +- .../decode/serialized_object_parsing_error.rs | 4 +- .../consensus/basic/decode/version_error.rs | 4 +- ...d_identity_asset_lock_transaction_error.rs | 4 +- .../json_schema_error/json_schema_error.rs | 4 +- .../src/errors/consensus/consensus_error.rs | 9 +- .../src/errors/consensus/fee/fee_error.rs | 4 +- .../consensus/signature/signature_error.rs | 4 +- .../data_trigger_condition_error.rs | 4 +- .../data_trigger_execution_error.rs | 4 +- .../data_trigger_invalid_result_error.rs | 4 +- .../consensus/state/data_trigger/mod.rs | 4 +- .../src/errors/consensus/state/state_error.rs | 4 +- .../v0/mod.rs | 46 +- .../voting/lock_contested_resource/mod.rs | 43 ++ .../voting/lock_contested_resource/v0/mod.rs | 34 + .../voting/lock_vote_poll/mod.rs | 1 - .../execution/platform_events/voting/mod.rs | 2 +- .../state_transitions/masternode_vote/mod.rs | 731 ++++++++++-------- .../mod.rs | 2 +- packages/rs-drive/Cargo.toml | 1 + .../mod.rs | 39 + .../v0/mod.rs | 21 + .../rs-drive/src/drive/votes/cleanup/mod.rs | 2 + packages/rs-drive/src/drive/votes/mod.rs | 4 +- .../src/query/vote_poll_vote_state_query.rs | 27 + .../src/version/drive_abci_versions.rs | 2 +- .../src/version/drive_versions.rs | 1 + .../src/version/mocks/v2_test.rs | 3 +- .../src/version/mocks/v3_test.rs | 3 +- .../rs-platform-version/src/version/v1.rs | 3 +- 37 files changed, 708 insertions(+), 371 deletions(-) create mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/lock_contested_resource/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/lock_contested_resource/v0/mod.rs delete mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/lock_vote_poll/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/cleanup/add_lock_for_contested_document_resource_vote_poll/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/cleanup/add_lock_for_contested_document_resource_vote_poll/v0/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 3f94adc7ef..9c41c90914 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -530,9 +530,9 @@ dependencies = [ [[package]] name = "borsh" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbe5b10e214954177fb1dc9fbd20a1a2608fe99e6c832033bdc7cea287a20d77" +checksum = "a6362ed55def622cddc70a4746a68554d7b687713770de539e59a739b249f8ed" dependencies = [ "borsh-derive", "cfg_aliases", @@ -540,9 +540,9 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7a8646f94ab393e43e8b35a2558b1624bed28b97ee09c5d15456e3c9463f46d" +checksum = "c3ef8005764f53cd4dca619f5bf64cafd4664dada50ece25e4d81de54c80cc0b" dependencies = [ "once_cell", "proc-macro-crate 3.1.0", @@ -757,9 +757,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cfg_aliases" -version = "0.1.1" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "check-features" @@ -1603,6 +1603,7 @@ version = "1.0.0-dev.15" dependencies = [ "arc-swap", "base64 0.22.1", + "bincode 2.0.0-rc.3", "bs58 0.5.1", "byteorder", "chrono", @@ -2189,7 +2190,7 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "grovedb" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#229b7f26b4195b145a9f2621defc58ddaca913ce" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#c3d78a3e0f99aff8735896e6a1e5c06a38468bb1" dependencies = [ "bincode 2.0.0-rc.3", "bitvec", @@ -2212,7 +2213,7 @@ dependencies = [ [[package]] name = "grovedb-costs" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#229b7f26b4195b145a9f2621defc58ddaca913ce" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#c3d78a3e0f99aff8735896e6a1e5c06a38468bb1" dependencies = [ "integer-encoding", "intmap", @@ -2222,7 +2223,7 @@ dependencies = [ [[package]] name = "grovedb-merk" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#229b7f26b4195b145a9f2621defc58ddaca913ce" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#c3d78a3e0f99aff8735896e6a1e5c06a38468bb1" dependencies = [ "blake3", "byteorder", @@ -2245,12 +2246,12 @@ dependencies = [ [[package]] name = "grovedb-path" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#229b7f26b4195b145a9f2621defc58ddaca913ce" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#c3d78a3e0f99aff8735896e6a1e5c06a38468bb1" [[package]] name = "grovedb-storage" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#229b7f26b4195b145a9f2621defc58ddaca913ce" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#c3d78a3e0f99aff8735896e6a1e5c06a38468bb1" dependencies = [ "blake3", "grovedb-costs", @@ -2269,7 +2270,7 @@ dependencies = [ [[package]] name = "grovedb-visualize" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#229b7f26b4195b145a9f2621defc58ddaca913ce" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#c3d78a3e0f99aff8735896e6a1e5c06a38468bb1" dependencies = [ "hex", "itertools 0.12.1", @@ -3800,9 +3801,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.84" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] @@ -4833,7 +4834,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" dependencies = [ - "strum_macros 0.26.2", + "strum_macros 0.26.3", ] [[package]] @@ -4851,11 +4852,11 @@ dependencies = [ [[package]] name = "strum_macros" -version = "0.26.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" +checksum = "f7993a8e3a9e88a00351486baae9522c91b123a088f76469e5bd5cc17198ea87" dependencies = [ - "heck 0.4.1", + "heck 0.5.0", "proc-macro2", "quote", "rustversion", diff --git a/packages/rs-dpp/src/data_contract/errors/contract.rs b/packages/rs-dpp/src/data_contract/errors/contract.rs index db6df72423..80dee9f226 100644 --- a/packages/rs-dpp/src/data_contract/errors/contract.rs +++ b/packages/rs-dpp/src/data_contract/errors/contract.rs @@ -11,7 +11,9 @@ use crate::data_contract::errors::json_schema_error::JsonSchemaError; use crate::ProtocolError; // @append_only -#[derive(Error, Debug, PlatformSerialize, PlatformDeserialize, Encode, Decode, Clone)] +#[derive( + Error, Debug, PartialEq, PlatformSerialize, PlatformDeserialize, Encode, Decode, Clone, +)] pub enum DataContractError { #[error(transparent)] DecodingContractError(DecodingError), diff --git a/packages/rs-dpp/src/data_contract/errors/json_schema_error.rs b/packages/rs-dpp/src/data_contract/errors/json_schema_error.rs index 2d37615797..6d31854108 100644 --- a/packages/rs-dpp/src/data_contract/errors/json_schema_error.rs +++ b/packages/rs-dpp/src/data_contract/errors/json_schema_error.rs @@ -4,7 +4,9 @@ use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use thiserror::Error; // @append_only -#[derive(Error, Debug, PlatformSerialize, PlatformDeserialize, Encode, Decode, Clone)] +#[derive( + Error, Debug, PartialEq, Eq, PlatformSerialize, PlatformDeserialize, Encode, Decode, Clone, +)] pub enum JsonSchemaError { #[error("can't create json schema: {0}")] CreateSchemaError(String), diff --git a/packages/rs-dpp/src/errors/consensus/basic/basic_error.rs b/packages/rs-dpp/src/errors/consensus/basic/basic_error.rs index 7f4931eb60..6569a38eaa 100644 --- a/packages/rs-dpp/src/errors/consensus/basic/basic_error.rs +++ b/packages/rs-dpp/src/errors/consensus/basic/basic_error.rs @@ -70,7 +70,9 @@ use crate::consensus::basic::{ use crate::consensus::state::identity::master_public_key_update_error::MasterPublicKeyUpdateError; use crate::data_contract::errors::DataContractError; -#[derive(Error, Debug, PlatformSerialize, PlatformDeserialize, Encode, Decode, Clone)] +#[derive( + Error, Debug, PlatformSerialize, PlatformDeserialize, Encode, Decode, PartialEq, Clone, +)] pub enum BasicError { /* diff --git a/packages/rs-dpp/src/errors/consensus/basic/data_contract/data_contract_immutable_properties_update_error.rs b/packages/rs-dpp/src/errors/consensus/basic/data_contract/data_contract_immutable_properties_update_error.rs index 326a4316e1..2eeebfb0ce 100644 --- a/packages/rs-dpp/src/errors/consensus/basic/data_contract/data_contract_immutable_properties_update_error.rs +++ b/packages/rs-dpp/src/errors/consensus/basic/data_contract/data_contract_immutable_properties_update_error.rs @@ -7,7 +7,9 @@ use thiserror::Error; use bincode::{Decode, Encode}; -#[derive(Error, Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize)] +#[derive( + Error, Debug, Clone, PartialEq, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] #[error("only $defs, version and documents fields are allowed to be updated. Forbidden operation '{operation}' on '{field_path}'")] #[platform_serialize(unversioned)] pub struct DataContractImmutablePropertiesUpdateError { diff --git a/packages/rs-dpp/src/errors/consensus/basic/decode/decoding_error.rs b/packages/rs-dpp/src/errors/consensus/basic/decode/decoding_error.rs index 2fe833be13..6f3bb18e9f 100644 --- a/packages/rs-dpp/src/errors/consensus/basic/decode/decoding_error.rs +++ b/packages/rs-dpp/src/errors/consensus/basic/decode/decoding_error.rs @@ -7,7 +7,9 @@ use crate::consensus::ConsensusError; use crate::data_contract::errors::DataContractError; use bincode::{Decode, Encode}; -#[derive(Error, Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize)] +#[derive( + Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] #[error("Decoding error: {error}")] #[platform_serialize(unversioned)] pub struct DecodingError { diff --git a/packages/rs-dpp/src/errors/consensus/basic/decode/protocol_version_parsing_error.rs b/packages/rs-dpp/src/errors/consensus/basic/decode/protocol_version_parsing_error.rs index fdf2d879ba..c64e379c0b 100644 --- a/packages/rs-dpp/src/errors/consensus/basic/decode/protocol_version_parsing_error.rs +++ b/packages/rs-dpp/src/errors/consensus/basic/decode/protocol_version_parsing_error.rs @@ -6,7 +6,9 @@ use thiserror::Error; use crate::consensus::ConsensusError; use bincode::{Decode, Encode}; -#[derive(Error, Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize)] +#[derive( + Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] #[error("Can't read protocol version from serialized object: {parsing_error}")] #[platform_serialize(unversioned)] pub struct ProtocolVersionParsingError { diff --git a/packages/rs-dpp/src/errors/consensus/basic/decode/serialized_object_parsing_error.rs b/packages/rs-dpp/src/errors/consensus/basic/decode/serialized_object_parsing_error.rs index c93e1e4439..c415b41e93 100644 --- a/packages/rs-dpp/src/errors/consensus/basic/decode/serialized_object_parsing_error.rs +++ b/packages/rs-dpp/src/errors/consensus/basic/decode/serialized_object_parsing_error.rs @@ -5,7 +5,9 @@ use bincode::{Decode, Encode}; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use thiserror::Error; -#[derive(Error, Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize)] +#[derive( + Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] #[error("Parsing of serialized object failed due to: {parsing_error}")] #[platform_serialize(unversioned)] pub struct SerializedObjectParsingError { diff --git a/packages/rs-dpp/src/errors/consensus/basic/decode/version_error.rs b/packages/rs-dpp/src/errors/consensus/basic/decode/version_error.rs index f5429f5739..013204d5de 100644 --- a/packages/rs-dpp/src/errors/consensus/basic/decode/version_error.rs +++ b/packages/rs-dpp/src/errors/consensus/basic/decode/version_error.rs @@ -6,7 +6,9 @@ use thiserror::Error; use crate::consensus::ConsensusError; use bincode::{Decode, Encode}; -#[derive(Error, Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize)] +#[derive( + Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] #[error("Can't read protocol version from serialized object: {error}")] #[platform_serialize(unversioned)] pub struct VersionError { diff --git a/packages/rs-dpp/src/errors/consensus/basic/identity/invalid_identity_asset_lock_transaction_error.rs b/packages/rs-dpp/src/errors/consensus/basic/identity/invalid_identity_asset_lock_transaction_error.rs index 758c9fa362..344a55633d 100644 --- a/packages/rs-dpp/src/errors/consensus/basic/identity/invalid_identity_asset_lock_transaction_error.rs +++ b/packages/rs-dpp/src/errors/consensus/basic/identity/invalid_identity_asset_lock_transaction_error.rs @@ -6,7 +6,9 @@ use thiserror::Error; use bincode::{Decode, Encode}; -#[derive(Error, Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize)] +#[derive( + Error, Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize, PartialEq, +)] #[error("Invalid asset lock transaction: {message}")] #[platform_serialize(unversioned)] pub struct InvalidIdentityAssetLockTransactionError { diff --git a/packages/rs-dpp/src/errors/consensus/basic/json_schema_error/json_schema_error.rs b/packages/rs-dpp/src/errors/consensus/basic/json_schema_error/json_schema_error.rs index 5ea5ff2b00..143b4015b6 100644 --- a/packages/rs-dpp/src/errors/consensus/basic/json_schema_error/json_schema_error.rs +++ b/packages/rs-dpp/src/errors/consensus/basic/json_schema_error/json_schema_error.rs @@ -9,7 +9,9 @@ use platform_value::Value; use serde_json::Value as JsonValue; use thiserror::Error; -#[derive(Error, Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize)] +#[derive( + Error, Debug, Clone, PartialEq, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] #[error("JsonSchemaError: {error_summary}, path: {instance_path}")] #[platform_serialize(unversioned)] pub struct JsonSchemaError { diff --git a/packages/rs-dpp/src/errors/consensus/consensus_error.rs b/packages/rs-dpp/src/errors/consensus/consensus_error.rs index 7be628f29c..72d41d4aa3 100644 --- a/packages/rs-dpp/src/errors/consensus/consensus_error.rs +++ b/packages/rs-dpp/src/errors/consensus/consensus_error.rs @@ -16,7 +16,14 @@ use crate::errors::consensus::basic::BasicError; // TODO It must be versioned as all other serializable types #[derive( - thiserror::Error, Debug, Encode, Decode, PlatformSerialize, PlatformDeserialize, Clone, + thiserror::Error, + Debug, + Encode, + Decode, + PlatformSerialize, + PlatformDeserialize, + Clone, + PartialEq, )] #[platform_serialize(limit = 2000)] #[error(transparent)] diff --git a/packages/rs-dpp/src/errors/consensus/fee/fee_error.rs b/packages/rs-dpp/src/errors/consensus/fee/fee_error.rs index ad853b4bc7..cc19ca60f2 100644 --- a/packages/rs-dpp/src/errors/consensus/fee/fee_error.rs +++ b/packages/rs-dpp/src/errors/consensus/fee/fee_error.rs @@ -6,7 +6,9 @@ use thiserror::Error; use crate::errors::ProtocolError; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; -#[derive(Error, Debug, Encode, Decode, PlatformSerialize, PlatformDeserialize, Clone)] +#[derive( + Error, Debug, PartialEq, Encode, Decode, PlatformSerialize, PlatformDeserialize, Clone, +)] pub enum FeeError { /* diff --git a/packages/rs-dpp/src/errors/consensus/signature/signature_error.rs b/packages/rs-dpp/src/errors/consensus/signature/signature_error.rs index 74b2c6a724..f4d9811f09 100644 --- a/packages/rs-dpp/src/errors/consensus/signature/signature_error.rs +++ b/packages/rs-dpp/src/errors/consensus/signature/signature_error.rs @@ -12,7 +12,9 @@ use crate::consensus::signature::invalid_signature_public_key_purpose_error::Inv use crate::errors::ProtocolError; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; -#[derive(Error, Debug, Encode, Decode, PlatformSerialize, PlatformDeserialize, Clone)] +#[derive( + Error, Debug, PartialEq, Encode, Decode, PlatformSerialize, PlatformDeserialize, Clone, +)] pub enum SignatureError { /* diff --git a/packages/rs-dpp/src/errors/consensus/state/data_trigger/data_trigger_condition_error.rs b/packages/rs-dpp/src/errors/consensus/state/data_trigger/data_trigger_condition_error.rs index 16130f396d..9f0c216588 100644 --- a/packages/rs-dpp/src/errors/consensus/state/data_trigger/data_trigger_condition_error.rs +++ b/packages/rs-dpp/src/errors/consensus/state/data_trigger/data_trigger_condition_error.rs @@ -8,7 +8,9 @@ use thiserror::Error; use crate::consensus::state::data_trigger::DataTriggerError; use bincode::{Decode, Encode}; -#[derive(Error, Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize)] +#[derive( + Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] #[error("{message}")] #[platform_serialize(unversioned)] pub struct DataTriggerConditionError { diff --git a/packages/rs-dpp/src/errors/consensus/state/data_trigger/data_trigger_execution_error.rs b/packages/rs-dpp/src/errors/consensus/state/data_trigger/data_trigger_execution_error.rs index 3268926edf..f8bc1b46cf 100644 --- a/packages/rs-dpp/src/errors/consensus/state/data_trigger/data_trigger_execution_error.rs +++ b/packages/rs-dpp/src/errors/consensus/state/data_trigger/data_trigger_execution_error.rs @@ -8,7 +8,9 @@ use thiserror::Error; use crate::consensus::state::data_trigger::DataTriggerError; use bincode::{Decode, Encode}; -#[derive(Error, Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize)] +#[derive( + Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] #[error("{message}")] #[platform_serialize(unversioned)] pub struct DataTriggerExecutionError { diff --git a/packages/rs-dpp/src/errors/consensus/state/data_trigger/data_trigger_invalid_result_error.rs b/packages/rs-dpp/src/errors/consensus/state/data_trigger/data_trigger_invalid_result_error.rs index 97ecc5fd5b..35f06d3ff9 100644 --- a/packages/rs-dpp/src/errors/consensus/state/data_trigger/data_trigger_invalid_result_error.rs +++ b/packages/rs-dpp/src/errors/consensus/state/data_trigger/data_trigger_invalid_result_error.rs @@ -8,7 +8,9 @@ use thiserror::Error; use crate::consensus::state::data_trigger::DataTriggerError; use bincode::{Decode, Encode}; -#[derive(Error, Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize)] +#[derive( + Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] #[error("Data trigger have not returned any result")] #[platform_serialize(unversioned)] pub struct DataTriggerInvalidResultError { diff --git a/packages/rs-dpp/src/errors/consensus/state/data_trigger/mod.rs b/packages/rs-dpp/src/errors/consensus/state/data_trigger/mod.rs index cd61d89b7c..a753c9ccd6 100644 --- a/packages/rs-dpp/src/errors/consensus/state/data_trigger/mod.rs +++ b/packages/rs-dpp/src/errors/consensus/state/data_trigger/mod.rs @@ -12,7 +12,9 @@ pub mod data_trigger_condition_error; pub mod data_trigger_execution_error; pub mod data_trigger_invalid_result_error; -#[derive(Error, Debug, Encode, Decode, PlatformSerialize, PlatformDeserialize, Clone)] +#[derive( + Error, Debug, PartialEq, Encode, Decode, PlatformSerialize, PlatformDeserialize, Clone, +)] pub enum DataTriggerError { /* diff --git a/packages/rs-dpp/src/errors/consensus/state/state_error.rs b/packages/rs-dpp/src/errors/consensus/state/state_error.rs index 6443e404c2..7964e789e2 100644 --- a/packages/rs-dpp/src/errors/consensus/state/state_error.rs +++ b/packages/rs-dpp/src/errors/consensus/state/state_error.rs @@ -39,7 +39,9 @@ use crate::consensus::state::voting::masternode_not_found_error::MasternodeNotFo use super::document::document_timestamps_are_equal_error::DocumentTimestampsAreEqualError; -#[derive(Error, Debug, Encode, Decode, PlatformSerialize, PlatformDeserialize, Clone)] +#[derive( + Error, Debug, PartialEq, Encode, Decode, PlatformSerialize, PlatformDeserialize, Clone, +)] pub enum StateError { /* diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs index c77fcb8857..13676e3ac9 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs @@ -48,6 +48,9 @@ where platform_version, )?; let contenders = result.contenders; + // For each contender if there vote_tally is 1 or more we need to get their votes + // We don't do this for contenders with 0 votes, as there is no point. + let max_vote_tally = contenders.iter().map(|c| c.final_vote_tally).max(); if let Some(max_tally) = max_vote_tally { @@ -84,22 +87,33 @@ where // We award the document to the top contender if let Some(top_contender) = maybe_top_contender { - // We want to keep a record of how everyone voted - self.keep_record_of_vote_poll( - block_info, - &top_contender, - &resolved_vote_poll, - transaction, - platform_version, - )?; - // We award the document to the winner of the vote poll - self.award_document_to_winner( - block_info, - top_contender, - resolved_vote_poll, - transaction, - platform_version, - )?; + // let's check to make sure the lock votes didn't win it + // if the lock is tied with the top contender the top contender gets it + if result.locked_vote_tally > top_contender.final_vote_tally { + self.lock_contested_resource( + block_info, + &resolved_vote_poll, + transaction, + platform_version, + )?; + } else { + // We want to keep a record of how everyone voted + self.keep_record_of_vote_poll( + block_info, + &top_contender, + &resolved_vote_poll, + transaction, + platform_version, + )?; + // We award the document to the winner of the vote poll + self.award_document_to_winner( + block_info, + top_contender, + resolved_vote_poll, + transaction, + platform_version, + )?; + } } } } diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/lock_contested_resource/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/lock_contested_resource/mod.rs new file mode 100644 index 0000000000..42207f2157 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/lock_contested_resource/mod.rs @@ -0,0 +1,43 @@ +use crate::error::execution::ExecutionError; +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::rpc::core::CoreRPCLike; +use dpp::block::block_info::BlockInfo; +use dpp::version::PlatformVersion; +use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use drive::grovedb::TransactionArg; + +mod v0; + +impl Platform +where + C: CoreRPCLike, +{ + /// Keeps a record of the vote poll after it has finished + pub(in crate::execution) fn lock_contested_resource( + &self, + block_info: &BlockInfo, + vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive_abci + .methods + .voting + .lock_contested_resource + { + 0 => self.lock_contested_resource_v0( + block_info, + vote_poll, + transaction, + platform_version, + ), + version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { + method: "lock_contested_resource".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/lock_contested_resource/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/lock_contested_resource/v0/mod.rs new file mode 100644 index 0000000000..5265e8b877 --- /dev/null +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/lock_contested_resource/v0/mod.rs @@ -0,0 +1,34 @@ +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::rpc::core::CoreRPCLike; +use dpp::block::block_info::BlockInfo; +use dpp::version::PlatformVersion; +use drive::drive::votes::paths::VotePollPaths; +use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use drive::grovedb::TransactionArg; + +impl Platform +where + C: CoreRPCLike, +{ + /// Locks a contested resource after the lock vote wins + #[inline(always)] + pub(super) fn lock_contested_resource_v0( + &self, + block_info: &BlockInfo, + vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + // We need to lock the vote_poll + + self.drive + .add_lock_for_contested_document_resource_vote_poll( + vote_poll, + transaction, + platform_version, + )?; + + Ok(()) + } +} diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/lock_vote_poll/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/lock_vote_poll/mod.rs deleted file mode 100644 index 8b13789179..0000000000 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/lock_vote_poll/mod.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs index fbc3fba77e..44f8e29b25 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs @@ -4,5 +4,5 @@ mod check_for_ended_vote_polls; mod clean_up_after_contested_resources_vote_polls_end; mod delay_vote_poll; mod keep_record_of_vote_poll; -mod lock_vote_poll; +mod lock_contested_resource; mod tally_votes_for_contested_document_resource_vote_poll; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 2429b34296..6f6ef33c9e 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -183,8 +183,18 @@ mod tests { use std::ops::Deref; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0; use drive::query::vote_poll_vote_state_query::Contender; + use dapi_grpc::platform::v0::get_prefunded_specialized_balance_response; + use dapi_grpc::platform::v0::get_prefunded_specialized_balance_response::{ + get_prefunded_specialized_balance_response_v0, + GetPrefundedSpecializedBalanceResponseV0, + }; + use dpp::fee::Credits; + use drive::drive::Drive; mod vote_tests { + use assert_matches::assert_matches; + use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType; + use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult::SuccessfulExecution; use super::*; fn setup_masternode_identity( @@ -819,7 +829,8 @@ mod tests { .unwrap() .expect("expected to commit transaction"); - assert_eq!(processing_result.valid_count(), 1); + let execution_result = processing_result.into_execution_results().remove(0); + assert_matches!(execution_result, SuccessfulExecution(..)); } fn perform_votes( @@ -852,7 +863,249 @@ mod tests { } } - mod contests_requests { + fn perform_votes_multi( + platform: &mut TempPlatform, + dpns_contract: &DataContract, + resource_vote_choices: Vec<(ResourceVoteChoice, u64)>, + name: &str, + start_seed: u64, + platform_version: &PlatformVersion, + ) { + let mut count_aggregate = start_seed; + for (resource_vote_choice, count) in resource_vote_choices.into_iter() { + perform_votes( + platform, + dpns_contract, + resource_vote_choice, + name, + count, + count_aggregate, + platform_version, + ); + count_aggregate += count; + } + } + + fn get_vote_states( + platform: &TempPlatform, + platform_state: &PlatformState, + dpns_contract: &DataContract, + name: &str, + count: Option, + order_ascending: bool, + allow_include_locked_and_abstaining_vote_tally: bool, + start_at_identifier_info: Option< + get_contested_resource_vote_state_request_v0::StartAtIdentifierInfo, + >, + result_type: ResultType, + platform_version: &PlatformVersion, + ) -> (Vec, Option, Option) { + // Now let's run a query for the vote totals + + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); + + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + + let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) + .expect("expected to encode the word dash"); + + let quantum_encoded = + bincode::encode_to_vec(Value::Text(convert_to_homograph_safe_chars(name)), config) + .expect("expected to encode the word quantum"); + + let index_name = "parentNameAndLabel".to_string(); + + let query_validation_result = platform + .query_contested_resource_vote_state( + GetContestedResourceVoteStateRequest { + version: Some(get_contested_resource_vote_state_request::Version::V0( + GetContestedResourceVoteStateRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![dash_encoded.clone(), quantum_encoded.clone()], + result_type: result_type as i32, + allow_include_locked_and_abstaining_vote_tally, + start_at_identifier_info, + count, + order_ascending, + prove: false, + }, + )), + }, + platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_vote_state_response::Version::V0( + GetContestedResourceVoteStateResponseV0 { + metadata: _, + result, + }, + ) = query_validation_result.version.expect("expected a version"); + + let Some( + get_contested_resource_vote_state_response_v0::Result::ContestedResourceContenders( + get_contested_resource_vote_state_response_v0::ContestedResourceContenders { + contenders, + abstain_vote_tally, + lock_vote_tally, + }, + ), + ) = result + else { + panic!("expected contenders") + }; + ( + contenders + .into_iter() + .map(|contender| Contender { + identity_id: contender.identifier.try_into().expect("expected 32 bytes"), + document: contender.document.map(|document_bytes| { + Document::from_bytes( + document_bytes.as_slice(), + domain, + platform_version, + ) + .expect("expected to deserialize document") + }), + vote_tally: contender.vote_count, + }) + .collect(), + abstain_vote_tally, + lock_vote_tally, + ) + } + + fn get_proved_vote_states( + platform: &TempPlatform, + platform_state: &PlatformState, + dpns_contract: &DataContract, + name: &str, + count: Option, + order_ascending: bool, + allow_include_locked_and_abstaining_vote_tally: bool, + start_at_identifier_info: Option< + get_contested_resource_vote_state_request_v0::StartAtIdentifierInfo, + >, + result_type: ResultType, + platform_version: &PlatformVersion, + ) -> (Vec, Option, Option) { + // Now let's run a query for the vote totals + + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); + + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + + let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) + .expect("expected to encode the word dash"); + + let quantum_encoded = + bincode::encode_to_vec(Value::Text(convert_to_homograph_safe_chars(name)), config) + .expect("expected to encode the word quantum"); + + let index_name = "parentNameAndLabel".to_string(); + + let query_validation_result = platform + .query_contested_resource_vote_state( + GetContestedResourceVoteStateRequest { + version: Some(get_contested_resource_vote_state_request::Version::V0( + GetContestedResourceVoteStateRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![dash_encoded.clone(), quantum_encoded.clone()], + result_type: result_type as i32, + allow_include_locked_and_abstaining_vote_tally, + start_at_identifier_info, + count, + order_ascending, + prove: true, + }, + )), + }, + platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_vote_state_response::Version::V0( + GetContestedResourceVoteStateResponseV0 { + metadata: _, + result, + }, + ) = query_validation_result.version.expect("expected a version"); + + let Some(get_contested_resource_vote_state_response_v0::Result::Proof(proof)) = result + else { + panic!("expected contenders") + }; + + let resolved_contested_document_vote_poll_drive_query = + ResolvedContestedDocumentVotePollDriveQuery { + vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { + contract: DataContractResolvedInfo::BorrowedDataContract(dpns_contract), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![ + Value::Text("dash".to_string()), + Value::Text("quantum".to_string()), + ], + }, + result_type: ContestedDocumentVotePollDriveQueryResultType::try_from( + result_type as i32, + ) + .expect("expected valid result type"), + offset: None, + limit: count.map(|a| a as u16), + start_at: None, + order_ascending, + allow_include_locked_and_abstaining_vote_tally, + }; + + let (_, result) = resolved_contested_document_vote_poll_drive_query + .verify_vote_poll_vote_state_proof(proof.grovedb_proof.as_ref(), platform_version) + .expect("expected to verify proof"); + + let abstaining_vote_tally = result.abstaining_vote_tally; + let lock_vote_tally = result.locked_vote_tally; + + let contenders = result.contenders; + ( + contenders + .into_iter() + .map(|contender| Contender { + identity_id: contender.identity_id, + document: contender.serialized_document.map(|document_bytes| { + Document::from_bytes( + document_bytes.as_slice(), + domain, + platform_version, + ) + .expect("expected to deserialize document") + }), + vote_tally: contender.vote_tally, + }) + .collect(), + abstaining_vote_tally, + lock_vote_tally, + ) + } + + mod contests_requests_query { use super::*; #[test] fn test_not_proved_contests_request() { @@ -1052,240 +1305,6 @@ mod tests { mod vote_state_query { use super::*; - use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType; - fn get_vote_states( - platform: &TempPlatform, - platform_state: &PlatformState, - dpns_contract: &DataContract, - name: &str, - count: Option, - order_ascending: bool, - allow_include_locked_and_abstaining_vote_tally: bool, - start_at_identifier_info: Option< - get_contested_resource_vote_state_request_v0::StartAtIdentifierInfo, - >, - result_type: ResultType, - platform_version: &PlatformVersion, - ) -> (Vec, Option, Option) { - // Now let's run a query for the vote totals - - let domain = dpns_contract - .document_type_for_name("domain") - .expect("expected a profile document type"); - - let config = bincode::config::standard() - .with_big_endian() - .with_no_limit(); - - let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) - .expect("expected to encode the word dash"); - - let quantum_encoded = bincode::encode_to_vec( - Value::Text(convert_to_homograph_safe_chars(name)), - config, - ) - .expect("expected to encode the word quantum"); - - let index_name = "parentNameAndLabel".to_string(); - - let query_validation_result = platform - .query_contested_resource_vote_state( - GetContestedResourceVoteStateRequest { - version: Some(get_contested_resource_vote_state_request::Version::V0( - GetContestedResourceVoteStateRequestV0 { - contract_id: dpns_contract.id().to_vec(), - document_type_name: domain.name().clone(), - index_name: index_name.clone(), - index_values: vec![ - dash_encoded.clone(), - quantum_encoded.clone(), - ], - result_type: result_type as i32, - allow_include_locked_and_abstaining_vote_tally, - start_at_identifier_info, - count, - order_ascending, - prove: false, - }, - )), - }, - platform_state, - platform_version, - ) - .expect("expected to execute query") - .into_data() - .expect("expected query to be valid"); - - let get_contested_resource_vote_state_response::Version::V0( - GetContestedResourceVoteStateResponseV0 { - metadata: _, - result, - }, - ) = query_validation_result.version.expect("expected a version"); - - let Some( - get_contested_resource_vote_state_response_v0::Result::ContestedResourceContenders( - get_contested_resource_vote_state_response_v0::ContestedResourceContenders { - contenders, abstain_vote_tally, lock_vote_tally, - }, - ), - ) = result - else { - panic!("expected contenders") - }; - ( - contenders - .into_iter() - .map(|contender| Contender { - identity_id: contender - .identifier - .try_into() - .expect("expected 32 bytes"), - document: contender.document.map(|document_bytes| { - Document::from_bytes( - document_bytes.as_slice(), - domain, - platform_version, - ) - .expect("expected to deserialize document") - }), - vote_tally: contender.vote_count, - }) - .collect(), - abstain_vote_tally, - lock_vote_tally, - ) - } - - fn get_proved_vote_states( - platform: &TempPlatform, - platform_state: &PlatformState, - dpns_contract: &DataContract, - name: &str, - count: Option, - order_ascending: bool, - allow_include_locked_and_abstaining_vote_tally: bool, - start_at_identifier_info: Option< - get_contested_resource_vote_state_request_v0::StartAtIdentifierInfo, - >, - result_type: ResultType, - platform_version: &PlatformVersion, - ) -> (Vec, Option, Option) { - // Now let's run a query for the vote totals - - let domain = dpns_contract - .document_type_for_name("domain") - .expect("expected a profile document type"); - - let config = bincode::config::standard() - .with_big_endian() - .with_no_limit(); - - let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) - .expect("expected to encode the word dash"); - - let quantum_encoded = bincode::encode_to_vec( - Value::Text(convert_to_homograph_safe_chars(name)), - config, - ) - .expect("expected to encode the word quantum"); - - let index_name = "parentNameAndLabel".to_string(); - - let query_validation_result = platform - .query_contested_resource_vote_state( - GetContestedResourceVoteStateRequest { - version: Some(get_contested_resource_vote_state_request::Version::V0( - GetContestedResourceVoteStateRequestV0 { - contract_id: dpns_contract.id().to_vec(), - document_type_name: domain.name().clone(), - index_name: index_name.clone(), - index_values: vec![ - dash_encoded.clone(), - quantum_encoded.clone(), - ], - result_type: result_type as i32, - allow_include_locked_and_abstaining_vote_tally, - start_at_identifier_info, - count, - order_ascending, - prove: true, - }, - )), - }, - platform_state, - platform_version, - ) - .expect("expected to execute query") - .into_data() - .expect("expected query to be valid"); - - let get_contested_resource_vote_state_response::Version::V0( - GetContestedResourceVoteStateResponseV0 { - metadata: _, - result, - }, - ) = query_validation_result.version.expect("expected a version"); - - let Some(get_contested_resource_vote_state_response_v0::Result::Proof(proof)) = - result - else { - panic!("expected contenders") - }; - - let resolved_contested_document_vote_poll_drive_query = - ResolvedContestedDocumentVotePollDriveQuery { - vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { - contract: DataContractResolvedInfo::BorrowedDataContract(dpns_contract), - document_type_name: domain.name().clone(), - index_name: index_name.clone(), - index_values: vec![ - Value::Text("dash".to_string()), - Value::Text("quantum".to_string()), - ], - }, - result_type: ContestedDocumentVotePollDriveQueryResultType::try_from( - result_type as i32, - ) - .expect("expected valid result type"), - offset: None, - limit: count.map(|a| a as u16), - start_at: None, - order_ascending, - allow_include_locked_and_abstaining_vote_tally, - }; - - let (_, result) = resolved_contested_document_vote_poll_drive_query - .verify_vote_poll_vote_state_proof( - proof.grovedb_proof.as_ref(), - platform_version, - ) - .expect("expected to verify proof"); - - let abstaining_vote_tally = result.abstaining_vote_tally; - let lock_vote_tally = result.locked_vote_tally; - - let contenders = result.contenders; - ( - contenders - .into_iter() - .map(|contender| Contender { - identity_id: contender.identity_id, - document: contender.serialized_document.map(|document_bytes| { - Document::from_bytes( - document_bytes.as_slice(), - domain, - platform_version, - ) - .expect("expected to deserialize document") - }), - vote_tally: contender.vote_tally, - }) - .collect(), - abstaining_vote_tally, - lock_vote_tally, - ) - } #[test] fn test_not_proved_vote_state_query_request_after_vote() { @@ -1350,6 +1369,10 @@ mod tests { assert_eq!(first_contender.vote_tally, Some(1)); assert_eq!(second_contender.vote_tally, Some(0)); + + assert_eq!(abstaining, Some(0)); + + assert_eq!(locking, Some(0)); } #[test] @@ -1415,6 +1438,10 @@ mod tests { assert_eq!(first_contender.vote_tally, Some(1)); assert_eq!(second_contender.vote_tally, Some(0)); + + assert_eq!(abstaining, Some(0)); + + assert_eq!(locking, Some(0)); } #[test] @@ -1434,43 +1461,17 @@ mod tests { platform_version, ); - perform_votes( - &mut platform, - dpns_contract.as_ref(), - TowardsIdentity(contender_1.id()), - "quantum", - 50, - 10, - platform_version, - ); - - perform_votes( - &mut platform, - dpns_contract.as_ref(), - TowardsIdentity(contender_2.id()), - "quantum", - 5, - 100, - platform_version, - ); - - perform_votes( + perform_votes_multi( &mut platform, dpns_contract.as_ref(), - ResourceVoteChoice::Abstain, + vec![ + (TowardsIdentity(contender_1.id()), 50), + (TowardsIdentity(contender_2.id()), 5), + (ResourceVoteChoice::Abstain, 10), + (ResourceVoteChoice::Lock, 3), + ], "quantum", 10, - 200, - platform_version, - ); - - perform_votes( - &mut platform, - dpns_contract.as_ref(), - ResourceVoteChoice::Lock, - "quantum", - 3, - 300, platform_version, ); @@ -1560,43 +1561,17 @@ mod tests { platform_version, ); - perform_votes( - &mut platform, - dpns_contract.as_ref(), - TowardsIdentity(contender_1.id()), - "quantum", - 50, - 10, - platform_version, - ); - - perform_votes( - &mut platform, - dpns_contract.as_ref(), - TowardsIdentity(contender_2.id()), - "quantum", - 5, - 100, - platform_version, - ); - - perform_votes( + perform_votes_multi( &mut platform, dpns_contract.as_ref(), - ResourceVoteChoice::Abstain, + vec![ + (TowardsIdentity(contender_1.id()), 50), + (TowardsIdentity(contender_2.id()), 5), + (ResourceVoteChoice::Abstain, 10), + (ResourceVoteChoice::Lock, 3), + ], "quantum", 10, - 200, - platform_version, - ); - - perform_votes( - &mut platform, - dpns_contract.as_ref(), - ResourceVoteChoice::Lock, - "quantum", - 3, - 300, platform_version, ); @@ -3992,15 +3967,8 @@ mod tests { } } - mod prefunded_specialized_balance { + mod prefunded_specialized_balance_query { use super::*; - use dapi_grpc::platform::v0::get_prefunded_specialized_balance_response; - use dapi_grpc::platform::v0::get_prefunded_specialized_balance_response::{ - get_prefunded_specialized_balance_response_v0, - GetPrefundedSpecializedBalanceResponseV0, - }; - use dpp::fee::Credits; - use drive::drive::Drive; fn get_specialized_balance( platform: &TempPlatform, @@ -4331,5 +4299,148 @@ mod tests { assert_eq!(balance_after_55_votes, dash_to_credits!(0.7945)); } } + mod document_distribution { + use super::*; + #[test] + fn test_document_distribution() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + perform_votes_multi( + &mut platform, + dpns_contract.as_ref(), + vec![ + (TowardsIdentity(contender_1.id()), 50), + (TowardsIdentity(contender_2.id()), 5), + (ResourceVoteChoice::Abstain, 10), + (ResourceVoteChoice::Lock, 3), + ], + "quantum", + 10, + platform_version, + ); + + let platform_state = platform.state.load(); + let mut platform_state = (**platform_state).clone(); + + let block_info = BlockInfo { + time_ms: 1_209_900_000, //2 weeks and 300s + height: 10000, + core_height: 42, + epoch: Default::default(), + }; + + platform_state.set_last_committed_block_info(Some( + ExtendedBlockInfoV0 { + basic_info: block_info, + app_hash: platform.drive.grove.root_hash(None).unwrap().unwrap(), + quorum_hash: [0u8; 32], + block_id_hash: [0u8; 32], + signature: [0u8; 96], + round: 0, + } + .into(), + )); + + platform.state.store(Arc::new(platform_state)); + + let platform_state = platform.state.load(); + + let transaction = platform.drive.grove.start_transaction(); + + platform + .check_for_ended_vote_polls(&block_info, Some(&transaction), platform_version) + .expect("expected to check for ended vote polls"); + + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit transaction"); + + // At this point the document should have been awarded to contender 1. + + let (contenders, abstaining, locking) = get_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + assert_ne!(first_contender.document, second_contender.document); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(50)); + + assert_eq!(second_contender.vote_tally, Some(5)); + + assert_eq!(abstaining, Some(10)); + + assert_eq!(locking, Some(3)); + + // Now let's not include locked and abstaining + + let (contenders, abstaining, locking) = get_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + false, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + assert_ne!(first_contender.document, second_contender.document); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(50)); + + assert_eq!(second_contender.vote_tally, Some(5)); + + assert_eq!(abstaining, None); + + assert_eq!(locking, None); + } + } } } diff --git a/packages/rs-drive-abci/src/platform_types/state_transitions_processing_result/mod.rs b/packages/rs-drive-abci/src/platform_types/state_transitions_processing_result/mod.rs index 4c05c32666..268f8fefd8 100644 --- a/packages/rs-drive-abci/src/platform_types/state_transitions_processing_result/mod.rs +++ b/packages/rs-drive-abci/src/platform_types/state_transitions_processing_result/mod.rs @@ -6,7 +6,7 @@ use dpp::fee::fee_result::FeeResult; /// State Transition Execution Result represents a result of the single state transition execution. /// There are four possible outcomes of the state transition execution described by this enum -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub enum StateTransitionExecutionResult { /// State Transition is invalid, but we have a proved identity associated with it, /// and we can deduct processing fees calculated until this validation error happened diff --git a/packages/rs-drive/Cargo.toml b/packages/rs-drive/Cargo.toml index 9e9d205f72..6614151e6f 100644 --- a/packages/rs-drive/Cargo.toml +++ b/packages/rs-drive/Cargo.toml @@ -14,6 +14,7 @@ license = "MIT" resolver = "2" [dependencies] +bincode = { version = "2.0.0-rc.3", features = ["serde"] } platform-version = { path = "../rs-platform-version" } # used to convert integers to bytes, needed in verifier integer-encoding = { version = "4.0.0" } diff --git a/packages/rs-drive/src/drive/votes/cleanup/add_lock_for_contested_document_resource_vote_poll/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/add_lock_for_contested_document_resource_vote_poll/mod.rs new file mode 100644 index 0000000000..8c1889f4df --- /dev/null +++ b/packages/rs-drive/src/drive/votes/cleanup/add_lock_for_contested_document_resource_vote_poll/mod.rs @@ -0,0 +1,39 @@ +mod v0; + +use crate::drive::Drive; + +use crate::error::drive::DriveError; +use crate::error::Error; + +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +impl Drive { + /// Adding a lock to a vote poll disables voting for the vote poll + pub fn add_lock_for_contested_document_resource_vote_poll( + &self, + vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive + .methods + .vote + .cleanup + .add_lock_for_contested_document_resource_vote_poll + { + 0 => self.add_lock_for_contested_document_resource_vote_poll_v0( + vote_poll, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "add_lock_for_contested_document_resource_vote_poll".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/votes/cleanup/add_lock_for_contested_document_resource_vote_poll/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/add_lock_for_contested_document_resource_vote_poll/v0/mod.rs new file mode 100644 index 0000000000..63745b5a83 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/cleanup/add_lock_for_contested_document_resource_vote_poll/v0/mod.rs @@ -0,0 +1,21 @@ +use crate::drive::votes::paths::VotePollPaths; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use crate::drive::Drive; +use crate::error::Error; +use grovedb::TransactionArg; +use platform_version::version::PlatformVersion; + +impl Drive { + /// We remove vote_choices for an identity when that identity is somehow disabled. Currently there is + /// no way to "disable" identities except for masternodes being removed from the list + pub(super) fn add_lock_for_contested_document_resource_vote_poll_v0( + &self, + vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + let path = vote_poll.contenders_path(platform_version)?; + + Ok(()) + } +} diff --git a/packages/rs-drive/src/drive/votes/cleanup/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/mod.rs index 7abdec7feb..1634d7257a 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/mod.rs @@ -1 +1,3 @@ mod remove_votes_for_identity; + +mod add_lock_for_contested_document_resource_vote_poll; diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 4f198ee94b..3c924f3d5c 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -34,10 +34,10 @@ mod setup; #[cfg(any(feature = "server", feature = "verify"))] /// Resolve contested document resource vote poll module pub mod resolved; -#[cfg(feature = "server")] +#[cfg(any(feature = "server", feature = "verify"))] /// Storage form pub mod storage_form; -#[cfg(feature = "server")] +#[cfg(any(feature = "server", feature = "verify"))] /// Tree path storage form pub mod tree_path_storage_form; diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index 9b38b7ae38..554fd49fc1 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -12,6 +12,7 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; #[cfg(feature = "server")] use crate::query::GroveError; +use dpp::bincode::{Decode, Encode}; #[cfg(feature = "server")] use dpp::block::block_info::BlockInfo; use dpp::data_contract::document_type::DocumentTypeRef; @@ -135,6 +136,19 @@ pub struct FinalizedContenderWithSerializedDocument { pub final_vote_tally: u32, } +/// Represents a finalized contender in the contested document vote poll. +/// This is for keeping information about previous vote polls +/// +/// This struct holds the identity ID of the contender, the serialized document, +/// and the vote tally. +#[derive(Debug, PartialEq, Eq, Clone, Default, Encode, Decode)] +pub struct FinalizedContenderWithVoterInfo { + /// The identity ID of the contender. + pub identity_id: Identifier, + /// The pro_tx_hashes of the voters for this contender. + pub voters: Vec, +} + /// Represents a finalized contender in the contested document vote poll. /// This is for internal use where the document is in serialized form /// @@ -240,6 +254,19 @@ pub struct FinalizedContestedDocumentVotePollDriveQueryExecutionResult { pub abstaining_vote_tally: u32, } +/// Represents the stored info after a contested document vote poll. +/// +/// This struct holds the list of contenders, the abstaining vote tally. +#[derive(Debug, PartialEq, Eq, Clone, Default, Encode, Decode)] +pub struct FinalizedContestedDocumentVotePollStoredInfo { + /// The list of contenders returned by the query. + pub contenders: Vec, + /// Locked tally + pub locking_voters: Vec, + /// Abstaining tally + pub abstaining_voters: Vec, +} + impl TryFrom for FinalizedContestedDocumentVotePollDriveQueryExecutionResult { diff --git a/packages/rs-platform-version/src/version/drive_abci_versions.rs b/packages/rs-platform-version/src/version/drive_abci_versions.rs index d14665cf09..ef80afed92 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions.rs @@ -306,7 +306,7 @@ pub struct DriveAbciVotingMethodVersions { pub check_for_ended_contested_resource_vote_polls: FeatureVersion, pub tally_votes_for_contested_document_resource_vote_poll: FeatureVersion, pub award_document_to_winner: FeatureVersion, - pub lock_vote_poll: FeatureVersion, + pub lock_contested_resource: FeatureVersion, pub delay_vote_poll: FeatureVersion, } diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 65edf689e4..1596e520f4 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -284,6 +284,7 @@ pub struct DriveVoteSetupMethodVersions { #[derive(Clone, Debug, Default)] pub struct DriveVoteCleanupMethodVersions { + pub add_lock_for_contested_document_resource_vote_poll: FeatureVersion, pub remove_votes_for_identity: FeatureVersion, } diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index a08f2583e7..d91e464817 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -236,6 +236,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { remove_contested_resource_vote_poll_end_date_query_operations: 0, }, cleanup: DriveVoteCleanupMethodVersions { + add_lock_for_contested_document_resource_vote_poll: 0, remove_votes_for_identity: 0, }, setup: DriveVoteSetupMethodVersions { @@ -641,7 +642,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { check_for_ended_contested_resource_vote_polls: 0, tally_votes_for_contested_document_resource_vote_poll: 0, award_document_to_winner: 0, - lock_vote_poll: 0, + lock_contested_resource: 0, delay_vote_poll: 0, }, state_transition_processing: DriveAbciStateTransitionProcessingMethodVersions { diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 555409b9a9..e4cfe28ff5 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -244,6 +244,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { remove_contested_resource_vote_poll_end_date_query_operations: 0, }, cleanup: DriveVoteCleanupMethodVersions { + add_lock_for_contested_document_resource_vote_poll: 0, remove_votes_for_identity: 0, }, setup: DriveVoteSetupMethodVersions { @@ -641,7 +642,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { check_for_ended_contested_resource_vote_polls: 0, tally_votes_for_contested_document_resource_vote_poll: 0, award_document_to_winner: 0, - lock_vote_poll: 0, + lock_contested_resource: 0, delay_vote_poll: 0, }, state_transition_processing: DriveAbciStateTransitionProcessingMethodVersions { diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index f0862bb88b..20e92a63c1 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -235,6 +235,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { remove_contested_resource_vote_poll_end_date_query_operations: 0, }, cleanup: DriveVoteCleanupMethodVersions { + add_lock_for_contested_document_resource_vote_poll: 0, remove_votes_for_identity: 0, }, setup: DriveVoteSetupMethodVersions { @@ -640,7 +641,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { check_for_ended_contested_resource_vote_polls: 0, tally_votes_for_contested_document_resource_vote_poll: 0, award_document_to_winner: 0, - lock_vote_poll: 0, + lock_contested_resource: 0, delay_vote_poll: 0, }, state_transition_processing: DriveAbciStateTransitionProcessingMethodVersions { From aa2d25759371003683c5797022d7f693daaaf2df Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 5 Jun 2024 18:08:03 +0300 Subject: [PATCH 111/135] more work --- Cargo.lock | 58 +++--- .../v0/mod.rs | 132 -------------- .../check_for_ended_vote_polls/v0/mod.rs | 165 +++++++++++++++++- .../mod.rs | 4 +- .../v0/mod.rs | 3 +- .../mod.rs | 12 +- .../clean_up_after_vote_polls_end/v0/mod.rs | 43 +++++ .../voting/keep_record_of_vote_poll/v0/mod.rs | 2 +- .../execution/platform_events/voting/mod.rs | 2 +- .../mod.rs | 8 +- .../v0/mod.rs | 7 +- .../v0/mod.rs | 1 - .../mod.rs | 42 +++++ .../v0/mod.rs | 72 ++++++++ .../v0/mod.rs | 7 +- .../mod.rs | 2 +- .../v0/mod.rs | 7 +- packages/rs-drive/src/drive/votes/mod.rs | 11 +- packages/rs-drive/src/drive/votes/paths.rs | 14 +- .../mod.rs | 60 +++---- .../resolve.rs | 6 +- .../drive/votes/resolved/vote_polls/mod.rs | 2 +- .../votes/resolved/vote_polls/resolve.rs | 2 + .../v0/mod.rs | 5 +- .../src/query/vote_poll_vote_state_query.rs | 19 +- .../vote_polls_by_document_type_query.rs | 14 +- .../src/query/vote_polls_by_end_date_query.rs | 31 ++-- .../rs-platform-value/src/types/identifier.rs | 4 +- .../src/version/drive_abci_versions.rs | 2 +- .../src/version/drive_versions.rs | 1 + .../src/version/mocks/v2_test.rs | 7 +- .../src/version/mocks/v3_test.rs | 7 +- .../rs-platform-version/src/version/v1.rs | 7 +- 33 files changed, 469 insertions(+), 290 deletions(-) delete mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs rename packages/rs-drive-abci/src/execution/platform_events/voting/{check_for_ended_contested_resource_vote_polls => clean_up_after_vote_polls_end}/mod.rs (68%) create mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/v0/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 9c41c90914..bf2d07b293 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -110,9 +110,9 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" dependencies = [ "windows-sys 0.52.0", ] @@ -261,7 +261,7 @@ dependencies = [ "futures-util", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.28", + "hyper 0.14.29", "itoa", "matchit", "memchr", @@ -2190,7 +2190,7 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "grovedb" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#c3d78a3e0f99aff8735896e6a1e5c06a38468bb1" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#b29791803245b834370929302922c267dcadc99e" dependencies = [ "bincode 2.0.0-rc.3", "bitvec", @@ -2213,7 +2213,7 @@ dependencies = [ [[package]] name = "grovedb-costs" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#c3d78a3e0f99aff8735896e6a1e5c06a38468bb1" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#b29791803245b834370929302922c267dcadc99e" dependencies = [ "integer-encoding", "intmap", @@ -2223,7 +2223,7 @@ dependencies = [ [[package]] name = "grovedb-merk" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#c3d78a3e0f99aff8735896e6a1e5c06a38468bb1" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#b29791803245b834370929302922c267dcadc99e" dependencies = [ "blake3", "byteorder", @@ -2246,12 +2246,12 @@ dependencies = [ [[package]] name = "grovedb-path" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#c3d78a3e0f99aff8735896e6a1e5c06a38468bb1" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#b29791803245b834370929302922c267dcadc99e" [[package]] name = "grovedb-storage" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#c3d78a3e0f99aff8735896e6a1e5c06a38468bb1" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#b29791803245b834370929302922c267dcadc99e" dependencies = [ "blake3", "grovedb-costs", @@ -2270,7 +2270,7 @@ dependencies = [ [[package]] name = "grovedb-visualize" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#c3d78a3e0f99aff8735896e6a1e5c06a38468bb1" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#b29791803245b834370929302922c267dcadc99e" dependencies = [ "hex", "itertools 0.12.1", @@ -2488,9 +2488,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.28" +version = "0.14.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" dependencies = [ "bytes", "futures-channel", @@ -2537,7 +2537,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper 0.14.28", + "hyper 0.14.29", "pin-project-lite", "tokio", "tokio-io-timeout", @@ -4834,7 +4834,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" dependencies = [ - "strum_macros 0.26.3", + "strum_macros 0.26.4", ] [[package]] @@ -4852,9 +4852,9 @@ dependencies = [ [[package]] name = "strum_macros" -version = "0.26.3" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7993a8e3a9e88a00351486baae9522c91b123a088f76469e5bd5cc17198ea87" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -5266,14 +5266,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.13" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.13", + "toml_edit 0.22.14", ] [[package]] @@ -5309,15 +5309,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.13" +version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" +checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.9", + "winnow 0.6.11", ] [[package]] @@ -5334,7 +5334,7 @@ dependencies = [ "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.28", + "hyper 0.14.29", "hyper-timeout", "percent-encoding", "pin-project", @@ -5361,7 +5361,7 @@ dependencies = [ "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.28", + "hyper 0.14.29", "hyper-timeout", "percent-encoding", "pin-project", @@ -5565,9 +5565,9 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "unicode-xid" @@ -6077,9 +6077,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" +checksum = "3c452ad30530b54a4d8e71952716a212b08efd0f3562baa66c29a618b07da7c3" dependencies = [ "rustls-pki-types", ] @@ -6328,9 +6328,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.9" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86c949fede1d13936a99f14fafd3e76fd642b556dd2ce96287fbe2e0151bfac6" +checksum = "56c52728401e1dc672a56e81e593e912aa54c78f40246869f78359a2bf24d29d" dependencies = [ "memchr", ] diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs deleted file mode 100644 index 13676e3ac9..0000000000 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/v0/mod.rs +++ /dev/null @@ -1,132 +0,0 @@ -use crate::error::Error; -use crate::platform_types::platform::Platform; -use crate::rpc::core::CoreRPCLike; -use dpp::block::block_info::BlockInfo; -use dpp::document::DocumentV0Getters; -use dpp::version::PlatformVersion; -use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; -use drive::grovedb::TransactionArg; -use drive::query::vote_poll_vote_state_query::FinalizedContender; -use drive::query::VotePollsByEndDateDriveQuery; - -impl Platform -where - C: CoreRPCLike, -{ - /// Checks for ended vote polls - #[inline(always)] - pub(super) fn check_for_ended_contested_resource_vote_polls_v0( - &self, - block_info: &BlockInfo, - transaction: TransactionArg, - platform_version: &PlatformVersion, - ) -> Result<(), Error> { - // let's start by getting the vote polls that have finished - let vote_polls = - VotePollsByEndDateDriveQuery::execute_no_proof_for_specialized_end_time_query( - block_info.time_ms, - platform_version - .drive_abci - .validation_and_processing - .event_constants - .maximum_vote_polls_to_process, - &self.drive, - transaction, - &mut vec![], - platform_version, - )?; - - for (end_date, vote_polls) in vote_polls { - for vote_poll in &vote_polls { - let resolved_vote_poll = - vote_poll.resolve(&self.drive, transaction, platform_version)?; - let document_type = resolved_vote_poll.document_type()?; - // let's see who actually won - let result = self.tally_votes_for_contested_document_resource_vote_poll( - vote_poll, - transaction, - platform_version, - )?; - let contenders = result.contenders; - // For each contender if there vote_tally is 1 or more we need to get their votes - // We don't do this for contenders with 0 votes, as there is no point. - - let max_vote_tally = contenders.iter().map(|c| c.final_vote_tally).max(); - - if let Some(max_tally) = max_vote_tally { - // These are all the people who got top votes - let top_contenders: Vec = contenders - .into_iter() - .filter(|c| c.final_vote_tally == max_tally) - .map(|contender| { - FinalizedContender::try_from_contender_with_serialized_document( - contender, - document_type, - platform_version, - ) - .map_err(Error::Drive) - }) - .collect::, Error>>()?; - // Now we sort by the document creation date - let maybe_top_contender = top_contenders.into_iter().max_by(|a, b| { - a.document - .created_at() - .cmp(&b.document.created_at()) - .then_with(|| { - a.document - .created_at_block_height() - .cmp(&b.document.created_at_block_height()) - }) - .then_with(|| { - a.document - .created_at_core_block_height() - .cmp(&b.document.created_at_core_block_height()) - }) - .then_with(|| a.document.id().cmp(&b.document.id())) - }); - - // We award the document to the top contender - if let Some(top_contender) = maybe_top_contender { - // let's check to make sure the lock votes didn't win it - // if the lock is tied with the top contender the top contender gets it - if result.locked_vote_tally > top_contender.final_vote_tally { - self.lock_contested_resource( - block_info, - &resolved_vote_poll, - transaction, - platform_version, - )?; - } else { - // We want to keep a record of how everyone voted - self.keep_record_of_vote_poll( - block_info, - &top_contender, - &resolved_vote_poll, - transaction, - platform_version, - )?; - // We award the document to the winner of the vote poll - self.award_document_to_winner( - block_info, - top_contender, - resolved_vote_poll, - transaction, - platform_version, - )?; - } - } - } - } - // We need to clean up the vote poll - // This means removing it and also removing all current votes - self.clean_up_after_contested_resources_vote_polls_end( - block_info, - &vote_polls, - transaction, - platform_version, - )?; - } - - Ok(()) - } -} diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs index 511418f05e..dab40cf954 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs @@ -2,8 +2,14 @@ use crate::error::Error; use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; use dpp::block::block_info::BlockInfo; +use dpp::document::DocumentV0Getters; use dpp::version::PlatformVersion; +use drive::drive::votes::resolved::vote_polls::resolve::VotePollResolver; +use drive::drive::votes::resolved::vote_polls::ResolvedVotePoll; use drive::grovedb::TransactionArg; +use drive::query::vote_poll_vote_state_query::FinalizedContender; +use drive::query::VotePollsByEndDateDriveQuery; +use itertools::Itertools; impl Platform where @@ -17,11 +23,158 @@ where transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { - // Only contested vote polls for v0 - self.check_for_ended_contested_resource_vote_polls( - block_info, - transaction, - platform_version, - ) + // let's start by getting the vote polls that have finished + let vote_polls = + VotePollsByEndDateDriveQuery::execute_no_proof_for_specialized_end_time_query( + block_info.time_ms, + platform_version + .drive_abci + .validation_and_processing + .event_constants + .maximum_vote_polls_to_process, + &self.drive, + transaction, + &mut vec![], + platform_version, + )?; + + for (end_date, vote_polls) in vote_polls { + for vote_poll in &vote_polls { + let resolved_vote_poll = + vote_poll.resolve(&self.drive, transaction, platform_version)?; + match resolved_vote_poll { + ResolvedVotePoll::ContestedDocumentResourceVotePollWithContractInfo( + resolved_contested_document_resource_vote_poll, + ) => { + let document_type = + resolved_contested_document_resource_vote_poll.document_type()?; + // let's see who actually won + let result = self.tally_votes_for_contested_document_resource_vote_poll( + (&resolved_contested_document_resource_vote_poll).into(), + transaction, + platform_version, + )?; + let contenders = result.contenders; + // For each contender if there vote_tally is 1 or more we need to get their votes + // We don't do this for contenders with 0 votes, as there is no point. + + let sorted_contenders: Vec<_> = contenders + .into_iter() + .sorted_by(|a, b| Ord::cmp(&b.final_vote_tally, &a.final_vote_tally)) + .collect(); + + let restrict_to_only_fetch_contenders = if sorted_contenders + .last() + .map(|last| last.final_vote_tally > 0) + .unwrap_or_default() + { + None + } else { + // We only take the first 100 + Some( + sorted_contenders + .iter() + .take(100) + .filter_map(|contender| { + if contender.final_vote_tally > 0 { + Some(contender.identity_id) + } else { + None + } + }) + .collect(), + ) + }; + + // We need to get the votes of the sorted contenders + let identifiers_voting_for_contenders = + self.drive.fetch_identities_voting_for_contenders( + &resolved_contested_document_resource_vote_poll, + restrict_to_only_fetch_contenders, + transaction, + platform_version, + )?; + + let highest_vote_tally = sorted_contenders + .first() + .map(|max_voted_contender| max_voted_contender.final_vote_tally) + .unwrap_or_default(); + // These are all the people who got top votes + let top_contenders: Vec = sorted_contenders + .into_iter() + .filter(|c| c.final_vote_tally == highest_vote_tally) + .take(100) // Limit to the first 100 before the expensive operation + .map(|contender| { + FinalizedContender::try_from_contender_with_serialized_document( + contender, + document_type, + platform_version, + ) + .map_err(Error::Drive) + }) + .collect::, Error>>()?; + // Now we sort by the document creation date + let maybe_top_contender = top_contenders.into_iter().max_by(|a, b| { + a.document + .created_at() + .cmp(&b.document.created_at()) + .then_with(|| { + a.document + .created_at_block_height() + .cmp(&b.document.created_at_block_height()) + }) + .then_with(|| { + a.document + .created_at_core_block_height() + .cmp(&b.document.created_at_core_block_height()) + }) + .then_with(|| a.document.id().cmp(&b.document.id())) + }); + + // We award the document to the top contender + if let Some(top_contender) = maybe_top_contender { + // let's check to make sure the lock votes didn't win it + // if the lock is tied with the top contender the top contender gets it + if result.locked_vote_tally > top_contender.final_vote_tally { + self.lock_contested_resource( + block_info, + &resolved_contested_document_resource_vote_poll, + transaction, + platform_version, + )?; + } else { + // We want to keep a record of how everyone voted + self.keep_record_of_vote_poll( + block_info, + &top_contender, + &resolved_contested_document_resource_vote_poll, + transaction, + platform_version, + )?; + // We award the document to the winner of the vote poll + self.award_document_to_winner( + block_info, + top_contender, + resolved_contested_document_resource_vote_poll, + transaction, + platform_version, + )?; + } + } + } + } + } + + // We need to clean up the vote poll + // This means removing it and also removing all current votes + // todo() + // self.clean_up_after_vote_polls_end( + // block_info, + // &vote_polls, + // transaction, + // platform_version, + // )?; + } + Ok(()) } } diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/mod.rs index fd787e0759..f686af76db 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/mod.rs @@ -17,7 +17,7 @@ where pub(in crate::execution) fn clean_up_after_contested_resources_vote_polls_end( &self, block_info: &BlockInfo, - vote_polls: &[ContestedDocumentResourceVotePoll], + vote_polls: &[&ContestedDocumentResourceVotePoll], transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { @@ -25,7 +25,7 @@ where .drive_abci .methods .voting - .clean_up_after_vote_poll_end + .clean_up_after_contested_resources_vote_poll_end { 0 => self.clean_up_after_contested_resources_vote_polls_end_v0( block_info, diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs index 907f38a916..19ee7e53f7 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs @@ -4,6 +4,7 @@ use crate::rpc::core::CoreRPCLike; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::voting::vote_polls::VotePoll; use drive::grovedb::TransactionArg; impl Platform @@ -15,7 +16,7 @@ where pub(super) fn clean_up_after_contested_resources_vote_polls_end_v0( &self, block_info: &BlockInfo, - vote_polls: &[ContestedDocumentResourceVotePoll], + vote_polls: &[&ContestedDocumentResourceVotePoll], transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/mod.rs similarity index 68% rename from packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/mod.rs rename to packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/mod.rs index ca9daeae31..bd1d2833ac 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_contested_resource_vote_polls/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/mod.rs @@ -4,6 +4,8 @@ use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::voting::vote_polls::VotePoll; use drive::grovedb::TransactionArg; mod v0; @@ -13,9 +15,10 @@ where C: CoreRPCLike, { /// Checks for ended vote polls - pub(in crate::execution) fn check_for_ended_contested_resource_vote_polls( + pub(in crate::execution) fn clean_up_after_vote_polls_end( &self, block_info: &BlockInfo, + vote_polls: &[VotePoll], transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { @@ -23,15 +26,16 @@ where .drive_abci .methods .voting - .check_for_ended_contested_resource_vote_polls + .clean_up_after_vote_poll_end { - 0 => self.check_for_ended_contested_resource_vote_polls_v0( + 0 => self.clean_up_after_vote_polls_end_v0( block_info, + vote_polls, transaction, platform_version, ), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { - method: "check_for_ended_contested_resource_vote_polls".to_string(), + method: "clean_up_after_vote_polls_end".to_string(), known_versions: vec![0], received: version, })), diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/v0/mod.rs new file mode 100644 index 0000000000..b50f32136e --- /dev/null +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/v0/mod.rs @@ -0,0 +1,43 @@ +use crate::error::Error; +use crate::platform_types::platform::Platform; +use crate::rpc::core::CoreRPCLike; +use dpp::block::block_info::BlockInfo; +use dpp::version::PlatformVersion; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::voting::vote_polls::VotePoll; +use drive::grovedb::TransactionArg; + +impl Platform +where + C: CoreRPCLike, +{ + /// Checks for ended vote polls + #[inline(always)] + pub(super) fn clean_up_after_vote_polls_end_v0( + &self, + block_info: &BlockInfo, + vote_polls: &[VotePoll], + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + // Create a vector to hold the references to the contested document resource vote polls + let mut contested_polls: Vec<&ContestedDocumentResourceVotePoll> = Vec::new(); + + // Iterate over the vote polls and match on the enum variant + for vote_poll in vote_polls { + match vote_poll { + VotePoll::ContestedDocumentResourceVotePoll(contested_poll) => { + contested_polls.push(contested_poll); + } // Add more match arms here for other types of vote polls in the future + } + } + + // Call the function to clean up contested document resource vote polls + self.clean_up_after_contested_resources_vote_polls_end( + block_info, + &contested_polls, + transaction, + platform_version, + ) + } +} diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs index 06b3897188..09d3716736 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs @@ -22,6 +22,6 @@ where platform_version: &PlatformVersion, ) -> Result<(), Error> { // We want to store information about the vote poll in an efficient way - todo!() + Ok(()) } } diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs index 44f8e29b25..99bb77f91c 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs @@ -1,7 +1,7 @@ mod award_document_to_winner; -mod check_for_ended_contested_resource_vote_polls; mod check_for_ended_vote_polls; mod clean_up_after_contested_resources_vote_polls_end; +mod clean_up_after_vote_polls_end; mod delay_vote_poll; mod keep_record_of_vote_poll; mod lock_contested_resource; diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/mod.rs index 0f781dc339..0d6f61268e 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/mod.rs @@ -4,11 +4,9 @@ use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; use dpp::version::PlatformVersion; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use drive::grovedb::TransactionArg; -use drive::query::vote_poll_vote_state_query::{ - FinalizedContenderWithSerializedDocument, - FinalizedContestedDocumentVotePollDriveQueryExecutionResult, -}; +use drive::query::vote_poll_vote_state_query::FinalizedContestedDocumentVotePollDriveQueryExecutionResult; mod v0; @@ -19,7 +17,7 @@ where /// Tally the votes for a contested resource vote poll pub(in crate::execution) fn tally_votes_for_contested_document_resource_vote_poll( &self, - contested_document_resource_vote_poll: &ContestedDocumentResourceVotePoll, + contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/v0/mod.rs index 9b2367d5cf..a0d337dcee 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/v0/mod.rs @@ -6,7 +6,6 @@ use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDoc use drive::grovedb::TransactionArg; use drive::query::vote_poll_vote_state_query::{ ContestedDocumentVotePollDriveQuery, ContestedDocumentVotePollDriveQueryResultType, - FinalizedContenderWithSerializedDocument, FinalizedContestedDocumentVotePollDriveQueryExecutionResult, }; @@ -17,15 +16,15 @@ where /// Checks for ended vote polls pub(super) fn tally_votes_for_contested_document_resource_vote_poll_v0( &self, - contested_document_resource_vote_poll: &ContestedDocumentResourceVotePoll, + contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { //todo: try to figure out how to do this without a clone //we start by only requesting the vote tally because we don't want to load all the documents let query = ContestedDocumentVotePollDriveQuery { - vote_poll: contested_document_resource_vote_poll.clone(), - result_type: ContestedDocumentVotePollDriveQueryResultType::Documents, + vote_poll: contested_document_resource_vote_poll, + result_type: ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally, offset: None, limit: Some( platform_version diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_polls_end_date_query/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_polls_end_date_query/v0/mod.rs index 76355770bd..7659a5b8de 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_vote_polls_end_date_query/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_polls_end_date_query/v0/mod.rs @@ -9,7 +9,6 @@ use crate::error::Error; use crate::common::encode::decode_u64; use crate::error::drive::DriveError; use crate::query::VotePollsByEndDateDriveQuery; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::voting::vote_polls::VotePoll; impl VotePollsByEndDateDriveQuery { diff --git a/packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/mod.rs b/packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/mod.rs new file mode 100644 index 0000000000..1607c356a5 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/mod.rs @@ -0,0 +1,42 @@ +mod v0; + +use crate::drive::Drive; +use std::collections::BTreeMap; + +use crate::error::drive::DriveError; +use crate::error::Error; + +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use dpp::platform_value::Identifier; +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +impl Drive { + /// Fetches the identities voting for contenders. + pub fn fetch_identities_voting_for_contenders( + &self, + contested_document_resource_vote_poll_with_contract_info: &ContestedDocumentResourceVotePollWithContractInfo, + restrict_to_only_fetch_contenders: Option>, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result>, Error> { + match platform_version + .drive + .methods + .vote + .fetch_identities_voting_for_contenders + { + 0 => self.fetch_identities_voting_for_contenders_v0( + contested_document_resource_vote_poll_with_contract_info, + restrict_to_only_fetch_contenders, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "fetch_identities_voting_for_contenders".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/v0/mod.rs b/packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/v0/mod.rs new file mode 100644 index 0000000000..92448b40ad --- /dev/null +++ b/packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/v0/mod.rs @@ -0,0 +1,72 @@ +use crate::drive::votes::paths::{ + VotePollPaths, RESOURCE_LOCK_VOTE_TREE_KEY_U8, VOTE_DECISIONS_TREE_KEY, VOTING_STORAGE_TREE_KEY, +}; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use crate::drive::Drive; +use crate::error::Error; +use dpp::identifier::Identifier; +use grovedb::query_result_type::QueryResultType; +use grovedb::{PathQuery, Query, QueryItem, SizedQuery, TransactionArg}; +use platform_version::version::PlatformVersion; +use std::collections::BTreeMap; +use std::ops::RangeFull; + +impl Drive { + /// Fetches the identities voting for contenders. + pub fn fetch_identities_voting_for_contenders_v0( + &self, + contested_document_resource_vote_poll_with_contract_info: &ContestedDocumentResourceVotePollWithContractInfo, + restrict_to_only_fetch_contenders: Option>, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result>, Error> { + let mut path = contested_document_resource_vote_poll_with_contract_info + .contenders_path(platform_version)?; + + let mut query = Query::new_with_direction(true); + + if let Some(restrict_to_only_fetch_contenders) = restrict_to_only_fetch_contenders { + query.insert_keys( + restrict_to_only_fetch_contenders + .into_iter() + .map(|id| id.to_vec()) + .collect(), + ) + } else { + query.insert_range_after(vec![RESOURCE_LOCK_VOTE_TREE_KEY_U8]..) + } + + query.set_subquery_path(vec![vec![VOTING_STORAGE_TREE_KEY]]); + query.set_subquery(Query::new_single_query_item(QueryItem::RangeFull( + RangeFull, + ))); + + let path_query = PathQuery { + path, + query: SizedQuery { + query, + limit: None, + offset: None, + }, + }; + + self.grove_get_path_query( + &path_query, + transaction, + QueryResultType::QueryPathKeyElementTrioResultType, + &mut vec![], + &platform_version.drive, + )? + .0 + .to_previous_of_last_path_to_keys_btree_map() + .into_iter() + .map(|(key, value_array)| { + let voters_array = value_array + .into_iter() + .map(|value| value.try_into()) + .collect::, dpp::platform_value::Error>>()?; + Ok((key.try_into()?, voters_array)) + }) + .collect() + } +} diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs index e065943a8b..703ed2a126 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/add_vote_poll_end_date_query_operations/v0/mod.rs @@ -9,8 +9,7 @@ use crate::drive::object_size_info::PathKeyElementInfo::{PathKeyElementSize, Pat use crate::drive::object_size_info::{DriveKeyInfo, PathInfo, PathKeyElementInfo}; use crate::drive::votes::paths::{ vote_contested_resource_end_date_queries_at_time_tree_path_vec, - vote_contested_resource_end_date_queries_tree_path, - vote_contested_resource_end_date_queries_tree_path_vec, + vote_end_date_queries_tree_path, vote_end_date_queries_tree_path_vec, }; use crate::drive::Drive; use crate::error::Error; @@ -51,7 +50,7 @@ impl Drive { if let Some(estimated_costs_only_with_layer_info) = estimated_costs_only_with_layer_info { estimated_costs_only_with_layer_info.insert( - KeyInfoPath::from_known_path(vote_contested_resource_end_date_queries_tree_path()), + KeyInfoPath::from_known_path(vote_end_date_queries_tree_path()), EstimatedLayerInformation { is_sum_tree: false, // We can estimate that there is at least a vote concluding every block, and we put blocks at 6 seconds. @@ -90,7 +89,7 @@ impl Drive { // Let's start by inserting a tree for the end date - let end_date_query_path = vote_contested_resource_end_date_queries_tree_path_vec(); + let end_date_query_path = vote_end_date_queries_tree_path_vec(); let drive_key = DriveKeyInfo::Key(encode_u64(end_date)); diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/mod.rs index 635e594367..540ed2f530 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/mod.rs @@ -16,7 +16,7 @@ impl Drive { /// any votes poll should be closed. This will remove them to recoup space pub fn remove_contested_resource_vote_poll_end_date_query_operations( &self, - vote_polls: &[ContestedDocumentResourceVotePoll], + vote_polls: &[&ContestedDocumentResourceVotePoll], end_date: TimestampMillis, batch_operations: &mut Vec, transaction: TransactionArg, diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/v0/mod.rs index bf1817314b..0fcef0c8f0 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/v0/mod.rs @@ -1,8 +1,7 @@ use crate::common::encode::encode_u64; use crate::drive::grove_operations::BatchDeleteApplyType::StatefulBatchDelete; use crate::drive::votes::paths::{ - vote_contested_resource_end_date_queries_at_time_tree_path_vec, - vote_contested_resource_end_date_queries_tree_path, + vote_contested_resource_end_date_queries_at_time_tree_path_vec, vote_end_date_queries_tree_path, }; use crate::drive::Drive; use crate::error::Error; @@ -17,7 +16,7 @@ impl Drive { /// any vote polls should be closed. pub(in crate::drive::votes::insert) fn remove_contested_resource_vote_poll_end_date_query_operations_v0( &self, - vote_polls: &[ContestedDocumentResourceVotePoll], + vote_polls: &[&ContestedDocumentResourceVotePoll], end_date: TimestampMillis, batch_operations: &mut Vec, transaction: TransactionArg, @@ -53,7 +52,7 @@ impl Drive { )?; } - let end_date_query_path = vote_contested_resource_end_date_queries_tree_path(); + let end_date_query_path = vote_end_date_queries_tree_path(); let end_date_key = encode_u64(end_date); diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 3c924f3d5c..5b5609f63b 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -1,19 +1,11 @@ -use crate::drive::defaults::{DEFAULT_HASH_SIZE, DEFAULT_HASH_SIZE_USIZE}; use crate::drive::document::paths::contract_document_type_path; -use crate::drive::votes::paths::{ - ACTIVE_POLLS_TREE_KEY, CONTESTED_RESOURCE_TREE_KEY, RESOURCE_ABSTAIN_VOTE_TREE_KEY, - RESOURCE_LOCK_VOTE_TREE_KEY, VOTE_DECISIONS_TREE_KEY, -}; -use crate::drive::RootTree::Votes; +use crate::drive::votes::paths::{RESOURCE_ABSTAIN_VOTE_TREE_KEY, RESOURCE_LOCK_VOTE_TREE_KEY}; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::data_contract::DataContract; -use dpp::identifier::Identifier; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::voting::vote_polls::VotePoll; use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; -use dpp::voting::votes::resource_vote::v0::ResourceVoteV0; use dpp::voting::votes::resource_vote::ResourceVote; use dpp::voting::votes::Vote; use dpp::ProtocolError; @@ -31,6 +23,7 @@ pub mod paths; #[cfg(feature = "server")] mod setup; +mod fetch_identities_voting_for_contenders; #[cfg(any(feature = "server", feature = "verify"))] /// Resolve contested document resource vote poll module pub mod resolved; diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index c4b398c1ba..e85d84fc4e 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -18,9 +18,9 @@ use platform_version::version::PlatformVersion; /// /// Votes /// +/// |- End date Queries [key: "e"] /// |- Decisions [key: "d"] /// |- Contested Resource [key: "c"] -/// |- End date Queries [key: "e"] /// |- Active polls [key: "p"] /// |- Identifier Votes Query [key: "i"] /// @@ -53,6 +53,9 @@ pub const RESOURCE_LOCK_VOTE_TREE_KEY_U8: u8 = 'l' as u8; /// In the active vote poll this will contain votes for abstaining on the vote for the contested resource pub const RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8: u8 = 'a' as u8; +/// The tree key for storage +pub const VOTING_STORAGE_TREE_KEY: u8 = 1; + /// Convenience methods to be easily able to get a path when we know the vote poll pub trait VotePollPaths { /// The root path, under this there should be the documents area and the contract itself @@ -172,7 +175,7 @@ impl VotePollPaths for ContestedDocumentResourceVotePollWithContractInfo { let key = vote_choice.to_key(); let mut contender_voting_path = self.contenders_path(platform_version)?; contender_voting_path.push(key); - contender_voting_path.push(vec![1]); + contender_voting_path.push(vec![VOTING_STORAGE_TREE_KEY]); Ok(contender_voting_path) } } @@ -306,19 +309,17 @@ pub fn vote_contested_resource_tree_path_vec() -> Vec> { } /// the end dates of contested resources -pub fn vote_contested_resource_end_date_queries_tree_path<'a>() -> [&'a [u8]; 3] { +pub fn vote_end_date_queries_tree_path<'a>() -> [&'a [u8]; 2] { [ Into::<&[u8; 1]>::into(RootTree::Votes), - &[CONTESTED_RESOURCE_TREE_KEY as u8], &[END_DATE_QUERIES_TREE_KEY as u8], ] } /// the end dates of contested resources as a vec -pub fn vote_contested_resource_end_date_queries_tree_path_vec() -> Vec> { +pub fn vote_end_date_queries_tree_path_vec() -> Vec> { vec![ vec![RootTree::Votes as u8], - vec![CONTESTED_RESOURCE_TREE_KEY as u8], vec![END_DATE_QUERIES_TREE_KEY as u8], ] } @@ -428,7 +429,6 @@ pub fn vote_contested_resource_end_date_queries_at_time_tree_path_vec( ) -> Vec> { vec![ vec![RootTree::Votes as u8], - vec![CONTESTED_RESOURCE_TREE_KEY as u8], vec![END_DATE_QUERIES_TREE_KEY as u8], encode_u64(time), ] diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/mod.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/mod.rs index a344636454..b7f3814565 100644 --- a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/mod.rs @@ -31,23 +31,6 @@ pub struct ContestedDocumentResourceVotePollWithContractInfo { pub index_values: Vec, } -/// Represents information related to a contested document resource vote poll, along with -/// associated contract details. -/// -/// This structure holds a reference to the contract, the document type name, -/// the index name, and the index values used for the poll. -#[derive(Debug, PartialEq, Clone)] -pub struct ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed<'a> { - /// The contract information associated with the document. - pub contract: DataContractResolvedInfo<'a>, - /// The name of the document type. - pub document_type_name: String, - /// The name of the index. - pub index_name: String, - /// The values used in the index for the poll. - pub index_values: Vec, -} - impl From for ContestedDocumentResourceVotePoll { fn from(value: ContestedDocumentResourceVotePollWithContractInfo) -> Self { let ContestedDocumentResourceVotePollWithContractInfo { @@ -56,7 +39,6 @@ impl From for ContestedDocume index_name, index_values, } = value; - ContestedDocumentResourceVotePoll { contract_id: contract.id(), document_type_name, @@ -66,31 +48,47 @@ impl From for ContestedDocume } } -impl<'a> From> +impl From<&ContestedDocumentResourceVotePollWithContractInfo> for ContestedDocumentResourceVotePoll { - fn from(value: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed) -> Self { - let ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { + fn from(value: &ContestedDocumentResourceVotePollWithContractInfo) -> Self { + let ContestedDocumentResourceVotePollWithContractInfo { contract, document_type_name, index_name, index_values, } = value; - ContestedDocumentResourceVotePoll { contract_id: contract.id(), - document_type_name, - index_name, - index_values, + document_type_name: document_type_name.clone(), + index_name: index_name.clone(), + index_values: index_values.clone(), } } } -impl From<&ContestedDocumentResourceVotePollWithContractInfo> +/// Represents information related to a contested document resource vote poll, along with +/// associated contract details. +/// +/// This structure holds a reference to the contract, the document type name, +/// the index name, and the index values used for the poll. +#[derive(Debug, PartialEq, Clone)] +pub struct ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed<'a> { + /// The contract information associated with the document. + pub contract: DataContractResolvedInfo<'a>, + /// The name of the document type. + pub document_type_name: String, + /// The name of the index. + pub index_name: String, + /// The values used in the index for the poll. + pub index_values: Vec, +} + +impl<'a> From> for ContestedDocumentResourceVotePoll { - fn from(value: &ContestedDocumentResourceVotePollWithContractInfo) -> Self { - let ContestedDocumentResourceVotePollWithContractInfo { + fn from(value: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed) -> Self { + let ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { contract, document_type_name, index_name, @@ -99,9 +97,9 @@ impl From<&ContestedDocumentResourceVotePollWithContractInfo> ContestedDocumentResourceVotePoll { contract_id: contract.id(), - document_type_name: document_type_name.clone(), - index_name: index_name.clone(), - index_values: index_values.clone(), + document_type_name, + index_name, + index_values, } } } diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs index db992f239e..309040a50a 100644 --- a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs @@ -135,7 +135,7 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote index_values, } = self; - let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll".to_string())))?; + let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll as owned".to_string())))?; Ok(ContestedDocumentResourceVotePollWithContractInfo { contract: DataContractOwnedResolvedInfo::DataContractFetchInfo(contract), document_type_name, @@ -158,7 +158,7 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote index_values, } = self; - let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll".to_string())))?; + let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll as borrowed".to_string())))?; Ok( ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { contract: DataContractResolvedInfo::ArcDataContractFetchInfo(contract), @@ -242,7 +242,7 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote index_values, } = self; - let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll".to_string())))?; + let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll as owned, but allowing borrowed".to_string())))?; Ok( ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { contract: DataContractResolvedInfo::ArcDataContractFetchInfo(contract), diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs index 864e863aa4..b80b52e5f1 100644 --- a/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs @@ -8,7 +8,7 @@ pub mod contested_document_resource_vote_poll; /// Module containing logic to resolve various components. #[cfg(feature = "server")] -pub(crate) mod resolve; +pub mod resolve; /// Represents a resolved vote poll in the system. #[derive(Debug, Clone, PartialEq, From)] diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/resolve.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/resolve.rs index 78a801e5a4..eecb852f1b 100644 --- a/packages/rs-drive/src/drive/votes/resolved/vote_polls/resolve.rs +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/resolve.rs @@ -6,6 +6,7 @@ use dpp::voting::vote_polls::VotePoll; use grovedb::TransactionArg; use platform_version::version::PlatformVersion; +/// The vote poll resolver pub trait VotePollResolver { /// Resolves the contested document resource vote poll information. /// @@ -34,6 +35,7 @@ pub trait VotePollResolver { platform_version: &PlatformVersion, ) -> Result; + /// Resolve owned fn resolve_owned( self, drive: &Drive, diff --git a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs index d50c5ac0d9..457751a544 100644 --- a/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/setup/setup_initial_vote_tree_main_structure/v0/mod.rs @@ -19,10 +19,7 @@ impl Drive { vec![CONTESTED_RESOURCE_TREE_KEY as u8], ); - batch.add_insert_empty_tree( - vote_contested_resource_tree_path_vec(), - vec![END_DATE_QUERIES_TREE_KEY as u8], - ); + batch.add_insert_empty_tree(vote_root_path_vec(), vec![END_DATE_QUERIES_TREE_KEY as u8]); batch.add_insert_empty_tree( vote_contested_resource_tree_path_vec(), diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index 554fd49fc1..871667f67d 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -590,9 +590,14 @@ impl ContestedDocumentVotePollDriveQuery { ContestedDocumentVotePollDriveQueryResultType::Documents => { // with documents only we don't need to work about lock and abstaining tree let contenders = query_result_elements - .to_key_elements() + .to_path_key_elements() .into_iter() - .map(|(identity_id, document)| { + .map(|(mut path, _, document)| { + let identity_id = path.pop().ok_or(Error::Drive( + DriveError::CorruptedDriveState( + "the path must have a last element".to_string(), + ), + ))?; Ok(ContenderWithSerializedDocument { identity_id: Identifier::try_from(identity_id)?, serialized_document: Some(document.into_item_bytes()?), @@ -886,7 +891,7 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { if allow_include_locked_and_abstaining_vote_tally { query.insert_all() } else { - query.insert_range_after(vec![RESOURCE_LOCK_VOTE_TREE_KEY as u8]..) + query.insert_range_after(vec![RESOURCE_LOCK_VOTE_TREE_KEY_U8]..) } } Some((starts_at_key_bytes, start_at_included)) => { @@ -902,7 +907,7 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { query.insert_range_to_inclusive(..=starts_at_key) } else { query.insert_range_after_to_inclusive( - vec![RESOURCE_LOCK_VOTE_TREE_KEY as u8]..=starts_at_key, + vec![RESOURCE_LOCK_VOTE_TREE_KEY_U8]..=starts_at_key, ) } } @@ -911,7 +916,7 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { query.insert_range_to(..starts_at_key) } else { query.insert_range_after_to( - vec![RESOURCE_LOCK_VOTE_TREE_KEY as u8]..starts_at_key, + vec![RESOURCE_LOCK_VOTE_TREE_KEY_U8]..starts_at_key, ) } } @@ -936,12 +941,12 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { if allow_include_locked_and_abstaining_vote_tally { query.add_conditional_subquery( - QueryItem::Key(vec![RESOURCE_LOCK_VOTE_TREE_KEY as u8]), + QueryItem::Key(vec![RESOURCE_LOCK_VOTE_TREE_KEY_U8]), Some(vec![vec![1]]), None, ); query.add_conditional_subquery( - QueryItem::Key(vec![RESOURCE_ABSTAIN_VOTE_TREE_KEY as u8]), + QueryItem::Key(vec![RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8]), Some(vec![vec![1]]), None, ); diff --git a/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs b/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs index c88c736b74..e9aab6d3db 100644 --- a/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs +++ b/packages/rs-drive/src/query/vote_polls_by_document_type_query.rs @@ -111,7 +111,19 @@ impl VotePollsByDocumentTypeQuery { limit, order_ascending, } = self; - let contract = drive.fetch_contract(contract_id.to_buffer(), None, None, transaction, platform_version).unwrap()?.ok_or(Error::DataContract(DataContractError::MissingContract("data contract not found when trying to resolve contested document resource vote poll".to_string())))?; + let contract = drive + .fetch_contract( + contract_id.to_buffer(), + None, + None, + transaction, + platform_version, + ) + .unwrap()? + .ok_or(Error::DataContract(DataContractError::MissingContract( + "data contract not found when resolving vote polls by document type query" + .to_string(), + )))?; Ok(ResolvedVotePollsByDocumentTypeQuery { contract: DataContractResolvedInfo::ArcDataContractFetchInfo(contract), diff --git a/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs b/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs index 28d7b5636a..b0a4d47544 100644 --- a/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs +++ b/packages/rs-drive/src/query/vote_polls_by_end_date_query.rs @@ -1,5 +1,5 @@ use crate::common::encode::{decode_u64, encode_u64}; -use crate::drive::votes::paths::vote_contested_resource_end_date_queries_tree_path_vec; +use crate::drive::votes::paths::vote_end_date_queries_tree_path_vec; use crate::drive::Drive; #[cfg(feature = "server")] use crate::error::drive::DriveError; @@ -17,8 +17,7 @@ use dpp::fee::Credits; use dpp::prelude::{TimestampIncluded, TimestampMillis}; #[cfg(feature = "server")] use dpp::serialization::PlatformDeserializable; -#[cfg(feature = "server")] -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::voting::vote_polls::VotePoll; #[cfg(feature = "server")] use grovedb::query_result_type::{QueryResultElements, QueryResultType}; #[cfg(feature = "server")] @@ -47,7 +46,7 @@ pub struct VotePollsByEndDateDriveQuery { impl VotePollsByEndDateDriveQuery { /// Get the path query for an abci query that gets vote polls by the end time pub fn path_query_for_end_time_included(end_time: TimestampMillis, limit: u16) -> PathQuery { - let path = vote_contested_resource_end_date_queries_tree_path_vec(); + let path = vote_end_date_queries_tree_path_vec(); let mut query = Query::new_with_direction(true); @@ -81,7 +80,7 @@ impl VotePollsByEndDateDriveQuery { transaction: TransactionArg, drive_operations: &mut Vec, platform_version: &PlatformVersion, - ) -> Result>, Error> { + ) -> Result>, Error> { let path_query = Self::path_query_for_end_time_included(end_time, limit); let query_result = drive.grove_get_path_query( &path_query, @@ -108,7 +107,7 @@ impl VotePollsByEndDateDriveQuery { let timestamp = decode_u64(last_path_component).map_err(Error::from)?; let contested_document_resource_vote_poll_bytes = element.into_item_bytes().map_err(Error::from)?; - let vote_poll = ContestedDocumentResourceVotePoll::deserialize_from_bytes( + let vote_poll = VotePoll::deserialize_from_bytes( &contested_document_resource_vote_poll_bytes, )?; Ok((timestamp, vote_poll)) @@ -117,8 +116,7 @@ impl VotePollsByEndDateDriveQuery { .into_iter() .fold( BTreeMap::new(), - |mut acc: BTreeMap>, - (timestamp, vote_poll)| { + |mut acc: BTreeMap>, (timestamp, vote_poll)| { acc.entry(timestamp).or_default().push(vote_poll); acc }, @@ -130,7 +128,7 @@ impl VotePollsByEndDateDriveQuery { /// Operations to construct a path query. pub fn construct_path_query(&self) -> PathQuery { - let path = vote_contested_resource_end_date_queries_tree_path_vec(); + let path = vote_end_date_queries_tree_path_vec(); let mut query = Query::new_with_direction(self.order_ascending); @@ -242,13 +240,7 @@ impl VotePollsByEndDateDriveQuery { block_info: Option, transaction: TransactionArg, platform_version: &PlatformVersion, - ) -> Result< - ( - BTreeMap>, - Credits, - ), - Error, - > { + ) -> Result<(BTreeMap>, Credits), Error> { let mut drive_operations = vec![]; let result = self.execute_no_proof(drive, transaction, &mut drive_operations, platform_version)?; @@ -275,7 +267,7 @@ impl VotePollsByEndDateDriveQuery { transaction: TransactionArg, drive_operations: &mut Vec, platform_version: &PlatformVersion, - ) -> Result>, Error> { + ) -> Result>, Error> { let path_query = self.construct_path_query(); let query_result = drive.grove_get_path_query( &path_query, @@ -302,7 +294,7 @@ impl VotePollsByEndDateDriveQuery { let timestamp = decode_u64(last_path_component).map_err(Error::from)?; let contested_document_resource_vote_poll_bytes = element.into_item_bytes().map_err(Error::from)?; - let vote_poll = ContestedDocumentResourceVotePoll::deserialize_from_bytes( + let vote_poll = VotePoll::deserialize_from_bytes( &contested_document_resource_vote_poll_bytes, )?; Ok((timestamp, vote_poll)) @@ -311,8 +303,7 @@ impl VotePollsByEndDateDriveQuery { .into_iter() .fold( BTreeMap::new(), - |mut acc: BTreeMap>, - (timestamp, vote_poll)| { + |mut acc: BTreeMap>, (timestamp, vote_poll)| { acc.entry(timestamp).or_default().push(vote_poll); acc }, diff --git a/packages/rs-platform-value/src/types/identifier.rs b/packages/rs-platform-value/src/types/identifier.rs index 4529310c84..445514730d 100644 --- a/packages/rs-platform-value/src/types/identifier.rs +++ b/packages/rs-platform-value/src/types/identifier.rs @@ -173,7 +173,7 @@ impl Identifier { pub fn from_bytes(bytes: &[u8]) -> Result { if bytes.len() != 32 { return Err(Error::ByteLengthNot32BytesError(String::from( - "Identifier must be 32 bytes long", + "Identifier must be 32 bytes long from bytes", ))); } @@ -184,7 +184,7 @@ impl Identifier { pub fn from_vec(vec: Vec) -> Result { if vec.len() != 32 { return Err(Error::ByteLengthNot32BytesError(String::from( - "Identifier must be 32 bytes long", + "Identifier must be 32 bytes long from vec", ))); } diff --git a/packages/rs-platform-version/src/version/drive_abci_versions.rs b/packages/rs-platform-version/src/version/drive_abci_versions.rs index ef80afed92..f7b543389d 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions.rs @@ -302,8 +302,8 @@ pub struct DriveAbciBlockEndMethodVersions { pub struct DriveAbciVotingMethodVersions { pub keep_record_of_vote_poll: FeatureVersion, pub clean_up_after_vote_poll_end: FeatureVersion, + pub clean_up_after_contested_resources_vote_poll_end: FeatureVersion, pub check_for_ended_vote_polls: FeatureVersion, - pub check_for_ended_contested_resource_vote_polls: FeatureVersion, pub tally_votes_for_contested_document_resource_vote_poll: FeatureVersion, pub award_document_to_winner: FeatureVersion, pub lock_contested_resource: FeatureVersion, diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 1596e520f4..631f56375a 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -270,6 +270,7 @@ pub struct DriveVoteMethodVersions { pub cleanup: DriveVoteCleanupMethodVersions, pub setup: DriveVoteSetupMethodVersions, pub storage_form: DriveVoteStorageFormMethodVersions, + pub fetch_identities_voting_for_contenders: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index d91e464817..dff75fc861 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -245,6 +245,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { storage_form: DriveVoteStorageFormMethodVersions { resolve_with_contract: 0, }, + fetch_identities_voting_for_contenders: 0, }, contract: DriveContractMethodVersions { prove: DriveContractProveMethodVersions { @@ -638,8 +639,8 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { voting: DriveAbciVotingMethodVersions { keep_record_of_vote_poll: 0, clean_up_after_vote_poll_end: 0, + clean_up_after_contested_resources_vote_poll_end: 0, check_for_ended_vote_polls: 0, - check_for_ended_contested_resource_vote_polls: 0, tally_votes_for_contested_document_resource_vote_poll: 0, award_document_to_winner: 0, lock_contested_resource: 0, @@ -801,8 +802,8 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { validation_of_added_keys_proof_of_possession_failure: 50000000, }, event_constants: DriveAbciValidationConstants { - maximum_vote_polls_to_process: 0, - maximum_contenders_to_consider: 0, + maximum_vote_polls_to_process: 2, + maximum_contenders_to_consider: 100, }, }, query: DriveAbciQueryVersions { diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index e4cfe28ff5..541a7916f8 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -253,6 +253,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { storage_form: DriveVoteStorageFormMethodVersions { resolve_with_contract: 0, }, + fetch_identities_voting_for_contenders: 0, }, contract: DriveContractMethodVersions { prove: DriveContractProveMethodVersions { @@ -638,8 +639,8 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { voting: DriveAbciVotingMethodVersions { keep_record_of_vote_poll: 0, clean_up_after_vote_poll_end: 0, + clean_up_after_contested_resources_vote_poll_end: 0, check_for_ended_vote_polls: 0, - check_for_ended_contested_resource_vote_polls: 0, tally_votes_for_contested_document_resource_vote_poll: 0, award_document_to_winner: 0, lock_contested_resource: 0, @@ -801,8 +802,8 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { validation_of_added_keys_proof_of_possession_failure: 50000000, }, event_constants: DriveAbciValidationConstants { - maximum_vote_polls_to_process: 0, - maximum_contenders_to_consider: 0, + maximum_vote_polls_to_process: 2, + maximum_contenders_to_consider: 100, }, }, query: DriveAbciQueryVersions { diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 20e92a63c1..be9bd71681 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -244,6 +244,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { storage_form: DriveVoteStorageFormMethodVersions { resolve_with_contract: 0, }, + fetch_identities_voting_for_contenders: 0, }, contract: DriveContractMethodVersions { prove: DriveContractProveMethodVersions { @@ -637,8 +638,8 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { voting: DriveAbciVotingMethodVersions { keep_record_of_vote_poll: 0, clean_up_after_vote_poll_end: 0, + clean_up_after_contested_resources_vote_poll_end: 0, check_for_ended_vote_polls: 0, - check_for_ended_contested_resource_vote_polls: 0, tally_votes_for_contested_document_resource_vote_poll: 0, award_document_to_winner: 0, lock_contested_resource: 0, @@ -800,8 +801,8 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { validation_of_added_keys_proof_of_possession_failure: 50000000, }, event_constants: DriveAbciValidationConstants { - maximum_vote_polls_to_process: 0, - maximum_contenders_to_consider: 0, + maximum_vote_polls_to_process: 2, + maximum_contenders_to_consider: 100, }, }, query: DriveAbciQueryVersions { From 8757326f519c103c9c8c740eae76f640d42ca30a Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 5 Jun 2024 18:38:14 +0300 Subject: [PATCH 112/135] small fix --- packages/rs-drive/src/drive/votes/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 5b5609f63b..2a181053ea 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -23,6 +23,7 @@ pub mod paths; #[cfg(feature = "server")] mod setup; +#[cfg(feature = "server")] mod fetch_identities_voting_for_contenders; #[cfg(any(feature = "server", feature = "verify"))] /// Resolve contested document resource vote poll module From 58398acdf717bf6718094ab9880b3330760f8c4e Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Thu, 6 Jun 2024 10:34:36 +0300 Subject: [PATCH 113/135] temp --- .../voting/check_for_ended_vote_polls/v0/mod.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs index dab40cf954..5930eb5a9f 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs @@ -167,13 +167,12 @@ where // We need to clean up the vote poll // This means removing it and also removing all current votes - // todo() - // self.clean_up_after_vote_polls_end( - // block_info, - // &vote_polls, - // transaction, - // platform_version, - // )?; + self.clean_up_after_vote_polls_end( + block_info, + &vote_polls, + transaction, + platform_version, + )?; } Ok(()) } From 8e0c9d0ade59efe0ec2142035969a76378bcadac Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 7 Jun 2024 05:55:41 +0300 Subject: [PATCH 114/135] more work on cleanup --- Cargo.lock | 38 ++++----- .../vote_choices/resource_vote_choice/mod.rs | 2 +- packages/rs-dpp/src/voting/vote_polls/mod.rs | 2 + .../voting/award_document_to_winner/mod.rs | 2 +- .../voting/award_document_to_winner/v0/mod.rs | 2 +- .../check_for_ended_vote_polls/v0/mod.rs | 33 ++++---- .../mod.rs | 13 +++- .../v0/mod.rs | 36 +++++++-- .../clean_up_after_vote_polls_end/mod.rs | 13 ++-- .../clean_up_after_vote_polls_end/v0/mod.rs | 30 +++++--- .../state_transitions/masternode_vote/mod.rs | 77 +++++++++---------- .../src/drive/grove_operations/mod.rs | 1 + .../rs-drive/src/drive/votes/cleanup/mod.rs | 2 + .../mod.rs | 15 ++-- .../v0/mod.rs | 54 +++++-------- .../mod.rs | 52 +++++++++++++ .../v0/mod.rs | 54 +++++++++++++ .../mod.rs | 5 +- .../v0/mod.rs | 28 ++++++- .../v0/mod.rs | 2 +- .../src/drive/votes/insert/vote_poll/mod.rs | 1 - packages/rs-drive/src/drive/votes/paths.rs | 6 +- .../drive/votes/resolved/vote_polls/mod.rs | 13 ++++ .../query/vote_poll_contestant_votes_query.rs | 2 +- .../src/version/drive_versions.rs | 1 + .../src/version/mocks/v2_test.rs | 1 + .../src/version/mocks/v3_test.rs | 1 + .../rs-platform-version/src/version/v1.rs | 1 + 28 files changed, 332 insertions(+), 155 deletions(-) rename packages/rs-drive/src/drive/votes/{insert/vote_poll/remove_vote_poll_end_date_query_operations => cleanup/remove_contested_resource_vote_poll_end_date_query_operations}/mod.rs (73%) rename packages/rs-drive/src/drive/votes/{insert/vote_poll/remove_vote_poll_end_date_query_operations => cleanup/remove_contested_resource_vote_poll_end_date_query_operations}/v0/mod.rs (50%) create mode 100644 packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/v0/mod.rs diff --git a/Cargo.lock b/Cargo.lock index bf2d07b293..47aa11d74e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -831,9 +831,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.4" +version = "4.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +checksum = "a9689a29b593160de5bc4aacab7b5d54fb52231de70122626c178e6a368994c7" dependencies = [ "clap_builder", "clap_derive", @@ -841,9 +841,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.2" +version = "4.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +checksum = "2e5387378c84f6faa26890ebf9f0a92989f8873d4d380467bcd0d8d8620424df" dependencies = [ "anstream", "anstyle", @@ -853,9 +853,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.4" +version = "4.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -865,9 +865,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" [[package]] name = "colorchoice" @@ -1313,7 +1313,7 @@ dependencies = [ "bincode 2.0.0-rc.3", "bip37-bloom-filter", "ciborium", - "clap 4.5.4", + "clap 4.5.6", "dapi-grpc", "dapi-grpc-macros", "dashcore-rpc", @@ -1646,7 +1646,7 @@ dependencies = [ "bincode 2.0.0-rc.3", "chrono", "ciborium", - "clap 4.5.4", + "clap 4.5.6", "console-subscriber", "dapi-grpc", "dashcore-rpc", @@ -2190,7 +2190,7 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "grovedb" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#b29791803245b834370929302922c267dcadc99e" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#07a5a192b4d9e9b0fabf79ff1570b492d09f892a" dependencies = [ "bincode 2.0.0-rc.3", "bitvec", @@ -2213,7 +2213,7 @@ dependencies = [ [[package]] name = "grovedb-costs" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#b29791803245b834370929302922c267dcadc99e" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#07a5a192b4d9e9b0fabf79ff1570b492d09f892a" dependencies = [ "integer-encoding", "intmap", @@ -2223,7 +2223,7 @@ dependencies = [ [[package]] name = "grovedb-merk" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#b29791803245b834370929302922c267dcadc99e" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#07a5a192b4d9e9b0fabf79ff1570b492d09f892a" dependencies = [ "blake3", "byteorder", @@ -2246,12 +2246,12 @@ dependencies = [ [[package]] name = "grovedb-path" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#b29791803245b834370929302922c267dcadc99e" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#07a5a192b4d9e9b0fabf79ff1570b492d09f892a" [[package]] name = "grovedb-storage" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#b29791803245b834370929302922c267dcadc99e" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#07a5a192b4d9e9b0fabf79ff1570b492d09f892a" dependencies = [ "blake3", "grovedb-costs", @@ -2270,7 +2270,7 @@ dependencies = [ [[package]] name = "grovedb-visualize" version = "1.0.0-rc.2" -source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#b29791803245b834370929302922c267dcadc99e" +source = "git+https://github.com/dashpay/grovedb?branch=feat/QuerySumTree#07a5a192b4d9e9b0fabf79ff1570b492d09f892a" dependencies = [ "hex", "itertools 0.12.1", @@ -5317,7 +5317,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.11", + "winnow 0.6.13", ] [[package]] @@ -6328,9 +6328,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.11" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c52728401e1dc672a56e81e593e912aa54c78f40246869f78359a2bf24d29d" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" dependencies = [ "memchr", ] diff --git a/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs b/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs index 876289e664..b522f4d44e 100644 --- a/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs +++ b/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs @@ -16,7 +16,7 @@ use serde::{Deserialize, Serialize}; /// In this case Malaka might have a bad connotation in Greek, hence some might votes to Lock /// the name. /// -#[derive(Debug, Clone, Copy, Encode, Decode, PartialEq, Default)] +#[derive(Debug, Clone, Copy, Encode, Decode, Ord, Eq, PartialOrd, PartialEq, Default)] #[cfg_attr( feature = "vote-serde-conversion", derive(Serialize, Deserialize), diff --git a/packages/rs-dpp/src/voting/vote_polls/mod.rs b/packages/rs-dpp/src/voting/vote_polls/mod.rs index d05bcb344d..50fec4fe6c 100644 --- a/packages/rs-dpp/src/voting/vote_polls/mod.rs +++ b/packages/rs-dpp/src/voting/vote_polls/mod.rs @@ -1,4 +1,5 @@ use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; +use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use crate::ProtocolError; use derive_more::From; @@ -6,6 +7,7 @@ use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use platform_value::Identifier; #[cfg(feature = "vote-serde-conversion")] use serde::{Deserialize, Serialize}; +use std::collections::BTreeMap; pub mod contested_document_resource_vote_poll; diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/mod.rs index 3342fbccb2..d868ba2abc 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/mod.rs @@ -18,7 +18,7 @@ where &self, block_info: &BlockInfo, contender: FinalizedContender, - vote_poll: ContestedDocumentResourceVotePollWithContractInfo, + vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/v0/mod.rs index d74c3b130a..30f7a1c8c9 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/v0/mod.rs @@ -19,7 +19,7 @@ where &self, block_info: &BlockInfo, contender: FinalizedContender, - vote_poll: ContestedDocumentResourceVotePollWithContractInfo, + vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs index 5930eb5a9f..4fa583d36f 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs @@ -3,13 +3,15 @@ use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; use dpp::block::block_info::BlockInfo; use dpp::document::DocumentV0Getters; +use dpp::prelude::TimestampMillis; use dpp::version::PlatformVersion; use drive::drive::votes::resolved::vote_polls::resolve::VotePollResolver; -use drive::drive::votes::resolved::vote_polls::ResolvedVotePoll; +use drive::drive::votes::resolved::vote_polls::{ResolvedVotePoll, ResolvedVotePollWithVotes}; use drive::grovedb::TransactionArg; use drive::query::vote_poll_vote_state_query::FinalizedContender; use drive::query::VotePollsByEndDateDriveQuery; use itertools::Itertools; +use std::collections::BTreeMap; impl Platform where @@ -24,7 +26,7 @@ where platform_version: &PlatformVersion, ) -> Result<(), Error> { // let's start by getting the vote polls that have finished - let vote_polls = + let vote_polls_by_timestamp = VotePollsByEndDateDriveQuery::execute_no_proof_for_specialized_end_time_query( block_info.time_ms, platform_version @@ -38,8 +40,8 @@ where platform_version, )?; - for (end_date, vote_polls) in vote_polls { - for vote_poll in &vote_polls { + let vote_polls_with_info = vote_polls_by_timestamp.into_iter().map(|(end_date, vote_polls)| { + let vote_polls_with_votes = vote_polls.into_iter().map(|vote_poll| { let resolved_vote_poll = vote_poll.resolve(&self.drive, transaction, platform_version)?; match resolved_vote_poll { @@ -91,6 +93,7 @@ where self.drive.fetch_identities_voting_for_contenders( &resolved_contested_document_resource_vote_poll, restrict_to_only_fetch_contenders, + true, transaction, platform_version, )?; @@ -110,7 +113,7 @@ where document_type, platform_version, ) - .map_err(Error::Drive) + .map_err(Error::Drive) }) .collect::, Error>>()?; // Now we sort by the document creation date @@ -155,25 +158,23 @@ where self.award_document_to_winner( block_info, top_contender, - resolved_contested_document_resource_vote_poll, + &resolved_contested_document_resource_vote_poll, transaction, platform_version, )?; } } + Ok(ResolvedVotePollWithVotes::ContestedDocumentResourceVotePollWithContractInfoAndVotes(resolved_contested_document_resource_vote_poll, identifiers_voting_for_contenders)) } } - } + }).collect::, Error>>()?; + Ok((end_date, vote_polls_with_votes)) + }).collect::>, Error>>()?; + + // We need to clean up the vote polls + // This means removing it and also removing all current votes + self.clean_up_after_vote_polls_end(&vote_polls_with_info, transaction, platform_version)?; - // We need to clean up the vote poll - // This means removing it and also removing all current votes - self.clean_up_after_vote_polls_end( - block_info, - &vote_polls, - transaction, - platform_version, - )?; - } Ok(()) } } diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/mod.rs index f686af76db..4a6bba3ee2 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/mod.rs @@ -3,9 +3,14 @@ use crate::error::Error; use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; use dpp::block::block_info::BlockInfo; +use dpp::identifier::Identifier; +use dpp::prelude::TimestampMillis; use dpp::version::PlatformVersion; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use drive::grovedb::TransactionArg; +use std::collections::BTreeMap; mod v0; @@ -16,8 +21,11 @@ where /// Checks for ended vote polls pub(in crate::execution) fn clean_up_after_contested_resources_vote_polls_end( &self, - block_info: &BlockInfo, - vote_polls: &[&ContestedDocumentResourceVotePoll], + vote_polls: Vec<( + &ContestedDocumentResourceVotePollWithContractInfo, + &TimestampMillis, + &BTreeMap>, + )>, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { @@ -28,7 +36,6 @@ where .clean_up_after_contested_resources_vote_poll_end { 0 => self.clean_up_after_contested_resources_vote_polls_end_v0( - block_info, vote_polls, transaction, platform_version, diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs index 19ee7e53f7..664cc5600b 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs @@ -1,11 +1,13 @@ use crate::error::Error; use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; -use dpp::block::block_info::BlockInfo; +use dpp::identifier::Identifier; +use dpp::prelude::TimestampMillis; use dpp::version::PlatformVersion; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; -use dpp::voting::vote_polls::VotePoll; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use drive::grovedb::TransactionArg; +use std::collections::BTreeMap; impl Platform where @@ -15,21 +17,39 @@ where #[inline(always)] pub(super) fn clean_up_after_contested_resources_vote_polls_end_v0( &self, - block_info: &BlockInfo, - vote_polls: &[&ContestedDocumentResourceVotePoll], + vote_polls: Vec<( + &ContestedDocumentResourceVotePollWithContractInfo, + &TimestampMillis, + &BTreeMap>, + )>, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { let mut operations = vec![]; self.drive .remove_contested_resource_vote_poll_end_date_query_operations( - vote_polls, - block_info.time_ms, + vote_polls.as_slice(), &mut operations, transaction, platform_version, )?; - //todo() + + self.drive + .remove_contested_resource_vote_poll_votes_operations( + vote_polls.as_slice(), + &mut operations, + transaction, + platform_version, + )?; + + self.drive.apply_batch_low_level_drive_operations( + None, + transaction, + operations, + &mut vec![], + &platform_version.drive, + )?; + Ok(()) } } diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/mod.rs index bd1d2833ac..bc79f90ccc 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/mod.rs @@ -3,10 +3,13 @@ use crate::error::Error; use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; use dpp::block::block_info::BlockInfo; +use dpp::prelude::TimestampMillis; use dpp::version::PlatformVersion; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::voting::vote_polls::VotePoll; +use drive::drive::votes::resolved::vote_polls::ResolvedVotePollWithVotes; use drive::grovedb::TransactionArg; +use std::collections::BTreeMap; mod v0; @@ -17,8 +20,7 @@ where /// Checks for ended vote polls pub(in crate::execution) fn clean_up_after_vote_polls_end( &self, - block_info: &BlockInfo, - vote_polls: &[VotePoll], + vote_polls: &BTreeMap>, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { @@ -28,12 +30,7 @@ where .voting .clean_up_after_vote_poll_end { - 0 => self.clean_up_after_vote_polls_end_v0( - block_info, - vote_polls, - transaction, - platform_version, - ), + 0 => self.clean_up_after_vote_polls_end_v0(vote_polls, transaction, platform_version), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { method: "clean_up_after_vote_polls_end".to_string(), known_versions: vec![0], diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/v0/mod.rs index b50f32136e..d4111e7bc1 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/v0/mod.rs @@ -2,10 +2,16 @@ use crate::error::Error; use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; use dpp::block::block_info::BlockInfo; +use dpp::identifier::Identifier; +use dpp::prelude::TimestampMillis; use dpp::version::PlatformVersion; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::voting::vote_polls::VotePoll; +use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use drive::drive::votes::resolved::vote_polls::ResolvedVotePollWithVotes; use drive::grovedb::TransactionArg; +use std::collections::BTreeMap; impl Platform where @@ -15,27 +21,31 @@ where #[inline(always)] pub(super) fn clean_up_after_vote_polls_end_v0( &self, - block_info: &BlockInfo, - vote_polls: &[VotePoll], + vote_polls: &BTreeMap>, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { // Create a vector to hold the references to the contested document resource vote polls - let mut contested_polls: Vec<&ContestedDocumentResourceVotePoll> = Vec::new(); + let mut contested_polls: Vec<( + &ContestedDocumentResourceVotePollWithContractInfo, + &TimestampMillis, + &BTreeMap>, + )> = Vec::new(); // Iterate over the vote polls and match on the enum variant - for vote_poll in vote_polls { - match vote_poll { - VotePoll::ContestedDocumentResourceVotePoll(contested_poll) => { - contested_polls.push(contested_poll); - } // Add more match arms here for other types of vote polls in the future + for (end_date, vote_polls_for_time) in vote_polls { + for vote_poll in vote_polls_for_time { + match vote_poll { + ResolvedVotePollWithVotes::ContestedDocumentResourceVotePollWithContractInfoAndVotes(contested_poll, vote_info) => { + contested_polls.push((contested_poll, end_date, vote_info)); + } // Add more match arms here for other types of vote polls in the future + } } } // Call the function to clean up contested document resource vote polls self.clean_up_after_contested_resources_vote_polls_end( - block_info, - &contested_polls, + contested_polls, transaction, platform_version, ) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 6f6ef33c9e..27d0ff67bc 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -4333,6 +4333,40 @@ mod tests { ); let platform_state = platform.state.load(); + + let (contenders, abstaining, locking) = get_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + assert_ne!(first_contender.document, second_contender.document); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(50)); + + assert_eq!(second_contender.vote_tally, Some(5)); + + assert_eq!(abstaining, Some(10)); + + assert_eq!(locking, Some(3)); + let mut platform_state = (**platform_state).clone(); let block_info = BlockInfo { @@ -4398,48 +4432,13 @@ mod tests { assert_eq!(second_contender.identity_id, contender_2.id()); - assert_eq!(first_contender.vote_tally, Some(50)); - - assert_eq!(second_contender.vote_tally, Some(5)); - - assert_eq!(abstaining, Some(10)); - - assert_eq!(locking, Some(3)); - - // Now let's not include locked and abstaining - - let (contenders, abstaining, locking) = get_vote_states( - &platform, - &platform_state, - &dpns_contract, - "quantum", - None, - true, - false, - None, - ResultType::DocumentsAndVoteTally, - platform_version, - ); - - assert_eq!(contenders.len(), 2); - - let first_contender = contenders.first().unwrap(); - - let second_contender = contenders.last().unwrap(); - - assert_ne!(first_contender.document, second_contender.document); - - assert_eq!(first_contender.identity_id, contender_1.id()); - - assert_eq!(second_contender.identity_id, contender_2.id()); - - assert_eq!(first_contender.vote_tally, Some(50)); + assert_eq!(first_contender.vote_tally, Some(0)); - assert_eq!(second_contender.vote_tally, Some(5)); + assert_eq!(second_contender.vote_tally, Some(0)); - assert_eq!(abstaining, None); + assert_eq!(abstaining, Some(0)); - assert_eq!(locking, None); + assert_eq!(locking, Some(0)); } } } diff --git a/packages/rs-drive/src/drive/grove_operations/mod.rs b/packages/rs-drive/src/drive/grove_operations/mod.rs index b622df63b6..1791853ce5 100644 --- a/packages/rs-drive/src/drive/grove_operations/mod.rs +++ b/packages/rs-drive/src/drive/grove_operations/mod.rs @@ -197,6 +197,7 @@ pub enum BatchDeleteApplyType { }, } +#[derive(Clone)] /// Batch delete up tree apply type pub enum BatchDeleteUpTreeApplyType { /// Stateless batch delete diff --git a/packages/rs-drive/src/drive/votes/cleanup/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/mod.rs index 1634d7257a..84cd94c602 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/mod.rs @@ -1,3 +1,5 @@ mod remove_votes_for_identity; mod add_lock_for_contested_document_resource_vote_poll; +mod remove_contested_resource_vote_poll_end_date_query_operations; +mod remove_contested_resource_vote_poll_votes_operations; diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_end_date_query_operations/mod.rs similarity index 73% rename from packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/mod.rs rename to packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_end_date_query_operations/mod.rs index 540ed2f530..788ba71454 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_end_date_query_operations/mod.rs @@ -1,14 +1,17 @@ mod v0; use crate::drive::Drive; +use std::collections::BTreeMap; use crate::error::drive::DriveError; use crate::error::Error; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use crate::fee::op::LowLevelDriveOperation; -use dpp::prelude::TimestampMillis; +use dpp::identifier::Identifier; +use dpp::identity::TimestampMillis; use dpp::version::PlatformVersion; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use grovedb::TransactionArg; impl Drive { @@ -16,8 +19,11 @@ impl Drive { /// any votes poll should be closed. This will remove them to recoup space pub fn remove_contested_resource_vote_poll_end_date_query_operations( &self, - vote_polls: &[&ContestedDocumentResourceVotePoll], - end_date: TimestampMillis, + vote_polls: &[( + &ContestedDocumentResourceVotePollWithContractInfo, + &TimestampMillis, + &BTreeMap>, + )], batch_operations: &mut Vec, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -31,7 +37,6 @@ impl Drive { { 0 => self.remove_contested_resource_vote_poll_end_date_query_operations_v0( vote_polls, - end_date, batch_operations, transaction, platform_version, diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_end_date_query_operations/v0/mod.rs similarity index 50% rename from packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/v0/mod.rs rename to packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_end_date_query_operations/v0/mod.rs index 0fcef0c8f0..2cf1dac3df 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/remove_vote_poll_end_date_query_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_end_date_query_operations/v0/mod.rs @@ -1,23 +1,29 @@ -use crate::common::encode::encode_u64; -use crate::drive::grove_operations::BatchDeleteApplyType::StatefulBatchDelete; +use crate::drive::grove_operations::BatchDeleteUpTreeApplyType; use crate::drive::votes::paths::{ vote_contested_resource_end_date_queries_at_time_tree_path_vec, vote_end_date_queries_tree_path, }; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; +use dpp::identifier::Identifier; use dpp::identity::TimestampMillis; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use grovedb::batch::KeyInfoPath; use grovedb::TransactionArg; use platform_version::version::PlatformVersion; +use std::collections::BTreeMap; impl Drive { /// We add votes poll references by end date in order to be able to check on every new block if /// any vote polls should be closed. - pub(in crate::drive::votes::insert) fn remove_contested_resource_vote_poll_end_date_query_operations_v0( + pub(in crate::drive::votes) fn remove_contested_resource_vote_poll_end_date_query_operations_v0( &self, - vote_polls: &[&ContestedDocumentResourceVotePoll], - end_date: TimestampMillis, + vote_polls: &[( + &ContestedDocumentResourceVotePollWithContractInfo, + &TimestampMillis, + &BTreeMap>, + )], batch_operations: &mut Vec, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -29,46 +35,28 @@ impl Drive { // / \ | // VotePoll Info 1 VotePoll Info 2 VotePoll Info 3 - // Let's start by inserting a tree for the end date - - let time_path = vote_contested_resource_end_date_queries_at_time_tree_path_vec(end_date); - - let delete_apply_type = StatefulBatchDelete { + let delete_apply_type = BatchDeleteUpTreeApplyType::StatefulBatchDelete { is_known_to_be_subtree_with_sum: Some((false, false)), }; - let time_path_borrowed: Vec<&[u8]> = time_path.iter().map(|a| a.as_slice()).collect(); + for (vote_poll, end_date, _) in vote_polls { + let time_path = + vote_contested_resource_end_date_queries_at_time_tree_path_vec(**end_date); - for vote_poll in vote_polls { let unique_id = vote_poll.unique_id()?; - self.batch_delete( - time_path_borrowed.as_slice().into(), + self.batch_delete_up_tree_while_empty( + KeyInfoPath::from_known_owned_path(time_path), unique_id.as_bytes(), - delete_apply_type, + Some(2), + delete_apply_type.clone(), transaction, + &None, batch_operations, &platform_version.drive, )?; } - let end_date_query_path = vote_end_date_queries_tree_path(); - - let end_date_key = encode_u64(end_date); - - let delete_apply_type = StatefulBatchDelete { - is_known_to_be_subtree_with_sum: Some((true, false)), - }; - - self.batch_delete( - (&end_date_query_path).into(), - end_date_key.as_slice(), - delete_apply_type, - transaction, - batch_operations, - &platform_version.drive, - )?; - Ok(()) } } diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/mod.rs new file mode 100644 index 0000000000..20b5791e38 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/mod.rs @@ -0,0 +1,52 @@ +mod v0; + +use crate::drive::Drive; +use std::collections::BTreeMap; + +use crate::error::drive::DriveError; +use crate::error::Error; + +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use crate::fee::op::LowLevelDriveOperation; +use dpp::identifier::Identifier; +use dpp::prelude::TimestampMillis; +use dpp::version::PlatformVersion; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use grovedb::TransactionArg; + +impl Drive { + /// We add votes poll references by end date in order to be able to check on every new block if + /// any votes poll should be closed. This will remove them to recoup space + pub fn remove_contested_resource_vote_poll_votes_operations( + &self, + vote_polls: &[( + &ContestedDocumentResourceVotePollWithContractInfo, + &TimestampMillis, + &BTreeMap>, + )], + batch_operations: &mut Vec, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive + .methods + .vote + .contested_resource_insert + .remove_contested_resource_vote_poll_votes_operations + { + 0 => self.remove_contested_resource_vote_poll_votes_operations_v0( + vote_polls, + batch_operations, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "remove_contested_resource_vote_poll_votes_operations".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/v0/mod.rs new file mode 100644 index 0000000000..50e1aa35d7 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/v0/mod.rs @@ -0,0 +1,54 @@ +use crate::drive::grove_operations::{BatchDeleteApplyType, BatchDeleteUpTreeApplyType}; +use crate::drive::votes::paths::{ + vote_contested_resource_end_date_queries_at_time_tree_path_vec, VotePollPaths, +}; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use crate::drive::Drive; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use dpp::identifier::Identifier; +use dpp::identity::TimestampMillis; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use grovedb::batch::KeyInfoPath; +use grovedb::TransactionArg; +use platform_version::version::PlatformVersion; +use std::collections::BTreeMap; + +impl Drive { + /// We add votes poll references by end date in order to be able to check on every new block if + /// any vote polls should be closed. + pub(in crate::drive::votes) fn remove_contested_resource_vote_poll_votes_operations_v0( + &self, + vote_polls: &[( + &ContestedDocumentResourceVotePollWithContractInfo, + &TimestampMillis, + &BTreeMap>, + )], + batch_operations: &mut Vec, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + for (vote_poll, _, votes) in vote_polls { + for (resource_vote_choice, votes) in *votes { + let path = + vote_poll.contender_voting_path(resource_vote_choice, platform_version)?; + + for vote in votes { + self.batch_delete( + path.as_slice().into(), + vote.as_slice(), + BatchDeleteApplyType::StatefulBatchDelete { + is_known_to_be_subtree_with_sum: Some((false, false)), + }, + transaction, + batch_operations, + &platform_version.drive, + )?; + } + } + } + + Ok(()) + } +} diff --git a/packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/mod.rs b/packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/mod.rs index 1607c356a5..a6d6c1ccd3 100644 --- a/packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/mod.rs +++ b/packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/mod.rs @@ -9,6 +9,7 @@ use crate::error::Error; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use dpp::platform_value::Identifier; use dpp::version::PlatformVersion; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use grovedb::TransactionArg; impl Drive { @@ -17,9 +18,10 @@ impl Drive { &self, contested_document_resource_vote_poll_with_contract_info: &ContestedDocumentResourceVotePollWithContractInfo, restrict_to_only_fetch_contenders: Option>, + also_fetch_abstaining_and_locked_votes: bool, transaction: TransactionArg, platform_version: &PlatformVersion, - ) -> Result>, Error> { + ) -> Result>, Error> { match platform_version .drive .methods @@ -29,6 +31,7 @@ impl Drive { 0 => self.fetch_identities_voting_for_contenders_v0( contested_document_resource_vote_poll_with_contract_info, restrict_to_only_fetch_contenders, + also_fetch_abstaining_and_locked_votes, transaction, platform_version, ), diff --git a/packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/v0/mod.rs b/packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/v0/mod.rs index 92448b40ad..b4fd3352f6 100644 --- a/packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/v0/mod.rs @@ -1,10 +1,12 @@ use crate::drive::votes::paths::{ - VotePollPaths, RESOURCE_LOCK_VOTE_TREE_KEY_U8, VOTE_DECISIONS_TREE_KEY, VOTING_STORAGE_TREE_KEY, + VotePollPaths, RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8, RESOURCE_LOCK_VOTE_TREE_KEY_U8, + VOTING_STORAGE_TREE_KEY, }; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use crate::drive::Drive; use crate::error::Error; use dpp::identifier::Identifier; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use grovedb::query_result_type::QueryResultType; use grovedb::{PathQuery, Query, QueryItem, SizedQuery, TransactionArg}; use platform_version::version::PlatformVersion; @@ -17,9 +19,10 @@ impl Drive { &self, contested_document_resource_vote_poll_with_contract_info: &ContestedDocumentResourceVotePollWithContractInfo, restrict_to_only_fetch_contenders: Option>, + also_fetch_abstaining_and_locked_votes: bool, transaction: TransactionArg, platform_version: &PlatformVersion, - ) -> Result>, Error> { + ) -> Result>, Error> { let mut path = contested_document_resource_vote_poll_with_contract_info .contenders_path(platform_version)?; @@ -31,7 +34,15 @@ impl Drive { .into_iter() .map(|id| id.to_vec()) .collect(), - ) + ); + if also_fetch_abstaining_and_locked_votes { + query.insert_keys(vec![ + vec![RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8], + vec![RESOURCE_LOCK_VOTE_TREE_KEY_U8], + ]); + } + } else if also_fetch_abstaining_and_locked_votes { + query.insert_all() } else { query.insert_range_after(vec![RESOURCE_LOCK_VOTE_TREE_KEY_U8]..) } @@ -65,7 +76,16 @@ impl Drive { .into_iter() .map(|value| value.try_into()) .collect::, dpp::platform_value::Error>>()?; - Ok((key.try_into()?, voters_array)) + if key == vec![RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8] { + Ok((ResourceVoteChoice::Abstain, voters_array)) + } else if key == vec![RESOURCE_LOCK_VOTE_TREE_KEY_U8] { + Ok((ResourceVoteChoice::Lock, voters_array)) + } else { + Ok(( + ResourceVoteChoice::TowardsIdentity(key.try_into()?), + voters_array, + )) + } }) .collect() } diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index 5e40fed7d6..4931593d07 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -91,7 +91,7 @@ impl Drive { // We start by inserting the main vote as a value of 1 or 4 depending on the strength - let mut voting_path = vote_poll.contender_voting_path(vote_choice, platform_version)?; + let mut voting_path = vote_poll.contender_voting_path(&vote_choice, platform_version)?; self.batch_insert::<0>( PathKeyElement(( diff --git a/packages/rs-drive/src/drive/votes/insert/vote_poll/mod.rs b/packages/rs-drive/src/drive/votes/insert/vote_poll/mod.rs index 405420e10a..26d37fb179 100644 --- a/packages/rs-drive/src/drive/votes/insert/vote_poll/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/vote_poll/mod.rs @@ -1,2 +1 @@ mod add_vote_poll_end_date_query_operations; -mod remove_vote_poll_end_date_query_operations; diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index e85d84fc4e..282c8e84d3 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -89,7 +89,7 @@ pub trait VotePollPaths { /// The path that would store the votes for a single contender fn contender_voting_path( &self, - vote_choice: ResourceVoteChoice, + vote_choice: &ResourceVoteChoice, platform_version: &PlatformVersion, ) -> Result>, Error>; } @@ -169,7 +169,7 @@ impl VotePollPaths for ContestedDocumentResourceVotePollWithContractInfo { fn contender_voting_path( &self, - vote_choice: ResourceVoteChoice, + vote_choice: &ResourceVoteChoice, platform_version: &PlatformVersion, ) -> Result>, Error> { let key = vote_choice.to_key(); @@ -255,7 +255,7 @@ impl<'a> VotePollPaths for ContestedDocumentResourceVotePollWithContractInfoAllo fn contender_voting_path( &self, - vote_choice: ResourceVoteChoice, + vote_choice: &ResourceVoteChoice, platform_version: &PlatformVersion, ) -> Result>, Error> { let key = vote_choice.to_key(); diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs index b80b52e5f1..d34171fe0d 100644 --- a/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs @@ -1,7 +1,10 @@ use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use derive_more::From; use dpp::identifier::Identifier; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::ProtocolError; +use std::collections::BTreeMap; /// Module containing logic for contested document resource vote polls. pub mod contested_document_resource_vote_poll; @@ -19,6 +22,16 @@ pub enum ResolvedVotePoll { ), } +/// Represents a resolved vote poll in the system that also contains votes. +#[derive(Debug, Clone, PartialEq, From)] +pub enum ResolvedVotePollWithVotes { + /// A resolved vote poll with contract information for a contested document resource. + ContestedDocumentResourceVotePollWithContractInfoAndVotes( + ContestedDocumentResourceVotePollWithContractInfo, + BTreeMap>, + ), +} + impl ResolvedVotePoll { /// Retrieves the specialized balance identifier associated with the resolved vote poll. /// diff --git a/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs b/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs index 6d04885222..f4fd57b974 100644 --- a/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs +++ b/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs @@ -261,7 +261,7 @@ impl<'a> ResolvedContestedDocumentVotePollVotesDriveQuery<'a> { ) -> Result { let path = self .vote_poll - .contender_voting_path(TowardsIdentity(self.contestant_id), platform_version)?; + .contender_voting_path(&TowardsIdentity(self.contestant_id), platform_version)?; let mut query = Query::new_with_direction(self.order_ascending); diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 631f56375a..44dfdcacf0 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -300,6 +300,7 @@ pub struct DriveVoteContestedResourceInsertMethodVersions { pub register_identity_vote: FeatureVersion, pub add_vote_poll_end_date_query_operations: FeatureVersion, pub remove_contested_resource_vote_poll_end_date_query_operations: FeatureVersion, + pub remove_contested_resource_vote_poll_votes_operations: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index dff75fc861..fd4a227b86 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -234,6 +234,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { register_identity_vote: 0, add_vote_poll_end_date_query_operations: 0, remove_contested_resource_vote_poll_end_date_query_operations: 0, + remove_contested_resource_vote_poll_votes_operations: 0, }, cleanup: DriveVoteCleanupMethodVersions { add_lock_for_contested_document_resource_vote_poll: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 541a7916f8..286d5b7ea7 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -242,6 +242,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { register_identity_vote: 0, add_vote_poll_end_date_query_operations: 0, remove_contested_resource_vote_poll_end_date_query_operations: 0, + remove_contested_resource_vote_poll_votes_operations: 0, }, cleanup: DriveVoteCleanupMethodVersions { add_lock_for_contested_document_resource_vote_poll: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index be9bd71681..aa44374f79 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -233,6 +233,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { register_identity_vote: 0, add_vote_poll_end_date_query_operations: 0, remove_contested_resource_vote_poll_end_date_query_operations: 0, + remove_contested_resource_vote_poll_votes_operations: 0, }, cleanup: DriveVoteCleanupMethodVersions { add_lock_for_contested_document_resource_vote_poll: 0, From 6dfa6107990225234487f5e9b8713061ff25522b Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 7 Jun 2024 16:50:59 +0300 Subject: [PATCH 115/135] more work --- .../protos/platform/v0/platform.proto | 11 +++ packages/rs-dpp/src/voting/mod.rs | 1 + .../mod.rs | 9 +++ .../rs-dpp/src/voting/vote_outcomes/mod.rs | 1 + .../state_transitions/documents_batch/mod.rs | 2 +- .../state_transitions/masternode_vote/mod.rs | 37 +++++++--- .../contested_resource_vote_state/v0/mod.rs | 26 +++++++ .../tests/strategy_tests/voting_tests.rs | 67 +++++-------------- .../v0/mod.rs | 4 ++ .../src/query/vote_poll_vote_state_query.rs | 10 ++- .../src/errors/consensus/consensus_error.rs | 4 ++ 11 files changed, 109 insertions(+), 63 deletions(-) create mode 100644 packages/rs-dpp/src/voting/vote_outcomes/contested_document_vote_poll_winner_info/mod.rs create mode 100644 packages/rs-dpp/src/voting/vote_outcomes/mod.rs diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index 9a26645472..76b6b36d7d 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -758,10 +758,21 @@ message GetContestedResourceVoteStateRequest { message GetContestedResourceVoteStateResponse { message GetContestedResourceVoteStateResponseV0 { + message FinishedVoteInfo { + enum FinishedVoteOutcome { + TOWARDS_IDENTITY = 0; + LOCKED = 1; + NO_PREVIOUS_WINNER = 2; + } + FinishedVoteOutcome finished_vote_outcome = 1; + optional bytes won_by_identity_id = 2; // Only used when vote_choice_type is TOWARDS_IDENTITY + } + message ContestedResourceContenders { repeated Contender contenders = 1; optional uint32 abstain_vote_tally = 2; optional uint32 lock_vote_tally = 3; + optional FinishedVoteInfo finished_vote_info = 4; } message Contender { diff --git a/packages/rs-dpp/src/voting/mod.rs b/packages/rs-dpp/src/voting/mod.rs index 2bf044eca7..0b1cb91fb5 100644 --- a/packages/rs-dpp/src/voting/mod.rs +++ b/packages/rs-dpp/src/voting/mod.rs @@ -1,3 +1,4 @@ pub mod vote_choices; pub mod vote_polls; pub mod votes; +pub mod vote_outcomes; diff --git a/packages/rs-dpp/src/voting/vote_outcomes/contested_document_vote_poll_winner_info/mod.rs b/packages/rs-dpp/src/voting/vote_outcomes/contested_document_vote_poll_winner_info/mod.rs new file mode 100644 index 0000000000..241ae34123 --- /dev/null +++ b/packages/rs-dpp/src/voting/vote_outcomes/contested_document_vote_poll_winner_info/mod.rs @@ -0,0 +1,9 @@ +use platform_value::Identifier; + +#[derive(Debug, PartialEq, Eq, Clone, Default)] +pub enum ContestedDocumentVotePollWinnerInfo { + #[default] + NoWinner, + WonByIdentity(Identifier), + Locked, +} \ No newline at end of file diff --git a/packages/rs-dpp/src/voting/vote_outcomes/mod.rs b/packages/rs-dpp/src/voting/vote_outcomes/mod.rs new file mode 100644 index 0000000000..216248fb8c --- /dev/null +++ b/packages/rs-dpp/src/voting/vote_outcomes/mod.rs @@ -0,0 +1 @@ +pub mod contested_document_vote_poll_winner_info; \ No newline at end of file diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs index 1326b06bc5..a03eeff310 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs @@ -671,7 +671,7 @@ mod tests { get_contested_resource_vote_state_response_v0::ContestedResourceContenders { contenders, abstain_vote_tally, - lock_vote_tally, + lock_vote_tally, finished_vote_info, }, ), ) = result diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 27d0ff67bc..ad899c7023 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -193,6 +193,7 @@ mod tests { mod vote_tests { use assert_matches::assert_matches; + use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::get_contested_resource_vote_state_response_v0::{finished_vote_info, FinishedVoteInfo}; use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType; use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult::SuccessfulExecution; use super::*; @@ -899,7 +900,7 @@ mod tests { >, result_type: ResultType, platform_version: &PlatformVersion, - ) -> (Vec, Option, Option) { + ) -> (Vec, Option, Option, Option) { // Now let's run a query for the vote totals let domain = dpns_contract @@ -957,6 +958,7 @@ mod tests { contenders, abstain_vote_tally, lock_vote_tally, + finished_vote_info, }, ), ) = result @@ -981,6 +983,7 @@ mod tests { .collect(), abstain_vote_tally, lock_vote_tally, + finished_vote_info, ) } @@ -1341,7 +1344,7 @@ mod tests { platform_version, ); - let (contenders, abstaining, locking) = get_vote_states( + let (contenders, abstaining, locking, finished_vote_info) = get_vote_states( &platform, &platform_state, &dpns_contract, @@ -1353,6 +1356,8 @@ mod tests { ResultType::DocumentsAndVoteTally, platform_version, ); + + assert_eq!(finished_vote_info, None); assert_eq!(contenders.len(), 2); @@ -1475,7 +1480,7 @@ mod tests { platform_version, ); - let (contenders, abstaining, locking) = get_vote_states( + let (contenders, abstaining, locking, finished_vote_info) = get_vote_states( &platform, &platform_state, &dpns_contract, @@ -1488,6 +1493,8 @@ mod tests { platform_version, ); + assert_eq!(finished_vote_info, None); + assert_eq!(contenders.len(), 2); let first_contender = contenders.first().unwrap(); @@ -1510,7 +1517,7 @@ mod tests { // Now let's not include locked and abstaining - let (contenders, abstaining, locking) = get_vote_states( + let (contenders, abstaining, locking, finished_vote_info) = get_vote_states( &platform, &platform_state, &dpns_contract, @@ -1523,6 +1530,8 @@ mod tests { platform_version, ); + assert_eq!(finished_vote_info, None); + assert_eq!(contenders.len(), 2); let first_contender = contenders.first().unwrap(); @@ -4334,7 +4343,7 @@ mod tests { let platform_state = platform.state.load(); - let (contenders, abstaining, locking) = get_vote_states( + let (contenders, abstaining, locking, finished_vote_info) = get_vote_states( &platform, &platform_state, &dpns_contract, @@ -4347,6 +4356,8 @@ mod tests { platform_version, ); + assert_eq!(finished_vote_info, None); + assert_eq!(contenders.len(), 2); let first_contender = contenders.first().unwrap(); @@ -4407,7 +4418,7 @@ mod tests { // At this point the document should have been awarded to contender 1. - let (contenders, abstaining, locking) = get_vote_states( + let (contenders, abstaining, locking, finished_vote_info) = get_vote_states( &platform, &platform_state, &dpns_contract, @@ -4420,25 +4431,29 @@ mod tests { platform_version, ); + assert_eq!(finished_vote_info, None); + assert_eq!(contenders.len(), 2); let first_contender = contenders.first().unwrap(); let second_contender = contenders.last().unwrap(); - assert_ne!(first_contender.document, second_contender.document); + assert_eq!(first_contender.document, None); + + assert_eq!(second_contender.document, None); assert_eq!(first_contender.identity_id, contender_1.id()); assert_eq!(second_contender.identity_id, contender_2.id()); - assert_eq!(first_contender.vote_tally, Some(0)); + assert_eq!(first_contender.vote_tally, Some(50)); - assert_eq!(second_contender.vote_tally, Some(0)); + assert_eq!(second_contender.vote_tally, Some(5)); - assert_eq!(abstaining, Some(0)); + assert_eq!(abstaining, Some(10)); - assert_eq!(locking, Some(0)); + assert_eq!(locking, Some(3)); } } } diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs index be713abbd9..c10bdecf14 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs @@ -7,6 +7,8 @@ use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::GetConte use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{ get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0, }; +use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::get_contested_resource_vote_state_response_v0::finished_vote_info::FinishedVoteOutcome; +use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::get_contested_resource_vote_state_response_v0::FinishedVoteInfo; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::identifier::Identifier; @@ -14,6 +16,7 @@ use dpp::validation::ValidationResult; use dpp::version::PlatformVersion; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::{check_validation_result_with_data, platform_value}; +use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; use drive::error::query::QuerySyntaxError; use drive::query::vote_poll_vote_state_query::{ ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQuery, @@ -180,6 +183,28 @@ impl Platform { let abstain_vote_tally = results.abstaining_vote_tally; let lock_vote_tally = results.locked_vote_tally; + let finished_vote_info = results.winner.map(|winner_info| { + match winner_info { + ContestedDocumentVotePollWinnerInfo::NoWinner => { + FinishedVoteInfo { + finished_vote_outcome: FinishedVoteOutcome::NoPreviousWinner as i32, + won_by_identity_id: None, + } + } + ContestedDocumentVotePollWinnerInfo::WonByIdentity(identity_id) => { + FinishedVoteInfo { + finished_vote_outcome: FinishedVoteOutcome::TowardsIdentity as i32, + won_by_identity_id: Some(identity_id.to_vec()) + } + } + ContestedDocumentVotePollWinnerInfo::Locked => { + FinishedVoteInfo { + finished_vote_outcome: FinishedVoteOutcome::Locked as i32, + won_by_identity_id: None, + } + } + } + }); let contenders = results .contenders @@ -206,6 +231,7 @@ impl Platform { contenders, abstain_vote_tally, lock_vote_tally, + finished_vote_info, }, ), ), diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index 0996d9aa35..087051a612 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -265,7 +265,7 @@ mod tests { let Some( get_contested_resource_vote_state_response_v0::Result::ContestedResourceContenders( get_contested_resource_vote_state_response_v0::ContestedResourceContenders { - contenders, + contenders, abstain_vote_tally, lock_vote_tally, finished_vote_info, }, ), ) = result @@ -279,37 +279,20 @@ mod tests { let second_contender = contenders.last().unwrap(); - let first_contender_document = Document::from_bytes( - first_contender - .document - .as_ref() - .expect("expected a document") - .as_slice(), - document_type.as_ref(), - platform_version, - ) - .expect("expected to get document"); - - let second_contender_document = Document::from_bytes( - second_contender - .document - .as_ref() - .expect("expected a document") - .as_slice(), - document_type.as_ref(), - platform_version, - ) - .expect("expected to get document"); + assert_eq!(first_contender + .document, None); + + assert_eq!(second_contender + .document, None); - assert_ne!(first_contender_document, second_contender_document); assert_eq!(first_contender.identifier, identity2_id.to_vec()); assert_eq!(second_contender.identifier, identity1_id.to_vec()); - assert_eq!(first_contender.vote_count, Some(0)); + assert_eq!(first_contender.vote_count, Some(50)); - assert_eq!(second_contender.vote_count, Some(0)); + assert_eq!(second_contender.vote_count, Some(3)); let GetContestedResourceVoteStateResponse { version } = platform .query_contested_resource_vote_state( @@ -383,37 +366,21 @@ mod tests { let first_contender = result.contenders.first().unwrap(); let second_contender = result.contenders.last().unwrap(); + + // When something is here + + assert_eq!(first_contender + .serialized_document, None); - let first_contender_document = Document::from_bytes( - first_contender - .serialized_document - .as_ref() - .expect("expected a document") - .as_slice(), - document_type.as_ref(), - platform_version, - ) - .expect("expected to get document"); - - let second_contender_document = Document::from_bytes( - second_contender - .serialized_document - .as_ref() - .expect("expected a document") - .as_slice(), - document_type.as_ref(), - platform_version, - ) - .expect("expected to get document"); - - assert_ne!(first_contender_document, second_contender_document); + assert_eq!(second_contender + .serialized_document, None); assert_eq!(first_contender.identity_id, identity2_id); assert_eq!(second_contender.identity_id, identity1_id); - assert_eq!(first_contender.vote_tally, Some(0)); + assert_eq!(first_contender.vote_tally, Some(50)); - assert_eq!(second_contender.vote_tally, Some(0)); + assert_eq!(second_contender.vote_tally, Some(3)); } } diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs index 8bf1e24d87..87ae6ca36c 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs @@ -64,6 +64,7 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { contenders, locked_vote_tally: None, abstaining_vote_tally: None, + winner: None, skipped: 0, }, )) @@ -88,6 +89,7 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { contenders, locked_vote_tally: None, abstaining_vote_tally: None, + winner: None, skipped: 0, }, )) @@ -134,6 +136,7 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { contenders, locked_vote_tally, abstaining_vote_tally, + winner: None, skipped: 0, }, )) @@ -295,6 +298,7 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { contenders, locked_vote_tally, abstaining_vote_tally, + winner: None, skipped: 0, }, )) diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index 871667f67d..232f6732c8 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -29,6 +29,8 @@ use grovedb::{PathQuery, Query, QueryItem, SizedQuery}; use platform_version::version::PlatformVersion; #[cfg(feature = "verify")] use std::sync::Arc; +use dpp::prelude::{Identity, TimestampMillis}; +use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; /// Represents the types of results that can be obtained from a contested document vote poll query. /// @@ -236,6 +238,8 @@ pub struct ContestedDocumentVotePollDriveQueryExecutionResult { pub locked_vote_tally: Option, /// Abstaining tally pub abstaining_vote_tally: Option, + /// Finalization info + pub winner: Option, /// The number of skipped items when an offset is given. pub skipped: u16, } @@ -279,7 +283,7 @@ impl TryFrom contenders, locked_vote_tally, abstaining_vote_tally, - skipped, + .. } = value; let finalized_contenders = contenders @@ -584,6 +588,7 @@ impl ContestedDocumentVotePollDriveQuery { contenders, locked_vote_tally: None, abstaining_vote_tally: None, + winner: None, skipped, }) } @@ -610,6 +615,7 @@ impl ContestedDocumentVotePollDriveQuery { contenders, locked_vote_tally: None, abstaining_vote_tally: None, + winner: None, skipped, }) } @@ -650,6 +656,7 @@ impl ContestedDocumentVotePollDriveQuery { contenders, locked_vote_tally, abstaining_vote_tally, + winner: None, skipped, }) } @@ -808,6 +815,7 @@ impl ContestedDocumentVotePollDriveQuery { contenders, locked_vote_tally, abstaining_vote_tally, + winner: None, skipped, }) } diff --git a/packages/wasm-dpp/src/errors/consensus/consensus_error.rs b/packages/wasm-dpp/src/errors/consensus/consensus_error.rs index 5522dcaca3..3948b67ec6 100644 --- a/packages/wasm-dpp/src/errors/consensus/consensus_error.rs +++ b/packages/wasm-dpp/src/errors/consensus/consensus_error.rs @@ -72,6 +72,7 @@ use dpp::consensus::state::identity::identity_public_key_already_exists_for_uniq use dpp::consensus::state::identity::master_public_key_update_error::MasterPublicKeyUpdateError; use dpp::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_insufficient_error::PrefundedSpecializedBalanceInsufficientError; use dpp::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_not_found_error::PrefundedSpecializedBalanceNotFoundError; +use dpp::consensus::state::voting::masternode_not_found_error::MasternodeNotFoundError; use crate::errors::consensus::basic::data_contract::{ DataContractErrorWasm, DataContractHaveNewUniqueIndexErrorWasm, @@ -249,6 +250,9 @@ pub fn from_state_error(state_error: &StateError) -> JsValue { StateError::DataContractUpdatePermissionError(e) => { DataContractUpdatePermissionErrorWasm::from(e).into() } + StateError::MasternodeNotFoundError(e) => { + generic_consensus_error!(MasternodeNotFoundError, e).into() + } } } From a3089fad0ea5993903de72b9c1fe7a4b31a15a00 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Fri, 7 Jun 2024 19:40:12 +0300 Subject: [PATCH 116/135] removed votes from identity table --- packages/rs-dpp/src/voting/mod.rs | 2 +- .../mod.rs | 2 +- .../rs-dpp/src/voting/vote_outcomes/mod.rs | 2 +- .../v0/mod.rs | 50 ++++++++++++++++++- .../state_transitions/documents_batch/mod.rs | 3 +- .../state_transitions/masternode_vote/mod.rs | 9 +++- .../contested_resource_vote_state/v0/mod.rs | 32 +++++------- .../tests/strategy_tests/voting_tests.rs | 22 ++++---- .../rs-drive/src/drive/votes/cleanup/mod.rs | 3 +- .../mod.rs | 12 +++-- .../v0/mod.rs | 2 +- .../mod.rs | 2 +- .../mod.rs | 2 +- .../mod.rs | 44 ++++++++++++++++ .../v0/mod.rs | 42 ++++++++++++++++ .../src/query/vote_poll_vote_state_query.rs | 4 +- .../src/version/drive_versions.rs | 7 +-- .../src/version/mocks/v2_test.rs | 7 +-- .../src/version/mocks/v3_test.rs | 7 +-- .../rs-platform-version/src/version/v1.rs | 7 +-- 20 files changed, 201 insertions(+), 60 deletions(-) rename packages/rs-drive/src/drive/votes/cleanup/{remove_votes_for_identity => remove_all_votes_given_by_identity}/mod.rs (72%) rename packages/rs-drive/src/drive/votes/cleanup/{remove_votes_for_identity => remove_all_votes_given_by_identity}/v0/mod.rs (98%) create mode 100644 packages/rs-drive/src/drive/votes/cleanup/remove_specific_votes_given_by_identity/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/cleanup/remove_specific_votes_given_by_identity/v0/mod.rs diff --git a/packages/rs-dpp/src/voting/mod.rs b/packages/rs-dpp/src/voting/mod.rs index 0b1cb91fb5..c2936049e6 100644 --- a/packages/rs-dpp/src/voting/mod.rs +++ b/packages/rs-dpp/src/voting/mod.rs @@ -1,4 +1,4 @@ pub mod vote_choices; +pub mod vote_outcomes; pub mod vote_polls; pub mod votes; -pub mod vote_outcomes; diff --git a/packages/rs-dpp/src/voting/vote_outcomes/contested_document_vote_poll_winner_info/mod.rs b/packages/rs-dpp/src/voting/vote_outcomes/contested_document_vote_poll_winner_info/mod.rs index 241ae34123..6d1aea6e5f 100644 --- a/packages/rs-dpp/src/voting/vote_outcomes/contested_document_vote_poll_winner_info/mod.rs +++ b/packages/rs-dpp/src/voting/vote_outcomes/contested_document_vote_poll_winner_info/mod.rs @@ -6,4 +6,4 @@ pub enum ContestedDocumentVotePollWinnerInfo { NoWinner, WonByIdentity(Identifier), Locked, -} \ No newline at end of file +} diff --git a/packages/rs-dpp/src/voting/vote_outcomes/mod.rs b/packages/rs-dpp/src/voting/vote_outcomes/mod.rs index 216248fb8c..6e9510a84c 100644 --- a/packages/rs-dpp/src/voting/vote_outcomes/mod.rs +++ b/packages/rs-dpp/src/voting/vote_outcomes/mod.rs @@ -1 +1 @@ -pub mod contested_document_vote_poll_winner_info; \ No newline at end of file +pub mod contested_document_vote_poll_winner_info; diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs index 664cc5600b..ccb5decd11 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs @@ -1,3 +1,4 @@ +use crate::error::execution::ExecutionError; use crate::error::Error; use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; @@ -5,9 +6,11 @@ use dpp::identifier::Identifier; use dpp::prelude::TimestampMillis; use dpp::version::PlatformVersion; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use dpp::ProtocolError; use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use drive::error::drive::DriveError; use drive::grovedb::TransactionArg; -use std::collections::BTreeMap; +use std::collections::{BTreeMap, HashMap}; impl Platform where @@ -26,6 +29,8 @@ where platform_version: &PlatformVersion, ) -> Result<(), Error> { let mut operations = vec![]; + + // We remove the end date query self.drive .remove_contested_resource_vote_poll_end_date_query_operations( vote_polls.as_slice(), @@ -34,6 +39,7 @@ where platform_version, )?; + // We remove the votes from under the contenders votes received self.drive .remove_contested_resource_vote_poll_votes_operations( vote_polls.as_slice(), @@ -42,6 +48,48 @@ where platform_version, )?; + let vote_poll_ids = vote_polls + .iter() + .map(|(vote_poll, _, _)| Ok((*vote_poll, vote_poll.unique_id()?))) + .collect::, + ProtocolError, + >>()?; + + let mut identity_to_vote_ids_map: BTreeMap<&Identifier, Vec<&Identifier>> = BTreeMap::new(); + + for (vote_poll, _, voters_for_contender) in &vote_polls { + let vote_id = vote_poll_ids + .iter() + .find_map(|(vp, vid)| if vp == vote_poll { Some(vid) } else { None }) + .ok_or(Error::Execution(ExecutionError::CorruptedCodeExecution( + "the vote poll must exist in this lookup table", + )))?; + + for identifiers in voters_for_contender.values() { + for identity_id in identifiers { + identity_to_vote_ids_map + .entry(identity_id) + .or_default() + .push(vote_id); + } + } + } + + for (identity, vote_ids) in identity_to_vote_ids_map { + // We remove the identity votes given + self.drive.remove_specific_votes_given_by_identity( + identity, + vote_ids.as_slice(), + &mut operations, + transaction, + platform_version, + )?; + } + self.drive.apply_batch_low_level_drive_operations( None, transaction, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs index a03eeff310..df7829196a 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs @@ -671,7 +671,8 @@ mod tests { get_contested_resource_vote_state_response_v0::ContestedResourceContenders { contenders, abstain_vote_tally, - lock_vote_tally, finished_vote_info, + lock_vote_tally, + finished_vote_info, }, ), ) = result diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index ad899c7023..fb26d4bd3f 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -900,7 +900,12 @@ mod tests { >, result_type: ResultType, platform_version: &PlatformVersion, - ) -> (Vec, Option, Option, Option) { + ) -> ( + Vec, + Option, + Option, + Option, + ) { // Now let's run a query for the vote totals let domain = dpns_contract @@ -1356,7 +1361,7 @@ mod tests { ResultType::DocumentsAndVoteTally, platform_version, ); - + assert_eq!(finished_vote_info, None); assert_eq!(contenders.len(), 2); diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs index c10bdecf14..b65a1eeebf 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs @@ -183,27 +183,21 @@ impl Platform { let abstain_vote_tally = results.abstaining_vote_tally; let lock_vote_tally = results.locked_vote_tally; - let finished_vote_info = results.winner.map(|winner_info| { - match winner_info { - ContestedDocumentVotePollWinnerInfo::NoWinner => { - FinishedVoteInfo { - finished_vote_outcome: FinishedVoteOutcome::NoPreviousWinner as i32, - won_by_identity_id: None, - } - } - ContestedDocumentVotePollWinnerInfo::WonByIdentity(identity_id) => { - FinishedVoteInfo { - finished_vote_outcome: FinishedVoteOutcome::TowardsIdentity as i32, - won_by_identity_id: Some(identity_id.to_vec()) - } - } - ContestedDocumentVotePollWinnerInfo::Locked => { - FinishedVoteInfo { - finished_vote_outcome: FinishedVoteOutcome::Locked as i32, - won_by_identity_id: None, - } + let finished_vote_info = results.winner.map(|winner_info| match winner_info { + ContestedDocumentVotePollWinnerInfo::NoWinner => FinishedVoteInfo { + finished_vote_outcome: FinishedVoteOutcome::NoPreviousWinner as i32, + won_by_identity_id: None, + }, + ContestedDocumentVotePollWinnerInfo::WonByIdentity(identity_id) => { + FinishedVoteInfo { + finished_vote_outcome: FinishedVoteOutcome::TowardsIdentity as i32, + won_by_identity_id: Some(identity_id.to_vec()), } } + ContestedDocumentVotePollWinnerInfo::Locked => FinishedVoteInfo { + finished_vote_outcome: FinishedVoteOutcome::Locked as i32, + won_by_identity_id: None, + }, }); let contenders = results diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index 087051a612..70346e2c98 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -265,7 +265,10 @@ mod tests { let Some( get_contested_resource_vote_state_response_v0::Result::ContestedResourceContenders( get_contested_resource_vote_state_response_v0::ContestedResourceContenders { - contenders, abstain_vote_tally, lock_vote_tally, finished_vote_info, + contenders, + abstain_vote_tally, + lock_vote_tally, + finished_vote_info, }, ), ) = result @@ -279,12 +282,9 @@ mod tests { let second_contender = contenders.last().unwrap(); - assert_eq!(first_contender - .document, None); - - assert_eq!(second_contender - .document, None); + assert_eq!(first_contender.document, None); + assert_eq!(second_contender.document, None); assert_eq!(first_contender.identifier, identity2_id.to_vec()); @@ -366,14 +366,12 @@ mod tests { let first_contender = result.contenders.first().unwrap(); let second_contender = result.contenders.last().unwrap(); - + // When something is here - - assert_eq!(first_contender - .serialized_document, None); - assert_eq!(second_contender - .serialized_document, None); + assert_eq!(first_contender.serialized_document, None); + + assert_eq!(second_contender.serialized_document, None); assert_eq!(first_contender.identity_id, identity2_id); diff --git a/packages/rs-drive/src/drive/votes/cleanup/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/mod.rs index 84cd94c602..cbf5721188 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/mod.rs @@ -1,5 +1,6 @@ -mod remove_votes_for_identity; +mod remove_all_votes_given_by_identity; mod add_lock_for_contested_document_resource_vote_poll; mod remove_contested_resource_vote_poll_end_date_query_operations; mod remove_contested_resource_vote_poll_votes_operations; +mod remove_specific_votes_given_by_identity; diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_all_votes_given_by_identity/mod.rs similarity index 72% rename from packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs rename to packages/rs-drive/src/drive/votes/cleanup/remove_all_votes_given_by_identity/mod.rs index 0d5b38b5c1..7c8e5859f9 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_all_votes_given_by_identity/mod.rs @@ -12,7 +12,7 @@ use grovedb::TransactionArg; impl Drive { /// We remove vote_choices for an identity when that identity is somehow disabled. Currently there is /// no way to "disable" identities except for masternodes being removed from the list - pub fn remove_votes_for_identity( + pub fn remove_all_votes_given_by_identity( &self, identity_id: Identifier, transaction: TransactionArg, @@ -23,11 +23,15 @@ impl Drive { .methods .vote .cleanup - .remove_votes_for_identity + .remove_all_votes_given_by_identity { - 0 => self.remove_votes_for_identity_v0(identity_id, transaction, platform_version), + 0 => self.remove_all_votes_given_by_identity_v0( + identity_id, + transaction, + platform_version, + ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "remove_votes_for_identity".to_string(), + method: "remove_all_votes_given_by_identity".to_string(), known_versions: vec![0], received: version, })), diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_all_votes_given_by_identity/v0/mod.rs similarity index 98% rename from packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs rename to packages/rs-drive/src/drive/votes/cleanup/remove_all_votes_given_by_identity/v0/mod.rs index c522589c5a..93a9a72f82 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_votes_for_identity/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_all_votes_given_by_identity/v0/mod.rs @@ -19,7 +19,7 @@ use grovedb::{Element, PathQuery, Query, SizedQuery, TransactionArg}; impl Drive { /// We remove vote_choices for an identity when that identity is somehow disabled. Currently there is /// no way to "disable" identities except for masternodes being removed from the list - pub(super) fn remove_votes_for_identity_v0( + pub(super) fn remove_all_votes_given_by_identity_v0( &self, identity_id: Identifier, transaction: TransactionArg, diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_end_date_query_operations/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_end_date_query_operations/mod.rs index 788ba71454..a6a3bf8399 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_end_date_query_operations/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_end_date_query_operations/mod.rs @@ -32,7 +32,7 @@ impl Drive { .drive .methods .vote - .contested_resource_insert + .cleanup .remove_contested_resource_vote_poll_end_date_query_operations { 0 => self.remove_contested_resource_vote_poll_end_date_query_operations_v0( diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/mod.rs index 20b5791e38..96eeb1b0a2 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/mod.rs @@ -33,7 +33,7 @@ impl Drive { .drive .methods .vote - .contested_resource_insert + .cleanup .remove_contested_resource_vote_poll_votes_operations { 0 => self.remove_contested_resource_vote_poll_votes_operations_v0( diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_specific_votes_given_by_identity/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_specific_votes_given_by_identity/mod.rs new file mode 100644 index 0000000000..b09cc01481 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_specific_votes_given_by_identity/mod.rs @@ -0,0 +1,44 @@ +mod v0; + +use crate::drive::Drive; + +use crate::error::drive::DriveError; +use crate::error::Error; + +use crate::fee::op::LowLevelDriveOperation; +use dpp::prelude::Identifier; +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +impl Drive { + /// We remove the references of specific votes given by an identity when the vote poll ends + pub fn remove_specific_votes_given_by_identity( + &self, + identity_id: &Identifier, + votes: &[&Identifier], + batch_operations: &mut Vec, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive + .methods + .vote + .cleanup + .remove_all_votes_given_by_identity + { + 0 => self.remove_specific_votes_given_by_identity_v0( + identity_id, + votes, + batch_operations, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "remove_specific_votes_given_by_identity".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_specific_votes_given_by_identity/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_specific_votes_given_by_identity/v0/mod.rs new file mode 100644 index 0000000000..e8f7e27f57 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_specific_votes_given_by_identity/v0/mod.rs @@ -0,0 +1,42 @@ +use crate::drive::Drive; +use crate::error::Error; + +use crate::drive::grove_operations::BatchDeleteApplyType; +use crate::drive::votes::paths::vote_contested_resource_identity_votes_tree_path_for_identity; +use crate::fee::op::LowLevelDriveOperation; +use dpp::prelude::Identifier; +use dpp::version::PlatformVersion; +use grovedb::TransactionArg; + +impl Drive { + /// We remove vote_choices for an identity when that identity is somehow disabled. Currently there is + /// no way to "disable" identities except for masternodes being removed from the list + pub(super) fn remove_specific_votes_given_by_identity_v0( + &self, + identity_id: &Identifier, + votes: &[&Identifier], + batch_operations: &mut Vec, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + // Then we take each votes and go looking for it (to remove it) + + let vote_path_ref = + vote_contested_resource_identity_votes_tree_path_for_identity(identity_id.as_bytes()); + + for vote_identifier_to_remove in votes { + self.batch_delete( + vote_path_ref.as_slice().into(), + vote_identifier_to_remove.as_slice(), + BatchDeleteApplyType::StatefulBatchDelete { + is_known_to_be_subtree_with_sum: Some((false, false)), + }, + transaction, + batch_operations, + &platform_version.drive, + )?; + } + + Ok(()) + } +} diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index 232f6732c8..1973e8867d 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -20,6 +20,8 @@ use dpp::data_contract::DataContract; use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use dpp::document::Document; use dpp::identifier::Identifier; +use dpp::prelude::{Identity, TimestampMillis}; +use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; #[cfg(feature = "server")] use grovedb::query_result_type::{QueryResultElements, QueryResultType}; @@ -29,8 +31,6 @@ use grovedb::{PathQuery, Query, QueryItem, SizedQuery}; use platform_version::version::PlatformVersion; #[cfg(feature = "verify")] use std::sync::Arc; -use dpp::prelude::{Identity, TimestampMillis}; -use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; /// Represents the types of results that can be obtained from a contested document vote poll query. /// diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 44dfdcacf0..a93ab2153e 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -286,7 +286,10 @@ pub struct DriveVoteSetupMethodVersions { #[derive(Clone, Debug, Default)] pub struct DriveVoteCleanupMethodVersions { pub add_lock_for_contested_document_resource_vote_poll: FeatureVersion, - pub remove_votes_for_identity: FeatureVersion, + pub remove_all_votes_given_by_identity: FeatureVersion, + pub remove_specific_votes_given_by_identity: FeatureVersion, + pub remove_contested_resource_vote_poll_end_date_query_operations: FeatureVersion, + pub remove_contested_resource_vote_poll_votes_operations: FeatureVersion, } #[derive(Clone, Debug, Default)] @@ -299,8 +302,6 @@ pub struct DriveVoteContestedResourceInsertMethodVersions { pub register_contested_resource_identity_vote: FeatureVersion, pub register_identity_vote: FeatureVersion, pub add_vote_poll_end_date_query_operations: FeatureVersion, - pub remove_contested_resource_vote_poll_end_date_query_operations: FeatureVersion, - pub remove_contested_resource_vote_poll_votes_operations: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index fd4a227b86..0f1f51d54d 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -233,12 +233,13 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { register_contested_resource_identity_vote: 0, register_identity_vote: 0, add_vote_poll_end_date_query_operations: 0, - remove_contested_resource_vote_poll_end_date_query_operations: 0, - remove_contested_resource_vote_poll_votes_operations: 0, }, cleanup: DriveVoteCleanupMethodVersions { add_lock_for_contested_document_resource_vote_poll: 0, - remove_votes_for_identity: 0, + remove_all_votes_given_by_identity: 0, + remove_specific_votes_given_by_identity: 0, + remove_contested_resource_vote_poll_end_date_query_operations: 0, + remove_contested_resource_vote_poll_votes_operations: 0, }, setup: DriveVoteSetupMethodVersions { add_initial_vote_tree_main_structure_operations: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 286d5b7ea7..a821a4034c 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -241,12 +241,13 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { register_contested_resource_identity_vote: 0, register_identity_vote: 0, add_vote_poll_end_date_query_operations: 0, - remove_contested_resource_vote_poll_end_date_query_operations: 0, - remove_contested_resource_vote_poll_votes_operations: 0, }, cleanup: DriveVoteCleanupMethodVersions { add_lock_for_contested_document_resource_vote_poll: 0, - remove_votes_for_identity: 0, + remove_all_votes_given_by_identity: 0, + remove_specific_votes_given_by_identity: 0, + remove_contested_resource_vote_poll_end_date_query_operations: 0, + remove_contested_resource_vote_poll_votes_operations: 0, }, setup: DriveVoteSetupMethodVersions { add_initial_vote_tree_main_structure_operations: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index aa44374f79..1a4d770cdc 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -232,12 +232,13 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { register_contested_resource_identity_vote: 0, register_identity_vote: 0, add_vote_poll_end_date_query_operations: 0, - remove_contested_resource_vote_poll_end_date_query_operations: 0, - remove_contested_resource_vote_poll_votes_operations: 0, }, cleanup: DriveVoteCleanupMethodVersions { add_lock_for_contested_document_resource_vote_poll: 0, - remove_votes_for_identity: 0, + remove_all_votes_given_by_identity: 0, + remove_specific_votes_given_by_identity: 0, + remove_contested_resource_vote_poll_end_date_query_operations: 0, + remove_contested_resource_vote_poll_votes_operations: 0, }, setup: DriveVoteSetupMethodVersions { add_initial_vote_tree_main_structure_operations: 0, From a2ece4ad387186ecec15f737bbeb863a054b17fa Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sat, 8 Jun 2024 16:06:49 +0300 Subject: [PATCH 117/135] more cleanup --- .../src/document/extended_document/mod.rs | 2 - .../v0/mod.rs | 9 ++ .../v0/mod.rs | 1 + .../object_size_info/path_key_element_info.rs | 1 + .../v0/mod.rs | 3 +- .../rs-drive/src/drive/votes/cleanup/mod.rs | 1 + .../mod.rs | 51 +++++++++++ .../v0/mod.rs | 84 +++++++++++++++++++ .../src/version/drive_versions.rs | 1 + .../src/version/mocks/v2_test.rs | 1 + .../src/version/mocks/v3_test.rs | 1 + .../rs-platform-version/src/version/v1.rs | 1 + 12 files changed, 153 insertions(+), 3 deletions(-) create mode 100644 packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_documents_operations/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_documents_operations/v0/mod.rs diff --git a/packages/rs-dpp/src/document/extended_document/mod.rs b/packages/rs-dpp/src/document/extended_document/mod.rs index c97b4b588b..fc7c78858e 100644 --- a/packages/rs-dpp/src/document/extended_document/mod.rs +++ b/packages/rs-dpp/src/document/extended_document/mod.rs @@ -597,8 +597,6 @@ mod test { .to_pretty_json(LATEST_PLATFORM_VERSION) .expect("no errors"); - println!("{:?}", json_document); - assert_eq!( json_document["$id"], JsonValue::String(bs58::encode(&id).into_string()) diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs index ccb5decd11..cc550e4917 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs @@ -48,6 +48,15 @@ where platform_version, )?; + // We remove the documents + self.drive + .remove_contested_resource_vote_poll_documents_operations( + vote_polls.as_slice(), + &mut operations, + transaction, + platform_version, + )?; + let vote_poll_ids = vote_polls .iter() .map(|(vote_poll, _, _)| Ok((*vote_poll, vote_poll.unique_id()?))) diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/v0/mod.rs index a3e76b226f..3e86457d2e 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_to_primary_storage/v0/mod.rs @@ -198,6 +198,7 @@ impl Drive { target: QueryTargetValue(document_type.estimated_size(platform_version)? as u32), } }; + let inserted = self.batch_insert_if_not_exists( path_key_element_info, apply_type, diff --git a/packages/rs-drive/src/drive/object_size_info/path_key_element_info.rs b/packages/rs-drive/src/drive/object_size_info/path_key_element_info.rs index 7c2ef3e9c0..08afa70ee6 100644 --- a/packages/rs-drive/src/drive/object_size_info/path_key_element_info.rs +++ b/packages/rs-drive/src/drive/object_size_info/path_key_element_info.rs @@ -11,6 +11,7 @@ use grovedb::batch::KeyInfoPath; use grovedb::Element; /// Path key element info +#[derive(Debug)] pub enum PathKeyElementInfo<'a, const N: usize> { /// A triple Path Key and Element PathFixedSizeKeyRefElement(([&'a [u8]; N], &'a [u8], Element)), diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs index 87ae6ca36c..b5c38b637a 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs @@ -177,7 +177,8 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { } _ => { return Err(Error::Drive(DriveError::CorruptedDriveState( - "unexpected key for sum tree value".to_string(), + "unexpected key for sum tree value in verification" + .to_string(), ))); } } diff --git a/packages/rs-drive/src/drive/votes/cleanup/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/mod.rs index cbf5721188..a6cef9f2e2 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/mod.rs @@ -1,6 +1,7 @@ mod remove_all_votes_given_by_identity; mod add_lock_for_contested_document_resource_vote_poll; +mod remove_contested_resource_vote_poll_documents_operations; mod remove_contested_resource_vote_poll_end_date_query_operations; mod remove_contested_resource_vote_poll_votes_operations; mod remove_specific_votes_given_by_identity; diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_documents_operations/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_documents_operations/mod.rs new file mode 100644 index 0000000000..3cdca302a9 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_documents_operations/mod.rs @@ -0,0 +1,51 @@ +mod v0; + +use crate::drive::Drive; +use std::collections::BTreeMap; + +use crate::error::drive::DriveError; +use crate::error::Error; + +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use crate::fee::op::LowLevelDriveOperation; +use dpp::identifier::Identifier; +use dpp::prelude::TimestampMillis; +use dpp::version::PlatformVersion; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use grovedb::TransactionArg; + +impl Drive { + /// We add documents poll references by end date in order to be able to check on every new block if + /// any documents poll should be closed. This will remove them to recoup space + pub fn remove_contested_resource_vote_poll_documents_operations( + &self, + vote_polls: &[( + &ContestedDocumentResourceVotePollWithContractInfo, + &TimestampMillis, + &BTreeMap>, + )], + batch_operations: &mut Vec, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive + .methods + .vote + .cleanup + .remove_contested_resource_vote_poll_documents_operations + { + 0 => self.remove_contested_resource_vote_poll_documents_operations_v0( + vote_polls, + batch_operations, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "remove_contested_resource_vote_poll_documents_operations".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_documents_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_documents_operations/v0/mod.rs new file mode 100644 index 0000000000..41f9396670 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_documents_operations/v0/mod.rs @@ -0,0 +1,84 @@ +use crate::drive::grove_operations::BatchDeleteApplyType; +use crate::drive::votes::paths::VotePollPaths; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use crate::drive::Drive; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use crate::query::QueryItem; +use dpp::identifier::Identifier; +use dpp::identity::TimestampMillis; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use grovedb::query_result_type::QueryResultType; +use grovedb::{PathQuery, TransactionArg}; +use platform_version::version::PlatformVersion; +use std::collections::BTreeMap; +use std::ops::RangeFull; + +impl Drive { + /// We add documents poll references by end date in order to be able to check on every new block if + /// any vote polls should be closed. + pub(in crate::drive::votes) fn remove_contested_resource_vote_poll_documents_operations_v0( + &self, + vote_polls: &[( + &ContestedDocumentResourceVotePollWithContractInfo, + &TimestampMillis, + &BTreeMap>, + )], + batch_operations: &mut Vec, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + for (vote_poll, _, vote_choices) in vote_polls { + let documents_storage_path = vote_poll.documents_storage_path_vec(); + + let path_query = PathQuery::new_single_query_item( + documents_storage_path.clone(), + QueryItem::RangeFull(RangeFull), + ); + + let document_keys = self + .grove_get_raw_path_query( + &path_query, + transaction, + QueryResultType::QueryKeyElementPairResultType, + &mut vec![], + &platform_version.drive, + )? + .0 + .to_keys(); + + for document_key in document_keys { + self.batch_delete( + documents_storage_path.as_slice().into(), + document_key.as_slice(), + BatchDeleteApplyType::StatefulBatchDelete { + is_known_to_be_subtree_with_sum: Some((false, false)), + }, + transaction, + batch_operations, + &platform_version.drive, + )?; + } + + // We also need to delete all the references + + for resource_vote_choice in vote_choices.keys() { + if let ResourceVoteChoice::TowardsIdentity(identifier) = resource_vote_choice { + let contender_path = vote_poll.contender_path(*identifier, platform_version)?; + self.batch_delete( + contender_path.as_slice().into(), + vec![0].as_slice(), + BatchDeleteApplyType::StatefulBatchDelete { + is_known_to_be_subtree_with_sum: Some((false, false)), + }, + transaction, + batch_operations, + &platform_version.drive, + )?; + } + } + } + + Ok(()) + } +} diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index a93ab2153e..bdfdc8b1b5 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -290,6 +290,7 @@ pub struct DriveVoteCleanupMethodVersions { pub remove_specific_votes_given_by_identity: FeatureVersion, pub remove_contested_resource_vote_poll_end_date_query_operations: FeatureVersion, pub remove_contested_resource_vote_poll_votes_operations: FeatureVersion, + pub remove_contested_resource_vote_poll_documents_operations: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 0f1f51d54d..612cef3b26 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -240,6 +240,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { remove_specific_votes_given_by_identity: 0, remove_contested_resource_vote_poll_end_date_query_operations: 0, remove_contested_resource_vote_poll_votes_operations: 0, + remove_contested_resource_vote_poll_documents_operations: 0, }, setup: DriveVoteSetupMethodVersions { add_initial_vote_tree_main_structure_operations: 0, diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index a821a4034c..710379347a 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -248,6 +248,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { remove_specific_votes_given_by_identity: 0, remove_contested_resource_vote_poll_end_date_query_operations: 0, remove_contested_resource_vote_poll_votes_operations: 0, + remove_contested_resource_vote_poll_documents_operations: 0, }, setup: DriveVoteSetupMethodVersions { add_initial_vote_tree_main_structure_operations: 0, diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 1a4d770cdc..774db389b2 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -239,6 +239,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { remove_specific_votes_given_by_identity: 0, remove_contested_resource_vote_poll_end_date_query_operations: 0, remove_contested_resource_vote_poll_votes_operations: 0, + remove_contested_resource_vote_poll_documents_operations: 0, }, setup: DriveVoteSetupMethodVersions { add_initial_vote_tree_main_structure_operations: 0, From da30633bc02654386a72bc0ae313453e8df0a634 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sat, 8 Jun 2024 18:32:57 +0300 Subject: [PATCH 118/135] storage of finishing info --- .../src/voting/contender_structs/mod.rs | 126 ++++++++++++++++ packages/rs-dpp/src/voting/mod.rs | 1 + .../mod.rs | 3 +- .../mod.rs | 50 +++++++ .../v0/mod.rs | 28 ++++ .../rs-dpp/src/voting/vote_outcomes/mod.rs | 1 + .../voting/award_document_to_winner/mod.rs | 2 +- .../voting/award_document_to_winner/v0/mod.rs | 2 +- .../check_for_ended_vote_polls/v0/mod.rs | 32 +++-- .../v0/mod.rs | 12 +- .../voting/keep_record_of_vote_poll/mod.rs | 19 ++- .../voting/keep_record_of_vote_poll/v0/mod.rs | 37 ++++- .../state_transitions/masternode_vote/mod.rs | 2 +- .../contested_resource_vote_state/v0/mod.rs | 3 +- .../mod.rs | 5 +- .../v0/mod.rs | 5 +- .../verify_vote_poll_vote_state_proof/mod.rs | 3 +- .../v0/mod.rs | 3 +- .../rs-drive/src/drive/votes/cleanup/mod.rs | 1 + .../mod.rs | 52 +++++++ .../v0/mod.rs | 47 ++++++ .../v0/mod.rs | 5 +- .../mod.rs | 2 + .../v0/mod.rs | 17 +++ .../mod.rs | 70 +++++++++ .../v0/mod.rs | 62 ++++++++ .../votes/insert/contested_resource/mod.rs | 1 + packages/rs-drive/src/drive/votes/paths.rs | 16 ++- .../src/query/vote_poll_vote_state_query.rs | 136 +----------------- .../src/version/dpp_versions.rs | 1 + .../src/version/drive_abci_versions.rs | 2 +- .../src/version/drive_versions.rs | 2 + .../src/version/mocks/v2_test.rs | 5 +- .../src/version/mocks/v3_test.rs | 5 +- .../rs-platform-version/src/version/v1.rs | 5 +- 35 files changed, 581 insertions(+), 182 deletions(-) create mode 100644 packages/rs-dpp/src/voting/contender_structs/mod.rs create mode 100644 packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/mod.rs create mode 100644 packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_contenders_operations/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_contenders_operations/v0/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/insert/contested_resource/insert_record_of_finished_vote_poll/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/insert/contested_resource/insert_record_of_finished_vote_poll/v0/mod.rs diff --git a/packages/rs-dpp/src/voting/contender_structs/mod.rs b/packages/rs-dpp/src/voting/contender_structs/mod.rs new file mode 100644 index 0000000000..3b7a803e7e --- /dev/null +++ b/packages/rs-dpp/src/voting/contender_structs/mod.rs @@ -0,0 +1,126 @@ +use crate::data_contract::document_type::DocumentTypeRef; +use crate::document::serialization_traits::DocumentPlatformConversionMethodsV0; +use crate::document::Document; +use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; +use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use crate::ProtocolError; +use platform_value::Identifier; +use platform_version::version::PlatformVersion; + +/// Represents a contender in the contested document vote poll. +/// This is for internal use where the document is in serialized form +/// +/// This struct holds the identity ID of the contender, the serialized document, +/// and the vote tally. +#[derive(Debug, PartialEq, Eq, Clone, Default)] +pub struct ContenderWithSerializedDocument { + /// The identity ID of the contender. + pub identity_id: Identifier, + /// The serialized document associated with the contender. + pub serialized_document: Option>, + /// The vote tally for the contender. + pub vote_tally: Option, +} + +/// Represents a finalized contender in the contested document vote poll. +/// This is for internal use where the document is in serialized form +/// +/// This struct holds the identity ID of the contender, the serialized document, +/// and the vote tally. +#[derive(Debug, PartialEq, Eq, Clone, Default)] +pub struct FinalizedContenderWithSerializedDocument { + /// The identity ID of the contender. + pub identity_id: Identifier, + /// The serialized document associated with the contender. + pub serialized_document: Vec, + /// The vote tally for the contender. + pub final_vote_tally: u32, +} + +/// Represents a finalized contender in the contested document vote poll. +/// This is for keeping information about previous vote polls +/// +/// This struct holds the identity ID of the contender, the serialized document, +/// and the vote tally. +#[derive(Debug, PartialEq, Eq, Clone, Default, Encode, Decode)] +pub struct FinalizedResourceVoteChoicesWithVoterInfo { + /// The resource vote choice. + pub resource_vote_choice: ResourceVoteChoice, + /// The pro_tx_hashes of the voters for this contender. + pub voters: Vec, +} + +/// Represents a finalized contender in the contested document vote poll. +/// This is for internal use where the document is in serialized form +/// +/// This struct holds the identity ID of the contender, the document, +/// and the vote tally. +#[derive(Debug, PartialEq, Clone)] +pub struct FinalizedContender { + /// The identity ID of the contender. + pub identity_id: Identifier, + /// The document associated with the contender. + pub document: Document, + /// The still serialized document + pub serialized_document: Vec, + /// The vote tally for the contender. + pub final_vote_tally: u32, +} + +impl FinalizedContender { + /// Try to get the finalized contender from a finalized contender with a serialized document + pub fn try_from_contender_with_serialized_document( + value: FinalizedContenderWithSerializedDocument, + document_type: DocumentTypeRef, + platform_version: &PlatformVersion, + ) -> Result { + let FinalizedContenderWithSerializedDocument { + identity_id, + serialized_document, + final_vote_tally, + } = value; + + Ok(FinalizedContender { + identity_id, + document: Document::from_bytes(&serialized_document, document_type, platform_version)?, + serialized_document, + final_vote_tally, + }) + } +} + +impl TryFrom for FinalizedContenderWithSerializedDocument { + type Error = ProtocolError; + + fn try_from(value: ContenderWithSerializedDocument) -> Result { + let ContenderWithSerializedDocument { + identity_id, + serialized_document, + vote_tally, + } = value; + + Ok(FinalizedContenderWithSerializedDocument { + identity_id, + serialized_document: serialized_document.ok_or( + ProtocolError::CorruptedCodeExecution("expected serialized document".to_string()), + )?, + final_vote_tally: vote_tally.ok_or(ProtocolError::CorruptedCodeExecution( + "expected vote tally".to_string(), + ))?, + }) + } +} + +/// Represents a contender in the contested document vote poll. +/// +/// This struct holds the identity ID of the contender, the serialized document, +/// and the vote tally. +#[derive(Debug, PartialEq, Clone, Default)] +pub struct Contender { + /// The identity ID of the contender. + pub identity_id: Identifier, + /// The document associated with the contender. + pub document: Option, + /// The vote tally for the contender. + pub vote_tally: Option, +} diff --git a/packages/rs-dpp/src/voting/mod.rs b/packages/rs-dpp/src/voting/mod.rs index c2936049e6..95f31e124d 100644 --- a/packages/rs-dpp/src/voting/mod.rs +++ b/packages/rs-dpp/src/voting/mod.rs @@ -1,3 +1,4 @@ +pub mod contender_structs; pub mod vote_choices; pub mod vote_outcomes; pub mod vote_polls; diff --git a/packages/rs-dpp/src/voting/vote_outcomes/contested_document_vote_poll_winner_info/mod.rs b/packages/rs-dpp/src/voting/vote_outcomes/contested_document_vote_poll_winner_info/mod.rs index 6d1aea6e5f..30cda2d9bf 100644 --- a/packages/rs-dpp/src/voting/vote_outcomes/contested_document_vote_poll_winner_info/mod.rs +++ b/packages/rs-dpp/src/voting/vote_outcomes/contested_document_vote_poll_winner_info/mod.rs @@ -1,6 +1,7 @@ +use bincode::{Decode, Encode}; use platform_value::Identifier; -#[derive(Debug, PartialEq, Eq, Clone, Default)] +#[derive(Debug, PartialEq, Eq, Clone, Default, Encode, Decode)] pub enum ContestedDocumentVotePollWinnerInfo { #[default] NoWinner, diff --git a/packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/mod.rs b/packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/mod.rs new file mode 100644 index 0000000000..924887b97a --- /dev/null +++ b/packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/mod.rs @@ -0,0 +1,50 @@ +mod v0; + +use crate::block::block_info::BlockInfo; +use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; +use crate::voting::contender_structs::FinalizedResourceVoteChoicesWithVoterInfo; +use crate::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; +use crate::voting::vote_outcomes::finalized_contested_document_vote_poll_stored_info::v0::FinalizedContestedDocumentVotePollStoredInfoV0; +use crate::ProtocolError; +use derive_more::From; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +use platform_version::version::PlatformVersion; + +/// Represents the stored info after a contested document vote poll. +/// +/// This struct holds the list of contenders, the abstaining vote tally. +#[derive( + Debug, PartialEq, Eq, Clone, From, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] +#[platform_serialize(unversioned)] +pub enum FinalizedContestedDocumentVotePollStoredInfo { + /// V0. + V0(FinalizedContestedDocumentVotePollStoredInfoV0), +} + +impl FinalizedContestedDocumentVotePollStoredInfo { + pub fn new( + resource_vote_choices: Vec, + finalization_block: BlockInfo, + winner: ContestedDocumentVotePollWinnerInfo, + platform_version: &PlatformVersion, + ) -> Result { + match platform_version + .dpp + .voting_versions + .finalized_contested_document_vote_poll_stored_info_version + { + 0 => Ok(FinalizedContestedDocumentVotePollStoredInfoV0::new( + resource_vote_choices, + finalization_block, + winner, + ) + .into()), + version => Err(ProtocolError::UnknownVersionMismatch { + method: "FinalizedContestedDocumentVotePollStoredInfo::new".to_string(), + known_versions: vec![0], + received: version, + }), + } + } +} diff --git a/packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/v0/mod.rs b/packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/v0/mod.rs new file mode 100644 index 0000000000..ddba532997 --- /dev/null +++ b/packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/v0/mod.rs @@ -0,0 +1,28 @@ +use crate::block::block_info::BlockInfo; +use crate::voting::contender_structs::FinalizedResourceVoteChoicesWithVoterInfo; +use crate::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; +use bincode::{Decode, Encode}; + +#[derive(Debug, PartialEq, Eq, Clone, Default, Encode, Decode)] +pub struct FinalizedContestedDocumentVotePollStoredInfoV0 { + /// The list of contenders returned by the query. + pub resource_vote_choices: Vec, + /// Finalization Block + pub finalization_block: BlockInfo, + /// Winner info + pub winner: ContestedDocumentVotePollWinnerInfo, +} + +impl FinalizedContestedDocumentVotePollStoredInfoV0 { + pub fn new( + resource_vote_choices: Vec, + finalization_block: BlockInfo, + winner: ContestedDocumentVotePollWinnerInfo, + ) -> FinalizedContestedDocumentVotePollStoredInfoV0 { + FinalizedContestedDocumentVotePollStoredInfoV0 { + resource_vote_choices, + finalization_block, + winner, + } + } +} diff --git a/packages/rs-dpp/src/voting/vote_outcomes/mod.rs b/packages/rs-dpp/src/voting/vote_outcomes/mod.rs index 6e9510a84c..ac6f33b0ab 100644 --- a/packages/rs-dpp/src/voting/vote_outcomes/mod.rs +++ b/packages/rs-dpp/src/voting/vote_outcomes/mod.rs @@ -1 +1,2 @@ pub mod contested_document_vote_poll_winner_info; +pub mod finalized_contested_document_vote_poll_stored_info; diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/mod.rs index d868ba2abc..16115f5048 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/mod.rs @@ -4,9 +4,9 @@ use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; +use dpp::voting::contender_structs::FinalizedContender; use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use drive::grovedb::TransactionArg; -use drive::query::vote_poll_vote_state_query::FinalizedContender; mod v0; impl Platform diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/v0/mod.rs index 30f7a1c8c9..c6e9698c0d 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/v0/mod.rs @@ -3,11 +3,11 @@ use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; +use dpp::voting::contender_structs::FinalizedContender; use drive::drive::object_size_info::DocumentInfo::DocumentAndSerialization; use drive::drive::object_size_info::{DocumentAndContractInfo, OwnedDocumentInfo}; use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use drive::grovedb::TransactionArg; -use drive::query::vote_poll_vote_state_query::FinalizedContender; impl Platform where diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs index 4fa583d36f..56657d57c6 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs @@ -5,10 +5,11 @@ use dpp::block::block_info::BlockInfo; use dpp::document::DocumentV0Getters; use dpp::prelude::TimestampMillis; use dpp::version::PlatformVersion; +use dpp::voting::contender_structs::FinalizedContender; +use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; use drive::drive::votes::resolved::vote_polls::resolve::VotePollResolver; use drive::drive::votes::resolved::vote_polls::{ResolvedVotePoll, ResolvedVotePollWithVotes}; use drive::grovedb::TransactionArg; -use drive::query::vote_poll_vote_state_query::FinalizedContender; use drive::query::VotePollsByEndDateDriveQuery; use itertools::Itertools; use std::collections::BTreeMap; @@ -113,7 +114,7 @@ where document_type, platform_version, ) - .map_err(Error::Drive) + .map_err(Error::Protocol) }) .collect::, Error>>()?; // Now we sort by the document creation date @@ -133,9 +134,8 @@ where }) .then_with(|| a.document.id().cmp(&b.document.id())) }); - // We award the document to the top contender - if let Some(top_contender) = maybe_top_contender { + let winner_info = if let Some(top_contender) = maybe_top_contender { // let's check to make sure the lock votes didn't win it // if the lock is tied with the top contender the top contender gets it if result.locked_vote_tally > top_contender.final_vote_tally { @@ -145,15 +145,9 @@ where transaction, platform_version, )?; + ContestedDocumentVotePollWinnerInfo::Locked } else { - // We want to keep a record of how everyone voted - self.keep_record_of_vote_poll( - block_info, - &top_contender, - &resolved_contested_document_resource_vote_poll, - transaction, - platform_version, - )?; + let contender_id = top_contender.identity_id; // We award the document to the winner of the vote poll self.award_document_to_winner( block_info, @@ -162,8 +156,20 @@ where transaction, platform_version, )?; + ContestedDocumentVotePollWinnerInfo::WonByIdentity(contender_id) } - } + } else { + ContestedDocumentVotePollWinnerInfo::NoWinner + }; + // We want to keep a record of how everyone voted + self.keep_record_of_finished_contested_resource_vote_poll( + block_info, + &resolved_contested_document_resource_vote_poll, + &identifiers_voting_for_contenders, + winner_info, + transaction, + platform_version, + )?; Ok(ResolvedVotePollWithVotes::ContestedDocumentResourceVotePollWithContractInfoAndVotes(resolved_contested_document_resource_vote_poll, identifiers_voting_for_contenders)) } } diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs index cc550e4917..f90c76e841 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs @@ -43,12 +43,13 @@ where self.drive .remove_contested_resource_vote_poll_votes_operations( vote_polls.as_slice(), + true, &mut operations, transaction, platform_version, )?; - // We remove the documents + // We remove the documents that contenders have self.drive .remove_contested_resource_vote_poll_documents_operations( vote_polls.as_slice(), @@ -57,6 +58,15 @@ where platform_version, )?; + // We remove the contenders + self.drive + .remove_contested_resource_vote_poll_contenders_operations( + vote_polls.as_slice(), + &mut operations, + transaction, + platform_version, + )?; + let vote_poll_ids = vote_polls .iter() .map(|(vote_poll, _, _)| Ok((*vote_poll, vote_poll.unique_id()?))) diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/mod.rs index d897187c53..12c9948e48 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/mod.rs @@ -3,10 +3,13 @@ use crate::error::Error; use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; use dpp::block::block_info::BlockInfo; +use dpp::identifier::Identifier; use dpp::version::PlatformVersion; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use drive::grovedb::TransactionArg; -use drive::query::vote_poll_vote_state_query::FinalizedContender; +use std::collections::BTreeMap; mod v0; @@ -15,11 +18,12 @@ where C: CoreRPCLike, { /// Keeps a record of the vote poll after it has finished - pub(in crate::execution) fn keep_record_of_vote_poll( + pub(in crate::execution) fn keep_record_of_finished_contested_resource_vote_poll( &self, block_info: &BlockInfo, - contender: &FinalizedContender, vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, + contender_votes: &BTreeMap>, + winner_info: ContestedDocumentVotePollWinnerInfo, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { @@ -27,17 +31,18 @@ where .drive_abci .methods .voting - .keep_record_of_vote_poll + .keep_record_of_finished_contested_resource_vote_poll { - 0 => self.keep_record_of_vote_poll_v0( + 0 => self.keep_record_of_finished_contested_resource_vote_poll_v0( block_info, - contender, vote_poll, + contender_votes, + winner_info, transaction, platform_version, ), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { - method: "keep_record_of_vote_poll".to_string(), + method: "keep_record_of_finished_contested_resource_vote_poll".to_string(), known_versions: vec![0], received: version, })), diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs index 09d3716736..022c139c13 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs @@ -2,10 +2,15 @@ use crate::error::Error; use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; use dpp::block::block_info::BlockInfo; +use dpp::identifier::Identifier; use dpp::version::PlatformVersion; +use dpp::voting::contender_structs::FinalizedResourceVoteChoicesWithVoterInfo; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; +use dpp::voting::vote_outcomes::finalized_contested_document_vote_poll_stored_info::FinalizedContestedDocumentVotePollStoredInfo; use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use drive::grovedb::TransactionArg; -use drive::query::vote_poll_vote_state_query::FinalizedContender; +use std::collections::BTreeMap; impl Platform where @@ -13,15 +18,39 @@ where { /// Keeps a record of the vote poll after it has finished #[inline(always)] - pub(super) fn keep_record_of_vote_poll_v0( + pub(super) fn keep_record_of_finished_contested_resource_vote_poll_v0( &self, block_info: &BlockInfo, - contender: &FinalizedContender, vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, + contender_votes: &BTreeMap>, + winner_info: ContestedDocumentVotePollWinnerInfo, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { - // We want to store information about the vote poll in an efficient way + let finalized_resource_vote_choices_with_voter_infos = contender_votes + .iter() + .map( + |(resource_vote_choice, voters)| FinalizedResourceVoteChoicesWithVoterInfo { + resource_vote_choice: resource_vote_choice.clone(), + voters: voters.clone(), + }, + ) + .collect(); + // We need to construct the finalized contested document vote poll stored info + let info_to_store = FinalizedContestedDocumentVotePollStoredInfo::new( + finalized_resource_vote_choices_with_voter_infos, + *block_info, + winner_info, + platform_version, + )?; + + self.drive.insert_record_of_finished_vote_poll( + vote_poll, + info_to_store, + transaction, + platform_version, + )?; + Ok(()) } } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index fb26d4bd3f..bd30099d95 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -182,7 +182,6 @@ mod tests { use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::ops::Deref; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0; - use drive::query::vote_poll_vote_state_query::Contender; use dapi_grpc::platform::v0::get_prefunded_specialized_balance_response; use dapi_grpc::platform::v0::get_prefunded_specialized_balance_response::{ get_prefunded_specialized_balance_response_v0, @@ -194,6 +193,7 @@ mod tests { mod vote_tests { use assert_matches::assert_matches; use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::get_contested_resource_vote_state_response_v0::{finished_vote_info, FinishedVoteInfo}; + use dpp::voting::contender_structs::Contender; use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType; use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult::SuccessfulExecution; use super::*; diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs index b65a1eeebf..103ffcf80e 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs @@ -16,10 +16,11 @@ use dpp::validation::ValidationResult; use dpp::version::PlatformVersion; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::{check_validation_result_with_data, platform_value}; +use dpp::voting::contender_structs::ContenderWithSerializedDocument; use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; use drive::error::query::QuerySyntaxError; use drive::query::vote_poll_vote_state_query::{ - ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQuery, + ContestedDocumentVotePollDriveQuery, }; impl Platform { diff --git a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs index 01af7dbb38..aaf7d74936 100644 --- a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs +++ b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/mod.rs @@ -4,13 +4,12 @@ use crate::error::Error; use derive_more::From; use dpp::block::epoch::Epoch; use dpp::version::{PlatformVersion, PlatformVersionCurrentVersion}; +use dpp::voting::contender_structs::ContenderWithSerializedDocument; use grovedb::TransactionArg; mod v0; -use crate::query::vote_poll_vote_state_query::{ - ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQuery, -}; +use crate::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQuery; pub use v0::*; /// Represents the outcome of a query to retrieve documents. diff --git a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs index 8f42972a29..e6a996bf62 100644 --- a/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs @@ -1,11 +1,10 @@ use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; -use crate::query::vote_poll_vote_state_query::{ - ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQuery, -}; +use crate::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQuery; use dpp::block::epoch::Epoch; use dpp::version::PlatformVersion; +use dpp::voting::contender_structs::ContenderWithSerializedDocument; use grovedb::TransactionArg; /// The outcome of a query diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/mod.rs index dffff4f323..c65041dbe5 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/mod.rs @@ -6,8 +6,7 @@ use crate::error::drive::DriveError; use crate::error::Error; use crate::query::vote_poll_vote_state_query::{ - ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQueryExecutionResult, - ResolvedContestedDocumentVotePollDriveQuery, + ContestedDocumentVotePollDriveQueryExecutionResult, ResolvedContestedDocumentVotePollDriveQuery, }; use dpp::version::PlatformVersion; diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs index b5c38b637a..4b90008b49 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs @@ -9,10 +9,11 @@ use crate::drive::votes::paths::{ }; use crate::error::drive::DriveError; use crate::query::vote_poll_vote_state_query::{ - ContenderWithSerializedDocument, ContestedDocumentVotePollDriveQueryExecutionResult, + ContestedDocumentVotePollDriveQueryExecutionResult, ContestedDocumentVotePollDriveQueryResultType, ResolvedContestedDocumentVotePollDriveQuery, }; use dpp::version::PlatformVersion; +use dpp::voting::contender_structs::ContenderWithSerializedDocument; impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { /// Verifies a proof for a collection of documents. diff --git a/packages/rs-drive/src/drive/votes/cleanup/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/mod.rs index a6cef9f2e2..6527b13667 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/mod.rs @@ -1,6 +1,7 @@ mod remove_all_votes_given_by_identity; mod add_lock_for_contested_document_resource_vote_poll; +mod remove_contested_resource_vote_poll_contenders_operations; mod remove_contested_resource_vote_poll_documents_operations; mod remove_contested_resource_vote_poll_end_date_query_operations; mod remove_contested_resource_vote_poll_votes_operations; diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_contenders_operations/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_contenders_operations/mod.rs new file mode 100644 index 0000000000..bdcf77e248 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_contenders_operations/mod.rs @@ -0,0 +1,52 @@ +mod v0; + +use crate::drive::Drive; +use std::collections::BTreeMap; + +use crate::error::drive::DriveError; +use crate::error::Error; + +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use crate::fee::op::LowLevelDriveOperation; +use dpp::identifier::Identifier; +use dpp::prelude::TimestampMillis; +use dpp::version::PlatformVersion; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use grovedb::TransactionArg; + +impl Drive { + /// We add votes poll references by end date in order to be able to check on every new block if + /// any votes poll should be closed. This will remove them to recoup space + pub fn remove_contested_resource_vote_poll_contenders_operations( + &self, + vote_polls: &[( + &ContestedDocumentResourceVotePollWithContractInfo, + &TimestampMillis, + &BTreeMap>, + )], + batch_operations: &mut Vec, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive + .methods + .vote + .cleanup + .remove_contested_resource_vote_poll_contenders_operations + { + 0 => self.remove_contested_resource_vote_poll_contenders_operations_v0( + vote_polls, + batch_operations, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "remove_contested_resource_vote_poll_contenders_operations".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_contenders_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_contenders_operations/v0/mod.rs new file mode 100644 index 0000000000..2646f841c1 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_contenders_operations/v0/mod.rs @@ -0,0 +1,47 @@ +use crate::drive::grove_operations::BatchDeleteApplyType; +use crate::drive::votes::paths::{VotePollPaths, VOTING_STORAGE_TREE_KEY}; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use crate::drive::votes::ResourceVoteChoiceToKeyTrait; +use crate::drive::Drive; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use dpp::identifier::Identifier; +use dpp::identity::TimestampMillis; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use grovedb::TransactionArg; +use platform_version::version::PlatformVersion; +use std::collections::BTreeMap; + +impl Drive { + /// We add votes poll references by end date in order to be able to check on every new block if + /// any vote polls should be closed. + pub(in crate::drive::votes) fn remove_contested_resource_vote_poll_contenders_operations_v0( + &self, + vote_polls: &[( + &ContestedDocumentResourceVotePollWithContractInfo, + &TimestampMillis, + &BTreeMap>, + )], + batch_operations: &mut Vec, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + for (vote_poll, _, votes) in vote_polls { + let path = vote_poll.contenders_path(platform_version)?; + for (resource_vote_choice, _) in *votes { + self.batch_delete( + path.as_slice().into(), + resource_vote_choice.to_key().as_slice(), + BatchDeleteApplyType::StatefulBatchDelete { + is_known_to_be_subtree_with_sum: Some((false, false)), + }, + transaction, + batch_operations, + &platform_version.drive, + )?; + } + } + + Ok(()) + } +} diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_documents_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_documents_operations/v0/mod.rs index 41f9396670..4fee15ded3 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_documents_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_documents_operations/v0/mod.rs @@ -63,8 +63,9 @@ impl Drive { // We also need to delete all the references for resource_vote_choice in vote_choices.keys() { - if let ResourceVoteChoice::TowardsIdentity(identifier) = resource_vote_choice { - let contender_path = vote_poll.contender_path(*identifier, platform_version)?; + if matches!(resource_vote_choice, ResourceVoteChoice::TowardsIdentity(_)) { + let contender_path = + vote_poll.contender_path(resource_vote_choice, platform_version)?; self.batch_delete( contender_path.as_slice().into(), vec![0].as_slice(), diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/mod.rs index 96eeb1b0a2..6d8015fe04 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/mod.rs @@ -25,6 +25,7 @@ impl Drive { &TimestampMillis, &BTreeMap>, )], + remove_vote_tree_too: bool, batch_operations: &mut Vec, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -38,6 +39,7 @@ impl Drive { { 0 => self.remove_contested_resource_vote_poll_votes_operations_v0( vote_polls, + remove_vote_tree_too, batch_operations, transaction, platform_version, diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/v0/mod.rs index 50e1aa35d7..004ddb9e0e 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/v0/mod.rs @@ -1,6 +1,7 @@ use crate::drive::grove_operations::{BatchDeleteApplyType, BatchDeleteUpTreeApplyType}; use crate::drive::votes::paths::{ vote_contested_resource_end_date_queries_at_time_tree_path_vec, VotePollPaths, + VOTING_STORAGE_TREE_KEY, }; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use crate::drive::Drive; @@ -25,6 +26,7 @@ impl Drive { &TimestampMillis, &BTreeMap>, )], + remove_vote_tree_too: bool, batch_operations: &mut Vec, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -46,6 +48,21 @@ impl Drive { &platform_version.drive, )?; } + + let path = vote_poll.contender_path(resource_vote_choice, platform_version)?; + + if remove_vote_tree_too { + self.batch_delete( + path.as_slice().into(), + vec![VOTING_STORAGE_TREE_KEY].as_slice(), + BatchDeleteApplyType::StatefulBatchDelete { + is_known_to_be_subtree_with_sum: Some((false, false)), + }, + transaction, + batch_operations, + &platform_version.drive, + )?; + } } } diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/insert_record_of_finished_vote_poll/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/insert_record_of_finished_vote_poll/mod.rs new file mode 100644 index 0000000000..07a7524ab9 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/insert_record_of_finished_vote_poll/mod.rs @@ -0,0 +1,70 @@ +mod v0; + +use crate::drive::Drive; + +use crate::error::drive::DriveError; +use crate::error::Error; + +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use crate::fee::op::LowLevelDriveOperation; +use dpp::version::PlatformVersion; +use dpp::voting::vote_outcomes::finalized_contested_document_vote_poll_stored_info::FinalizedContestedDocumentVotePollStoredInfo; +use grovedb::TransactionArg; + +impl Drive { + /// Inserts a record of a finished vote poll that can later be queried + pub fn insert_record_of_finished_vote_poll( + &self, + vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, + finalized_contested_document_vote_poll_stored_info: FinalizedContestedDocumentVotePollStoredInfo, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + match platform_version + .drive + .methods + .vote + .contested_resource_insert + .insert_record_of_finished_vote_poll + { + 0 => self.insert_record_of_finished_vote_poll_v0( + vote_poll, + finalized_contested_document_vote_poll_stored_info, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "insert_record_of_finished_vote_poll".to_string(), + known_versions: vec![0], + received: version, + })), + } + } + + /// Returns the operations of inserting a record of a finished vote poll that can later be queried + pub fn insert_record_of_finished_vote_poll_operations( + &self, + vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, + finalized_contested_document_vote_poll_stored_info: FinalizedContestedDocumentVotePollStoredInfo, + platform_version: &PlatformVersion, + ) -> Result, Error> { + match platform_version + .drive + .methods + .vote + .contested_resource_insert + .insert_record_of_finished_vote_poll + { + 0 => self.insert_record_of_finished_vote_poll_operations_v0( + vote_poll, + finalized_contested_document_vote_poll_stored_info, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "insert_record_of_finished_vote_poll_operations".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/insert_record_of_finished_vote_poll/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/insert_record_of_finished_vote_poll/v0/mod.rs new file mode 100644 index 0000000000..b20d271c40 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/insert_record_of_finished_vote_poll/v0/mod.rs @@ -0,0 +1,62 @@ +use crate::drive::object_size_info::PathKeyElementInfo::PathKeyElement; +use crate::drive::votes::paths::{VotePollPaths, RESOURCE_FINISHED_INFO_KEY_U8}; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use crate::drive::Drive; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use dpp::serialization::PlatformSerializable; +use dpp::voting::vote_outcomes::finalized_contested_document_vote_poll_stored_info::FinalizedContestedDocumentVotePollStoredInfo; +use grovedb::{Element, TransactionArg}; +use platform_version::version::PlatformVersion; + +impl Drive { + pub(super) fn insert_record_of_finished_vote_poll_v0( + &self, + vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, + finalized_contested_document_vote_poll_stored_info: FinalizedContestedDocumentVotePollStoredInfo, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(), Error> { + let batch_operations = self.insert_record_of_finished_vote_poll_operations_v0( + vote_poll, + finalized_contested_document_vote_poll_stored_info, + platform_version, + )?; + + let mut drive_operations: Vec = vec![]; + self.apply_batch_low_level_drive_operations( + None, + transaction, + batch_operations, + &mut drive_operations, + &platform_version.drive, + )?; + + Ok(()) + } + + pub(super) fn insert_record_of_finished_vote_poll_operations_v0( + &self, + vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, + finalized_contested_document_vote_poll_stored_info: FinalizedContestedDocumentVotePollStoredInfo, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let mut drive_operations: Vec = vec![]; + + let serialization = + finalized_contested_document_vote_poll_stored_info.serialize_consume_to_bytes()?; + let vote_poll_root_path = vote_poll.contenders_path(platform_version)?; + + self.batch_insert::<0>( + PathKeyElement(( + vote_poll_root_path.clone(), + vec![RESOURCE_FINISHED_INFO_KEY_U8], + Element::new_item(serialization), + )), + &mut drive_operations, + &platform_version.drive, + )?; + + Ok(drive_operations) + } +} diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/mod.rs index 5f7ca5cdce..6d6c632b53 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/mod.rs @@ -1 +1,2 @@ mod individual_vote; +mod insert_record_of_finished_vote_poll; diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index 282c8e84d3..3866819b21 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -53,6 +53,12 @@ pub const RESOURCE_LOCK_VOTE_TREE_KEY_U8: u8 = 'l' as u8; /// In the active vote poll this will contain votes for abstaining on the vote for the contested resource pub const RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8: u8 = 'a' as u8; +/// The finished info +pub const RESOURCE_FINISHED_INFO_KEY: char = 'f'; + +/// The finished info +pub const RESOURCE_FINISHED_INFO_KEY_U8: u8 = 'f' as u8; + /// The tree key for storage pub const VOTING_STORAGE_TREE_KEY: u8 = 1; @@ -82,7 +88,7 @@ pub trait VotePollPaths { /// The path that would store the contender information for a single contender fn contender_path( &self, - identity_id: Identifier, + vote_choice: &ResourceVoteChoice, platform_version: &PlatformVersion, ) -> Result>, Error>; @@ -159,11 +165,11 @@ impl VotePollPaths for ContestedDocumentResourceVotePollWithContractInfo { fn contender_path( &self, - identity_id: Identifier, + vote_choice: &ResourceVoteChoice, platform_version: &PlatformVersion, ) -> Result>, Error> { let mut contenders_path = self.contenders_path(platform_version)?; - contenders_path.push(identity_id.to_vec()); + contenders_path.push(vote_choice.to_key()); Ok(contenders_path) } @@ -245,11 +251,11 @@ impl<'a> VotePollPaths for ContestedDocumentResourceVotePollWithContractInfoAllo fn contender_path( &self, - identity_id: Identifier, + vote_choice: &ResourceVoteChoice, platform_version: &PlatformVersion, ) -> Result>, Error> { let mut contenders_path = self.contenders_path(platform_version)?; - contenders_path.push(identity_id.to_vec()); + contenders_path.push(vote_choice.to_key()); Ok(contenders_path) } diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index 1973e8867d..4a6af31650 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -20,7 +20,10 @@ use dpp::data_contract::DataContract; use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use dpp::document::Document; use dpp::identifier::Identifier; -use dpp::prelude::{Identity, TimestampMillis}; +use dpp::voting::contender_structs::{ + ContenderWithSerializedDocument, FinalizedContenderWithSerializedDocument, + FinalizedResourceVoteChoicesWithVoterInfo, +}; use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; #[cfg(feature = "server")] @@ -108,124 +111,6 @@ pub struct ContestedDocumentVotePollDriveQuery { pub allow_include_locked_and_abstaining_vote_tally: bool, } -/// Represents a contender in the contested document vote poll. -/// This is for internal use where the document is in serialized form -/// -/// This struct holds the identity ID of the contender, the serialized document, -/// and the vote tally. -#[derive(Debug, PartialEq, Eq, Clone, Default)] -pub struct ContenderWithSerializedDocument { - /// The identity ID of the contender. - pub identity_id: Identifier, - /// The serialized document associated with the contender. - pub serialized_document: Option>, - /// The vote tally for the contender. - pub vote_tally: Option, -} - -/// Represents a finalized contender in the contested document vote poll. -/// This is for internal use where the document is in serialized form -/// -/// This struct holds the identity ID of the contender, the serialized document, -/// and the vote tally. -#[derive(Debug, PartialEq, Eq, Clone, Default)] -pub struct FinalizedContenderWithSerializedDocument { - /// The identity ID of the contender. - pub identity_id: Identifier, - /// The serialized document associated with the contender. - pub serialized_document: Vec, - /// The vote tally for the contender. - pub final_vote_tally: u32, -} - -/// Represents a finalized contender in the contested document vote poll. -/// This is for keeping information about previous vote polls -/// -/// This struct holds the identity ID of the contender, the serialized document, -/// and the vote tally. -#[derive(Debug, PartialEq, Eq, Clone, Default, Encode, Decode)] -pub struct FinalizedContenderWithVoterInfo { - /// The identity ID of the contender. - pub identity_id: Identifier, - /// The pro_tx_hashes of the voters for this contender. - pub voters: Vec, -} - -/// Represents a finalized contender in the contested document vote poll. -/// This is for internal use where the document is in serialized form -/// -/// This struct holds the identity ID of the contender, the document, -/// and the vote tally. -#[derive(Debug, PartialEq, Clone)] -pub struct FinalizedContender { - /// The identity ID of the contender. - pub identity_id: Identifier, - /// The document associated with the contender. - pub document: Document, - /// The still serialized document - pub serialized_document: Vec, - /// The vote tally for the contender. - pub final_vote_tally: u32, -} - -impl FinalizedContender { - /// Try to get the finalized contender from a finalized contender with a serialized document - pub fn try_from_contender_with_serialized_document( - value: FinalizedContenderWithSerializedDocument, - document_type: DocumentTypeRef, - platform_version: &PlatformVersion, - ) -> Result { - let FinalizedContenderWithSerializedDocument { - identity_id, - serialized_document, - final_vote_tally, - } = value; - - Ok(FinalizedContender { - identity_id, - document: Document::from_bytes(&serialized_document, document_type, platform_version)?, - serialized_document, - final_vote_tally, - }) - } -} - -impl TryFrom for FinalizedContenderWithSerializedDocument { - type Error = Error; - - fn try_from(value: ContenderWithSerializedDocument) -> Result { - let ContenderWithSerializedDocument { - identity_id, - serialized_document, - vote_tally, - } = value; - - Ok(FinalizedContenderWithSerializedDocument { - identity_id, - serialized_document: serialized_document.ok_or(Error::Drive( - DriveError::CorruptedCodeExecution("expected serialized document"), - ))?, - final_vote_tally: vote_tally.ok_or(Error::Drive( - DriveError::CorruptedCodeExecution("expected vote tally"), - ))?, - }) - } -} - -/// Represents a contender in the contested document vote poll. -/// -/// This struct holds the identity ID of the contender, the serialized document, -/// and the vote tally. -#[derive(Debug, PartialEq, Clone, Default)] -pub struct Contender { - /// The identity ID of the contender. - pub identity_id: Identifier, - /// The document associated with the contender. - pub document: Option, - /// The vote tally for the contender. - pub vote_tally: Option, -} - /// Represents the result of executing a contested document vote poll drive query. /// /// This struct holds the list of contenders and the number of skipped items @@ -258,19 +143,6 @@ pub struct FinalizedContestedDocumentVotePollDriveQueryExecutionResult { pub abstaining_vote_tally: u32, } -/// Represents the stored info after a contested document vote poll. -/// -/// This struct holds the list of contenders, the abstaining vote tally. -#[derive(Debug, PartialEq, Eq, Clone, Default, Encode, Decode)] -pub struct FinalizedContestedDocumentVotePollStoredInfo { - /// The list of contenders returned by the query. - pub contenders: Vec, - /// Locked tally - pub locking_voters: Vec, - /// Abstaining tally - pub abstaining_voters: Vec, -} - impl TryFrom for FinalizedContestedDocumentVotePollDriveQueryExecutionResult { diff --git a/packages/rs-platform-version/src/version/dpp_versions.rs b/packages/rs-platform-version/src/version/dpp_versions.rs index b582adca4c..53e707e070 100644 --- a/packages/rs-platform-version/src/version/dpp_versions.rs +++ b/packages/rs-platform-version/src/version/dpp_versions.rs @@ -228,6 +228,7 @@ pub struct IdentityVersions { #[derive(Clone, Debug, Default)] pub struct VotingVersions { pub default_vote_poll_time_duration_ms: u64, + pub finalized_contested_document_vote_poll_stored_info_version: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/drive_abci_versions.rs b/packages/rs-platform-version/src/version/drive_abci_versions.rs index f7b543389d..4243734740 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions.rs @@ -300,7 +300,7 @@ pub struct DriveAbciBlockEndMethodVersions { #[derive(Clone, Debug, Default)] pub struct DriveAbciVotingMethodVersions { - pub keep_record_of_vote_poll: FeatureVersion, + pub keep_record_of_finished_contested_resource_vote_poll: FeatureVersion, pub clean_up_after_vote_poll_end: FeatureVersion, pub clean_up_after_contested_resources_vote_poll_end: FeatureVersion, pub check_for_ended_vote_polls: FeatureVersion, diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index bdfdc8b1b5..0e4389a5f8 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -291,6 +291,7 @@ pub struct DriveVoteCleanupMethodVersions { pub remove_contested_resource_vote_poll_end_date_query_operations: FeatureVersion, pub remove_contested_resource_vote_poll_votes_operations: FeatureVersion, pub remove_contested_resource_vote_poll_documents_operations: FeatureVersion, + pub remove_contested_resource_vote_poll_contenders_operations: FeatureVersion, } #[derive(Clone, Debug, Default)] @@ -301,6 +302,7 @@ pub struct DriveVoteInsertMethodVersions { #[derive(Clone, Debug, Default)] pub struct DriveVoteContestedResourceInsertMethodVersions { pub register_contested_resource_identity_vote: FeatureVersion, + pub insert_record_of_finished_vote_poll: FeatureVersion, pub register_identity_vote: FeatureVersion, pub add_vote_poll_end_date_query_operations: FeatureVersion, } diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 612cef3b26..986ce979e0 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -231,6 +231,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { }, contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { register_contested_resource_identity_vote: 0, + insert_record_of_finished_vote_poll: 0, register_identity_vote: 0, add_vote_poll_end_date_query_operations: 0, }, @@ -241,6 +242,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { remove_contested_resource_vote_poll_end_date_query_operations: 0, remove_contested_resource_vote_poll_votes_operations: 0, remove_contested_resource_vote_poll_documents_operations: 0, + remove_contested_resource_vote_poll_contenders_operations: 0, }, setup: DriveVoteSetupMethodVersions { add_initial_vote_tree_main_structure_operations: 0, @@ -640,7 +642,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { append_signatures_and_broadcast_withdrawal_transactions: 0, }, voting: DriveAbciVotingMethodVersions { - keep_record_of_vote_poll: 0, + keep_record_of_finished_contested_resource_vote_poll: 0, clean_up_after_vote_poll_end: 0, clean_up_after_contested_resources_vote_poll_end: 0, check_for_ended_vote_polls: 0, @@ -1182,6 +1184,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { }, voting_versions: VotingVersions { default_vote_poll_time_duration_ms: 1_209_600_000, //2 weeks + finalized_contested_document_vote_poll_stored_info_version: 0, }, asset_lock_versions: AssetLockVersions { reduced_asset_lock_value: FeatureVersionBounds { diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 710379347a..22857b4029 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -239,6 +239,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { }, contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { register_contested_resource_identity_vote: 0, + insert_record_of_finished_vote_poll: 0, register_identity_vote: 0, add_vote_poll_end_date_query_operations: 0, }, @@ -249,6 +250,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { remove_contested_resource_vote_poll_end_date_query_operations: 0, remove_contested_resource_vote_poll_votes_operations: 0, remove_contested_resource_vote_poll_documents_operations: 0, + remove_contested_resource_vote_poll_contenders_operations: 0, }, setup: DriveVoteSetupMethodVersions { add_initial_vote_tree_main_structure_operations: 0, @@ -640,7 +642,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { append_signatures_and_broadcast_withdrawal_transactions: 0, }, voting: DriveAbciVotingMethodVersions { - keep_record_of_vote_poll: 0, + keep_record_of_finished_contested_resource_vote_poll: 0, clean_up_after_vote_poll_end: 0, clean_up_after_contested_resources_vote_poll_end: 0, check_for_ended_vote_polls: 0, @@ -1182,6 +1184,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { }, voting_versions: VotingVersions { default_vote_poll_time_duration_ms: 1_209_600_000, //2 weeks + finalized_contested_document_vote_poll_stored_info_version: 0, }, asset_lock_versions: AssetLockVersions { reduced_asset_lock_value: FeatureVersionBounds { diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index 774db389b2..c82d399d94 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -230,6 +230,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { }, contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { register_contested_resource_identity_vote: 0, + insert_record_of_finished_vote_poll: 0, register_identity_vote: 0, add_vote_poll_end_date_query_operations: 0, }, @@ -240,6 +241,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { remove_contested_resource_vote_poll_end_date_query_operations: 0, remove_contested_resource_vote_poll_votes_operations: 0, remove_contested_resource_vote_poll_documents_operations: 0, + remove_contested_resource_vote_poll_contenders_operations: 0, }, setup: DriveVoteSetupMethodVersions { add_initial_vote_tree_main_structure_operations: 0, @@ -639,7 +641,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { append_signatures_and_broadcast_withdrawal_transactions: 0, }, voting: DriveAbciVotingMethodVersions { - keep_record_of_vote_poll: 0, + keep_record_of_finished_contested_resource_vote_poll: 0, clean_up_after_vote_poll_end: 0, clean_up_after_contested_resources_vote_poll_end: 0, check_for_ended_vote_polls: 0, @@ -1181,6 +1183,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { }, voting_versions: VotingVersions { default_vote_poll_time_duration_ms: 1_209_600_000, //2 weeks + finalized_contested_document_vote_poll_stored_info_version: 0, }, asset_lock_versions: AssetLockVersions { reduced_asset_lock_value: FeatureVersionBounds { From 3fc6346cd46588e3e1b4b97efe55147aed5c0cc2 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sat, 8 Jun 2024 19:47:09 +0300 Subject: [PATCH 119/135] its alive --- .../protos/platform/v0/platform.proto | 4 + .../mod.rs | 2 +- .../mod.rs | 62 +++++++++- .../v0/mod.rs | 93 ++++++++++++++- .../state_transitions/masternode_vote/mod.rs | 13 +- .../contested_resource_vote_state/v0/mod.rs | 47 +++++--- .../v0/mod.rs | 111 ++++++++++++++---- .../src/query/vote_poll_vote_state_query.rs | 108 ++++++++++++++--- 8 files changed, 377 insertions(+), 63 deletions(-) diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index 76b6b36d7d..577eed1e8b 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -766,6 +766,10 @@ message GetContestedResourceVoteStateResponse { } FinishedVoteOutcome finished_vote_outcome = 1; optional bytes won_by_identity_id = 2; // Only used when vote_choice_type is TOWARDS_IDENTITY + uint64 finished_at_block_height = 3; + uint32 finished_at_core_block_height = 4; + uint64 finished_at_block_time_ms = 5; + uint32 finished_at_epoch = 6; } message ContestedResourceContenders { diff --git a/packages/rs-dpp/src/voting/vote_outcomes/contested_document_vote_poll_winner_info/mod.rs b/packages/rs-dpp/src/voting/vote_outcomes/contested_document_vote_poll_winner_info/mod.rs index 30cda2d9bf..2a2317bd7b 100644 --- a/packages/rs-dpp/src/voting/vote_outcomes/contested_document_vote_poll_winner_info/mod.rs +++ b/packages/rs-dpp/src/voting/vote_outcomes/contested_document_vote_poll_winner_info/mod.rs @@ -1,7 +1,7 @@ use bincode::{Decode, Encode}; use platform_value::Identifier; -#[derive(Debug, PartialEq, Eq, Clone, Default, Encode, Decode)] +#[derive(Debug, PartialEq, Eq, Clone, Copy, Default, Encode, Decode)] pub enum ContestedDocumentVotePollWinnerInfo { #[default] NoWinner, diff --git a/packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/mod.rs b/packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/mod.rs index 924887b97a..4e087c8f5e 100644 --- a/packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/mod.rs +++ b/packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/mod.rs @@ -2,13 +2,17 @@ mod v0; use crate::block::block_info::BlockInfo; use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; -use crate::voting::contender_structs::FinalizedResourceVoteChoicesWithVoterInfo; +use crate::voting::contender_structs::{ + ContenderWithSerializedDocument, FinalizedResourceVoteChoicesWithVoterInfo, +}; use crate::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; use crate::voting::vote_outcomes::finalized_contested_document_vote_poll_stored_info::v0::FinalizedContestedDocumentVotePollStoredInfoV0; use crate::ProtocolError; use derive_more::From; use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +use platform_value::Identifier; use platform_version::version::PlatformVersion; +pub use v0::FinalizedContestedDocumentVotePollStoredInfoV0Getters; /// Represents the stored info after a contested document vote poll. /// @@ -48,3 +52,59 @@ impl FinalizedContestedDocumentVotePollStoredInfo { } } } + +impl FinalizedContestedDocumentVotePollStoredInfoV0Getters + for FinalizedContestedDocumentVotePollStoredInfo +{ + fn resource_vote_choices(&self) -> &Vec { + match self { + FinalizedContestedDocumentVotePollStoredInfo::V0(v0) => &v0.resource_vote_choices, + } + } + + fn finalization_block(&self) -> &BlockInfo { + match self { + FinalizedContestedDocumentVotePollStoredInfo::V0(v0) => &v0.finalization_block, + } + } + + fn winner(&self) -> &ContestedDocumentVotePollWinnerInfo { + match self { + FinalizedContestedDocumentVotePollStoredInfo::V0(v0) => &v0.winner, + } + } + + fn locked_votes(&self) -> u32 { + match self { + FinalizedContestedDocumentVotePollStoredInfo::V0(v0) => v0.locked_votes(), + } + } + + fn locked_voters(&self) -> Vec { + match self { + FinalizedContestedDocumentVotePollStoredInfo::V0(v0) => v0.locked_voters(), + } + } + + fn abstain_votes(&self) -> u32 { + match self { + FinalizedContestedDocumentVotePollStoredInfo::V0(v0) => v0.abstain_votes(), + } + } + + fn abstain_voters(&self) -> Vec { + match self { + FinalizedContestedDocumentVotePollStoredInfo::V0(v0) => v0.abstain_voters(), + } + } + + fn contender_votes_in_vec_of_contender_with_serialized_document( + &self, + ) -> Vec { + match self { + FinalizedContestedDocumentVotePollStoredInfo::V0(v0) => { + v0.contender_votes_in_vec_of_contender_with_serialized_document() + } + } + } +} diff --git a/packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/v0/mod.rs b/packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/v0/mod.rs index ddba532997..f1db7510b7 100644 --- a/packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/v0/mod.rs +++ b/packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/v0/mod.rs @@ -1,7 +1,12 @@ use crate::block::block_info::BlockInfo; -use crate::voting::contender_structs::FinalizedResourceVoteChoicesWithVoterInfo; +use crate::voting::contender_structs::{ + ContenderWithSerializedDocument, FinalizedResourceVoteChoicesWithVoterInfo, +}; +use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use crate::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; +use crate::voting::vote_outcomes::finalized_contested_document_vote_poll_stored_info::FinalizedContestedDocumentVotePollStoredInfo; use bincode::{Decode, Encode}; +use platform_value::Identifier; #[derive(Debug, PartialEq, Eq, Clone, Default, Encode, Decode)] pub struct FinalizedContestedDocumentVotePollStoredInfoV0 { @@ -26,3 +31,89 @@ impl FinalizedContestedDocumentVotePollStoredInfoV0 { } } } + +pub trait FinalizedContestedDocumentVotePollStoredInfoV0Getters { + fn resource_vote_choices(&self) -> &Vec; + fn finalization_block(&self) -> &BlockInfo; + fn winner(&self) -> &ContestedDocumentVotePollWinnerInfo; + + fn locked_votes(&self) -> u32; + + fn locked_voters(&self) -> Vec; + + fn abstain_votes(&self) -> u32; + + fn abstain_voters(&self) -> Vec; + fn contender_votes_in_vec_of_contender_with_serialized_document( + &self, + ) -> Vec; +} + +impl FinalizedContestedDocumentVotePollStoredInfoV0Getters + for FinalizedContestedDocumentVotePollStoredInfoV0 +{ + fn resource_vote_choices(&self) -> &Vec { + &self.resource_vote_choices + } + + fn finalization_block(&self) -> &BlockInfo { + &self.finalization_block + } + + fn winner(&self) -> &ContestedDocumentVotePollWinnerInfo { + &self.winner + } + + fn locked_votes(&self) -> u32 { + self.resource_vote_choices + .iter() + .filter(|choice| matches!(choice.resource_vote_choice, ResourceVoteChoice::Lock)) + .map(|choice| choice.voters.len() as u32) + .sum() + } + + fn locked_voters(&self) -> Vec { + self.resource_vote_choices + .iter() + .filter(|choice| matches!(choice.resource_vote_choice, ResourceVoteChoice::Lock)) + .flat_map(|choice| choice.voters.clone()) + .collect() + } + + fn abstain_votes(&self) -> u32 { + self.resource_vote_choices + .iter() + .filter(|choice| matches!(choice.resource_vote_choice, ResourceVoteChoice::Abstain)) + .map(|choice| choice.voters.len() as u32) + .sum() + } + + fn abstain_voters(&self) -> Vec { + self.resource_vote_choices + .iter() + .filter(|choice| matches!(choice.resource_vote_choice, ResourceVoteChoice::Abstain)) + .flat_map(|choice| choice.voters.clone()) + .collect() + } + + fn contender_votes_in_vec_of_contender_with_serialized_document( + &self, + ) -> Vec { + self.resource_vote_choices + .iter() + .filter_map(|choice| { + if let ResourceVoteChoice::TowardsIdentity(identity_id) = + &choice.resource_vote_choice + { + Some(ContenderWithSerializedDocument { + identity_id: *identity_id, + serialized_document: None, + vote_tally: Some(choice.voters.len() as u32), + }) + } else { + None + } + }) + .collect() + } +} diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index bd30099d95..9c320ae5e9 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -4436,7 +4436,18 @@ mod tests { platform_version, ); - assert_eq!(finished_vote_info, None); + assert_eq!( + finished_vote_info, + Some(FinishedVoteInfo { + finished_vote_outcome: + finished_vote_info::FinishedVoteOutcome::TowardsIdentity as i32, + won_by_identity_id: Some(contender_1.id().to_vec()), + finished_at_block_height: 10000, + finished_at_core_block_height: 42, + finished_at_block_time_ms: 1209900000, + finished_at_epoch: 0 + }) + ); assert_eq!(contenders.len(), 2); diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs index 103ffcf80e..3843d4dec4 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs @@ -184,22 +184,37 @@ impl Platform { let abstain_vote_tally = results.abstaining_vote_tally; let lock_vote_tally = results.locked_vote_tally; - let finished_vote_info = results.winner.map(|winner_info| match winner_info { - ContestedDocumentVotePollWinnerInfo::NoWinner => FinishedVoteInfo { - finished_vote_outcome: FinishedVoteOutcome::NoPreviousWinner as i32, - won_by_identity_id: None, - }, - ContestedDocumentVotePollWinnerInfo::WonByIdentity(identity_id) => { - FinishedVoteInfo { - finished_vote_outcome: FinishedVoteOutcome::TowardsIdentity as i32, - won_by_identity_id: Some(identity_id.to_vec()), - } - } - ContestedDocumentVotePollWinnerInfo::Locked => FinishedVoteInfo { - finished_vote_outcome: FinishedVoteOutcome::Locked as i32, - won_by_identity_id: None, - }, - }); + let finished_vote_info = + results + .winner + .map(|(winner_info, finished_at_block_info)| match winner_info { + ContestedDocumentVotePollWinnerInfo::NoWinner => FinishedVoteInfo { + finished_vote_outcome: FinishedVoteOutcome::NoPreviousWinner as i32, + won_by_identity_id: None, + finished_at_block_height: finished_at_block_info.height, + finished_at_core_block_height: finished_at_block_info.core_height, + finished_at_block_time_ms: finished_at_block_info.time_ms, + finished_at_epoch: finished_at_block_info.epoch.index as u32, + }, + ContestedDocumentVotePollWinnerInfo::WonByIdentity(identity_id) => { + FinishedVoteInfo { + finished_vote_outcome: FinishedVoteOutcome::TowardsIdentity as i32, + won_by_identity_id: Some(identity_id.to_vec()), + finished_at_block_height: finished_at_block_info.height, + finished_at_core_block_height: finished_at_block_info.core_height, + finished_at_block_time_ms: finished_at_block_info.time_ms, + finished_at_epoch: finished_at_block_info.epoch.index as u32, + } + } + ContestedDocumentVotePollWinnerInfo::Locked => FinishedVoteInfo { + finished_vote_outcome: FinishedVoteOutcome::Locked as i32, + won_by_identity_id: None, + finished_at_block_height: finished_at_block_info.height, + finished_at_core_block_height: finished_at_block_info.core_height, + finished_at_block_time_ms: finished_at_block_info.time_ms, + finished_at_epoch: finished_at_block_info.epoch.index as u32, + }, + }); let contenders = results .contenders diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs index 4b90008b49..694d7c8f68 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs @@ -1,11 +1,13 @@ use crate::drive::verify::RootHash; use dpp::identifier::Identifier; +use dpp::serialization::PlatformDeserializable; use grovedb::{Element, GroveDb}; use crate::error::Error; use crate::drive::votes::paths::{ - RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8, RESOURCE_LOCK_VOTE_TREE_KEY_U8, + RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8, RESOURCE_FINISHED_INFO_KEY_U8, + RESOURCE_LOCK_VOTE_TREE_KEY_U8, }; use crate::error::drive::DriveError; use crate::query::vote_poll_vote_state_query::{ @@ -14,6 +16,8 @@ use crate::query::vote_poll_vote_state_query::{ }; use dpp::version::PlatformVersion; use dpp::voting::contender_structs::ContenderWithSerializedDocument; +use dpp::voting::vote_outcomes::finalized_contested_document_vote_poll_stored_info::FinalizedContestedDocumentVotePollStoredInfo; +use dpp::voting::vote_outcomes::finalized_contested_document_vote_poll_stored_info::FinalizedContestedDocumentVotePollStoredInfoV0Getters; impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { /// Verifies a proof for a collection of documents. @@ -99,29 +103,59 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { let mut contenders = Vec::new(); let mut locked_vote_tally: Option = None; let mut abstaining_vote_tally: Option = None; + let mut winner = None; for (_, key, vote_tally) in proved_key_values.into_iter() { let Some(vote_tally) = vote_tally else { continue; }; - let sum_tree_value = vote_tally.into_sum_tree_value()?; - if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { - return Err(Error::Drive(DriveError::CorruptedDriveState(format!( - "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", - sum_tree_value - )))); - } match key.get(0) { Some(key) if key == &RESOURCE_LOCK_VOTE_TREE_KEY_U8 => { + let sum_tree_value = vote_tally.into_sum_tree_value()?; + if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!( + "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", + sum_tree_value + )))); + } locked_vote_tally = Some(sum_tree_value as u32); } - Some(key) => { - if key == &RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8 { - abstaining_vote_tally = Some(sum_tree_value as u32); + Some(key) if key == &RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8 => { + let sum_tree_value = vote_tally.into_sum_tree_value()?; + if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!( + "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", + sum_tree_value + )))); } + abstaining_vote_tally = Some(sum_tree_value as u32); + } + Some(key) if key == &RESOURCE_FINISHED_INFO_KEY_U8 => { + // The vote is actually over, let's deserialize the info + let finalized_contested_document_vote_poll_stored_info = FinalizedContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&vote_tally.into_item_bytes()?)?; + locked_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info.locked_votes(), + ); + abstaining_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info.abstain_votes(), + ); + winner = Some(( + *finalized_contested_document_vote_poll_stored_info.winner(), + *finalized_contested_document_vote_poll_stored_info + .finalization_block(), + )); + contenders = finalized_contested_document_vote_poll_stored_info + .contender_votes_in_vec_of_contender_with_serialized_document(); } _ => { + let sum_tree_value = vote_tally.into_sum_tree_value()?; + if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!( + "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", + sum_tree_value + )))); + } let identity_id = Identifier::try_from(key)?; contenders.push(ContenderWithSerializedDocument { identity_id, @@ -137,7 +171,7 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { contenders, locked_vote_tally, abstaining_vote_tally, - winner: None, + winner, skipped: 0, }, )) @@ -147,6 +181,7 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { let mut contenders = vec![]; let mut locked_vote_tally: Option = None; let mut abstaining_vote_tally: Option = None; + let mut winner = None; if self.order_ascending { // Handle ascending order @@ -184,7 +219,7 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { } } } - Element::Item(serialized_document, _) => { + Element::Item(serialized_item_info, _) => { // We should find a sum tree paired with this document if let Some(( path_tally, @@ -206,15 +241,28 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { let identity_id = Identifier::from_bytes(identity_bytes)?; let contender = ContenderWithSerializedDocument { identity_id, - serialized_document: Some(serialized_document), + serialized_document: Some(serialized_item_info), vote_tally: Some(sum_tree_value as u32), }; contenders.push(contender); } else { - return Err(Error::Drive(DriveError::CorruptedDriveState( - "expected a sum tree element after item element" - .to_string(), - ))); + // The vote is actually over, let's deserialize the info + let finalized_contested_document_vote_poll_stored_info = FinalizedContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&serialized_item_info)?; + locked_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .locked_votes(), + ); + abstaining_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .abstain_votes(), + ); + winner = Some(( + *finalized_contested_document_vote_poll_stored_info + .winner(), + *finalized_contested_document_vote_poll_stored_info + .finalization_block(), + )); + contenders = finalized_contested_document_vote_poll_stored_info.contender_votes_in_vec_of_contender_with_serialized_document(); } } _ => { @@ -260,7 +308,7 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { } } } - Element::Item(serialized_document, _) => { + Element::Item(serialized_item_info, _) => { if let Some(( prev_path, sum_tree_value, @@ -274,15 +322,28 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { let identity_id = Identifier::from_bytes(identity_bytes)?; let contender = ContenderWithSerializedDocument { identity_id, - serialized_document: Some(serialized_document), + serialized_document: Some(serialized_item_info), vote_tally: Some(sum_tree_value as u32), }; contenders.push(contender); } else { - return Err(Error::Drive(DriveError::CorruptedDriveState( - "expected a sum tree element before item element" - .to_string(), - ))); + // The vote is actually over, let's deserialize the info + let finalized_contested_document_vote_poll_stored_info = FinalizedContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&serialized_item_info)?; + locked_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .locked_votes(), + ); + abstaining_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .abstain_votes(), + ); + winner = Some(( + *finalized_contested_document_vote_poll_stored_info + .winner(), + *finalized_contested_document_vote_poll_stored_info + .finalization_block(), + )); + contenders = finalized_contested_document_vote_poll_stored_info.contender_votes_in_vec_of_contender_with_serialized_document(); } } _ => { @@ -300,7 +361,7 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { contenders, locked_vote_tally, abstaining_vote_tally, - winner: None, + winner, skipped: 0, }, )) diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index 4a6af31650..51ebdab457 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -1,6 +1,7 @@ use crate::drive::votes::paths::{ VotePollPaths, RESOURCE_ABSTAIN_VOTE_TREE_KEY, RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8, - RESOURCE_LOCK_VOTE_TREE_KEY, RESOURCE_LOCK_VOTE_TREE_KEY_U8, + RESOURCE_FINISHED_INFO_KEY, RESOURCE_FINISHED_INFO_KEY_U8, RESOURCE_LOCK_VOTE_TREE_KEY, + RESOURCE_LOCK_VOTE_TREE_KEY_U8, }; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; @@ -20,11 +21,16 @@ use dpp::data_contract::DataContract; use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use dpp::document::Document; use dpp::identifier::Identifier; +use dpp::serialization::PlatformDeserializable; use dpp::voting::contender_structs::{ ContenderWithSerializedDocument, FinalizedContenderWithSerializedDocument, FinalizedResourceVoteChoicesWithVoterInfo, }; use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; +use dpp::voting::vote_outcomes::finalized_contested_document_vote_poll_stored_info::{ + FinalizedContestedDocumentVotePollStoredInfo, + FinalizedContestedDocumentVotePollStoredInfoV0Getters, +}; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; #[cfg(feature = "server")] use grovedb::query_result_type::{QueryResultElements, QueryResultType}; @@ -124,7 +130,7 @@ pub struct ContestedDocumentVotePollDriveQueryExecutionResult { /// Abstaining tally pub abstaining_vote_tally: Option, /// Finalization info - pub winner: Option, + pub winner: Option<(ContestedDocumentVotePollWinnerInfo, BlockInfo)>, /// The number of skipped items when an offset is given. pub skipped: u16, } @@ -495,26 +501,59 @@ impl ContestedDocumentVotePollDriveQuery { let mut contenders = Vec::new(); let mut locked_vote_tally: Option = None; let mut abstaining_vote_tally: Option = None; + let mut winner = None; for (key, vote_tally) in query_result_elements.to_key_elements().into_iter() { - let sum_tree_value = vote_tally.into_sum_tree_value()?; - if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { - return Err(Error::Drive(DriveError::CorruptedDriveState(format!( - "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", - sum_tree_value - )))); - } - match key.get(0) { Some(key) if key == &RESOURCE_LOCK_VOTE_TREE_KEY_U8 => { + let sum_tree_value = vote_tally.into_sum_tree_value()?; + if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!( + "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", + sum_tree_value + )))); + } locked_vote_tally = Some(sum_tree_value as u32); } Some(key) if key == &RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8 => { + let sum_tree_value = vote_tally.into_sum_tree_value()?; + if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!( + "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", + sum_tree_value + )))); + } abstaining_vote_tally = Some(sum_tree_value as u32); } + Some(key) if key == &RESOURCE_FINISHED_INFO_KEY_U8 => { + // The vote is actually over, let's deserialize the info + let finalized_contested_document_vote_poll_stored_info = FinalizedContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&vote_tally.into_item_bytes()?)?; + locked_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .locked_votes(), + ); + abstaining_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .abstain_votes(), + ); + winner = Some(( + *finalized_contested_document_vote_poll_stored_info + .winner(), + *finalized_contested_document_vote_poll_stored_info + .finalization_block(), + )); + contenders = finalized_contested_document_vote_poll_stored_info.contender_votes_in_vec_of_contender_with_serialized_document(); + } _ => { + let sum_tree_value = vote_tally.into_sum_tree_value()?; + if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!( + "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", + sum_tree_value + )))); + } let identity_id = Identifier::try_from(key)?; contenders.push(ContenderWithSerializedDocument { identity_id, @@ -528,7 +567,7 @@ impl ContestedDocumentVotePollDriveQuery { contenders, locked_vote_tally, abstaining_vote_tally, - winner: None, + winner, skipped, }) } @@ -538,6 +577,7 @@ impl ContestedDocumentVotePollDriveQuery { let mut contenders = vec![]; let mut locked_vote_tally: Option = None; let mut abstaining_vote_tally: Option = None; + let mut winner = None; if order_ascending { // Handle ascending order @@ -576,7 +616,7 @@ impl ContestedDocumentVotePollDriveQuery { } } } - Element::Item(serialized_document, _) => { + Element::Item(serialized_item_info, _) => { // We should find a sum tree paired with this document if let Some(( path_tally, @@ -601,12 +641,28 @@ impl ContestedDocumentVotePollDriveQuery { Identifier::from_bytes(identity_bytes)?; let contender = ContenderWithSerializedDocument { identity_id, - serialized_document: Some(serialized_document), + serialized_document: Some(serialized_item_info), vote_tally: Some(sum_tree_value as u32), }; contenders.push(contender); } else { - return Err(Error::Drive(DriveError::CorruptedDriveState("expected a sum tree element after item element".to_string()))); + // The vote is actually over, let's deserialize the info + let finalized_contested_document_vote_poll_stored_info = FinalizedContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&serialized_item_info)?; + locked_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .locked_votes(), + ); + abstaining_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .abstain_votes(), + ); + winner = Some(( + *finalized_contested_document_vote_poll_stored_info + .winner(), + *finalized_contested_document_vote_poll_stored_info + .finalization_block(), + )); + contenders = finalized_contested_document_vote_poll_stored_info.contender_votes_in_vec_of_contender_with_serialized_document(); } } _ => { @@ -651,7 +707,7 @@ impl ContestedDocumentVotePollDriveQuery { } } } - Element::Item(serialized_document, _) => { + Element::Item(serialized_item_info, _) => { if let Some(( prev_path, sum_tree_value, @@ -666,12 +722,28 @@ impl ContestedDocumentVotePollDriveQuery { Identifier::from_bytes(identity_bytes)?; let contender = ContenderWithSerializedDocument { identity_id, - serialized_document: Some(serialized_document), + serialized_document: Some(serialized_item_info), vote_tally: Some(sum_tree_value as u32), }; contenders.push(contender); } else { - return Err(Error::Drive(DriveError::CorruptedDriveState("expected a sum tree element before item element".to_string()))); + // The vote is actually over, let's deserialize the info + let finalized_contested_document_vote_poll_stored_info = FinalizedContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&serialized_item_info)?; + locked_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .locked_votes(), + ); + abstaining_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .abstain_votes(), + ); + winner = Some(( + *finalized_contested_document_vote_poll_stored_info + .winner(), + *finalized_contested_document_vote_poll_stored_info + .finalization_block(), + )); + contenders = finalized_contested_document_vote_poll_stored_info.contender_votes_in_vec_of_contender_with_serialized_document(); } } _ => { @@ -687,7 +759,7 @@ impl ContestedDocumentVotePollDriveQuery { contenders, locked_vote_tally, abstaining_vote_tally, - winner: None, + winner, skipped, }) } From 01d29e0b759e288a877066e8e268f723e56e11df Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sat, 8 Jun 2024 19:53:45 +0300 Subject: [PATCH 120/135] more work --- .../state_transitions/masternode_vote/mod.rs | 140 +++++++++++++----- 1 file changed, 101 insertions(+), 39 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 9c320ae5e9..74d89da8b5 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -194,6 +194,7 @@ mod tests { use assert_matches::assert_matches; use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::get_contested_resource_vote_state_response_v0::{finished_vote_info, FinishedVoteInfo}; use dpp::voting::contender_structs::Contender; + use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType; use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult::SuccessfulExecution; use super::*; @@ -1005,7 +1006,12 @@ mod tests { >, result_type: ResultType, platform_version: &PlatformVersion, - ) -> (Vec, Option, Option) { + ) -> ( + Vec, + Option, + Option, + Option<(ContestedDocumentVotePollWinnerInfo, BlockInfo)>, + ) { // Now let's run a query for the vote totals let domain = dpns_contract @@ -1092,6 +1098,7 @@ mod tests { let lock_vote_tally = result.locked_vote_tally; let contenders = result.contenders; + let finished_vote_info = result.winner; ( contenders .into_iter() @@ -1110,6 +1117,7 @@ mod tests { .collect(), abstaining_vote_tally, lock_vote_tally, + finished_vote_info, ) } @@ -1420,7 +1428,7 @@ mod tests { platform_version, ); - let (contenders, abstaining, locking) = get_proved_vote_states( + let (contenders, abstaining, locking, finished_info) = get_proved_vote_states( &platform, &platform_state, &dpns_contract, @@ -1433,6 +1441,8 @@ mod tests { platform_version, ); + assert_eq!(finished_info, None); + assert_eq!(contenders.len(), 2); let first_contender = contenders.first().unwrap(); @@ -1589,7 +1599,7 @@ mod tests { platform_version, ); - let (contenders, abstaining, locking) = get_proved_vote_states( + let (contenders, abstaining, locking, finished_info) = get_proved_vote_states( &platform, &platform_state, &dpns_contract, @@ -1602,6 +1612,8 @@ mod tests { platform_version, ); + assert_eq!(finished_info, None); + assert_eq!(contenders.len(), 2); let first_contender = contenders.first().unwrap(); @@ -1624,7 +1636,7 @@ mod tests { // Now let's not include locked and abstaining - let (contenders, abstaining, locking) = get_proved_vote_states( + let (contenders, abstaining, locking, finished_info) = get_proved_vote_states( &platform, &platform_state, &dpns_contract, @@ -1637,6 +1649,8 @@ mod tests { platform_version, ); + assert_eq!(finished_info, None); + assert_eq!(contenders.len(), 2); let first_contender = contenders.first().unwrap(); @@ -4423,53 +4437,101 @@ mod tests { // At this point the document should have been awarded to contender 1. - let (contenders, abstaining, locking, finished_vote_info) = get_vote_states( - &platform, - &platform_state, - &dpns_contract, - "quantum", - None, - true, - true, - None, - ResultType::DocumentsAndVoteTally, - platform_version, - ); + { + let (contenders, abstaining, locking, finished_vote_info) = get_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); - assert_eq!( - finished_vote_info, - Some(FinishedVoteInfo { - finished_vote_outcome: - finished_vote_info::FinishedVoteOutcome::TowardsIdentity as i32, - won_by_identity_id: Some(contender_1.id().to_vec()), - finished_at_block_height: 10000, - finished_at_core_block_height: 42, - finished_at_block_time_ms: 1209900000, - finished_at_epoch: 0 - }) - ); + assert_eq!( + finished_vote_info, + Some(FinishedVoteInfo { + finished_vote_outcome: + finished_vote_info::FinishedVoteOutcome::TowardsIdentity as i32, + won_by_identity_id: Some(contender_1.id().to_vec()), + finished_at_block_height: 10000, + finished_at_core_block_height: 42, + finished_at_block_time_ms: 1209900000, + finished_at_epoch: 0 + }) + ); - assert_eq!(contenders.len(), 2); + assert_eq!(contenders.len(), 2); - let first_contender = contenders.first().unwrap(); + let first_contender = contenders.first().unwrap(); - let second_contender = contenders.last().unwrap(); + let second_contender = contenders.last().unwrap(); - assert_eq!(first_contender.document, None); + assert_eq!(first_contender.document, None); - assert_eq!(second_contender.document, None); + assert_eq!(second_contender.document, None); - assert_eq!(first_contender.identity_id, contender_1.id()); + assert_eq!(first_contender.identity_id, contender_1.id()); - assert_eq!(second_contender.identity_id, contender_2.id()); + assert_eq!(second_contender.identity_id, contender_2.id()); - assert_eq!(first_contender.vote_tally, Some(50)); + assert_eq!(first_contender.vote_tally, Some(50)); - assert_eq!(second_contender.vote_tally, Some(5)); + assert_eq!(second_contender.vote_tally, Some(5)); - assert_eq!(abstaining, Some(10)); + assert_eq!(abstaining, Some(10)); - assert_eq!(locking, Some(3)); + assert_eq!(locking, Some(3)); + } + + { + let (contenders, abstaining, locking, finished_vote_info) = + get_proved_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); + + assert_eq!( + finished_vote_info, + Some(( + ContestedDocumentVotePollWinnerInfo::WonByIdentity(contender_1.id()), + block_info + )) + ); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + assert_eq!(first_contender.document, None); + + assert_eq!(second_contender.document, None); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(50)); + + assert_eq!(second_contender.vote_tally, Some(5)); + + assert_eq!(abstaining, Some(10)); + + assert_eq!(locking, Some(3)); + } } } } From c7072e3c03fc7b4b2a5e91e3462531ae4bf9c8ad Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sat, 8 Jun 2024 20:15:44 +0300 Subject: [PATCH 121/135] locking test --- .../state_transitions/masternode_vote/mod.rs | 222 +++++++++++++++++- 1 file changed, 215 insertions(+), 7 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 74d89da8b5..c7b9b96f32 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -1123,6 +1123,7 @@ mod tests { mod contests_requests_query { use super::*; + #[test] fn test_not_proved_contests_request() { let platform_version = PlatformVersion::latest(); @@ -2300,13 +2301,13 @@ mod tests { ) = query_validation_result.version.expect("expected a version"); let Some(get_contested_resource_identity_votes_response_v0::Result::Votes( - get_contested_resource_identity_votes_response_v0::ContestedResourceIdentityVotes { - contested_resource_identity_votes, finished_results, - }, - )) = result - else { - panic!("expected contenders") - }; + get_contested_resource_identity_votes_response_v0::ContestedResourceIdentityVotes { + contested_resource_identity_votes, finished_results, + }, + )) = result + else { + panic!("expected contenders") + }; if should_be_finished { assert!(finished_results); } @@ -4221,6 +4222,7 @@ mod tests { assert_eq!(balance_after_55_votes, dash_to_credits!(0.7945)); } + #[test] fn test_proved_prefunded_specialized_balance_request_after_many_votes() { let platform_version = PlatformVersion::latest(); @@ -4327,8 +4329,10 @@ mod tests { assert_eq!(balance_after_55_votes, dash_to_credits!(0.7945)); } } + mod document_distribution { use super::*; + #[test] fn test_document_distribution() { let platform_version = PlatformVersion::latest(); @@ -4533,6 +4537,210 @@ mod tests { assert_eq!(locking, Some(3)); } } + + #[test] + fn test_document_locking() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + perform_votes_multi( + &mut platform, + dpns_contract.as_ref(), + vec![ + (TowardsIdentity(contender_1.id()), 20), + (TowardsIdentity(contender_2.id()), 5), + (ResourceVoteChoice::Abstain, 10), + (ResourceVoteChoice::Lock, 60), + ], + "quantum", + 10, + platform_version, + ); + + let platform_state = platform.state.load(); + + let (contenders, abstaining, locking, finished_vote_info) = get_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); + + assert_eq!(finished_vote_info, None); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + assert_ne!(first_contender.document, second_contender.document); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(20)); + + assert_eq!(second_contender.vote_tally, Some(5)); + + assert_eq!(abstaining, Some(10)); + + assert_eq!(locking, Some(60)); + + let mut platform_state = (**platform_state).clone(); + + let block_info = BlockInfo { + time_ms: 1_209_900_000, //2 weeks and 300s + height: 10000, + core_height: 42, + epoch: Default::default(), + }; + + platform_state.set_last_committed_block_info(Some( + ExtendedBlockInfoV0 { + basic_info: block_info, + app_hash: platform.drive.grove.root_hash(None).unwrap().unwrap(), + quorum_hash: [0u8; 32], + block_id_hash: [0u8; 32], + signature: [0u8; 96], + round: 0, + } + .into(), + )); + + platform.state.store(Arc::new(platform_state)); + + let platform_state = platform.state.load(); + + let transaction = platform.drive.grove.start_transaction(); + + platform + .check_for_ended_vote_polls(&block_info, Some(&transaction), platform_version) + .expect("expected to check for ended vote polls"); + + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit transaction"); + + // At this point the document should have been awarded to contender 1. + { + let (contenders, abstaining, locking, finished_vote_info) = get_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); + + assert_eq!( + finished_vote_info, + Some(FinishedVoteInfo { + finished_vote_outcome: + finished_vote_info::FinishedVoteOutcome::Locked as i32, + won_by_identity_id: None, + finished_at_block_height: 10000, + finished_at_core_block_height: 42, + finished_at_block_time_ms: 1209900000, + finished_at_epoch: 0 + }) + ); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + assert_eq!(first_contender.document, None); + + assert_eq!(second_contender.document, None); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(20)); + + assert_eq!(second_contender.vote_tally, Some(5)); + + assert_eq!(abstaining, Some(10)); + + assert_eq!(locking, Some(60)); + } + + { + let (contenders, abstaining, locking, finished_vote_info) = + get_proved_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); + + assert_eq!( + finished_vote_info, + Some(( + ContestedDocumentVotePollWinnerInfo::Locked, + block_info + )) + ); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + assert_eq!(first_contender.document, None); + + assert_eq!(second_contender.document, None); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(20)); + + assert_eq!(second_contender.vote_tally, Some(5)); + + assert_eq!(abstaining, Some(10)); + + assert_eq!(locking, Some(60)); + } + } } } } From b5b392b60b82e50d2a71250f243949cd19820c3e Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sat, 8 Jun 2024 20:15:52 +0300 Subject: [PATCH 122/135] locking test --- .../state_transitions/masternode_vote/mod.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index c7b9b96f32..7511759bf1 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -4662,8 +4662,8 @@ mod tests { assert_eq!( finished_vote_info, Some(FinishedVoteInfo { - finished_vote_outcome: - finished_vote_info::FinishedVoteOutcome::Locked as i32, + finished_vote_outcome: finished_vote_info::FinishedVoteOutcome::Locked + as i32, won_by_identity_id: None, finished_at_block_height: 10000, finished_at_core_block_height: 42, @@ -4712,10 +4712,7 @@ mod tests { assert_eq!( finished_vote_info, - Some(( - ContestedDocumentVotePollWinnerInfo::Locked, - block_info - )) + Some((ContestedDocumentVotePollWinnerInfo::Locked, block_info)) ); assert_eq!(contenders.len(), 2); From 83c23cef9558eeb376f8f175d3b60e8333824fc7 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 9 Jun 2024 03:20:28 +0300 Subject: [PATCH 123/135] more work --- .../state_transitions/documents_batch/mod.rs | 64 + .../state_transitions/masternode_vote/mod.rs | 975 +-------------- .../state_transition/state_transitions/mod.rs | 1046 ++++++++++++++++- 3 files changed, 1120 insertions(+), 965 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs index df7829196a..859d0cfaf4 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs @@ -266,21 +266,28 @@ mod tests { use rand::SeedableRng; mod creation_tests { + use std::sync::Arc; use rand::Rng; use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse}; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0::ResultType; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::GetContestedResourceVoteStateRequestV0; use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; + use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::get_contested_resource_vote_state_response_v0::finished_vote_info; + use dpp::block::extended_block_info::v0::ExtendedBlockInfoV0; use super::*; use dpp::data_contract::accessors::v0::DataContractV0Setters; use dpp::data_contract::document_type::restricted_creation::CreationRestrictionMode; use dpp::document::Document; use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use dpp::util::hash::hash_double; + use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; + use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice::TowardsIdentity; use drive::drive::object_size_info::DataContractResolvedInfo; use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; use drive::query::vote_poll_vote_state_query::ResolvedContestedDocumentVotePollDriveQuery; + use crate::execution::validation::state_transition::state_transitions::tests::{create_dpns_name_contest, fast_forward_to_block, get_vote_states, perform_votes_multi}; + use crate::platform_types::platform_state::v0::PlatformStateV0Methods; #[test] fn test_document_creation() { @@ -818,6 +825,63 @@ mod tests { assert_eq!(second_contender.vote_tally, Some(0)); } + #[test] + fn test_that_a_contested_vote_can_not_be_added_to_after_a_week() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + perform_votes_multi( + &mut platform, + dpns_contract.as_ref(), + vec![ + (TowardsIdentity(contender_1.id()), 50), + (TowardsIdentity(contender_2.id()), 5), + (ResourceVoteChoice::Abstain, 10), + (ResourceVoteChoice::Lock, 3), + ], + "quantum", + 10, + platform_version, + ); + + fast_forward_to_block(&platform, 500_000_000, 900); //less than a week + + let platform_state = platform.state.load(); + + let (contender_3, contender_4, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 8, + "quantum", + platform_version, + ); + + fast_forward_to_block(&platform, 1_000_000_000, 900); //more than a week, less than 2 weeks + + let platform_state = platform.state.load(); + + let (contender_5, contender_6, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 9, + "quantum", + platform_version, + ); + //todo() this should fail! + } + #[test] fn test_document_creation_on_restricted_document_type_that_only_allows_contract_owner_to_create( ) { diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 7511759bf1..9d58eab636 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -83,51 +83,31 @@ impl StateTransitionStateValidationV0 for MasternodeVoteTransition { #[cfg(test)] mod tests { - use crate::execution::validation::state_transition::state_transitions::tests::setup_identity; + use drive::query::contested_resource_votes_given_by_identity_query::ContestedResourceVotesGivenByIdentityQuery; use crate::test::helpers::setup::TestPlatformBuilder; use dpp::block::block_info::BlockInfo; use dpp::dash_to_credits; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; - use dpp::data_contract::document_type::random_document::{ - CreateRandomDocument, DocumentFieldFillSize, DocumentFieldFillType, - }; - use dpp::document::{Document, DocumentV0Getters, DocumentV0Setters}; use dpp::identity::accessors::IdentityGettersV0; - use dpp::platform_value::{Bytes32, Value}; - use dpp::serialization::PlatformSerializable; - use dpp::state_transition::documents_batch_transition::methods::v0::DocumentsBatchTransitionMethodsV0; - use dpp::state_transition::documents_batch_transition::DocumentsBatchTransition; + use dpp::platform_value::Value; use platform_version::version::PlatformVersion; - use rand::prelude::StdRng; - use rand::SeedableRng; - use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, get_contested_resources_request, get_contested_resources_response, get_vote_polls_by_end_date_request, get_vote_polls_by_end_date_response, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse, GetVotePollsByEndDateRequest, GetContestedResourcesRequest, GetVotePollsByEndDateResponse}; + use dapi_grpc::platform::v0::{get_contested_resources_request, get_contested_resources_response, get_vote_polls_by_end_date_request, get_vote_polls_by_end_date_response, GetContestedResourcesRequest, GetVotePollsByEndDateRequest, GetVotePollsByEndDateResponse}; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0::ResultType; - use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::GetContestedResourceVoteStateRequestV0; - use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; use dapi_grpc::platform::v0::get_vote_polls_by_end_date_request::GetVotePollsByEndDateRequestV0; use dapi_grpc::platform::v0::get_vote_polls_by_end_date_response::{get_vote_polls_by_end_date_response_v0, GetVotePollsByEndDateResponseV0}; use dapi_grpc::platform::v0::get_vote_polls_by_end_date_response::get_vote_polls_by_end_date_response_v0::SerializedVotePollsByTimestamp; - use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice::TowardsIdentity; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::voting::vote_polls::VotePoll; use dpp::voting::votes::resource_vote::ResourceVote; use dpp::voting::votes::resource_vote::v0::ResourceVoteV0; - use dpp::voting::votes::Vote; use drive::drive::object_size_info::DataContractResolvedInfo; use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; - use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; - use drive::query::vote_poll_vote_state_query::ResolvedContestedDocumentVotePollDriveQuery; - use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; use dpp::identifier::Identifier; - use dpp::identity::{IdentityPublicKey, IdentityV0}; - use dpp::prelude::{DataContract, Identity}; - use dpp::state_transition::masternode_vote_transition::methods::MasternodeVoteTransitionMethodsV0; - use dpp::util::hash::hash_double; + use dpp::prelude::DataContract; use dpp::util::strings::convert_to_homograph_safe_chars; use drive::query::vote_polls_by_document_type_query::ResolvedVotePollsByDocumentTypeQuery; - use simple_signer::signer::SimpleSigner; use crate::platform_types::platform_state::PlatformState; use crate::rpc::core::MockCoreRPCLike; use crate::test::helpers::setup::TempPlatform; @@ -141,7 +121,6 @@ mod tests { use dapi_grpc::platform::v0::get_prefunded_specialized_balance_request::GetPrefundedSpecializedBalanceRequestV0; use std::collections::BTreeMap; use std::sync::Arc; - use arc_swap::Guard; use rand::Rng; use dapi_grpc::platform::v0::get_contested_resources_request::GetContestedResourcesRequestV0; use dapi_grpc::platform::v0::get_contested_resources_response::{get_contested_resources_response_v0, GetContestedResourcesResponseV0}; @@ -174,14 +153,7 @@ mod tests { use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice::Lock; use drive::drive::votes::storage_form::contested_document_resource_storage_form::ContestedDocumentResourceVoteStorageForm; use crate::error::Error; - use dashcore_rpc::dashcore_rpc_json::{DMNState, MasternodeListItem, MasternodeType}; - use dpp::dashcore::hashes::Hash; - use dpp::dashcore::{ProTxHash, Txid}; - use dpp::prelude::IdentityNonce; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; - use std::net::{IpAddr, Ipv4Addr, SocketAddr}; - use std::ops::Deref; - use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0; use dapi_grpc::platform::v0::get_prefunded_specialized_balance_response; use dapi_grpc::platform::v0::get_prefunded_specialized_balance_response::{ get_prefunded_specialized_balance_response_v0, @@ -189,939 +161,16 @@ mod tests { }; use dpp::fee::Credits; use drive::drive::Drive; - + use crate::execution::validation::state_transition::state_transitions::tests::{create_dpns_name_contest, verify_dpns_name_contest, perform_vote, setup_masternode_identity, get_proved_vote_states, get_vote_states, perform_votes_multi}; + use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::get_contested_resource_vote_state_response_v0::{finished_vote_info, FinishedVoteInfo}; + use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; + use dapi_grpc::platform::v0::get_vote_polls_by_end_date_request::get_vote_polls_by_end_date_request_v0; mod vote_tests { - use assert_matches::assert_matches; - use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::get_contested_resource_vote_state_response_v0::{finished_vote_info, FinishedVoteInfo}; - use dpp::voting::contender_structs::Contender; - use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; - use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType; - use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult::SuccessfulExecution; - use super::*; - - fn setup_masternode_identity( - platform: &mut TempPlatform, - seed: u64, - platform_version: &PlatformVersion, - ) -> (Identity, SimpleSigner, IdentityPublicKey) { - let mut signer = SimpleSigner::default(); - - let mut rng = StdRng::seed_from_u64(seed); - - let (voting_key, voting_private_key) = - IdentityPublicKey::random_voting_key_with_rng(0, &mut rng, platform_version) - .expect("expected to get key pair"); - - signer.add_key(voting_key.clone(), voting_private_key.clone()); - - let identity: Identity = IdentityV0 { - id: Identifier::random_with_rng(&mut rng), - public_keys: BTreeMap::from([(0, voting_key.clone())]), - balance: 0, - revision: 0, - } - .into(); - - // We just add this identity to the system first - - platform - .drive - .add_new_identity( - identity.clone(), - true, - &BlockInfo::default(), - true, - None, - platform_version, - ) - .expect("expected to add a new identity"); - - let mut platform_state = platform.state.load().clone().deref().clone(); - - let pro_tx_hash = ProTxHash::from_byte_array(identity.id().to_buffer()); - - let random_ip = Ipv4Addr::new( - rng.gen_range(0..255), - rng.gen_range(0..255), - rng.gen_range(0..255), - rng.gen_range(0..255), - ); - - platform_state.full_masternode_list_mut().insert( - pro_tx_hash, - MasternodeListItem { - node_type: MasternodeType::Regular, - pro_tx_hash, - collateral_hash: Txid::from_byte_array(rng.gen()), - collateral_index: 0, - collateral_address: rng.gen(), - operator_reward: 0.0, - state: DMNState { - service: SocketAddr::new(IpAddr::V4(random_ip), 19999), - registered_height: 0, - pose_revived_height: None, - pose_ban_height: None, - revocation_reason: 0, - owner_address: rng.gen(), - voting_address: rng.gen(), - payout_address: rng.gen(), - pub_key_operator: vec![], - operator_payout_address: None, - platform_node_id: None, - platform_p2p_port: None, - platform_http_port: None, - }, - }, - ); - - platform.state.store(Arc::new(platform_state)); - - (identity, signer, voting_key) - } - - fn create_dpns_name_contest( - platform: &mut TempPlatform, - platform_state: &PlatformState, - seed: u64, - name: &str, - platform_version: &PlatformVersion, - ) -> (Identity, Identity, Arc) { - let mut rng = StdRng::seed_from_u64(seed); - - let (identity_1, signer_1, key_1) = - setup_identity(platform, rng.gen(), dash_to_credits!(0.5)); - - let (identity_2, signer_2, key_2) = - setup_identity(platform, rng.gen(), dash_to_credits!(0.5)); - - // Flip them if needed so identity 1 id is always smaller than identity 2 id - let (identity_1, identity_2, signer_1, signer_2, key_1, key_2) = - if identity_1.id() < identity_2.id() { - (identity_1, identity_2, signer_1, signer_2, key_1, key_2) - } else { - (identity_2, identity_1, signer_2, signer_1, key_2, key_1) - }; - - let dpns = platform.drive.cache.system_data_contracts.load_dpns(); - let dpns_contract = dpns.clone(); - - let preorder = dpns_contract - .document_type_for_name("preorder") - .expect("expected a profile document type"); - - assert!(!preorder.documents_mutable()); - assert!(preorder.documents_can_be_deleted()); - assert!(!preorder.documents_transferable().is_transferable()); - - let domain = dpns_contract - .document_type_for_name("domain") - .expect("expected a profile document type"); - - assert!(!domain.documents_mutable()); - assert!(!domain.documents_can_be_deleted()); - assert!(!domain.documents_transferable().is_transferable()); - - let entropy = Bytes32::random_with_rng(&mut rng); - - let mut preorder_document_1 = preorder - .random_document_with_identifier_and_entropy( - &mut rng, - identity_1.id(), - entropy, - DocumentFieldFillType::FillIfNotRequired, - DocumentFieldFillSize::AnyDocumentFillSize, - platform_version, - ) - .expect("expected a random document"); - - let mut preorder_document_2 = preorder - .random_document_with_identifier_and_entropy( - &mut rng, - identity_2.id(), - entropy, - DocumentFieldFillType::FillIfNotRequired, - DocumentFieldFillSize::AnyDocumentFillSize, - platform_version, - ) - .expect("expected a random document"); - - let mut document_1 = domain - .random_document_with_identifier_and_entropy( - &mut rng, - identity_1.id(), - entropy, - DocumentFieldFillType::FillIfNotRequired, - DocumentFieldFillSize::AnyDocumentFillSize, - platform_version, - ) - .expect("expected a random document"); - - let mut document_2 = domain - .random_document_with_identifier_and_entropy( - &mut rng, - identity_2.id(), - entropy, - DocumentFieldFillType::FillIfNotRequired, - DocumentFieldFillSize::AnyDocumentFillSize, - platform_version, - ) - .expect("expected a random document"); - - document_1.set("parentDomainName", "dash".into()); - document_1.set("normalizedParentDomainName", "dash".into()); - document_1.set("label", name.into()); - document_1.set( - "normalizedLabel", - convert_to_homograph_safe_chars(name).into(), - ); - document_1.set("records.dashUniqueIdentityId", document_1.owner_id().into()); - document_1.set("subdomainRules.allowSubdomains", false.into()); - - document_2.set("parentDomainName", "dash".into()); - document_2.set("normalizedParentDomainName", "dash".into()); - document_2.set("label", name.into()); - document_2.set( - "normalizedLabel", - convert_to_homograph_safe_chars(name).into(), - ); - document_2.set("records.dashUniqueIdentityId", document_2.owner_id().into()); - document_2.set("subdomainRules.allowSubdomains", false.into()); - - let salt_1: [u8; 32] = rng.gen(); - let salt_2: [u8; 32] = rng.gen(); - - let mut salted_domain_buffer_1: Vec = vec![]; - salted_domain_buffer_1.extend(salt_1); - salted_domain_buffer_1 - .extend((convert_to_homograph_safe_chars(name) + ".dash").as_bytes()); - - let salted_domain_hash_1 = hash_double(salted_domain_buffer_1); - - let mut salted_domain_buffer_2: Vec = vec![]; - salted_domain_buffer_2.extend(salt_2); - salted_domain_buffer_2 - .extend((convert_to_homograph_safe_chars(name) + ".dash").as_bytes()); - - let salted_domain_hash_2 = hash_double(salted_domain_buffer_2); - - preorder_document_1.set("saltedDomainHash", salted_domain_hash_1.into()); - preorder_document_2.set("saltedDomainHash", salted_domain_hash_2.into()); - - document_1.set("preorderSalt", salt_1.into()); - document_2.set("preorderSalt", salt_2.into()); - - let documents_batch_create_preorder_transition_1 = - DocumentsBatchTransition::new_document_creation_transition_from_document( - preorder_document_1, - preorder, - entropy.0, - &key_1, - 2, - 0, - &signer_1, - platform_version, - None, - None, - None, - ) - .expect("expect to create documents batch transition"); - - let documents_batch_create_serialized_preorder_transition_1 = - documents_batch_create_preorder_transition_1 - .serialize_to_bytes() - .expect("expected documents batch serialized state transition"); - - let documents_batch_create_preorder_transition_2 = - DocumentsBatchTransition::new_document_creation_transition_from_document( - preorder_document_2, - preorder, - entropy.0, - &key_2, - 2, - 0, - &signer_2, - platform_version, - None, - None, - None, - ) - .expect("expect to create documents batch transition"); - - let documents_batch_create_serialized_preorder_transition_2 = - documents_batch_create_preorder_transition_2 - .serialize_to_bytes() - .expect("expected documents batch serialized state transition"); - - let documents_batch_create_transition_1 = - DocumentsBatchTransition::new_document_creation_transition_from_document( - document_1, - domain, - entropy.0, - &key_1, - 3, - 0, - &signer_1, - platform_version, - None, - None, - None, - ) - .expect("expect to create documents batch transition"); - - let documents_batch_create_serialized_transition_1 = - documents_batch_create_transition_1 - .serialize_to_bytes() - .expect("expected documents batch serialized state transition"); - - let documents_batch_create_transition_2 = - DocumentsBatchTransition::new_document_creation_transition_from_document( - document_2, - domain, - entropy.0, - &key_2, - 3, - 0, - &signer_2, - platform_version, - None, - None, - None, - ) - .expect("expect to create documents batch transition"); - - let documents_batch_create_serialized_transition_2 = - documents_batch_create_transition_2 - .serialize_to_bytes() - .expect("expected documents batch serialized state transition"); - - let transaction = platform.drive.grove.start_transaction(); - - 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(), - ], - platform_state, - &BlockInfo::default_with_time( - platform_state - .last_committed_block_time_ms() - .unwrap_or_default() - + 3000, - ), - &transaction, - platform_version, - ) - .expect("expected to process state transition"); - - platform - .drive - .grove - .commit_transaction(transaction) - .unwrap() - .expect("expected to commit transaction"); - - assert_eq!(processing_result.valid_count(), 2); - - let transaction = platform.drive.grove.start_transaction(); - - let processing_result = platform - .platform - .process_raw_state_transitions( - &vec![ - documents_batch_create_serialized_transition_1.clone(), - documents_batch_create_serialized_transition_2.clone(), - ], - platform_state, - &BlockInfo::default_with_time( - platform_state - .last_committed_block_time_ms() - .unwrap_or_default() - + 3000, - ), - &transaction, - platform_version, - ) - .expect("expected to process state transition"); - - platform - .drive - .grove - .commit_transaction(transaction) - .unwrap() - .expect("expected to commit transaction"); - - assert_eq!(processing_result.valid_count(), 2); - (identity_1, identity_2, dpns_contract) - } - fn verify_dpns_name_contest( - platform: &mut TempPlatform, - platform_state: &Guard>, - dpns_contract: &DataContract, - identity_1: &Identity, - identity_2: &Identity, - name: &str, - platform_version: &PlatformVersion, - ) { - // Now let's run a query for the vote totals - - let domain = dpns_contract - .document_type_for_name("domain") - .expect("expected a profile document type"); - - let config = bincode::config::standard() - .with_big_endian() - .with_no_limit(); - - let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) - .expect("expected to encode the word dash"); - - let quantum_encoded = - bincode::encode_to_vec(Value::Text(convert_to_homograph_safe_chars(name)), config) - .expect("expected to encode the word quantum"); - - let index_name = "parentNameAndLabel".to_string(); - - let query_validation_result = platform - .query_contested_resource_vote_state( - GetContestedResourceVoteStateRequest { - version: Some(get_contested_resource_vote_state_request::Version::V0( - GetContestedResourceVoteStateRequestV0 { - contract_id: dpns_contract.id().to_vec(), - document_type_name: domain.name().clone(), - index_name: index_name.clone(), - index_values: vec![dash_encoded.clone(), quantum_encoded.clone()], - result_type: ResultType::DocumentsAndVoteTally as i32, - allow_include_locked_and_abstaining_vote_tally: true, - start_at_identifier_info: None, - count: None, - order_ascending: true, - prove: false, - }, - )), - }, - platform_state, - platform_version, - ) - .expect("expected to execute query") - .into_data() - .expect("expected query to be valid"); - - let get_contested_resource_vote_state_response::Version::V0( - GetContestedResourceVoteStateResponseV0 { - metadata: _, - result, - }, - ) = query_validation_result.version.expect("expected a version"); - - let Some( - get_contested_resource_vote_state_response_v0::Result::ContestedResourceContenders( - get_contested_resource_vote_state_response_v0::ContestedResourceContenders { - contenders, - .. - }, - ), - ) = result - else { - panic!("expected contenders") - }; - - assert_eq!(contenders.len(), 2); - - let first_contender = contenders.first().unwrap(); - - let second_contender = contenders.last().unwrap(); - - let first_contender_document = Document::from_bytes( - first_contender - .document - .as_ref() - .expect("expected a document") - .as_slice(), - domain, - platform_version, - ) - .expect("expected to get document"); - - let second_contender_document = Document::from_bytes( - second_contender - .document - .as_ref() - .expect("expected a document") - .as_slice(), - domain, - platform_version, - ) - .expect("expected to get document"); - - assert_ne!(first_contender_document, second_contender_document); - - assert_eq!(first_contender.identifier, identity_1.id().to_vec()); - - assert_eq!(second_contender.identifier, identity_2.id().to_vec()); - - assert_eq!(first_contender.vote_count, Some(0)); - - assert_eq!(second_contender.vote_count, Some(0)); - - let GetContestedResourceVoteStateResponse { version } = platform - .query_contested_resource_vote_state( - GetContestedResourceVoteStateRequest { - version: Some(get_contested_resource_vote_state_request::Version::V0( - GetContestedResourceVoteStateRequestV0 { - contract_id: dpns_contract.id().to_vec(), - document_type_name: domain.name().clone(), - index_name: "parentNameAndLabel".to_string(), - index_values: vec![dash_encoded, quantum_encoded], - result_type: ResultType::DocumentsAndVoteTally as i32, - allow_include_locked_and_abstaining_vote_tally: true, - start_at_identifier_info: None, - count: None, - order_ascending: true, - prove: true, - }, - )), - }, - platform_state, - platform_version, - ) - .expect("expected to execute query") - .into_data() - .expect("expected query to be valid"); - - let get_contested_resource_vote_state_response::Version::V0( - GetContestedResourceVoteStateResponseV0 { - metadata: _, - result, - }, - ) = version.expect("expected a version"); - - let Some(get_contested_resource_vote_state_response_v0::Result::Proof(proof)) = result - else { - panic!("expected contenders") - }; - - let resolved_contested_document_vote_poll_drive_query = - ResolvedContestedDocumentVotePollDriveQuery { - vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { - contract: DataContractResolvedInfo::BorrowedDataContract(dpns_contract), - document_type_name: domain.name().clone(), - index_name: index_name.clone(), - index_values: vec![ - Value::Text("dash".to_string()), - Value::Text(convert_to_homograph_safe_chars(name)), - ], - }, - result_type: DocumentsAndVoteTally, - offset: None, - limit: None, - start_at: None, - order_ascending: true, - allow_include_locked_and_abstaining_vote_tally: true, - }; - - let (_, result) = resolved_contested_document_vote_poll_drive_query - .verify_vote_poll_vote_state_proof(proof.grovedb_proof.as_ref(), platform_version) - .expect("expected to verify proof"); - - let contenders = result.contenders; - - assert_eq!(contenders.len(), 2); - - let first_contender = contenders.first().unwrap(); - - let second_contender = contenders.last().unwrap(); - - let first_contender_document = Document::from_bytes( - first_contender - .serialized_document - .as_ref() - .expect("expected a document") - .as_slice(), - domain, - platform_version, - ) - .expect("expected to get document"); - - let second_contender_document = Document::from_bytes( - second_contender - .serialized_document - .as_ref() - .expect("expected a document") - .as_slice(), - domain, - platform_version, - ) - .expect("expected to get document"); - - assert_ne!(first_contender_document, second_contender_document); - - assert_eq!(first_contender.identity_id, identity_1.id()); - - assert_eq!(second_contender.identity_id, identity_2.id()); - - assert_eq!(first_contender.vote_tally, Some(0)); - - assert_eq!(second_contender.vote_tally, Some(0)); - } - - fn perform_vote( - platform: &mut TempPlatform, - platform_state: &Guard>, - dpns_contract: &DataContract, - resource_vote_choice: ResourceVoteChoice, - name: &str, - signer: &SimpleSigner, - masternode_id: Identifier, - voting_key: &IdentityPublicKey, - nonce: IdentityNonce, - platform_version: &PlatformVersion, - ) { - // Let's vote for contender 1 - - let vote = Vote::ResourceVote(ResourceVote::V0(ResourceVoteV0 { - vote_poll: VotePoll::ContestedDocumentResourceVotePoll( - ContestedDocumentResourceVotePoll { - contract_id: dpns_contract.id(), - document_type_name: "domain".to_string(), - index_name: "parentNameAndLabel".to_string(), - index_values: vec![ - Value::Text("dash".to_string()), - Value::Text(convert_to_homograph_safe_chars(name)), - ], - }, - ), - resource_vote_choice, - })); - - let masternode_vote_transition = MasternodeVoteTransition::try_from_vote_with_signer( - vote, - signer, - masternode_id, - voting_key, - nonce, - platform_version, - None, - ) - .expect("expected to make transition vote"); - - let masternode_vote_serialized_transition = masternode_vote_transition - .serialize_to_bytes() - .expect("expected documents batch serialized state transition"); - - let transaction = platform.drive.grove.start_transaction(); - - let processing_result = platform - .platform - .process_raw_state_transitions( - &vec![masternode_vote_serialized_transition.clone()], - platform_state, - &BlockInfo::default(), - &transaction, - platform_version, - ) - .expect("expected to process state transition"); - - platform - .drive - .grove - .commit_transaction(transaction) - .unwrap() - .expect("expected to commit transaction"); - - let execution_result = processing_result.into_execution_results().remove(0); - assert_matches!(execution_result, SuccessfulExecution(..)); - } - - fn perform_votes( - platform: &mut TempPlatform, - dpns_contract: &DataContract, - resource_vote_choice: ResourceVoteChoice, - name: &str, - count: u64, - start_seed: u64, - platform_version: &PlatformVersion, - ) { - for i in 0..count { - let (masternode, signer, voting_key) = - setup_masternode_identity(platform, start_seed + i, platform_version); - - let platform_state = platform.state.load(); - - perform_vote( - platform, - &platform_state, - dpns_contract, - resource_vote_choice, - name, - &signer, - masternode.id(), - &voting_key, - 1, - platform_version, - ); - } - } - - fn perform_votes_multi( - platform: &mut TempPlatform, - dpns_contract: &DataContract, - resource_vote_choices: Vec<(ResourceVoteChoice, u64)>, - name: &str, - start_seed: u64, - platform_version: &PlatformVersion, - ) { - let mut count_aggregate = start_seed; - for (resource_vote_choice, count) in resource_vote_choices.into_iter() { - perform_votes( - platform, - dpns_contract, - resource_vote_choice, - name, - count, - count_aggregate, - platform_version, - ); - count_aggregate += count; - } - } - - fn get_vote_states( - platform: &TempPlatform, - platform_state: &PlatformState, - dpns_contract: &DataContract, - name: &str, - count: Option, - order_ascending: bool, - allow_include_locked_and_abstaining_vote_tally: bool, - start_at_identifier_info: Option< - get_contested_resource_vote_state_request_v0::StartAtIdentifierInfo, - >, - result_type: ResultType, - platform_version: &PlatformVersion, - ) -> ( - Vec, - Option, - Option, - Option, - ) { - // Now let's run a query for the vote totals - - let domain = dpns_contract - .document_type_for_name("domain") - .expect("expected a profile document type"); - - let config = bincode::config::standard() - .with_big_endian() - .with_no_limit(); - - let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) - .expect("expected to encode the word dash"); - - let quantum_encoded = - bincode::encode_to_vec(Value::Text(convert_to_homograph_safe_chars(name)), config) - .expect("expected to encode the word quantum"); - - let index_name = "parentNameAndLabel".to_string(); - - let query_validation_result = platform - .query_contested_resource_vote_state( - GetContestedResourceVoteStateRequest { - version: Some(get_contested_resource_vote_state_request::Version::V0( - GetContestedResourceVoteStateRequestV0 { - contract_id: dpns_contract.id().to_vec(), - document_type_name: domain.name().clone(), - index_name: index_name.clone(), - index_values: vec![dash_encoded.clone(), quantum_encoded.clone()], - result_type: result_type as i32, - allow_include_locked_and_abstaining_vote_tally, - start_at_identifier_info, - count, - order_ascending, - prove: false, - }, - )), - }, - platform_state, - platform_version, - ) - .expect("expected to execute query") - .into_data() - .expect("expected query to be valid"); - - let get_contested_resource_vote_state_response::Version::V0( - GetContestedResourceVoteStateResponseV0 { - metadata: _, - result, - }, - ) = query_validation_result.version.expect("expected a version"); - - let Some( - get_contested_resource_vote_state_response_v0::Result::ContestedResourceContenders( - get_contested_resource_vote_state_response_v0::ContestedResourceContenders { - contenders, - abstain_vote_tally, - lock_vote_tally, - finished_vote_info, - }, - ), - ) = result - else { - panic!("expected contenders") - }; - ( - contenders - .into_iter() - .map(|contender| Contender { - identity_id: contender.identifier.try_into().expect("expected 32 bytes"), - document: contender.document.map(|document_bytes| { - Document::from_bytes( - document_bytes.as_slice(), - domain, - platform_version, - ) - .expect("expected to deserialize document") - }), - vote_tally: contender.vote_count, - }) - .collect(), - abstain_vote_tally, - lock_vote_tally, - finished_vote_info, - ) - } - - fn get_proved_vote_states( - platform: &TempPlatform, - platform_state: &PlatformState, - dpns_contract: &DataContract, - name: &str, - count: Option, - order_ascending: bool, - allow_include_locked_and_abstaining_vote_tally: bool, - start_at_identifier_info: Option< - get_contested_resource_vote_state_request_v0::StartAtIdentifierInfo, - >, - result_type: ResultType, - platform_version: &PlatformVersion, - ) -> ( - Vec, - Option, - Option, - Option<(ContestedDocumentVotePollWinnerInfo, BlockInfo)>, - ) { - // Now let's run a query for the vote totals - - let domain = dpns_contract - .document_type_for_name("domain") - .expect("expected a profile document type"); - - let config = bincode::config::standard() - .with_big_endian() - .with_no_limit(); - - let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) - .expect("expected to encode the word dash"); - - let quantum_encoded = - bincode::encode_to_vec(Value::Text(convert_to_homograph_safe_chars(name)), config) - .expect("expected to encode the word quantum"); - - let index_name = "parentNameAndLabel".to_string(); - - let query_validation_result = platform - .query_contested_resource_vote_state( - GetContestedResourceVoteStateRequest { - version: Some(get_contested_resource_vote_state_request::Version::V0( - GetContestedResourceVoteStateRequestV0 { - contract_id: dpns_contract.id().to_vec(), - document_type_name: domain.name().clone(), - index_name: index_name.clone(), - index_values: vec![dash_encoded.clone(), quantum_encoded.clone()], - result_type: result_type as i32, - allow_include_locked_and_abstaining_vote_tally, - start_at_identifier_info, - count, - order_ascending, - prove: true, - }, - )), - }, - platform_state, - platform_version, - ) - .expect("expected to execute query") - .into_data() - .expect("expected query to be valid"); - - let get_contested_resource_vote_state_response::Version::V0( - GetContestedResourceVoteStateResponseV0 { - metadata: _, - result, - }, - ) = query_validation_result.version.expect("expected a version"); - - let Some(get_contested_resource_vote_state_response_v0::Result::Proof(proof)) = result - else { - panic!("expected contenders") - }; - - let resolved_contested_document_vote_poll_drive_query = - ResolvedContestedDocumentVotePollDriveQuery { - vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { - contract: DataContractResolvedInfo::BorrowedDataContract(dpns_contract), - document_type_name: domain.name().clone(), - index_name: index_name.clone(), - index_values: vec![ - Value::Text("dash".to_string()), - Value::Text("quantum".to_string()), - ], - }, - result_type: ContestedDocumentVotePollDriveQueryResultType::try_from( - result_type as i32, - ) - .expect("expected valid result type"), - offset: None, - limit: count.map(|a| a as u16), - start_at: None, - order_ascending, - allow_include_locked_and_abstaining_vote_tally, - }; - - let (_, result) = resolved_contested_document_vote_poll_drive_query - .verify_vote_poll_vote_state_proof(proof.grovedb_proof.as_ref(), platform_version) - .expect("expected to verify proof"); - - let abstaining_vote_tally = result.abstaining_vote_tally; - let lock_vote_tally = result.locked_vote_tally; - - let contenders = result.contenders; - let finished_vote_info = result.winner; - ( - contenders - .into_iter() - .map(|contender| Contender { - identity_id: contender.identity_id, - document: contender.serialized_document.map(|document_bytes| { - Document::from_bytes( - document_bytes.as_slice(), - domain, - platform_version, - ) - .expect("expected to deserialize document") - }), - vote_tally: contender.vote_tally, - }) - .collect(), - abstaining_vote_tally, - lock_vote_tally, - finished_vote_info, - ) - } + use super::*; mod contests_requests_query { + use super::*; #[test] @@ -1321,6 +370,7 @@ mod tests { } mod vote_state_query { + use super::*; #[test] @@ -2255,7 +1305,6 @@ mod tests { mod identity_given_votes_query { use super::*; - use drive::query::contested_resource_votes_given_by_identity_query::ContestedResourceVotesGivenByIdentityQuery; fn get_identity_given_votes( platform: &TempPlatform, @@ -2729,7 +1778,6 @@ mod tests { mod end_date_query { use super::*; - use dapi_grpc::platform::v0::get_vote_polls_by_end_date_request::get_vote_polls_by_end_date_request_v0; #[test] fn test_not_proved_end_date_query_request() { @@ -3997,6 +3045,7 @@ mod tests { } mod prefunded_specialized_balance_query { + use super::*; fn get_specialized_balance( 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 886046fed7..2b3921984b 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 @@ -1,3 +1,59 @@ +use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::{get_contested_resource_vote_state_request_v0, GetContestedResourceVoteStateRequestV0}; +use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0::ResultType; +use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse}; +use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; +use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::get_contested_resource_vote_state_response_v0::FinishedVoteInfo; +use dpp::block::block_info::BlockInfo; +use dpp::data_contract::DataContract; +use dpp::document::{Document, DocumentV0Getters, DocumentV0Setters}; +use dpp::identity::{Identity, IdentityPublicKey, IdentityV0}; +use dpp::platform_value::{Bytes32, Value}; +use dpp::util::strings::convert_to_homograph_safe_chars; +use dpp::voting::contender_structs::Contender; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; +use drive::drive::object_size_info::DataContractResolvedInfo; +use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; +use drive::query::vote_poll_vote_state_query::{ContestedDocumentVotePollDriveQueryResultType, ResolvedContestedDocumentVotePollDriveQuery}; +use platform_version::version::PlatformVersion; +use rand::prelude::StdRng; +use dpp::identifier::Identifier; +use simple_signer::signer::SimpleSigner; +use std::collections::BTreeMap; +use dpp::dashcore::{ProTxHash, Txid}; +use std::net::{IpAddr, Ipv4Addr, SocketAddr}; +use dashcore_rpc::dashcore_rpc_json::{DMNState, MasternodeListItem, MasternodeType}; +use std::sync::Arc; +use arc_swap::Guard; +use assert_matches::assert_matches; +use dpp::dash_to_credits; +use dpp::data_contract::document_type::random_document::{CreateRandomDocument, DocumentFieldFillSize, DocumentFieldFillType}; +use dpp::prelude::IdentityNonce; +use dpp::state_transition::documents_batch_transition::DocumentsBatchTransition; +use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; +use dpp::util::hash::hash_double; +use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::voting::vote_polls::VotePoll; +use dpp::voting::votes::resource_vote::ResourceVote; +use dpp::voting::votes::resource_vote::v0::ResourceVoteV0; +use dpp::voting::votes::Vote; +use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; +use rand::{Rng, SeedableRng}; +use std::ops::Deref; +use dpp::dashcore::hashes::Hash; +use dpp::data_contract::accessors::v0::DataContractV0Getters; +use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; +use dpp::identity::accessors::IdentityGettersV0; +use dpp::serialization::PlatformSerializable; +use dpp::state_transition::documents_batch_transition::methods::v0::DocumentsBatchTransitionMethodsV0; +use dpp::state_transition::masternode_vote_transition::methods::MasternodeVoteTransitionMethodsV0; +use crate::execution::validation::state_transition::state_transitions::tests::setup_identity; +use crate::platform_types::platform_state::PlatformState; +use crate::platform_types::platform_state::v0::PlatformStateV0Methods; +use crate::rpc::core::MockCoreRPCLike; +use crate::test::helpers::setup::TempPlatform; + /// Module containing functionality related to batch processing of documents. pub mod documents_batch; @@ -57,12 +113,57 @@ mod tests { use dpp::block::block_info::BlockInfo; use dpp::fee::Credits; use dpp::identity::{Identity, IdentityPublicKey, IdentityV0}; - use dpp::prelude::Identifier; + use dpp::prelude::{Identifier, IdentityNonce}; use platform_version::version::PlatformVersion; use rand::prelude::StdRng; - use rand::SeedableRng; + use rand::{Rng, SeedableRng}; use simple_signer::signer::SimpleSigner; use std::collections::BTreeMap; + use std::net::{IpAddr, Ipv4Addr, SocketAddr}; + use std::ops::Deref; + use std::sync::Arc; + use arc_swap::Guard; + use assert_matches::assert_matches; + use dashcore_rpc::dashcore_rpc_json::{DMNState, MasternodeListItem, MasternodeType}; + use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse}; + use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0::ResultType; + use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::{get_contested_resource_vote_state_request_v0, GetContestedResourceVoteStateRequestV0}; + use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; + use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::get_contested_resource_vote_state_response_v0::{finished_vote_info, FinishedVoteInfo}; + use dpp::block::extended_block_info::v0::ExtendedBlockInfoV0; + use dpp::dash_to_credits; + use dpp::dashcore::{ProTxHash, Txid}; + use dpp::dashcore::hashes::Hash; + use dpp::data_contract::accessors::v0::DataContractV0Getters; + use dpp::data_contract::DataContract; + use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; + use dpp::data_contract::document_type::random_document::{CreateRandomDocument, DocumentFieldFillSize, DocumentFieldFillType}; + use dpp::document::{Document, DocumentV0Getters, DocumentV0Setters}; + use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; + use dpp::identity::accessors::IdentityGettersV0; + use dpp::platform_value::{Bytes32, Value}; + use dpp::serialization::PlatformSerializable; + use dpp::state_transition::documents_batch_transition::DocumentsBatchTransition; + use dpp::state_transition::documents_batch_transition::methods::v0::DocumentsBatchTransitionMethodsV0; + use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; + use dpp::state_transition::masternode_vote_transition::methods::MasternodeVoteTransitionMethodsV0; + use dpp::util::hash::hash_double; + use dpp::util::strings::convert_to_homograph_safe_chars; + use dpp::voting::contender_structs::Contender; + use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; + use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; + use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; + use dpp::voting::vote_polls::VotePoll; + use dpp::voting::votes::resource_vote::ResourceVote; + use dpp::voting::votes::resource_vote::v0::ResourceVoteV0; + use dpp::voting::votes::Vote; + use drive::drive::object_size_info::DataContractResolvedInfo; + use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; + use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; + use drive::query::vote_poll_vote_state_query::{ContestedDocumentVotePollDriveQueryResultType, ResolvedContestedDocumentVotePollDriveQuery}; + use crate::platform_types::platform_state::PlatformState; + use crate::platform_types::platform_state::v0::PlatformStateV0Methods; + use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult::SuccessfulExecution; pub(in crate::execution::validation::state_transition::state_transitions) fn setup_identity( platform: &mut TempPlatform, @@ -121,4 +222,945 @@ mod tests { (identity, signer, critical_public_key) } + + pub(in crate::execution::validation::state_transition::state_transitions) fn setup_masternode_identity( + platform: &mut TempPlatform, + seed: u64, + platform_version: &PlatformVersion, + ) -> (Identity, SimpleSigner, IdentityPublicKey) { + let mut signer = SimpleSigner::default(); + + let mut rng = StdRng::seed_from_u64(seed); + + let (voting_key, voting_private_key) = + IdentityPublicKey::random_voting_key_with_rng(0, &mut rng, platform_version) + .expect("expected to get key pair"); + + signer.add_key(voting_key.clone(), voting_private_key.clone()); + + let identity: Identity = IdentityV0 { + id: Identifier::random_with_rng(&mut rng), + public_keys: BTreeMap::from([(0, voting_key.clone())]), + balance: 0, + revision: 0, + } + .into(); + + // We just add this identity to the system first + + platform + .drive + .add_new_identity( + identity.clone(), + true, + &BlockInfo::default(), + true, + None, + platform_version, + ) + .expect("expected to add a new identity"); + + let mut platform_state = platform.state.load().clone().deref().clone(); + + let pro_tx_hash = ProTxHash::from_byte_array(identity.id().to_buffer()); + + let random_ip = Ipv4Addr::new( + rng.gen_range(0..255), + rng.gen_range(0..255), + rng.gen_range(0..255), + rng.gen_range(0..255), + ); + + platform_state.full_masternode_list_mut().insert( + pro_tx_hash, + MasternodeListItem { + node_type: MasternodeType::Regular, + pro_tx_hash, + collateral_hash: Txid::from_byte_array(rng.gen()), + collateral_index: 0, + collateral_address: rng.gen(), + operator_reward: 0.0, + state: DMNState { + service: SocketAddr::new(IpAddr::V4(random_ip), 19999), + registered_height: 0, + pose_revived_height: None, + pose_ban_height: None, + revocation_reason: 0, + owner_address: rng.gen(), + voting_address: rng.gen(), + payout_address: rng.gen(), + pub_key_operator: vec![], + operator_payout_address: None, + platform_node_id: None, + platform_p2p_port: None, + platform_http_port: None, + }, + }, + ); + + platform.state.store(Arc::new(platform_state)); + + (identity, signer, voting_key) + } + + pub(in crate::execution::validation::state_transition::state_transitions) fn create_dpns_name_contest( + platform: &mut TempPlatform, + platform_state: &PlatformState, + seed: u64, + name: &str, + platform_version: &PlatformVersion, + ) -> (Identity, Identity, Arc) { + let mut rng = StdRng::seed_from_u64(seed); + + let (identity_1, signer_1, key_1) = + setup_identity(platform, rng.gen(), dash_to_credits!(0.5)); + + let (identity_2, signer_2, key_2) = + setup_identity(platform, rng.gen(), dash_to_credits!(0.5)); + + // Flip them if needed so identity 1 id is always smaller than identity 2 id + let (identity_1, identity_2, signer_1, signer_2, key_1, key_2) = + if identity_1.id() < identity_2.id() { + (identity_1, identity_2, signer_1, signer_2, key_1, key_2) + } else { + (identity_2, identity_1, signer_2, signer_1, key_2, key_1) + }; + + let dpns = platform.drive.cache.system_data_contracts.load_dpns(); + let dpns_contract = dpns.clone(); + + let preorder = dpns_contract + .document_type_for_name("preorder") + .expect("expected a profile document type"); + + assert!(!preorder.documents_mutable()); + assert!(preorder.documents_can_be_deleted()); + assert!(!preorder.documents_transferable().is_transferable()); + + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); + + assert!(!domain.documents_mutable()); + assert!(!domain.documents_can_be_deleted()); + assert!(!domain.documents_transferable().is_transferable()); + + let entropy = Bytes32::random_with_rng(&mut rng); + + let mut preorder_document_1 = preorder + .random_document_with_identifier_and_entropy( + &mut rng, + identity_1.id(), + entropy, + DocumentFieldFillType::FillIfNotRequired, + DocumentFieldFillSize::AnyDocumentFillSize, + platform_version, + ) + .expect("expected a random document"); + + let mut preorder_document_2 = preorder + .random_document_with_identifier_and_entropy( + &mut rng, + identity_2.id(), + entropy, + DocumentFieldFillType::FillIfNotRequired, + DocumentFieldFillSize::AnyDocumentFillSize, + platform_version, + ) + .expect("expected a random document"); + + let mut document_1 = domain + .random_document_with_identifier_and_entropy( + &mut rng, + identity_1.id(), + entropy, + DocumentFieldFillType::FillIfNotRequired, + DocumentFieldFillSize::AnyDocumentFillSize, + platform_version, + ) + .expect("expected a random document"); + + let mut document_2 = domain + .random_document_with_identifier_and_entropy( + &mut rng, + identity_2.id(), + entropy, + DocumentFieldFillType::FillIfNotRequired, + DocumentFieldFillSize::AnyDocumentFillSize, + platform_version, + ) + .expect("expected a random document"); + + document_1.set("parentDomainName", "dash".into()); + document_1.set("normalizedParentDomainName", "dash".into()); + document_1.set("label", name.into()); + document_1.set( + "normalizedLabel", + convert_to_homograph_safe_chars(name).into(), + ); + document_1.set("records.dashUniqueIdentityId", document_1.owner_id().into()); + document_1.set("subdomainRules.allowSubdomains", false.into()); + + document_2.set("parentDomainName", "dash".into()); + document_2.set("normalizedParentDomainName", "dash".into()); + document_2.set("label", name.into()); + document_2.set( + "normalizedLabel", + convert_to_homograph_safe_chars(name).into(), + ); + document_2.set("records.dashUniqueIdentityId", document_2.owner_id().into()); + document_2.set("subdomainRules.allowSubdomains", false.into()); + + let salt_1: [u8; 32] = rng.gen(); + let salt_2: [u8; 32] = rng.gen(); + + let mut salted_domain_buffer_1: Vec = vec![]; + salted_domain_buffer_1.extend(salt_1); + salted_domain_buffer_1.extend((convert_to_homograph_safe_chars(name) + ".dash").as_bytes()); + + let salted_domain_hash_1 = hash_double(salted_domain_buffer_1); + + let mut salted_domain_buffer_2: Vec = vec![]; + salted_domain_buffer_2.extend(salt_2); + salted_domain_buffer_2.extend((convert_to_homograph_safe_chars(name) + ".dash").as_bytes()); + + let salted_domain_hash_2 = hash_double(salted_domain_buffer_2); + + preorder_document_1.set("saltedDomainHash", salted_domain_hash_1.into()); + preorder_document_2.set("saltedDomainHash", salted_domain_hash_2.into()); + + document_1.set("preorderSalt", salt_1.into()); + document_2.set("preorderSalt", salt_2.into()); + + let documents_batch_create_preorder_transition_1 = + DocumentsBatchTransition::new_document_creation_transition_from_document( + preorder_document_1, + preorder, + entropy.0, + &key_1, + 2, + 0, + &signer_1, + platform_version, + None, + None, + None, + ) + .expect("expect to create documents batch transition"); + + let documents_batch_create_serialized_preorder_transition_1 = + documents_batch_create_preorder_transition_1 + .serialize_to_bytes() + .expect("expected documents batch serialized state transition"); + + let documents_batch_create_preorder_transition_2 = + DocumentsBatchTransition::new_document_creation_transition_from_document( + preorder_document_2, + preorder, + entropy.0, + &key_2, + 2, + 0, + &signer_2, + platform_version, + None, + None, + None, + ) + .expect("expect to create documents batch transition"); + + let documents_batch_create_serialized_preorder_transition_2 = + documents_batch_create_preorder_transition_2 + .serialize_to_bytes() + .expect("expected documents batch serialized state transition"); + + let documents_batch_create_transition_1 = + DocumentsBatchTransition::new_document_creation_transition_from_document( + document_1, + domain, + entropy.0, + &key_1, + 3, + 0, + &signer_1, + platform_version, + None, + None, + None, + ) + .expect("expect to create documents batch transition"); + + let documents_batch_create_serialized_transition_1 = documents_batch_create_transition_1 + .serialize_to_bytes() + .expect("expected documents batch serialized state transition"); + + let documents_batch_create_transition_2 = + DocumentsBatchTransition::new_document_creation_transition_from_document( + document_2, + domain, + entropy.0, + &key_2, + 3, + 0, + &signer_2, + platform_version, + None, + None, + None, + ) + .expect("expect to create documents batch transition"); + + let documents_batch_create_serialized_transition_2 = documents_batch_create_transition_2 + .serialize_to_bytes() + .expect("expected documents batch serialized state transition"); + + let transaction = platform.drive.grove.start_transaction(); + + 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(), + ], + platform_state, + &BlockInfo::default_with_time( + platform_state + .last_committed_block_time_ms() + .unwrap_or_default() + + 3000, + ), + &transaction, + platform_version, + ) + .expect("expected to process state transition"); + + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit transaction"); + + assert_eq!(processing_result.valid_count(), 2); + + let transaction = platform.drive.grove.start_transaction(); + + let processing_result = platform + .platform + .process_raw_state_transitions( + &vec![ + documents_batch_create_serialized_transition_1.clone(), + documents_batch_create_serialized_transition_2.clone(), + ], + platform_state, + &BlockInfo::default_with_time( + platform_state + .last_committed_block_time_ms() + .unwrap_or_default() + + 3000, + ), + &transaction, + platform_version, + ) + .expect("expected to process state transition"); + + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit transaction"); + + assert_eq!(processing_result.valid_count(), 2); + (identity_1, identity_2, dpns_contract) + } + + pub(in crate::execution::validation::state_transition::state_transitions) fn verify_dpns_name_contest( + platform: &mut TempPlatform, + platform_state: &Guard>, + dpns_contract: &DataContract, + identity_1: &Identity, + identity_2: &Identity, + name: &str, + platform_version: &PlatformVersion, + ) { + // Now let's run a query for the vote totals + + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); + + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + + let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) + .expect("expected to encode the word dash"); + + let quantum_encoded = + bincode::encode_to_vec(Value::Text(convert_to_homograph_safe_chars(name)), config) + .expect("expected to encode the word quantum"); + + let index_name = "parentNameAndLabel".to_string(); + + let query_validation_result = platform + .query_contested_resource_vote_state( + GetContestedResourceVoteStateRequest { + version: Some(get_contested_resource_vote_state_request::Version::V0( + GetContestedResourceVoteStateRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![dash_encoded.clone(), quantum_encoded.clone()], + result_type: ResultType::DocumentsAndVoteTally as i32, + allow_include_locked_and_abstaining_vote_tally: true, + start_at_identifier_info: None, + count: None, + order_ascending: true, + prove: false, + }, + )), + }, + platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_vote_state_response::Version::V0( + GetContestedResourceVoteStateResponseV0 { + metadata: _, + result, + }, + ) = query_validation_result.version.expect("expected a version"); + + let Some( + get_contested_resource_vote_state_response_v0::Result::ContestedResourceContenders( + get_contested_resource_vote_state_response_v0::ContestedResourceContenders { + contenders, + .. + }, + ), + ) = result + else { + panic!("expected contenders") + }; + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + let first_contender_document = Document::from_bytes( + first_contender + .document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); + + let second_contender_document = Document::from_bytes( + second_contender + .document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); + + assert_ne!(first_contender_document, second_contender_document); + + assert_eq!(first_contender.identifier, identity_1.id().to_vec()); + + assert_eq!(second_contender.identifier, identity_2.id().to_vec()); + + assert_eq!(first_contender.vote_count, Some(0)); + + assert_eq!(second_contender.vote_count, Some(0)); + + let GetContestedResourceVoteStateResponse { version } = platform + .query_contested_resource_vote_state( + GetContestedResourceVoteStateRequest { + version: Some(get_contested_resource_vote_state_request::Version::V0( + GetContestedResourceVoteStateRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![dash_encoded, quantum_encoded], + result_type: ResultType::DocumentsAndVoteTally as i32, + allow_include_locked_and_abstaining_vote_tally: true, + start_at_identifier_info: None, + count: None, + order_ascending: true, + prove: true, + }, + )), + }, + platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_vote_state_response::Version::V0( + GetContestedResourceVoteStateResponseV0 { + metadata: _, + result, + }, + ) = version.expect("expected a version"); + + let Some(get_contested_resource_vote_state_response_v0::Result::Proof(proof)) = result + else { + panic!("expected contenders") + }; + + let resolved_contested_document_vote_poll_drive_query = + ResolvedContestedDocumentVotePollDriveQuery { + vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { + contract: DataContractResolvedInfo::BorrowedDataContract(dpns_contract), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![ + Value::Text("dash".to_string()), + Value::Text(convert_to_homograph_safe_chars(name)), + ], + }, + result_type: DocumentsAndVoteTally, + offset: None, + limit: None, + start_at: None, + order_ascending: true, + allow_include_locked_and_abstaining_vote_tally: true, + }; + + let (_, result) = resolved_contested_document_vote_poll_drive_query + .verify_vote_poll_vote_state_proof(proof.grovedb_proof.as_ref(), platform_version) + .expect("expected to verify proof"); + + let contenders = result.contenders; + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + let first_contender_document = Document::from_bytes( + first_contender + .serialized_document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); + + let second_contender_document = Document::from_bytes( + second_contender + .serialized_document + .as_ref() + .expect("expected a document") + .as_slice(), + domain, + platform_version, + ) + .expect("expected to get document"); + + assert_ne!(first_contender_document, second_contender_document); + + assert_eq!(first_contender.identity_id, identity_1.id()); + + assert_eq!(second_contender.identity_id, identity_2.id()); + + assert_eq!(first_contender.vote_tally, Some(0)); + + assert_eq!(second_contender.vote_tally, Some(0)); + } + + pub(in crate::execution::validation::state_transition::state_transitions) fn perform_vote( + platform: &mut TempPlatform, + platform_state: &Guard>, + dpns_contract: &DataContract, + resource_vote_choice: ResourceVoteChoice, + name: &str, + signer: &SimpleSigner, + masternode_id: Identifier, + voting_key: &IdentityPublicKey, + nonce: IdentityNonce, + platform_version: &PlatformVersion, + ) { + // Let's vote for contender 1 + + let vote = Vote::ResourceVote(ResourceVote::V0(ResourceVoteV0 { + vote_poll: VotePoll::ContestedDocumentResourceVotePoll( + ContestedDocumentResourceVotePoll { + contract_id: dpns_contract.id(), + document_type_name: "domain".to_string(), + index_name: "parentNameAndLabel".to_string(), + index_values: vec![ + Value::Text("dash".to_string()), + Value::Text(convert_to_homograph_safe_chars(name)), + ], + }, + ), + resource_vote_choice, + })); + + let masternode_vote_transition = MasternodeVoteTransition::try_from_vote_with_signer( + vote, + signer, + masternode_id, + voting_key, + nonce, + platform_version, + None, + ) + .expect("expected to make transition vote"); + + let masternode_vote_serialized_transition = masternode_vote_transition + .serialize_to_bytes() + .expect("expected documents batch serialized state transition"); + + let transaction = platform.drive.grove.start_transaction(); + + let processing_result = platform + .platform + .process_raw_state_transitions( + &vec![masternode_vote_serialized_transition.clone()], + platform_state, + &BlockInfo::default(), + &transaction, + platform_version, + ) + .expect("expected to process state transition"); + + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit transaction"); + + let execution_result = processing_result.into_execution_results().remove(0); + assert_matches!(execution_result, SuccessfulExecution(..)); + } + + pub(in crate::execution::validation::state_transition::state_transitions) fn perform_votes( + platform: &mut TempPlatform, + dpns_contract: &DataContract, + resource_vote_choice: ResourceVoteChoice, + name: &str, + count: u64, + start_seed: u64, + platform_version: &PlatformVersion, + ) { + for i in 0..count { + let (masternode, signer, voting_key) = + setup_masternode_identity(platform, start_seed + i, platform_version); + + let platform_state = platform.state.load(); + + perform_vote( + platform, + &platform_state, + dpns_contract, + resource_vote_choice, + name, + &signer, + masternode.id(), + &voting_key, + 1, + platform_version, + ); + } + } + + pub(in crate::execution::validation::state_transition::state_transitions) fn perform_votes_multi( + platform: &mut TempPlatform, + dpns_contract: &DataContract, + resource_vote_choices: Vec<(ResourceVoteChoice, u64)>, + name: &str, + start_seed: u64, + platform_version: &PlatformVersion, + ) { + let mut count_aggregate = start_seed; + for (resource_vote_choice, count) in resource_vote_choices.into_iter() { + perform_votes( + platform, + dpns_contract, + resource_vote_choice, + name, + count, + count_aggregate, + platform_version, + ); + count_aggregate += count; + } + } + + pub(in crate::execution::validation::state_transition::state_transitions) fn get_vote_states( + platform: &TempPlatform, + platform_state: &PlatformState, + dpns_contract: &DataContract, + name: &str, + count: Option, + order_ascending: bool, + allow_include_locked_and_abstaining_vote_tally: bool, + start_at_identifier_info: Option< + get_contested_resource_vote_state_request_v0::StartAtIdentifierInfo, + >, + result_type: ResultType, + platform_version: &PlatformVersion, + ) -> ( + Vec, + Option, + Option, + Option, + ) { + // Now let's run a query for the vote totals + + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); + + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + + let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) + .expect("expected to encode the word dash"); + + let quantum_encoded = + bincode::encode_to_vec(Value::Text(convert_to_homograph_safe_chars(name)), config) + .expect("expected to encode the word quantum"); + + let index_name = "parentNameAndLabel".to_string(); + + let query_validation_result = platform + .query_contested_resource_vote_state( + GetContestedResourceVoteStateRequest { + version: Some(get_contested_resource_vote_state_request::Version::V0( + GetContestedResourceVoteStateRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![dash_encoded.clone(), quantum_encoded.clone()], + result_type: result_type as i32, + allow_include_locked_and_abstaining_vote_tally, + start_at_identifier_info, + count, + order_ascending, + prove: false, + }, + )), + }, + platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_vote_state_response::Version::V0( + GetContestedResourceVoteStateResponseV0 { + metadata: _, + result, + }, + ) = query_validation_result.version.expect("expected a version"); + + let Some( + get_contested_resource_vote_state_response_v0::Result::ContestedResourceContenders( + get_contested_resource_vote_state_response_v0::ContestedResourceContenders { + contenders, + abstain_vote_tally, + lock_vote_tally, + finished_vote_info, + }, + ), + ) = result + else { + panic!("expected contenders") + }; + ( + contenders + .into_iter() + .map(|contender| Contender { + identity_id: contender.identifier.try_into().expect("expected 32 bytes"), + document: contender.document.map(|document_bytes| { + Document::from_bytes(document_bytes.as_slice(), domain, platform_version) + .expect("expected to deserialize document") + }), + vote_tally: contender.vote_count, + }) + .collect(), + abstain_vote_tally, + lock_vote_tally, + finished_vote_info, + ) + } + + pub(in crate::execution::validation::state_transition::state_transitions) fn get_proved_vote_states( + platform: &TempPlatform, + platform_state: &PlatformState, + dpns_contract: &DataContract, + name: &str, + count: Option, + order_ascending: bool, + allow_include_locked_and_abstaining_vote_tally: bool, + start_at_identifier_info: Option< + get_contested_resource_vote_state_request_v0::StartAtIdentifierInfo, + >, + result_type: ResultType, + platform_version: &PlatformVersion, + ) -> ( + Vec, + Option, + Option, + Option<(ContestedDocumentVotePollWinnerInfo, BlockInfo)>, + ) { + // Now let's run a query for the vote totals + + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); + + let config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + + let dash_encoded = bincode::encode_to_vec(Value::Text("dash".to_string()), config) + .expect("expected to encode the word dash"); + + let quantum_encoded = + bincode::encode_to_vec(Value::Text(convert_to_homograph_safe_chars(name)), config) + .expect("expected to encode the word quantum"); + + let index_name = "parentNameAndLabel".to_string(); + + let query_validation_result = platform + .query_contested_resource_vote_state( + GetContestedResourceVoteStateRequest { + version: Some(get_contested_resource_vote_state_request::Version::V0( + GetContestedResourceVoteStateRequestV0 { + contract_id: dpns_contract.id().to_vec(), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![dash_encoded.clone(), quantum_encoded.clone()], + result_type: result_type as i32, + allow_include_locked_and_abstaining_vote_tally, + start_at_identifier_info, + count, + order_ascending, + prove: true, + }, + )), + }, + platform_state, + platform_version, + ) + .expect("expected to execute query") + .into_data() + .expect("expected query to be valid"); + + let get_contested_resource_vote_state_response::Version::V0( + GetContestedResourceVoteStateResponseV0 { + metadata: _, + result, + }, + ) = query_validation_result.version.expect("expected a version"); + + let Some(get_contested_resource_vote_state_response_v0::Result::Proof(proof)) = result + else { + panic!("expected contenders") + }; + + let resolved_contested_document_vote_poll_drive_query = + ResolvedContestedDocumentVotePollDriveQuery { + vote_poll: ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed { + contract: DataContractResolvedInfo::BorrowedDataContract(dpns_contract), + document_type_name: domain.name().clone(), + index_name: index_name.clone(), + index_values: vec![ + Value::Text("dash".to_string()), + Value::Text("quantum".to_string()), + ], + }, + result_type: ContestedDocumentVotePollDriveQueryResultType::try_from( + result_type as i32, + ) + .expect("expected valid result type"), + offset: None, + limit: count.map(|a| a as u16), + start_at: None, + order_ascending, + allow_include_locked_and_abstaining_vote_tally, + }; + + let (_, result) = resolved_contested_document_vote_poll_drive_query + .verify_vote_poll_vote_state_proof(proof.grovedb_proof.as_ref(), platform_version) + .expect("expected to verify proof"); + + let abstaining_vote_tally = result.abstaining_vote_tally; + let lock_vote_tally = result.locked_vote_tally; + + let contenders = result.contenders; + let finished_vote_info = result.winner; + ( + contenders + .into_iter() + .map(|contender| Contender { + identity_id: contender.identity_id, + document: contender.serialized_document.map(|document_bytes| { + Document::from_bytes(document_bytes.as_slice(), domain, platform_version) + .expect("expected to deserialize document") + }), + vote_tally: contender.vote_tally, + }) + .collect(), + abstaining_vote_tally, + lock_vote_tally, + finished_vote_info, + ) + } + + pub(in crate::execution::validation::state_transition::state_transitions) fn fast_forward_to_block( + platform: &TempPlatform, + time_ms: u64, + height: u64, + ) { + let platform_state = platform.state.load(); + + let mut platform_state = (**platform_state).clone(); + + let block_info = BlockInfo { + time_ms, //less than 2 weeks + height, + core_height: 42, + epoch: Default::default(), + }; + + platform_state.set_last_committed_block_info(Some( + ExtendedBlockInfoV0 { + basic_info: block_info, + app_hash: platform.drive.grove.root_hash(None).unwrap().unwrap(), + quorum_hash: [0u8; 32], + block_id_hash: [0u8; 32], + signature: [0u8; 96], + round: 0, + } + .into(), + )); + + platform.state.store(Arc::new(platform_state)); + } } From eec4cf443fd99f503bd5e130796fbd607f371000 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 9 Jun 2024 03:23:17 +0300 Subject: [PATCH 124/135] small fixes --- .../state_transition/state_transitions/mod.rs | 56 ------------------- packages/rs-drive-proof-verifier/src/types.rs | 3 +- packages/strategy-tests/src/lib.rs | 1 + 3 files changed, 2 insertions(+), 58 deletions(-) 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 2b3921984b..82bbda62f2 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 @@ -1,59 +1,3 @@ -use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::{get_contested_resource_vote_state_request_v0, GetContestedResourceVoteStateRequestV0}; -use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0::ResultType; -use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse}; -use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; -use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::get_contested_resource_vote_state_response_v0::FinishedVoteInfo; -use dpp::block::block_info::BlockInfo; -use dpp::data_contract::DataContract; -use dpp::document::{Document, DocumentV0Getters, DocumentV0Setters}; -use dpp::identity::{Identity, IdentityPublicKey, IdentityV0}; -use dpp::platform_value::{Bytes32, Value}; -use dpp::util::strings::convert_to_homograph_safe_chars; -use dpp::voting::contender_structs::Contender; -use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; -use drive::drive::object_size_info::DataContractResolvedInfo; -use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; -use drive::query::vote_poll_vote_state_query::{ContestedDocumentVotePollDriveQueryResultType, ResolvedContestedDocumentVotePollDriveQuery}; -use platform_version::version::PlatformVersion; -use rand::prelude::StdRng; -use dpp::identifier::Identifier; -use simple_signer::signer::SimpleSigner; -use std::collections::BTreeMap; -use dpp::dashcore::{ProTxHash, Txid}; -use std::net::{IpAddr, Ipv4Addr, SocketAddr}; -use dashcore_rpc::dashcore_rpc_json::{DMNState, MasternodeListItem, MasternodeType}; -use std::sync::Arc; -use arc_swap::Guard; -use assert_matches::assert_matches; -use dpp::dash_to_credits; -use dpp::data_contract::document_type::random_document::{CreateRandomDocument, DocumentFieldFillSize, DocumentFieldFillType}; -use dpp::prelude::IdentityNonce; -use dpp::state_transition::documents_batch_transition::DocumentsBatchTransition; -use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; -use dpp::util::hash::hash_double; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; -use dpp::voting::vote_polls::VotePoll; -use dpp::voting::votes::resource_vote::ResourceVote; -use dpp::voting::votes::resource_vote::v0::ResourceVoteV0; -use dpp::voting::votes::Vote; -use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; -use rand::{Rng, SeedableRng}; -use std::ops::Deref; -use dpp::dashcore::hashes::Hash; -use dpp::data_contract::accessors::v0::DataContractV0Getters; -use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; -use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; -use dpp::identity::accessors::IdentityGettersV0; -use dpp::serialization::PlatformSerializable; -use dpp::state_transition::documents_batch_transition::methods::v0::DocumentsBatchTransitionMethodsV0; -use dpp::state_transition::masternode_vote_transition::methods::MasternodeVoteTransitionMethodsV0; -use crate::execution::validation::state_transition::state_transitions::tests::setup_identity; -use crate::platform_types::platform_state::PlatformState; -use crate::platform_types::platform_state::v0::PlatformStateV0Methods; -use crate::rpc::core::MockCoreRPCLike; -use crate::test::helpers::setup::TempPlatform; - /// Module containing functionality related to batch processing of documents. pub mod documents_batch; diff --git a/packages/rs-drive-proof-verifier/src/types.rs b/packages/rs-drive-proof-verifier/src/types.rs index 07a70ec363..42b60d958a 100644 --- a/packages/rs-drive-proof-verifier/src/types.rs +++ b/packages/rs-drive-proof-verifier/src/types.rs @@ -9,9 +9,9 @@ use std::collections::BTreeMap; use dpp::prelude::IdentityNonce; pub use dpp::version::ProtocolVersionVoteCount; +use dpp::voting::contender_structs::Contender; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; -use dpp::voting::votes::resource_vote::ResourceVote; use dpp::{ block::{epoch::EpochIndex, extended_epoch_info::ExtendedEpochInfo}, dashcore::ProTxHash, @@ -21,7 +21,6 @@ use dpp::{ util::deserializer::ProtocolVersion, }; use drive::grovedb::Element; -use drive::query::vote_poll_vote_state_query::Contender; /// A data structure that holds a set of objects of a generic type `O`, indexed by a key of type `K`. /// diff --git a/packages/strategy-tests/src/lib.rs b/packages/strategy-tests/src/lib.rs index 29fd48ce37..168509ca05 100644 --- a/packages/strategy-tests/src/lib.rs +++ b/packages/strategy-tests/src/lib.rs @@ -1892,6 +1892,7 @@ mod tests { keys_per_identity: 3, starting_balances: 100_000_000, extra_keys: BTreeMap::new(), + hard_coded: vec![], }, identity_inserts: Default::default(), identity_contract_nonce_gaps: None, From 6a573037ece94b0d3030e244a8ecca5e01073e76 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 9 Jun 2024 15:29:30 +0300 Subject: [PATCH 125/135] a lot of validation --- packages/rs-dpp/src/block/block_info/mod.rs | 25 ++ packages/rs-dpp/src/block/epoch/mod.rs | 8 +- packages/rs-dpp/src/errors/consensus/codes.rs | 2 + ...document_contest_currently_locked_error.rs | 55 ++++ .../document_contest_not_joinable_error.rs | 70 +++++ .../errors/consensus/state/document/mod.rs | 2 + .../src/errors/consensus/state/state_error.rs | 8 + .../src/tests/fixtures/identity_fixture.rs | 3 +- .../src/voting/contender_structs/mod.rs | 17 + packages/rs-dpp/src/voting/mod.rs | 2 +- .../vote_choices/resource_vote_choice/mod.rs | 13 + .../mod.rs | 208 ++++++++++++ .../v0/mod.rs | 295 ++++++++++++++++++ .../mod.rs | 23 ++ .../src/voting/vote_info_storage/mod.rs | 2 + .../mod.rs | 10 - .../mod.rs | 110 ------- .../v0/mod.rs | 119 ------- .../rs-dpp/src/voting/vote_outcomes/mod.rs | 2 - .../mod.rs | 17 + packages/rs-dpp/src/voting/vote_polls/mod.rs | 2 - .../check_for_ended_vote_polls/v0/mod.rs | 2 +- .../mod.rs | 2 - .../v0/mod.rs | 3 +- .../clean_up_after_vote_polls_end/mod.rs | 3 - .../clean_up_after_vote_polls_end/v0/mod.rs | 3 - .../voting/keep_record_of_vote_poll/mod.rs | 2 +- .../voting/keep_record_of_vote_poll/v0/mod.rs | 39 ++- .../voting/lock_contested_resource/v0/mod.rs | 1 - .../mod.rs | 1 - .../state_transition/processor/v0/mod.rs | 21 +- .../data_contract_create/mod.rs | 5 +- .../data_contract_update/mod.rs | 7 +- .../data_contract_update/state/mod.rs | 6 +- .../document_create_transition_action/mod.rs | 8 +- .../state_v0/mod.rs | 86 ++++- .../document_delete_transition_action/mod.rs | 8 +- .../state_v0/mod.rs | 6 +- .../mod.rs | 8 +- .../state_v0/mod.rs | 6 +- .../document_replace_transition_action/mod.rs | 8 +- .../state_v0/mod.rs | 6 +- .../mod.rs | 8 +- .../state_v0/mod.rs | 6 +- .../mod.rs | 8 +- .../state_v0/mod.rs | 6 +- .../state_transitions/documents_batch/mod.rs | 19 +- .../documents_batch/state/v0/mod.rs | 17 +- .../identity_credit_transfer/mod.rs | 3 +- .../identity_credit_withdrawal/mod.rs | 3 +- .../state_transitions/identity_update/mod.rs | 3 +- .../state_transitions/masternode_vote/mod.rs | 6 +- .../state_transition/state_transitions/mod.rs | 182 ++++++++++- .../v0/mod.rs | 2 - .../contested_resource_vote_state/v0/mod.rs | 2 +- .../drive/batch/drive_op_batch/document.rs | 4 +- .../add_contested_document/mod.rs | 7 +- .../add_contested_document/v0/mod.rs | 16 +- .../mod.rs | 4 +- .../v0/mod.rs | 4 +- .../mod.rs | 4 +- .../v0/mod.rs | 4 +- .../mod.rs | 4 +- .../v0/mod.rs | 8 +- .../mod.rs | 2 +- .../v0/mod.rs | 17 +- .../voting/verify_masternode_vote/v0/mod.rs | 2 +- .../v0/mod.rs | 176 ++++++++--- .../verify_vote_poll_votes_proof/v0/mod.rs | 2 +- .../verify_vote_polls_end_date_query/mod.rs | 1 - .../mod.rs | 1 - .../v0/mod.rs | 2 +- .../v0/mod.rs | 4 +- .../mod.rs | 1 - .../v0/mod.rs | 9 +- .../mod.rs | 44 +++ .../v0/mod.rs | 49 +++ .../mod.rs | 1 + .../v0/mod.rs | 2 +- .../rs-drive/src/drive/votes/fetch/mod.rs | 2 + .../v0/mod.rs | 5 +- .../mod.rs | 23 +- .../v0/mod.rs | 25 +- .../votes/insert/contested_resource/mod.rs | 2 +- packages/rs-drive/src/drive/votes/mod.rs | 5 +- packages/rs-drive/src/drive/votes/paths.rs | 9 +- .../resolve.rs | 73 +++++ .../drive/votes/resolved/vote_polls/mod.rs | 1 - .../query/vote_poll_contestant_votes_query.rs | 4 +- .../src/query/vote_poll_vote_state_query.rs | 167 ++++++---- .../document_create_transition_action/mod.rs | 8 +- .../transformer.rs | 5 +- .../v0/mod.rs | 11 +- .../v0/transformer.rs | 20 +- .../src/state_transition_action/mod.rs | 2 +- .../src/version/dpp_versions.rs | 9 +- .../src/version/drive_versions.rs | 8 +- .../fee/vote_resolution_fund_fees/mod.rs | 2 + .../fee/vote_resolution_fund_fees/v1.rs | 1 + .../src/version/mocks/v2_test.rs | 19 +- .../src/version/mocks/v3_test.rs | 19 +- .../rs-platform-version/src/version/v1.rs | 19 +- 102 files changed, 1687 insertions(+), 609 deletions(-) create mode 100644 packages/rs-dpp/src/errors/consensus/state/document/document_contest_currently_locked_error.rs create mode 100644 packages/rs-dpp/src/errors/consensus/state/document/document_contest_not_joinable_error.rs create mode 100644 packages/rs-dpp/src/voting/vote_info_storage/contested_document_vote_poll_stored_info/mod.rs create mode 100644 packages/rs-dpp/src/voting/vote_info_storage/contested_document_vote_poll_stored_info/v0/mod.rs create mode 100644 packages/rs-dpp/src/voting/vote_info_storage/contested_document_vote_poll_winner_info/mod.rs create mode 100644 packages/rs-dpp/src/voting/vote_info_storage/mod.rs delete mode 100644 packages/rs-dpp/src/voting/vote_outcomes/contested_document_vote_poll_winner_info/mod.rs delete mode 100644 packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/mod.rs delete mode 100644 packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/v0/mod.rs delete mode 100644 packages/rs-dpp/src/voting/vote_outcomes/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/fetch/fetch_contested_document_vote_poll_stored_info/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/fetch/fetch_contested_document_vote_poll_stored_info/v0/mod.rs rename packages/rs-drive/src/drive/votes/{ => fetch}/fetch_identities_voting_for_contenders/mod.rs (98%) rename packages/rs-drive/src/drive/votes/{ => fetch}/fetch_identities_voting_for_contenders/v0/mod.rs (97%) create mode 100644 packages/rs-drive/src/drive/votes/fetch/mod.rs rename packages/rs-drive/src/drive/votes/insert/contested_resource/{insert_record_of_finished_vote_poll => insert_stored_info_for_contested_resource_vote_poll}/mod.rs (66%) rename packages/rs-drive/src/drive/votes/insert/contested_resource/{insert_record_of_finished_vote_poll => insert_stored_info_for_contested_resource_vote_poll}/v0/mod.rs (66%) diff --git a/packages/rs-dpp/src/block/block_info/mod.rs b/packages/rs-dpp/src/block/block_info/mod.rs index 62992d2845..477064f9a1 100644 --- a/packages/rs-dpp/src/block/block_info/mod.rs +++ b/packages/rs-dpp/src/block/block_info/mod.rs @@ -2,6 +2,7 @@ use crate::block::epoch::{Epoch, EPOCH_0}; use crate::prelude::{BlockHeight, CoreBlockHeight, TimestampMillis}; use bincode::{Decode, Encode}; use serde::{Deserialize, Serialize}; +use std::fmt; pub const DEFAULT_BLOCK_INFO: BlockInfo = BlockInfo { time_ms: 0, @@ -29,6 +30,30 @@ pub struct BlockInfo { pub epoch: Epoch, } +impl fmt::Display for BlockInfo { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "BlockInfo {{ time_ms: {}, height: {}, core_height: {}, epoch: {} }}", + self.time_ms, self.height, self.core_height, self.epoch.index + ) + } +} + +// Implementing PartialOrd for BlockInfo based on height +impl PartialOrd for BlockInfo { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +// Implementing Ord for BlockInfo based on height +impl Ord for BlockInfo { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.height.cmp(&other.height) + } +} + impl BlockInfo { // TODO: It's not actually a genesis one. We should use just default to avoid confusion /// Create block info for genesis block diff --git a/packages/rs-dpp/src/block/epoch/mod.rs b/packages/rs-dpp/src/block/epoch/mod.rs index e7fe4aef55..3215bd6103 100644 --- a/packages/rs-dpp/src/block/epoch/mod.rs +++ b/packages/rs-dpp/src/block/epoch/mod.rs @@ -19,7 +19,7 @@ pub const EPOCH_0: Epoch = Epoch { // We make this immutable because it should never be changed or updated // @immutable /// Epoch struct -#[derive(Serialize, Deserialize, Default, Clone, Eq, PartialEq, Copy, Encode, Decode, Debug)] +#[derive(Serialize, Deserialize, Clone, Eq, PartialEq, Copy, Encode, Decode, Debug)] #[serde(rename_all = "camelCase")] pub struct Epoch { /// Epoch index @@ -30,6 +30,12 @@ pub struct Epoch { pub key: [u8; 2], } +impl Default for Epoch { + fn default() -> Self { + Self::new(0).unwrap() + } +} + impl Epoch { /// Create new epoch pub fn new(index: EpochIndex) -> Result { diff --git a/packages/rs-dpp/src/errors/consensus/codes.rs b/packages/rs-dpp/src/errors/consensus/codes.rs index fa93a008f1..56693456a1 100644 --- a/packages/rs-dpp/src/errors/consensus/codes.rs +++ b/packages/rs-dpp/src/errors/consensus/codes.rs @@ -206,6 +206,8 @@ impl ErrorWithCode for StateError { Self::DocumentTimestampsAreEqualError(_) => 40107, Self::DocumentNotForSaleError(_) => 40108, Self::DocumentIncorrectPurchasePriceError(_) => 40109, + Self::DocumentContestCurrentlyLockedError(_) => 40110, + Self::DocumentContestNotJoinableError(_) => 40111, // Identity Errors: 40200-40299 Self::IdentityAlreadyExistsError(_) => 40200, diff --git a/packages/rs-dpp/src/errors/consensus/state/document/document_contest_currently_locked_error.rs b/packages/rs-dpp/src/errors/consensus/state/document/document_contest_currently_locked_error.rs new file mode 100644 index 0000000000..289d21a357 --- /dev/null +++ b/packages/rs-dpp/src/errors/consensus/state/document/document_contest_currently_locked_error.rs @@ -0,0 +1,55 @@ +use crate::consensus::state::state_error::StateError; +use crate::consensus::ConsensusError; +use crate::errors::ProtocolError; +use crate::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStoredInfo; +use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use bincode::{Decode, Encode}; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +use thiserror::Error; + +#[derive( + Error, Debug, Clone, PartialEq, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] +#[error("Document Contest for vote_poll {vote_poll} is currently already locked {stored_info}, unlocking is possible by paying {unlock_cost} credits")] +#[platform_serialize(unversioned)] +pub struct DocumentContestCurrentlyLockedError { + /* + + DO NOT CHANGE ORDER OF FIELDS WITHOUT INTRODUCING OF NEW VERSION + + */ + vote_poll: ContestedDocumentResourceVotePoll, + stored_info: ContestedDocumentVotePollStoredInfo, + unlock_cost: u64, +} + +impl DocumentContestCurrentlyLockedError { + pub fn new( + vote_poll: ContestedDocumentResourceVotePoll, + stored_info: ContestedDocumentVotePollStoredInfo, + unlock_cost: u64, + ) -> Self { + Self { + vote_poll, + stored_info, + unlock_cost, + } + } + + pub fn vote_poll(&self) -> &ContestedDocumentResourceVotePoll { + &self.vote_poll + } + pub fn stored_info(&self) -> &ContestedDocumentVotePollStoredInfo { + &self.stored_info + } + + pub fn unlock_cost(&self) -> u64 { + self.unlock_cost + } +} + +impl From for ConsensusError { + fn from(err: DocumentContestCurrentlyLockedError) -> Self { + Self::StateError(StateError::DocumentContestCurrentlyLockedError(err)) + } +} diff --git a/packages/rs-dpp/src/errors/consensus/state/document/document_contest_not_joinable_error.rs b/packages/rs-dpp/src/errors/consensus/state/document/document_contest_not_joinable_error.rs new file mode 100644 index 0000000000..01abd52d67 --- /dev/null +++ b/packages/rs-dpp/src/errors/consensus/state/document/document_contest_not_joinable_error.rs @@ -0,0 +1,70 @@ +use crate::consensus::state::state_error::StateError; +use crate::consensus::ConsensusError; +use crate::errors::ProtocolError; +use crate::prelude::TimestampMillis; +use crate::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStoredInfo; +use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use bincode::{Decode, Encode}; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +use thiserror::Error; + +#[derive( + Error, Debug, Clone, PartialEq, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] +#[error("Document Contest for vote_poll {vote_poll} is not joinable {stored_info}, it started {start_time} and it is now {current_time}, and you can only join for {joinable_time}")] +#[platform_serialize(unversioned)] +pub struct DocumentContestNotJoinableError { + /* + + DO NOT CHANGE ORDER OF FIELDS WITHOUT INTRODUCING OF NEW VERSION + + */ + vote_poll: ContestedDocumentResourceVotePoll, + stored_info: ContestedDocumentVotePollStoredInfo, + start_time: TimestampMillis, + current_time: TimestampMillis, + joinable_time: TimestampMillis, +} + +impl DocumentContestNotJoinableError { + pub fn new( + vote_poll: ContestedDocumentResourceVotePoll, + stored_info: ContestedDocumentVotePollStoredInfo, + start_time: TimestampMillis, + current_time: TimestampMillis, + joinable_time: TimestampMillis, + ) -> Self { + Self { + vote_poll, + stored_info, + start_time, + current_time, + joinable_time, + } + } + + pub fn vote_poll(&self) -> &ContestedDocumentResourceVotePoll { + &self.vote_poll + } + pub fn stored_info(&self) -> &ContestedDocumentVotePollStoredInfo { + &self.stored_info + } + + pub fn start_time(&self) -> TimestampMillis { + self.start_time + } + + pub fn current_time(&self) -> TimestampMillis { + self.current_time + } + + pub fn joinable_time(&self) -> TimestampMillis { + self.joinable_time + } +} + +impl From for ConsensusError { + fn from(err: DocumentContestNotJoinableError) -> Self { + Self::StateError(StateError::DocumentContestNotJoinableError(err)) + } +} diff --git a/packages/rs-dpp/src/errors/consensus/state/document/mod.rs b/packages/rs-dpp/src/errors/consensus/state/document/mod.rs index 36621070ab..e18c91dad6 100644 --- a/packages/rs-dpp/src/errors/consensus/state/document/mod.rs +++ b/packages/rs-dpp/src/errors/consensus/state/document/mod.rs @@ -1,4 +1,6 @@ pub mod document_already_present_error; +pub mod document_contest_currently_locked_error; +pub mod document_contest_not_joinable_error; pub mod document_incorrect_purchase_price_error; pub mod document_not_for_sale_error; pub mod document_not_found_error; diff --git a/packages/rs-dpp/src/errors/consensus/state/state_error.rs b/packages/rs-dpp/src/errors/consensus/state/state_error.rs index 7964e789e2..001b772085 100644 --- a/packages/rs-dpp/src/errors/consensus/state/state_error.rs +++ b/packages/rs-dpp/src/errors/consensus/state/state_error.rs @@ -29,6 +29,8 @@ use crate::consensus::state::identity::{ use crate::consensus::ConsensusError; use crate::consensus::state::data_contract::data_contract_update_permission_error::DataContractUpdatePermissionError; use crate::consensus::state::data_contract::document_type_update_error::DocumentTypeUpdateError; +use crate::consensus::state::document::document_contest_currently_locked_error::DocumentContestCurrentlyLockedError; +use crate::consensus::state::document::document_contest_not_joinable_error::DocumentContestNotJoinableError; use crate::consensus::state::document::document_incorrect_purchase_price_error::DocumentIncorrectPurchasePriceError; use crate::consensus::state::document::document_not_for_sale_error::DocumentNotForSaleError; use crate::consensus::state::identity::identity_public_key_already_exists_for_unique_contract_bounds_error::IdentityPublicKeyAlreadyExistsForUniqueContractBoundsError; @@ -60,6 +62,12 @@ pub enum StateError { #[error(transparent)] DocumentAlreadyPresentError(DocumentAlreadyPresentError), + #[error(transparent)] + DocumentContestCurrentlyLockedError(DocumentContestCurrentlyLockedError), + + #[error(transparent)] + DocumentContestNotJoinableError(DocumentContestNotJoinableError), + #[error(transparent)] DocumentNotFoundError(DocumentNotFoundError), diff --git a/packages/rs-dpp/src/tests/fixtures/identity_fixture.rs b/packages/rs-dpp/src/tests/fixtures/identity_fixture.rs index b0e92a5850..b8ff26652a 100644 --- a/packages/rs-dpp/src/tests/fixtures/identity_fixture.rs +++ b/packages/rs-dpp/src/tests/fixtures/identity_fixture.rs @@ -1,10 +1,9 @@ use crate::identity::identity_public_key::v0::IdentityPublicKeyV0; -use crate::identity::{IdentityPublicKey, IdentityV0, KeyType, Purpose, SecurityLevel}; +use crate::identity::{IdentityV0, KeyType, Purpose, SecurityLevel}; use platform_value::platform_value; use platform_value::string_encoding::Encoding; use platform_value::BinaryData; use serde_json::json; -use std::collections::BTreeMap; use crate::prelude::{Identifier, Identity}; diff --git a/packages/rs-dpp/src/voting/contender_structs/mod.rs b/packages/rs-dpp/src/voting/contender_structs/mod.rs index 3b7a803e7e..856ca73378 100644 --- a/packages/rs-dpp/src/voting/contender_structs/mod.rs +++ b/packages/rs-dpp/src/voting/contender_structs/mod.rs @@ -4,8 +4,10 @@ use crate::document::Document; use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use crate::ProtocolError; +use platform_value::string_encoding::Encoding; use platform_value::Identifier; use platform_version::version::PlatformVersion; +use std::fmt; /// Represents a contender in the contested document vote poll. /// This is for internal use where the document is in serialized form @@ -49,6 +51,21 @@ pub struct FinalizedResourceVoteChoicesWithVoterInfo { /// The pro_tx_hashes of the voters for this contender. pub voters: Vec, } +impl fmt::Display for FinalizedResourceVoteChoicesWithVoterInfo { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let voters_str: Vec = self + .voters + .iter() + .map(|v| v.to_string(Encoding::Base58)) + .collect(); + write!( + f, + "FinalizedResourceVoteChoicesWithVoterInfo {{ resource_vote_choice: {}, voters: [{}] }}", + self.resource_vote_choice, + voters_str.join(", ") + ) + } +} /// Represents a finalized contender in the contested document vote poll. /// This is for internal use where the document is in serialized form diff --git a/packages/rs-dpp/src/voting/mod.rs b/packages/rs-dpp/src/voting/mod.rs index 95f31e124d..dc8d5cb5fe 100644 --- a/packages/rs-dpp/src/voting/mod.rs +++ b/packages/rs-dpp/src/voting/mod.rs @@ -1,5 +1,5 @@ pub mod contender_structs; pub mod vote_choices; -pub mod vote_outcomes; +pub mod vote_info_storage; pub mod vote_polls; pub mod votes; diff --git a/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs b/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs index b522f4d44e..fa4b19a725 100644 --- a/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs +++ b/packages/rs-dpp/src/voting/vote_choices/resource_vote_choice/mod.rs @@ -6,6 +6,7 @@ use bincode::{Decode, Encode}; use platform_value::Identifier; #[cfg(feature = "vote-serde-conversion")] use serde::{Deserialize, Serialize}; +use std::fmt; /// A resource votes is a votes determining what we should do with a contested resource. /// For example Alice and Bob both want the username "Malaka" @@ -29,6 +30,18 @@ pub enum ResourceVoteChoice { Lock, } +impl fmt::Display for ResourceVoteChoice { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + ResourceVoteChoice::TowardsIdentity(identifier) => { + write!(f, "TowardsIdentity({})", identifier) + } + ResourceVoteChoice::Abstain => write!(f, "Abstain"), + ResourceVoteChoice::Lock => write!(f, "Lock"), + } + } +} + impl TryFrom<(i32, Option>)> for ResourceVoteChoice { type Error = ProtocolError; diff --git a/packages/rs-dpp/src/voting/vote_info_storage/contested_document_vote_poll_stored_info/mod.rs b/packages/rs-dpp/src/voting/vote_info_storage/contested_document_vote_poll_stored_info/mod.rs new file mode 100644 index 0000000000..e50b5c5477 --- /dev/null +++ b/packages/rs-dpp/src/voting/vote_info_storage/contested_document_vote_poll_stored_info/mod.rs @@ -0,0 +1,208 @@ +mod v0; + +use crate::block::block_info::BlockInfo; +use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; +use crate::voting::contender_structs::{ + ContenderWithSerializedDocument, FinalizedResourceVoteChoicesWithVoterInfo, +}; +use crate::voting::vote_info_storage::contested_document_vote_poll_stored_info::v0::ContestedDocumentVotePollStoredInfoV0; +use crate::voting::vote_info_storage::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; +use crate::ProtocolError; +use derive_more::From; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +use platform_value::Identifier; +use platform_version::version::PlatformVersion; +use std::fmt; +pub use v0::ContestedDocumentVotePollStoredInfoV0Getters; + +pub type LockedVotePollCounter = u16; + +#[derive(Debug, PartialEq, Eq, Clone, Copy, Default, Encode, Decode)] +pub enum ContestedDocumentVotePollStatus { + #[default] + NotStarted, + Awarded(Identifier), + Locked, + Started(BlockInfo), +} + +impl fmt::Display for ContestedDocumentVotePollStatus { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + ContestedDocumentVotePollStatus::NotStarted => write!(f, "NotStarted"), + ContestedDocumentVotePollStatus::Awarded(identifier) => { + write!(f, "Awarded({})", identifier) + } + ContestedDocumentVotePollStatus::Locked => write!(f, "Locked"), + ContestedDocumentVotePollStatus::Started(block_info) => { + write!(f, "Started({})", block_info) + } + } + } +} + +impl ContestedDocumentVotePollStatus { + pub fn awarded_or_locked(&self) -> bool { + matches!( + self, + ContestedDocumentVotePollStatus::Awarded(_) | ContestedDocumentVotePollStatus::Locked + ) + } +} + +/// Represents the stored info after a contested document vote poll. +/// +/// This struct holds the list of contenders, the abstaining vote tally. +#[derive( + Debug, PartialEq, Eq, Clone, From, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] +#[platform_serialize(unversioned)] +pub enum ContestedDocumentVotePollStoredInfo { + /// V0. + V0(ContestedDocumentVotePollStoredInfoV0), +} + +impl fmt::Display for ContestedDocumentVotePollStoredInfo { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + ContestedDocumentVotePollStoredInfo::V0(info) => write!(f, "V0({})", info), + } + } +} + +impl ContestedDocumentVotePollStoredInfo { + pub fn new( + start_block: BlockInfo, + platform_version: &PlatformVersion, + ) -> Result { + match platform_version + .dpp + .voting_versions + .contested_document_vote_poll_stored_info_version + { + 0 => Ok(ContestedDocumentVotePollStoredInfoV0::new(start_block).into()), + version => Err(ProtocolError::UnknownVersionMismatch { + method: "ContestedDocumentVotePollStoredInfo::new".to_string(), + known_versions: vec![0], + received: version, + }), + } + } + + pub fn update_to_latest_version( + self, + platform_version: &PlatformVersion, + ) -> Result { + match platform_version + .dpp + .voting_versions + .contested_document_vote_poll_stored_info_version + { + 0 => { + // Nothing to do + match self { + ContestedDocumentVotePollStoredInfo::V0(_) => Ok(self), + } + } + version => Err(ProtocolError::UnknownVersionMismatch { + method: "FinalizedContestedDocumentVotePollStoredInfo::update_to_latest_version" + .to_string(), + known_versions: vec![0], + received: version, + }), + } + } + + pub fn finalize_vote_poll( + &mut self, + resource_vote_choices: Vec, + finalization_block: BlockInfo, + winner: ContestedDocumentVotePollWinnerInfo, + ) -> Result<(), ProtocolError> { + match self { + ContestedDocumentVotePollStoredInfo::V0(v0) => { + v0.finalize_vote_poll(resource_vote_choices, finalization_block, winner) + } + } + } +} + +impl ContestedDocumentVotePollStoredInfoV0Getters for ContestedDocumentVotePollStoredInfo { + fn last_resource_vote_choices( + &self, + ) -> Option<&Vec> { + match self { + ContestedDocumentVotePollStoredInfo::V0(v0) => v0.last_resource_vote_choices(), + } + } + + fn awarded_block(&self) -> Option { + match self { + ContestedDocumentVotePollStoredInfo::V0(v0) => v0.awarded_block(), + } + } + + fn current_start_block(&self) -> Option { + match self { + ContestedDocumentVotePollStoredInfo::V0(v0) => v0.current_start_block(), + } + } + + fn last_finalization_block(&self) -> Option { + match self { + ContestedDocumentVotePollStoredInfo::V0(v0) => v0.last_finalization_block(), + } + } + + fn winner(&self) -> ContestedDocumentVotePollWinnerInfo { + match self { + ContestedDocumentVotePollStoredInfo::V0(v0) => v0.winner(), + } + } + + fn last_locked_votes(&self) -> Option { + match self { + ContestedDocumentVotePollStoredInfo::V0(v0) => v0.last_locked_votes(), + } + } + + fn last_locked_voters(&self) -> Option> { + match self { + ContestedDocumentVotePollStoredInfo::V0(v0) => v0.last_locked_voters(), + } + } + + fn last_abstain_votes(&self) -> Option { + match self { + ContestedDocumentVotePollStoredInfo::V0(v0) => v0.last_abstain_votes(), + } + } + + fn last_abstain_voters(&self) -> Option> { + match self { + ContestedDocumentVotePollStoredInfo::V0(v0) => v0.last_abstain_voters(), + } + } + + fn contender_votes_in_vec_of_contender_with_serialized_document( + &self, + ) -> Option> { + match self { + ContestedDocumentVotePollStoredInfo::V0(v0) => { + v0.contender_votes_in_vec_of_contender_with_serialized_document() + } + } + } + + fn vote_poll_status(&self) -> ContestedDocumentVotePollStatus { + match self { + ContestedDocumentVotePollStoredInfo::V0(v0) => v0.vote_poll_status, + } + } + + fn vote_poll_status_ref(&self) -> &ContestedDocumentVotePollStatus { + match self { + ContestedDocumentVotePollStoredInfo::V0(v0) => &v0.vote_poll_status, + } + } +} diff --git a/packages/rs-dpp/src/voting/vote_info_storage/contested_document_vote_poll_stored_info/v0/mod.rs b/packages/rs-dpp/src/voting/vote_info_storage/contested_document_vote_poll_stored_info/v0/mod.rs new file mode 100644 index 0000000000..c7d19399ff --- /dev/null +++ b/packages/rs-dpp/src/voting/vote_info_storage/contested_document_vote_poll_stored_info/v0/mod.rs @@ -0,0 +1,295 @@ +use crate::block::block_info::BlockInfo; +use crate::voting::contender_structs::{ + ContenderWithSerializedDocument, FinalizedResourceVoteChoicesWithVoterInfo, +}; +use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use crate::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStatus; +use crate::voting::vote_info_storage::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; +use crate::ProtocolError; +use bincode::{Decode, Encode}; +use platform_value::Identifier; +use std::fmt; + +// We can have multiple rounds of voting, after an unlock for example +#[derive(Debug, PartialEq, Eq, Clone, Default, Encode, Decode)] +pub struct ContestedDocumentVotePollStoredInfoVoteEventV0 { + /// The list of contenders returned by the query. + pub resource_vote_choices: Vec, + /// Start Block + pub start_block: BlockInfo, + /// Finalization Block + pub finalization_block: BlockInfo, + /// Winner info + pub winner: ContestedDocumentVotePollWinnerInfo, +} + +impl fmt::Display for ContestedDocumentVotePollStoredInfoVoteEventV0 { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let resource_vote_choices_str: Vec = self + .resource_vote_choices + .iter() + .map(|v| v.to_string()) + .collect(); + write!( + f, + "ContestedDocumentVotePollStoredInfoVoteEventV0 {{ resource_vote_choices: [{}], start_block: {}, finalization_block: {}, winner: {} }}", + resource_vote_choices_str.join(", "), + self.start_block, + self.finalization_block, + self.winner + ) + } +} + +#[derive(Debug, PartialEq, Eq, Clone, Default, Encode, Decode)] +pub struct ContestedDocumentVotePollStoredInfoV0 { + /// The list of contenders returned by the query. + pub finalized_events: Vec, + /// Start Block + pub vote_poll_status: ContestedDocumentVotePollStatus, + /// Locked count, aka how many times has this previously been locked + pub locked_count: u16, +} + +impl fmt::Display for ContestedDocumentVotePollStoredInfoV0 { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let finalized_events_str: Vec = self + .finalized_events + .iter() + .map(|v| v.to_string()) + .collect(); + write!( + f, + "ContestedDocumentVotePollStoredInfoV0 {{ finalized_events: [{}], vote_poll_status: {}, locked_count: {} }}", + finalized_events_str.join(", "), + self.vote_poll_status, + self.locked_count + ) + } +} + +impl ContestedDocumentVotePollStoredInfoV0 { + pub fn new(start_block: BlockInfo) -> ContestedDocumentVotePollStoredInfoV0 { + ContestedDocumentVotePollStoredInfoV0 { + finalized_events: vec![], + vote_poll_status: ContestedDocumentVotePollStatus::Started(start_block), + locked_count: 0, + } + } +} + +impl ContestedDocumentVotePollStoredInfoVoteEventV0 { + pub fn new( + resource_vote_choices: Vec, + start_block: BlockInfo, + finalization_block: BlockInfo, + winner: ContestedDocumentVotePollWinnerInfo, + ) -> ContestedDocumentVotePollStoredInfoVoteEventV0 { + ContestedDocumentVotePollStoredInfoVoteEventV0 { + resource_vote_choices, + start_block, + finalization_block, + winner, + } + } +} + +impl ContestedDocumentVotePollStoredInfoV0 { + /// This will finalize the current vote poll. + /// However, if this results in it being locked, then it is possible to unlock in the future. + pub fn finalize_vote_poll( + &mut self, + resource_vote_choices: Vec, + finalization_block: BlockInfo, + winner: ContestedDocumentVotePollWinnerInfo, + ) -> Result<(), ProtocolError> { + let ContestedDocumentVotePollStatus::Started(started_block) = self.vote_poll_status else { + return Err(ProtocolError::CorruptedCodeExecution( + "trying to finalized vote poll that hasn't started".to_string(), + )); + }; + self.finalized_events + .push(ContestedDocumentVotePollStoredInfoVoteEventV0::new( + resource_vote_choices, + started_block, + finalization_block, + winner, + )); + match winner { + ContestedDocumentVotePollWinnerInfo::NoWinner => { + if self.locked_count > 0 { + // We return it to being in the locked position + self.vote_poll_status = ContestedDocumentVotePollStatus::Locked; + } else { + self.vote_poll_status = ContestedDocumentVotePollStatus::NotStarted; + } + } + ContestedDocumentVotePollWinnerInfo::WonByIdentity(identifier) => { + self.vote_poll_status = ContestedDocumentVotePollStatus::Awarded(identifier); + } + ContestedDocumentVotePollWinnerInfo::Locked => { + self.locked_count += 1; + self.vote_poll_status = ContestedDocumentVotePollStatus::Locked; + } + } + Ok(()) + } +} + +pub trait ContestedDocumentVotePollStoredInfoV0Getters { + fn last_resource_vote_choices(&self) + -> Option<&Vec>; + fn awarded_block(&self) -> Option; + fn current_start_block(&self) -> Option; + fn last_finalization_block(&self) -> Option; + fn winner(&self) -> ContestedDocumentVotePollWinnerInfo; + + fn last_locked_votes(&self) -> Option; + + fn last_locked_voters(&self) -> Option>; + + fn last_abstain_votes(&self) -> Option; + + fn last_abstain_voters(&self) -> Option>; + fn contender_votes_in_vec_of_contender_with_serialized_document( + &self, + ) -> Option>; + fn vote_poll_status(&self) -> ContestedDocumentVotePollStatus; + fn vote_poll_status_ref(&self) -> &ContestedDocumentVotePollStatus; +} + +impl ContestedDocumentVotePollStoredInfoV0Getters for ContestedDocumentVotePollStoredInfoV0 { + fn last_resource_vote_choices( + &self, + ) -> Option<&Vec> { + self.finalized_events + .last() + .map(|event| &event.resource_vote_choices) + } + + fn awarded_block(&self) -> Option { + if matches!( + self.vote_poll_status, + ContestedDocumentVotePollStatus::Awarded(_) + ) { + self.finalized_events + .last() + .map(|event| event.finalization_block) + } else { + None + } + } + + fn current_start_block(&self) -> Option { + if let ContestedDocumentVotePollStatus::Started(start_block) = self.vote_poll_status { + Some(start_block) + } else { + None + } + } + + fn last_finalization_block(&self) -> Option { + self.finalized_events + .last() + .map(|event| event.finalization_block) + } + + fn winner(&self) -> ContestedDocumentVotePollWinnerInfo { + match self.vote_poll_status { + ContestedDocumentVotePollStatus::NotStarted => { + ContestedDocumentVotePollWinnerInfo::NoWinner + } + ContestedDocumentVotePollStatus::Awarded(identifier) => { + ContestedDocumentVotePollWinnerInfo::WonByIdentity(identifier) + } + ContestedDocumentVotePollStatus::Locked => ContestedDocumentVotePollWinnerInfo::Locked, + ContestedDocumentVotePollStatus::Started(_) => { + ContestedDocumentVotePollWinnerInfo::NoWinner + } + } + } + + fn last_locked_votes(&self) -> Option { + self.last_resource_vote_choices() + .map(|resource_vote_choices| { + resource_vote_choices + .iter() + .filter(|choice| { + matches!(choice.resource_vote_choice, ResourceVoteChoice::Lock) + }) + .map(|choice| choice.voters.len() as u32) + .sum() + }) + } + + fn last_locked_voters(&self) -> Option> { + self.last_resource_vote_choices() + .map(|resource_vote_choices| { + resource_vote_choices + .iter() + .filter(|choice| { + matches!(choice.resource_vote_choice, ResourceVoteChoice::Lock) + }) + .flat_map(|choice| choice.voters.clone()) + .collect() + }) + } + + fn last_abstain_votes(&self) -> Option { + self.last_resource_vote_choices() + .map(|resource_vote_choices| { + resource_vote_choices + .iter() + .filter(|choice| { + matches!(choice.resource_vote_choice, ResourceVoteChoice::Abstain) + }) + .map(|choice| choice.voters.len() as u32) + .sum() + }) + } + + fn last_abstain_voters(&self) -> Option> { + self.last_resource_vote_choices() + .map(|resource_vote_choices| { + resource_vote_choices + .iter() + .filter(|choice| { + matches!(choice.resource_vote_choice, ResourceVoteChoice::Abstain) + }) + .flat_map(|choice| choice.voters.clone()) + .collect() + }) + } + + fn contender_votes_in_vec_of_contender_with_serialized_document( + &self, + ) -> Option> { + self.last_resource_vote_choices() + .map(|resource_vote_choices| { + resource_vote_choices + .iter() + .filter_map(|choice| { + if let ResourceVoteChoice::TowardsIdentity(identity_id) = + &choice.resource_vote_choice + { + Some(ContenderWithSerializedDocument { + identity_id: *identity_id, + serialized_document: None, + vote_tally: Some(choice.voters.len() as u32), + }) + } else { + None + } + }) + .collect() + }) + } + + fn vote_poll_status(&self) -> ContestedDocumentVotePollStatus { + self.vote_poll_status + } + + fn vote_poll_status_ref(&self) -> &ContestedDocumentVotePollStatus { + &self.vote_poll_status + } +} diff --git a/packages/rs-dpp/src/voting/vote_info_storage/contested_document_vote_poll_winner_info/mod.rs b/packages/rs-dpp/src/voting/vote_info_storage/contested_document_vote_poll_winner_info/mod.rs new file mode 100644 index 0000000000..7e66612014 --- /dev/null +++ b/packages/rs-dpp/src/voting/vote_info_storage/contested_document_vote_poll_winner_info/mod.rs @@ -0,0 +1,23 @@ +use bincode::{Decode, Encode}; +use platform_value::Identifier; +use std::fmt; + +#[derive(Debug, PartialEq, Eq, Clone, Copy, Default, Encode, Decode)] +pub enum ContestedDocumentVotePollWinnerInfo { + #[default] + NoWinner, + WonByIdentity(Identifier), + Locked, +} + +impl fmt::Display for ContestedDocumentVotePollWinnerInfo { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + ContestedDocumentVotePollWinnerInfo::NoWinner => write!(f, "NoWinner"), + ContestedDocumentVotePollWinnerInfo::WonByIdentity(identifier) => { + write!(f, "WonByIdentity({})", identifier) + } + ContestedDocumentVotePollWinnerInfo::Locked => write!(f, "Locked"), + } + } +} diff --git a/packages/rs-dpp/src/voting/vote_info_storage/mod.rs b/packages/rs-dpp/src/voting/vote_info_storage/mod.rs new file mode 100644 index 0000000000..a69f0aee63 --- /dev/null +++ b/packages/rs-dpp/src/voting/vote_info_storage/mod.rs @@ -0,0 +1,2 @@ +pub mod contested_document_vote_poll_stored_info; +pub mod contested_document_vote_poll_winner_info; diff --git a/packages/rs-dpp/src/voting/vote_outcomes/contested_document_vote_poll_winner_info/mod.rs b/packages/rs-dpp/src/voting/vote_outcomes/contested_document_vote_poll_winner_info/mod.rs deleted file mode 100644 index 2a2317bd7b..0000000000 --- a/packages/rs-dpp/src/voting/vote_outcomes/contested_document_vote_poll_winner_info/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -use bincode::{Decode, Encode}; -use platform_value::Identifier; - -#[derive(Debug, PartialEq, Eq, Clone, Copy, Default, Encode, Decode)] -pub enum ContestedDocumentVotePollWinnerInfo { - #[default] - NoWinner, - WonByIdentity(Identifier), - Locked, -} diff --git a/packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/mod.rs b/packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/mod.rs deleted file mode 100644 index 4e087c8f5e..0000000000 --- a/packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/mod.rs +++ /dev/null @@ -1,110 +0,0 @@ -mod v0; - -use crate::block::block_info::BlockInfo; -use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; -use crate::voting::contender_structs::{ - ContenderWithSerializedDocument, FinalizedResourceVoteChoicesWithVoterInfo, -}; -use crate::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; -use crate::voting::vote_outcomes::finalized_contested_document_vote_poll_stored_info::v0::FinalizedContestedDocumentVotePollStoredInfoV0; -use crate::ProtocolError; -use derive_more::From; -use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; -use platform_value::Identifier; -use platform_version::version::PlatformVersion; -pub use v0::FinalizedContestedDocumentVotePollStoredInfoV0Getters; - -/// Represents the stored info after a contested document vote poll. -/// -/// This struct holds the list of contenders, the abstaining vote tally. -#[derive( - Debug, PartialEq, Eq, Clone, From, Encode, Decode, PlatformSerialize, PlatformDeserialize, -)] -#[platform_serialize(unversioned)] -pub enum FinalizedContestedDocumentVotePollStoredInfo { - /// V0. - V0(FinalizedContestedDocumentVotePollStoredInfoV0), -} - -impl FinalizedContestedDocumentVotePollStoredInfo { - pub fn new( - resource_vote_choices: Vec, - finalization_block: BlockInfo, - winner: ContestedDocumentVotePollWinnerInfo, - platform_version: &PlatformVersion, - ) -> Result { - match platform_version - .dpp - .voting_versions - .finalized_contested_document_vote_poll_stored_info_version - { - 0 => Ok(FinalizedContestedDocumentVotePollStoredInfoV0::new( - resource_vote_choices, - finalization_block, - winner, - ) - .into()), - version => Err(ProtocolError::UnknownVersionMismatch { - method: "FinalizedContestedDocumentVotePollStoredInfo::new".to_string(), - known_versions: vec![0], - received: version, - }), - } - } -} - -impl FinalizedContestedDocumentVotePollStoredInfoV0Getters - for FinalizedContestedDocumentVotePollStoredInfo -{ - fn resource_vote_choices(&self) -> &Vec { - match self { - FinalizedContestedDocumentVotePollStoredInfo::V0(v0) => &v0.resource_vote_choices, - } - } - - fn finalization_block(&self) -> &BlockInfo { - match self { - FinalizedContestedDocumentVotePollStoredInfo::V0(v0) => &v0.finalization_block, - } - } - - fn winner(&self) -> &ContestedDocumentVotePollWinnerInfo { - match self { - FinalizedContestedDocumentVotePollStoredInfo::V0(v0) => &v0.winner, - } - } - - fn locked_votes(&self) -> u32 { - match self { - FinalizedContestedDocumentVotePollStoredInfo::V0(v0) => v0.locked_votes(), - } - } - - fn locked_voters(&self) -> Vec { - match self { - FinalizedContestedDocumentVotePollStoredInfo::V0(v0) => v0.locked_voters(), - } - } - - fn abstain_votes(&self) -> u32 { - match self { - FinalizedContestedDocumentVotePollStoredInfo::V0(v0) => v0.abstain_votes(), - } - } - - fn abstain_voters(&self) -> Vec { - match self { - FinalizedContestedDocumentVotePollStoredInfo::V0(v0) => v0.abstain_voters(), - } - } - - fn contender_votes_in_vec_of_contender_with_serialized_document( - &self, - ) -> Vec { - match self { - FinalizedContestedDocumentVotePollStoredInfo::V0(v0) => { - v0.contender_votes_in_vec_of_contender_with_serialized_document() - } - } - } -} diff --git a/packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/v0/mod.rs b/packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/v0/mod.rs deleted file mode 100644 index f1db7510b7..0000000000 --- a/packages/rs-dpp/src/voting/vote_outcomes/finalized_contested_document_vote_poll_stored_info/v0/mod.rs +++ /dev/null @@ -1,119 +0,0 @@ -use crate::block::block_info::BlockInfo; -use crate::voting::contender_structs::{ - ContenderWithSerializedDocument, FinalizedResourceVoteChoicesWithVoterInfo, -}; -use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use crate::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; -use crate::voting::vote_outcomes::finalized_contested_document_vote_poll_stored_info::FinalizedContestedDocumentVotePollStoredInfo; -use bincode::{Decode, Encode}; -use platform_value::Identifier; - -#[derive(Debug, PartialEq, Eq, Clone, Default, Encode, Decode)] -pub struct FinalizedContestedDocumentVotePollStoredInfoV0 { - /// The list of contenders returned by the query. - pub resource_vote_choices: Vec, - /// Finalization Block - pub finalization_block: BlockInfo, - /// Winner info - pub winner: ContestedDocumentVotePollWinnerInfo, -} - -impl FinalizedContestedDocumentVotePollStoredInfoV0 { - pub fn new( - resource_vote_choices: Vec, - finalization_block: BlockInfo, - winner: ContestedDocumentVotePollWinnerInfo, - ) -> FinalizedContestedDocumentVotePollStoredInfoV0 { - FinalizedContestedDocumentVotePollStoredInfoV0 { - resource_vote_choices, - finalization_block, - winner, - } - } -} - -pub trait FinalizedContestedDocumentVotePollStoredInfoV0Getters { - fn resource_vote_choices(&self) -> &Vec; - fn finalization_block(&self) -> &BlockInfo; - fn winner(&self) -> &ContestedDocumentVotePollWinnerInfo; - - fn locked_votes(&self) -> u32; - - fn locked_voters(&self) -> Vec; - - fn abstain_votes(&self) -> u32; - - fn abstain_voters(&self) -> Vec; - fn contender_votes_in_vec_of_contender_with_serialized_document( - &self, - ) -> Vec; -} - -impl FinalizedContestedDocumentVotePollStoredInfoV0Getters - for FinalizedContestedDocumentVotePollStoredInfoV0 -{ - fn resource_vote_choices(&self) -> &Vec { - &self.resource_vote_choices - } - - fn finalization_block(&self) -> &BlockInfo { - &self.finalization_block - } - - fn winner(&self) -> &ContestedDocumentVotePollWinnerInfo { - &self.winner - } - - fn locked_votes(&self) -> u32 { - self.resource_vote_choices - .iter() - .filter(|choice| matches!(choice.resource_vote_choice, ResourceVoteChoice::Lock)) - .map(|choice| choice.voters.len() as u32) - .sum() - } - - fn locked_voters(&self) -> Vec { - self.resource_vote_choices - .iter() - .filter(|choice| matches!(choice.resource_vote_choice, ResourceVoteChoice::Lock)) - .flat_map(|choice| choice.voters.clone()) - .collect() - } - - fn abstain_votes(&self) -> u32 { - self.resource_vote_choices - .iter() - .filter(|choice| matches!(choice.resource_vote_choice, ResourceVoteChoice::Abstain)) - .map(|choice| choice.voters.len() as u32) - .sum() - } - - fn abstain_voters(&self) -> Vec { - self.resource_vote_choices - .iter() - .filter(|choice| matches!(choice.resource_vote_choice, ResourceVoteChoice::Abstain)) - .flat_map(|choice| choice.voters.clone()) - .collect() - } - - fn contender_votes_in_vec_of_contender_with_serialized_document( - &self, - ) -> Vec { - self.resource_vote_choices - .iter() - .filter_map(|choice| { - if let ResourceVoteChoice::TowardsIdentity(identity_id) = - &choice.resource_vote_choice - { - Some(ContenderWithSerializedDocument { - identity_id: *identity_id, - serialized_document: None, - vote_tally: Some(choice.voters.len() as u32), - }) - } else { - None - } - }) - .collect() - } -} diff --git a/packages/rs-dpp/src/voting/vote_outcomes/mod.rs b/packages/rs-dpp/src/voting/vote_outcomes/mod.rs deleted file mode 100644 index ac6f33b0ab..0000000000 --- a/packages/rs-dpp/src/voting/vote_outcomes/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod contested_document_vote_poll_winner_info; -pub mod finalized_contested_document_vote_poll_stored_info; diff --git a/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs b/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs index 2e4516d9f2..21f953f844 100644 --- a/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs +++ b/packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs @@ -6,6 +6,7 @@ use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use platform_value::{Identifier, Value}; #[cfg(feature = "vote-serde-conversion")] use serde::{Deserialize, Serialize}; +use std::fmt; #[derive(Debug, Clone, Encode, Decode, PlatformSerialize, PlatformDeserialize, PartialEq)] #[cfg_attr( @@ -22,6 +23,22 @@ pub struct ContestedDocumentResourceVotePoll { pub index_values: Vec, } +impl fmt::Display for ContestedDocumentResourceVotePoll { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + // Format the index_values as a comma-separated list + let index_values_str: Vec = + self.index_values.iter().map(|v| v.to_string()).collect(); + write!( + f, + "ContestedDocumentResourceVotePoll {{ contract_id: {}, document_type_name: {}, index_name: {}, index_values: [{}] }}", + self.contract_id, + self.document_type_name, + self.index_name, + index_values_str.join(", ") + ) + } +} + impl Default for ContestedDocumentResourceVotePoll { fn default() -> Self { ContestedDocumentResourceVotePoll { diff --git a/packages/rs-dpp/src/voting/vote_polls/mod.rs b/packages/rs-dpp/src/voting/vote_polls/mod.rs index 50fec4fe6c..d05bcb344d 100644 --- a/packages/rs-dpp/src/voting/vote_polls/mod.rs +++ b/packages/rs-dpp/src/voting/vote_polls/mod.rs @@ -1,5 +1,4 @@ use crate::identity::state_transition::asset_lock_proof::{Decode, Encode}; -use crate::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use crate::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use crate::ProtocolError; use derive_more::From; @@ -7,7 +6,6 @@ use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use platform_value::Identifier; #[cfg(feature = "vote-serde-conversion")] use serde::{Deserialize, Serialize}; -use std::collections::BTreeMap; pub mod contested_document_resource_vote_poll; diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs index 56657d57c6..ab49d06f83 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs @@ -6,7 +6,7 @@ use dpp::document::DocumentV0Getters; use dpp::prelude::TimestampMillis; use dpp::version::PlatformVersion; use dpp::voting::contender_structs::FinalizedContender; -use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; +use dpp::voting::vote_info_storage::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; use drive::drive::votes::resolved::vote_polls::resolve::VotePollResolver; use drive::drive::votes::resolved::vote_polls::{ResolvedVotePoll, ResolvedVotePollWithVotes}; use drive::grovedb::TransactionArg; diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/mod.rs index 4a6bba3ee2..05a48ad45c 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/mod.rs @@ -2,12 +2,10 @@ use crate::error::execution::ExecutionError; use crate::error::Error; use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; -use dpp::block::block_info::BlockInfo; use dpp::identifier::Identifier; use dpp::prelude::TimestampMillis; use dpp::version::PlatformVersion; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use drive::grovedb::TransactionArg; use std::collections::BTreeMap; diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs index f90c76e841..0941f359b2 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_contested_resources_vote_polls_end/v0/mod.rs @@ -8,9 +8,8 @@ use dpp::version::PlatformVersion; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use dpp::ProtocolError; use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; -use drive::error::drive::DriveError; use drive::grovedb::TransactionArg; -use std::collections::{BTreeMap, HashMap}; +use std::collections::BTreeMap; impl Platform where diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/mod.rs index bc79f90ccc..d5089264b8 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/mod.rs @@ -2,11 +2,8 @@ use crate::error::execution::ExecutionError; use crate::error::Error; use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; -use dpp::block::block_info::BlockInfo; use dpp::prelude::TimestampMillis; use dpp::version::PlatformVersion; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; -use dpp::voting::vote_polls::VotePoll; use drive::drive::votes::resolved::vote_polls::ResolvedVotePollWithVotes; use drive::grovedb::TransactionArg; use std::collections::BTreeMap; diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/v0/mod.rs index d4111e7bc1..c064112cf4 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/clean_up_after_vote_polls_end/v0/mod.rs @@ -1,13 +1,10 @@ use crate::error::Error; use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; -use dpp::block::block_info::BlockInfo; use dpp::identifier::Identifier; use dpp::prelude::TimestampMillis; use dpp::version::PlatformVersion; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; -use dpp::voting::vote_polls::VotePoll; use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use drive::drive::votes::resolved::vote_polls::ResolvedVotePollWithVotes; use drive::grovedb::TransactionArg; diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/mod.rs index 12c9948e48..9e8bb69e0e 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/mod.rs @@ -6,7 +6,7 @@ use dpp::block::block_info::BlockInfo; use dpp::identifier::Identifier; use dpp::version::PlatformVersion; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; +use dpp::voting::vote_info_storage::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use drive::grovedb::TransactionArg; use std::collections::BTreeMap; diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs index 022c139c13..ab8931d2f6 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs @@ -6,9 +6,9 @@ use dpp::identifier::Identifier; use dpp::version::PlatformVersion; use dpp::voting::contender_structs::FinalizedResourceVoteChoicesWithVoterInfo; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; -use dpp::voting::vote_outcomes::finalized_contested_document_vote_poll_stored_info::FinalizedContestedDocumentVotePollStoredInfo; +use dpp::voting::vote_info_storage::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use drive::error::drive::DriveError; use drive::grovedb::TransactionArg; use std::collections::BTreeMap; @@ -36,20 +36,39 @@ where }, ) .collect(); + let stored_info_from_disk = self + .drive + .fetch_contested_document_vote_poll_stored_info( + vote_poll, + &block_info.epoch, + transaction, + platform_version, + )? + .1 + .ok_or(Error::Drive(drive::error::Error::Drive( + DriveError::CorruptedDriveState( + "there must be a record of the vote poll in the state".to_string(), + ), + )))?; + + // We perform an upgrade of the stored version just in case, most of the time this does nothing + let mut stored_info = stored_info_from_disk.update_to_latest_version(platform_version)?; + // We need to construct the finalized contested document vote poll stored info - let info_to_store = FinalizedContestedDocumentVotePollStoredInfo::new( + stored_info.finalize_vote_poll( finalized_resource_vote_choices_with_voter_infos, *block_info, winner_info, - platform_version, )?; - self.drive.insert_record_of_finished_vote_poll( - vote_poll, - info_to_store, - transaction, - platform_version, - )?; + // We reinsert the info + self.drive + .insert_stored_info_for_contested_resource_vote_poll( + vote_poll, + stored_info, + transaction, + platform_version, + )?; Ok(()) } diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/lock_contested_resource/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/lock_contested_resource/v0/mod.rs index 5265e8b877..2bb073daa6 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/lock_contested_resource/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/lock_contested_resource/v0/mod.rs @@ -3,7 +3,6 @@ use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; -use drive::drive::votes::paths::VotePollPaths; use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use drive::grovedb::TransactionArg; diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/mod.rs index 0d6f61268e..3a70992c5b 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/mod.rs @@ -4,7 +4,6 @@ use crate::platform_types::platform::Platform; use crate::rpc::core::CoreRPCLike; use dpp::version::PlatformVersion; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; -use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use drive::grovedb::TransactionArg; use drive::query::vote_poll_vote_state_query::FinalizedContestedDocumentVotePollDriveQueryExecutionResult; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs index 86c5eb7953..eace82dae7 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs @@ -5,7 +5,6 @@ use crate::platform_types::platform::{PlatformRef, PlatformStateRef}; use crate::platform_types::platform_state::v0::PlatformStateV0Methods; use crate::rpc::core::CoreRPCLike; use dpp::block::block_info::BlockInfo; -use dpp::block::epoch::Epoch; use dpp::fee::Credits; use dpp::identity::PartialIdentity; use dpp::prefunded_specialized_balance::PrefundedSpecializedBalanceIdentifier; @@ -235,7 +234,7 @@ pub(super) fn process_state_transition_v0<'a, C: CoreRPCLike>( action, platform, ValidationMode::Validator, - &block_info.epoch, + block_info, &mut state_transition_execution_context, transaction, )?; @@ -481,7 +480,7 @@ pub(crate) trait StateTransitionStateValidationV0: action: Option, platform: &PlatformRef, validation_mode: ValidationMode, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, tx: TransactionArg, ) -> Result, Error>; @@ -865,7 +864,7 @@ impl StateTransitionStateValidationV0 for StateTransition { action: Option, platform: &PlatformRef, validation_mode: ValidationMode, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, tx: TransactionArg, ) -> Result, Error> { @@ -875,7 +874,7 @@ impl StateTransitionStateValidationV0 for StateTransition { action, platform, validation_mode, - epoch, + block_info, execution_context, tx, ), @@ -884,7 +883,7 @@ impl StateTransitionStateValidationV0 for StateTransition { action, platform, validation_mode, - epoch, + block_info, execution_context, tx, ), @@ -909,7 +908,7 @@ impl StateTransitionStateValidationV0 for StateTransition { action, platform, validation_mode, - epoch, + block_info, execution_context, tx, ), @@ -932,7 +931,7 @@ impl StateTransitionStateValidationV0 for StateTransition { action, platform, validation_mode, - epoch, + block_info, execution_context, tx, ), @@ -941,7 +940,7 @@ impl StateTransitionStateValidationV0 for StateTransition { action, platform, validation_mode, - epoch, + block_info, execution_context, tx, ), @@ -949,7 +948,7 @@ impl StateTransitionStateValidationV0 for StateTransition { action, platform, validation_mode, - epoch, + block_info, execution_context, tx, ), @@ -957,7 +956,7 @@ impl StateTransitionStateValidationV0 for StateTransition { action, platform, validation_mode, - epoch, + block_info, execution_context, tx, ), diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/mod.rs index 3b30f36a9b..5d028bbd88 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/mod.rs @@ -3,7 +3,6 @@ mod identity_nonce; mod state; use dpp::block::block_info::BlockInfo; -use dpp::block::epoch::Epoch; use dpp::identity::PartialIdentity; use dpp::prelude::ConsensusValidationResult; use dpp::state_transition::data_contract_create_transition::DataContractCreateTransition; @@ -109,7 +108,7 @@ impl StateTransitionStateValidationV0 for DataContractCreateTransition { _action: Option, platform: &PlatformRef, validation_mode: ValidationMode, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, tx: TransactionArg, ) -> Result, Error> { @@ -125,7 +124,7 @@ impl StateTransitionStateValidationV0 for DataContractCreateTransition { 0 => self.validate_state_v0( platform, validation_mode, - epoch, + &block_info.epoch, tx, execution_context, platform_version, 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 77a3e0dae4..105eb77250 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 @@ -204,7 +204,6 @@ mod tests { use crate::execution::validation::state_transition::processor::v0::StateTransitionStateValidationV0; use dpp::block::block_info::BlockInfo; - use dpp::block::epoch::Epoch; use dpp::data_contract::accessors::v0::{DataContractV0Getters, DataContractV0Setters}; use dpp::data_contract::config::v0::DataContractConfigSettersV0; @@ -291,7 +290,7 @@ mod tests { None, &platform_ref, ValidationMode::Validator, - &Epoch::new(0).unwrap(), + &BlockInfo::default(), &mut execution_context, None, ) @@ -385,7 +384,7 @@ mod tests { None, &platform_ref, ValidationMode::Validator, - &Epoch::new(0).unwrap(), + &BlockInfo::default(), &mut execution_context, None, ) @@ -543,7 +542,7 @@ mod tests { None, &platform_ref, ValidationMode::Validator, - &Epoch::new(0).unwrap(), + &BlockInfo::default(), &mut execution_context, None, ) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/state/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/state/mod.rs index 39e007b6b4..23ec6cf3e8 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/state/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/state/mod.rs @@ -6,7 +6,7 @@ use crate::execution::validation::state_transition::processor::v0::StateTransiti use crate::execution::validation::state_transition::ValidationMode; use crate::platform_types::platform::PlatformRef; use crate::rpc::core::CoreRPCLike; -use dpp::block::epoch::Epoch; +use dpp::block::block_info::BlockInfo; use dpp::state_transition::data_contract_update_transition::DataContractUpdateTransition; use dpp::validation::ConsensusValidationResult; use drive::grovedb::TransactionArg; @@ -20,7 +20,7 @@ impl StateTransitionStateValidationV0 for DataContractUpdateTransition { action: Option, platform: &PlatformRef, validation_mode: ValidationMode, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, tx: TransactionArg, ) -> Result, Error> { @@ -40,7 +40,7 @@ impl StateTransitionStateValidationV0 for DataContractUpdateTransition { self.validate_state_v0( platform, validation_mode, - epoch, + &block_info.epoch, execution_context, tx, platform_version, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_create_transition_action/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_create_transition_action/mod.rs index 2d5e116aa8..54176e1dce 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_create_transition_action/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_create_transition_action/mod.rs @@ -1,4 +1,4 @@ -use dpp::block::epoch::Epoch; +use dpp::block::block_info::BlockInfo; use dpp::identifier::Identifier; use dpp::validation::SimpleConsensusValidationResult; use drive::state_transition_action::document::documents_batch::document_transition::document_create_transition_action::DocumentCreateTransitionAction; @@ -25,7 +25,7 @@ pub trait DocumentCreateTransitionActionValidation { &self, platform: &PlatformStateRef, owner_id: Identifier, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -58,7 +58,7 @@ impl DocumentCreateTransitionActionValidation for DocumentCreateTransitionAction &self, platform: &PlatformStateRef, owner_id: Identifier, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -73,7 +73,7 @@ impl DocumentCreateTransitionActionValidation for DocumentCreateTransitionAction 0 => self.validate_state_v0( platform, owner_id, - epoch, + block_info, execution_context, transaction, platform_version, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_create_transition_action/state_v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_create_transition_action/state_v0/mod.rs index 22c71ac140..3c2ee12a91 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_create_transition_action/state_v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_create_transition_action/state_v0/mod.rs @@ -1,7 +1,9 @@ -use dpp::block::epoch::Epoch; +use dpp::block::block_info::BlockInfo; use dpp::consensus::basic::document::InvalidDocumentTypeError; use dpp::consensus::ConsensusError; use dpp::consensus::state::document::document_already_present_error::DocumentAlreadyPresentError; +use dpp::consensus::state::document::document_contest_currently_locked_error::DocumentContestCurrentlyLockedError; +use dpp::consensus::state::document::document_contest_not_joinable_error::DocumentContestNotJoinableError; use dpp::consensus::state::state_error::StateError; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; @@ -10,9 +12,12 @@ use dpp::validation::SimpleConsensusValidationResult; use drive::state_transition_action::document::documents_batch::document_transition::document_base_transition_action::DocumentBaseTransitionActionAccessorsV0; use drive::state_transition_action::document::documents_batch::document_transition::document_create_transition_action::{DocumentCreateTransitionAction, DocumentCreateTransitionActionAccessorsV0}; use dpp::version::PlatformVersion; +use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::{ContestedDocumentVotePollStatus, ContestedDocumentVotePollStoredInfoV0Getters}; +use drive::error::drive::DriveError; use drive::query::TransactionArg; use crate::error::Error; -use crate::execution::types::state_transition_execution_context::StateTransitionExecutionContext; +use crate::execution::types::execution_operation::ValidationOperation; +use crate::execution::types::state_transition_execution_context::{StateTransitionExecutionContext, StateTransitionExecutionContextMethodsV0}; use crate::execution::validation::state_transition::documents_batch::state::v0::fetch_documents::fetch_document_with_id; use crate::platform_types::platform::PlatformStateRef; @@ -21,7 +26,7 @@ pub(super) trait DocumentCreateTransitionActionStateValidationV0 { &self, platform: &PlatformStateRef, owner_id: Identifier, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -32,8 +37,8 @@ impl DocumentCreateTransitionActionStateValidationV0 for DocumentCreateTransitio &self, platform: &PlatformStateRef, owner_id: Identifier, - _epoch: &Epoch, - _execution_context: &mut StateTransitionExecutionContext, + block_info: &BlockInfo, + execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { @@ -73,7 +78,7 @@ impl DocumentCreateTransitionActionStateValidationV0 for DocumentCreateTransitio // this means for example having overlapping unique indexes if document_type.indexes().values().any(|index| index.unique) { - platform + let validation_result = platform .drive .validate_document_create_transition_action_uniqueness( contract, @@ -83,7 +88,74 @@ impl DocumentCreateTransitionActionStateValidationV0 for DocumentCreateTransitio transaction, platform_version, ) - .map_err(Error::Drive) + .map_err(Error::Drive)?; + + if !validation_result.is_valid() { + return Ok(validation_result); + } + } + + if let Some((contested_document_resource_vote_poll, credits)) = + self.prefunded_voting_balance() + { + let (fee_result, maybe_stored_info) = platform + .drive + .fetch_contested_document_vote_poll_stored_info( + contested_document_resource_vote_poll, + &block_info.epoch, + transaction, + platform_version, + )?; + execution_context + .add_operation(ValidationOperation::PrecalculatedOperation(fee_result)); + + if let Some(stored_info) = maybe_stored_info { + // We have previous stored info + match stored_info.vote_poll_status() { + ContestedDocumentVotePollStatus::NotStarted => { + Ok(SimpleConsensusValidationResult::new()) + } + ContestedDocumentVotePollStatus::Awarded(_) => { + // This is weird as it should have already been found when querying the document, however it is possible + // That it was destroyed + Ok(SimpleConsensusValidationResult::new_with_error( + ConsensusError::StateError(StateError::DocumentAlreadyPresentError( + DocumentAlreadyPresentError::new(self.base().id()), + )), + )) + } + ContestedDocumentVotePollStatus::Locked => { + Ok(SimpleConsensusValidationResult::new_with_error( + ConsensusError::StateError(StateError::DocumentContestCurrentlyLockedError( + DocumentContestCurrentlyLockedError::new( + contested_document_resource_vote_poll.into(), + stored_info, + platform_version.fee_version.vote_resolution_fund_fees.contested_document_vote_resolution_unlock_fund_required_amount, + ))), + )) + } + ContestedDocumentVotePollStatus::Started(start_block) => { + // We need to make sure that if there is a contest, it is in its first week + // The week might be more or less, as it's a versioned parameter + let time_ms_since_start = block_info.time_ms.checked_sub(start_block.time_ms).ok_or(Error::Drive(drive::error::Error::Drive(DriveError::CorruptedDriveState(format!("it makes no sense that the start block time {} is before our current block time {}", start_block.time_ms, block_info.time_ms)))))?; + let join_time_allowed = platform_version.dpp.validation.voting.allow_other_contenders_time_ms; + if time_ms_since_start > join_time_allowed { + Ok(SimpleConsensusValidationResult::new_with_error(ConsensusError::StateError(StateError::DocumentContestNotJoinableError( + DocumentContestNotJoinableError::new( + contested_document_resource_vote_poll.into(), + stored_info, + start_block.time_ms, + block_info.time_ms, + join_time_allowed, + ))))) + } else { + Ok(SimpleConsensusValidationResult::new()) + } + } + } + } else { + Ok(SimpleConsensusValidationResult::new()) + } } else { Ok(SimpleConsensusValidationResult::new()) } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_delete_transition_action/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_delete_transition_action/mod.rs index 79f55e4fcf..b36e68daa9 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_delete_transition_action/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_delete_transition_action/mod.rs @@ -1,4 +1,4 @@ -use dpp::block::epoch::Epoch; +use dpp::block::block_info::BlockInfo; use dpp::identifier::Identifier; use dpp::validation::SimpleConsensusValidationResult; use drive::state_transition_action::document::documents_batch::document_transition::document_delete_transition_action::DocumentDeleteTransitionAction; @@ -24,7 +24,7 @@ pub trait DocumentDeleteTransitionActionValidation { &self, platform: &PlatformStateRef, owner_id: Identifier, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -56,7 +56,7 @@ impl DocumentDeleteTransitionActionValidation for DocumentDeleteTransitionAction &self, platform: &PlatformStateRef, owner_id: Identifier, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -71,7 +71,7 @@ impl DocumentDeleteTransitionActionValidation for DocumentDeleteTransitionAction 0 => self.validate_state_v0( platform, owner_id, - epoch, + block_info, execution_context, transaction, platform_version, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_delete_transition_action/state_v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_delete_transition_action/state_v0/mod.rs index b598a2fd0a..ae90496472 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_delete_transition_action/state_v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_delete_transition_action/state_v0/mod.rs @@ -1,4 +1,4 @@ -use dpp::block::epoch::Epoch; +use dpp::block::block_info::BlockInfo; use dpp::consensus::basic::document::InvalidDocumentTypeError; use dpp::consensus::ConsensusError; use dpp::consensus::state::document::document_not_found_error::DocumentNotFoundError; @@ -24,7 +24,7 @@ pub(super) trait DocumentDeleteTransitionActionStateValidationV0 { &self, platform: &PlatformStateRef, owner_id: Identifier, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -35,7 +35,7 @@ impl DocumentDeleteTransitionActionStateValidationV0 for DocumentDeleteTransitio &self, platform: &PlatformStateRef, owner_id: Identifier, - _epoch: &Epoch, + _block_info: &BlockInfo, _execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_purchase_transition_action/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_purchase_transition_action/mod.rs index c72f4ea28d..ef6c32b996 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_purchase_transition_action/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_purchase_transition_action/mod.rs @@ -1,4 +1,4 @@ -use dpp::block::epoch::Epoch; +use dpp::block::block_info::BlockInfo; use dpp::identifier::Identifier; use dpp::validation::SimpleConsensusValidationResult; @@ -25,7 +25,7 @@ pub trait DocumentPurchaseTransitionActionValidation { &self, platform: &PlatformStateRef, owner_id: Identifier, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -57,7 +57,7 @@ impl DocumentPurchaseTransitionActionValidation for DocumentPurchaseTransitionAc &self, platform: &PlatformStateRef, owner_id: Identifier, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -72,7 +72,7 @@ impl DocumentPurchaseTransitionActionValidation for DocumentPurchaseTransitionAc 0 => self.validate_state_v0( platform, owner_id, - epoch, + block_info, execution_context, transaction, platform_version, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_purchase_transition_action/state_v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_purchase_transition_action/state_v0/mod.rs index 74bc3b36a5..79e4311344 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_purchase_transition_action/state_v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_purchase_transition_action/state_v0/mod.rs @@ -1,4 +1,4 @@ -use dpp::block::epoch::Epoch; +use dpp::block::block_info::BlockInfo; use dpp::consensus::basic::document::InvalidDocumentTypeError; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; @@ -17,7 +17,7 @@ pub(super) trait DocumentPurchaseTransitionActionStateValidationV0 { &self, platform: &PlatformStateRef, owner_id: Identifier, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -28,7 +28,7 @@ impl DocumentPurchaseTransitionActionStateValidationV0 for DocumentPurchaseTrans &self, platform: &PlatformStateRef, owner_id: Identifier, - _epoch: &Epoch, + _block_info: &BlockInfo, _execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_replace_transition_action/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_replace_transition_action/mod.rs index f745e690f2..fe65d922dd 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_replace_transition_action/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_replace_transition_action/mod.rs @@ -1,4 +1,4 @@ -use dpp::block::epoch::Epoch; +use dpp::block::block_info::BlockInfo; use dpp::identifier::Identifier; use dpp::validation::SimpleConsensusValidationResult; @@ -25,7 +25,7 @@ pub trait DocumentReplaceTransitionActionValidation { &self, platform: &PlatformStateRef, owner_id: Identifier, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -57,7 +57,7 @@ impl DocumentReplaceTransitionActionValidation for DocumentReplaceTransitionActi &self, platform: &PlatformStateRef, owner_id: Identifier, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -72,7 +72,7 @@ impl DocumentReplaceTransitionActionValidation for DocumentReplaceTransitionActi 0 => self.validate_state_v0( platform, owner_id, - epoch, + block_info, execution_context, transaction, platform_version, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_replace_transition_action/state_v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_replace_transition_action/state_v0/mod.rs index 0747945742..8fea8e2856 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_replace_transition_action/state_v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_replace_transition_action/state_v0/mod.rs @@ -1,4 +1,4 @@ -use dpp::block::epoch::Epoch; +use dpp::block::block_info::BlockInfo; use dpp::consensus::basic::document::InvalidDocumentTypeError; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; @@ -17,7 +17,7 @@ pub(super) trait DocumentReplaceTransitionActionStateValidationV0 { &self, platform: &PlatformStateRef, owner_id: Identifier, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -28,7 +28,7 @@ impl DocumentReplaceTransitionActionStateValidationV0 for DocumentReplaceTransit &self, platform: &PlatformStateRef, owner_id: Identifier, - _epoch: &Epoch, + _block_info: &BlockInfo, _execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_transfer_transition_action/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_transfer_transition_action/mod.rs index 376932cb42..9b4f6e8b55 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_transfer_transition_action/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_transfer_transition_action/mod.rs @@ -1,4 +1,4 @@ -use dpp::block::epoch::Epoch; +use dpp::block::block_info::BlockInfo; use dpp::identifier::Identifier; use dpp::validation::SimpleConsensusValidationResult; @@ -25,7 +25,7 @@ pub trait DocumentTransferTransitionActionValidation { &self, platform: &PlatformStateRef, owner_id: Identifier, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -57,7 +57,7 @@ impl DocumentTransferTransitionActionValidation for DocumentTransferTransitionAc &self, platform: &PlatformStateRef, owner_id: Identifier, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -72,7 +72,7 @@ impl DocumentTransferTransitionActionValidation for DocumentTransferTransitionAc 0 => self.validate_state_v0( platform, owner_id, - epoch, + block_info, execution_context, transaction, platform_version, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_transfer_transition_action/state_v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_transfer_transition_action/state_v0/mod.rs index c6d7eb4b4e..7613df9afc 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_transfer_transition_action/state_v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_transfer_transition_action/state_v0/mod.rs @@ -1,4 +1,4 @@ -use dpp::block::epoch::Epoch; +use dpp::block::block_info::BlockInfo; use dpp::consensus::basic::document::InvalidDocumentTypeError; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; @@ -17,7 +17,7 @@ pub(super) trait DocumentTransferTransitionActionStateValidationV0 { &self, platform: &PlatformStateRef, owner_id: Identifier, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -28,7 +28,7 @@ impl DocumentTransferTransitionActionStateValidationV0 for DocumentTransferTrans &self, platform: &PlatformStateRef, owner_id: Identifier, - _epoch: &Epoch, + _block_info: &BlockInfo, _execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_update_price_transition_action/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_update_price_transition_action/mod.rs index 18876a8fe8..39a18561c0 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_update_price_transition_action/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_update_price_transition_action/mod.rs @@ -1,4 +1,4 @@ -use dpp::block::epoch::Epoch; +use dpp::block::block_info::BlockInfo; use dpp::identifier::Identifier; use dpp::validation::SimpleConsensusValidationResult; @@ -25,7 +25,7 @@ pub trait DocumentUpdatePriceTransitionActionValidation { &self, platform: &PlatformStateRef, owner_id: Identifier, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -57,7 +57,7 @@ impl DocumentUpdatePriceTransitionActionValidation for DocumentUpdatePriceTransi &self, platform: &PlatformStateRef, owner_id: Identifier, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -72,7 +72,7 @@ impl DocumentUpdatePriceTransitionActionValidation for DocumentUpdatePriceTransi 0 => self.validate_state_v0( platform, owner_id, - epoch, + block_info, execution_context, transaction, platform_version, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_update_price_transition_action/state_v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_update_price_transition_action/state_v0/mod.rs index 33889ed634..43a72d50a5 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_update_price_transition_action/state_v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_update_price_transition_action/state_v0/mod.rs @@ -1,4 +1,4 @@ -use dpp::block::epoch::Epoch; +use dpp::block::block_info::BlockInfo; use dpp::consensus::basic::document::InvalidDocumentTypeError; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; @@ -17,7 +17,7 @@ pub(super) trait DocumentUpdatePriceTransitionActionStateValidationV0 { &self, platform: &PlatformStateRef, owner_id: Identifier, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -28,7 +28,7 @@ impl DocumentUpdatePriceTransitionActionStateValidationV0 for DocumentUpdatePric &self, platform: &PlatformStateRef, owner_id: Identifier, - _epoch: &Epoch, + _block_info: &BlockInfo, _execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs index 859d0cfaf4..5fbd6d2f04 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs @@ -7,7 +7,6 @@ mod state; mod transformer; use dpp::block::block_info::BlockInfo; -use dpp::block::epoch::Epoch; use dpp::identity::PartialIdentity; use dpp::prelude::*; use dpp::state_transition::documents_batch_transition::DocumentsBatchTransition; @@ -190,7 +189,7 @@ impl StateTransitionStateValidationV0 for DocumentsBatchTransition { action: Option, platform: &PlatformRef, _validation_mode: ValidationMode, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, tx: TransactionArg, ) -> Result, Error> { @@ -218,7 +217,7 @@ impl StateTransitionStateValidationV0 for DocumentsBatchTransition { self.validate_state_v0( documents_batch_transition_action, &platform.into(), - epoch, + block_info, execution_context, tx, platform_version, @@ -266,14 +265,11 @@ mod tests { use rand::SeedableRng; mod creation_tests { - use std::sync::Arc; use rand::Rng; use dapi_grpc::platform::v0::{get_contested_resource_vote_state_request, get_contested_resource_vote_state_response, GetContestedResourceVoteStateRequest, GetContestedResourceVoteStateResponse}; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0::ResultType; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::GetContestedResourceVoteStateRequestV0; use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; - use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::get_contested_resource_vote_state_response_v0::finished_vote_info; - use dpp::block::extended_block_info::v0::ExtendedBlockInfoV0; use super::*; use dpp::data_contract::accessors::v0::DataContractV0Setters; use dpp::data_contract::document_type::restricted_creation::CreationRestrictionMode; @@ -286,8 +282,7 @@ mod tests { use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; use drive::query::vote_poll_vote_state_query::ContestedDocumentVotePollDriveQueryResultType::DocumentsAndVoteTally; use drive::query::vote_poll_vote_state_query::ResolvedContestedDocumentVotePollDriveQuery; - use crate::execution::validation::state_transition::state_transitions::tests::{create_dpns_name_contest, fast_forward_to_block, get_vote_states, perform_votes_multi}; - use crate::platform_types::platform_state::v0::PlatformStateV0Methods; + use crate::execution::validation::state_transition::state_transitions::tests::{add_contender_to_dpns_name_contest, create_dpns_name_contest, fast_forward_to_block, perform_votes_multi}; #[test] fn test_document_creation() { @@ -860,11 +855,12 @@ mod tests { let platform_state = platform.state.load(); - let (contender_3, contender_4, dpns_contract) = create_dpns_name_contest( + let contender_3 = add_contender_to_dpns_name_contest( &mut platform, &platform_state, - 8, + 4, "quantum", + None, // this should succeed, as we are under a week platform_version, ); @@ -872,11 +868,12 @@ mod tests { let platform_state = platform.state.load(); - let (contender_5, contender_6, dpns_contract) = create_dpns_name_contest( + let contender_4 = add_contender_to_dpns_name_contest( &mut platform, &platform_state, 9, "quantum", + Some(""), // this should fail, as we are over a week platform_version, ); //todo() this should fail! diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/state/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/state/v0/mod.rs index ad7ed83761..408139d6ac 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/state/v0/mod.rs @@ -1,5 +1,4 @@ use dpp::block::block_info::BlockInfo; -use dpp::block::epoch::Epoch; use dpp::consensus::ConsensusError; use dpp::consensus::state::state_error::StateError; use dpp::prelude::ConsensusValidationResult; @@ -34,7 +33,7 @@ pub(in crate::execution::validation::state_transition::state_transitions::docume &self, action: DocumentsBatchTransitionAction, platform: &PlatformStateRef, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, tx: TransactionArg, platform_version: &PlatformVersion, @@ -54,7 +53,7 @@ impl DocumentsBatchStateTransitionStateValidationV0 for DocumentsBatchTransition &self, mut state_transition_action: DocumentsBatchTransitionAction, platform: &PlatformStateRef, - epoch: &Epoch, + block_info: &BlockInfo, execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -81,7 +80,7 @@ impl DocumentsBatchStateTransitionStateValidationV0 for DocumentsBatchTransition .validate_state( platform, owner_id, - epoch, + block_info, execution_context, transaction, platform_version, @@ -90,7 +89,7 @@ impl DocumentsBatchStateTransitionStateValidationV0 for DocumentsBatchTransition .validate_state( platform, owner_id, - epoch, + block_info, execution_context, transaction, platform_version, @@ -99,7 +98,7 @@ impl DocumentsBatchStateTransitionStateValidationV0 for DocumentsBatchTransition .validate_state( platform, owner_id, - epoch, + block_info, execution_context, transaction, platform_version, @@ -108,7 +107,7 @@ impl DocumentsBatchStateTransitionStateValidationV0 for DocumentsBatchTransition .validate_state( platform, owner_id, - epoch, + block_info, execution_context, transaction, platform_version, @@ -117,7 +116,7 @@ impl DocumentsBatchStateTransitionStateValidationV0 for DocumentsBatchTransition update_price_action.validate_state( platform, owner_id, - epoch, + block_info, execution_context, transaction, platform_version, @@ -127,7 +126,7 @@ impl DocumentsBatchStateTransitionStateValidationV0 for DocumentsBatchTransition .validate_state( platform, owner_id, - epoch, + block_info, execution_context, transaction, platform_version, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_transfer/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_transfer/mod.rs index d13319d128..914f0befe1 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_transfer/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_transfer/mod.rs @@ -4,7 +4,6 @@ mod state; mod structure; use dpp::block::block_info::BlockInfo; -use dpp::block::epoch::Epoch; use dpp::state_transition::identity_credit_transfer_transition::IdentityCreditTransferTransition; use dpp::validation::{ConsensusValidationResult, SimpleConsensusValidationResult}; use dpp::version::PlatformVersion; @@ -89,7 +88,7 @@ impl StateTransitionStateValidationV0 for IdentityCreditTransferTransition { _action: Option, platform: &PlatformRef, _validation_mode: ValidationMode, - _epoch: &Epoch, + _block_info: &BlockInfo, _execution_context: &mut StateTransitionExecutionContext, tx: TransactionArg, ) -> Result, Error> { diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/mod.rs index e83a4f37e7..bc0da27d44 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/mod.rs @@ -4,7 +4,6 @@ mod state; mod structure; use dpp::block::block_info::BlockInfo; -use dpp::block::epoch::Epoch; use dpp::state_transition::identity_credit_withdrawal_transition::IdentityCreditWithdrawalTransition; use dpp::validation::{ConsensusValidationResult, SimpleConsensusValidationResult}; use dpp::version::PlatformVersion; @@ -92,7 +91,7 @@ impl StateTransitionStateValidationV0 for IdentityCreditWithdrawalTransition { _action: Option, platform: &PlatformRef, _validation_mode: ValidationMode, - _epoch: &Epoch, + _block_info: &BlockInfo, _execution_context: &mut StateTransitionExecutionContext, tx: TransactionArg, ) -> Result, Error> { diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_update/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_update/mod.rs index 073bbeab2d..a8c09846bb 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_update/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_update/mod.rs @@ -4,7 +4,6 @@ mod nonce; mod state; use dpp::block::block_info::BlockInfo; -use dpp::block::epoch::Epoch; use dpp::state_transition::identity_update_transition::IdentityUpdateTransition; use dpp::validation::{ConsensusValidationResult, SimpleConsensusValidationResult}; use dpp::version::PlatformVersion; @@ -88,7 +87,7 @@ impl StateTransitionStateValidationV0 for IdentityUpdateTransition { _action: Option, platform: &PlatformRef, _validation_mode: ValidationMode, - _epoch: &Epoch, + _block_info: &BlockInfo, _execution_context: &mut StateTransitionExecutionContext, tx: TransactionArg, ) -> Result, Error> { diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 9d58eab636..e35f8c3bbb 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -4,7 +4,6 @@ mod state; mod structure; use dpp::block::block_info::BlockInfo; -use dpp::block::epoch::Epoch; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; use dpp::validation::ConsensusValidationResult; use dpp::version::PlatformVersion; @@ -58,7 +57,7 @@ impl StateTransitionStateValidationV0 for MasternodeVoteTransition { _action: Option, platform: &PlatformRef, _validation_mode: ValidationMode, - _epoch: &Epoch, + _block_info: &BlockInfo, _execution_context: &mut StateTransitionExecutionContext, tx: TransactionArg, ) -> Result, Error> { @@ -121,7 +120,6 @@ mod tests { use dapi_grpc::platform::v0::get_prefunded_specialized_balance_request::GetPrefundedSpecializedBalanceRequestV0; use std::collections::BTreeMap; use std::sync::Arc; - use rand::Rng; use dapi_grpc::platform::v0::get_contested_resources_request::GetContestedResourcesRequestV0; use dapi_grpc::platform::v0::get_contested_resources_response::{get_contested_resources_response_v0, GetContestedResourcesResponseV0}; use dapi_grpc::platform::v0::get_contested_resource_voters_for_identity_request::GetContestedResourceVotersForIdentityRequestV0; @@ -163,7 +161,7 @@ mod tests { use drive::drive::Drive; use crate::execution::validation::state_transition::state_transitions::tests::{create_dpns_name_contest, verify_dpns_name_contest, perform_vote, setup_masternode_identity, get_proved_vote_states, get_vote_states, perform_votes_multi}; use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::get_contested_resource_vote_state_response_v0::{finished_vote_info, FinishedVoteInfo}; - use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; + use dpp::voting::vote_info_storage::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; use dapi_grpc::platform::v0::get_vote_polls_by_end_date_request::get_vote_polls_by_end_date_request_v0; mod vote_tests { 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 82bbda62f2..08946fd7f9 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 @@ -73,7 +73,7 @@ mod tests { use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::get_contested_resource_vote_state_request_v0::ResultType; use dapi_grpc::platform::v0::get_contested_resource_vote_state_request::{get_contested_resource_vote_state_request_v0, GetContestedResourceVoteStateRequestV0}; use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::{get_contested_resource_vote_state_response_v0, GetContestedResourceVoteStateResponseV0}; - use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::get_contested_resource_vote_state_response_v0::{finished_vote_info, FinishedVoteInfo}; + use dapi_grpc::platform::v0::get_contested_resource_vote_state_response::get_contested_resource_vote_state_response_v0::FinishedVoteInfo; use dpp::block::extended_block_info::v0::ExtendedBlockInfoV0; use dpp::dash_to_credits; use dpp::dashcore::{ProTxHash, Txid}; @@ -95,7 +95,7 @@ mod tests { use dpp::util::strings::convert_to_homograph_safe_chars; use dpp::voting::contender_structs::Contender; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; - use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; + use dpp::voting::vote_info_storage::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::voting::vote_polls::VotePoll; use dpp::voting::votes::resource_vote::ResourceVote; @@ -107,6 +107,7 @@ mod tests { use drive::query::vote_poll_vote_state_query::{ContestedDocumentVotePollDriveQueryResultType, ResolvedContestedDocumentVotePollDriveQuery}; use crate::platform_types::platform_state::PlatformState; use crate::platform_types::platform_state::v0::PlatformStateV0Methods; + use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult; use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult::SuccessfulExecution; pub(in crate::execution::validation::state_transition::state_transitions) fn setup_identity( @@ -520,6 +521,183 @@ mod tests { (identity_1, identity_2, dpns_contract) } + pub(in crate::execution::validation::state_transition::state_transitions) fn add_contender_to_dpns_name_contest( + platform: &mut TempPlatform, + platform_state: &PlatformState, + seed: u64, + name: &str, + expect_err: Option<&str>, + platform_version: &PlatformVersion, + ) -> Identity { + let mut rng = StdRng::seed_from_u64(seed); + + let (identity_1, signer_1, key_1) = + setup_identity(platform, rng.gen(), dash_to_credits!(0.5)); + + let dpns = platform.drive.cache.system_data_contracts.load_dpns(); + let dpns_contract = dpns.clone(); + + let preorder = dpns_contract + .document_type_for_name("preorder") + .expect("expected a profile document type"); + + let domain = dpns_contract + .document_type_for_name("domain") + .expect("expected a profile document type"); + + let entropy = Bytes32::random_with_rng(&mut rng); + + let mut preorder_document_1 = preorder + .random_document_with_identifier_and_entropy( + &mut rng, + identity_1.id(), + entropy, + DocumentFieldFillType::FillIfNotRequired, + DocumentFieldFillSize::AnyDocumentFillSize, + platform_version, + ) + .expect("expected a random document"); + + let mut document_1 = domain + .random_document_with_identifier_and_entropy( + &mut rng, + identity_1.id(), + entropy, + DocumentFieldFillType::FillIfNotRequired, + DocumentFieldFillSize::AnyDocumentFillSize, + platform_version, + ) + .expect("expected a random document"); + + document_1.set("parentDomainName", "dash".into()); + document_1.set("normalizedParentDomainName", "dash".into()); + document_1.set("label", name.into()); + document_1.set( + "normalizedLabel", + convert_to_homograph_safe_chars(name).into(), + ); + document_1.set("records.dashUniqueIdentityId", document_1.owner_id().into()); + document_1.set("subdomainRules.allowSubdomains", false.into()); + + let salt_1: [u8; 32] = rng.gen(); + + let mut salted_domain_buffer_1: Vec = vec![]; + salted_domain_buffer_1.extend(salt_1); + salted_domain_buffer_1.extend((convert_to_homograph_safe_chars(name) + ".dash").as_bytes()); + + let salted_domain_hash_1 = hash_double(salted_domain_buffer_1); + + preorder_document_1.set("saltedDomainHash", salted_domain_hash_1.into()); + + document_1.set("preorderSalt", salt_1.into()); + + let documents_batch_create_preorder_transition_1 = + DocumentsBatchTransition::new_document_creation_transition_from_document( + preorder_document_1, + preorder, + entropy.0, + &key_1, + 2, + 0, + &signer_1, + platform_version, + None, + None, + None, + ) + .expect("expect to create documents batch transition"); + + let documents_batch_create_serialized_preorder_transition_1 = + documents_batch_create_preorder_transition_1 + .serialize_to_bytes() + .expect("expected documents batch serialized state transition"); + + let documents_batch_create_transition_1 = + DocumentsBatchTransition::new_document_creation_transition_from_document( + document_1, + domain, + entropy.0, + &key_1, + 3, + 0, + &signer_1, + platform_version, + None, + None, + None, + ) + .expect("expect to create documents batch transition"); + + let documents_batch_create_serialized_transition_1 = documents_batch_create_transition_1 + .serialize_to_bytes() + .expect("expected documents batch serialized state transition"); + + let transaction = platform.drive.grove.start_transaction(); + + let processing_result = platform + .platform + .process_raw_state_transitions( + &vec![documents_batch_create_serialized_preorder_transition_1.clone()], + platform_state, + &BlockInfo::default_with_time( + platform_state + .last_committed_block_time_ms() + .unwrap_or_default() + + 3000, + ), + &transaction, + platform_version, + ) + .expect("expected to process state transition"); + + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit transaction"); + + assert_eq!(processing_result.valid_count(), 1); + + let transaction = platform.drive.grove.start_transaction(); + + let processing_result = platform + .platform + .process_raw_state_transitions( + &vec![documents_batch_create_serialized_transition_1.clone()], + platform_state, + &BlockInfo::default_with_time( + platform_state + .last_committed_block_time_ms() + .unwrap_or_default() + + 3000, + ), + &transaction, + platform_version, + ) + .expect("expected to process state transition"); + + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit transaction"); + + if let Some(expected_err) = expect_err { + let result = processing_result.into_execution_results().remove(0); + + let StateTransitionExecutionResult::PaidConsensusError(consensus_error, _) = result + else { + panic!("expected a paid consensus error"); + }; + assert_eq!(consensus_error.to_string(), expected_err); + } else { + assert_eq!(processing_result.valid_count(), 2); + } + identity_1 + } + pub(in crate::execution::validation::state_transition::state_transitions) fn verify_dpns_name_contest( platform: &mut TempPlatform, platform_state: &Guard>, diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_identity_votes/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_votes/v0/mod.rs index fba356cdb0..52a19d22d1 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_identity_votes/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_identity_votes/v0/mod.rs @@ -7,9 +7,7 @@ use dapi_grpc::platform::v0::get_contested_resource_identity_votes_request::GetC use dapi_grpc::platform::v0::get_contested_resource_identity_votes_response::{ get_contested_resource_identity_votes_response_v0, GetContestedResourceIdentityVotesResponseV0, }; -use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::identifier::Identifier; -use dpp::serialization::PlatformSerializable; use dpp::validation::ValidationResult; use dpp::version::PlatformVersion; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs index 3843d4dec4..8407dfc699 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs @@ -17,7 +17,7 @@ use dpp::version::PlatformVersion; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::{check_validation_result_with_data, platform_value}; use dpp::voting::contender_structs::ContenderWithSerializedDocument; -use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; +use dpp::voting::vote_info_storage::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; use drive::error::query::QuerySyntaxError; use drive::query::vote_poll_vote_state_query::{ ContestedDocumentVotePollDriveQuery, diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/document.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/document.rs index fc168f0c44..695cb76e25 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/document.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/document.rs @@ -16,8 +16,8 @@ use dpp::prelude::Identifier; use dpp::system_data_contracts::withdrawals_contract::v1::document_types::withdrawal; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use dpp::version::PlatformVersion; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::ProtocolError; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; @@ -70,7 +70,7 @@ pub enum DocumentOperationType<'a> { /// The document and contract info, also may contain the owner_id owned_document_info: OwnedDocumentInfo<'a>, /// The vote poll in question that will should be created - contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll, + contested_document_resource_vote_poll: ContestedDocumentResourceVotePollWithContractInfo, /// Data Contract info to potentially be resolved if needed contract_info: DataContractInfo<'a>, /// Document type diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs index 52fb52f48d..7322d5ce85 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs @@ -9,8 +9,9 @@ use crate::error::Error; use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use dpp::version::PlatformVersion; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStoredInfo; use grovedb::TransactionArg; impl Drive { @@ -32,8 +33,9 @@ impl Drive { pub fn add_contested_document( &self, owned_document_info: OwnedDocumentInfo, - contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll, + contested_document_resource_vote_poll: ContestedDocumentResourceVotePollWithContractInfo, insert_without_check: bool, + also_insert_vote_poll_stored_start_info: Option, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, @@ -50,6 +52,7 @@ impl Drive { owned_document_info, contested_document_resource_vote_poll, insert_without_check, + also_insert_vote_poll_stored_start_info, block_info, apply, transaction, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/v0/mod.rs index 4fda31d05b..18fcb3ee9a 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/v0/mod.rs @@ -7,8 +7,9 @@ use dpp::block::block_info::BlockInfo; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::fee::fee_result::FeeResult; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use dpp::version::PlatformVersion; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStoredInfo; use grovedb::TransactionArg; impl Drive { @@ -17,8 +18,9 @@ impl Drive { pub(super) fn add_contested_document_v0( &self, owned_document_info: OwnedDocumentInfo, - contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll, + contested_document_resource_vote_poll: ContestedDocumentResourceVotePollWithContractInfo, insert_without_check: bool, + also_insert_vote_poll_stored_info: Option, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, @@ -29,7 +31,8 @@ impl Drive { let contract_fetch_info = self .get_contract_with_fetch_info_and_add_to_operations( contested_document_resource_vote_poll - .contract_id + .contract + .id() .into_buffer(), Some(&block_info.epoch), true, @@ -53,6 +56,13 @@ impl Drive { document_type, }; let mut drive_operations: Vec = vec![]; + if let Some(vote_poll_stored_start_info) = also_insert_vote_poll_stored_info { + self.insert_stored_info_for_contested_resource_vote_poll_operations( + &contested_document_resource_vote_poll, + vote_poll_stored_start_info, + platform_version, + )?; + } self.add_contested_document_for_contract_apply_and_add_to_operations( document_and_contract_info, contested_document_resource_vote_poll, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/mod.rs index cb7eb31518..3e1f8095ba 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/mod.rs @@ -9,8 +9,8 @@ use crate::error::Error; use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use dpp::version::PlatformVersion; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use grovedb::TransactionArg; impl Drive { @@ -30,7 +30,7 @@ impl Drive { pub fn add_contested_document_for_contract( &self, document_and_contract_info: DocumentAndContractInfo, - contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll, + contested_document_resource_vote_poll: ContestedDocumentResourceVotePollWithContractInfo, insert_without_check: bool, block_info: BlockInfo, apply: bool, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/v0/mod.rs index a19b641428..785bb7a51c 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/v0/mod.rs @@ -6,8 +6,8 @@ use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use dpp::version::PlatformVersion; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use grovedb::TransactionArg; impl Drive { @@ -16,7 +16,7 @@ impl Drive { pub(super) fn add_contested_document_for_contract_v0( &self, document_and_contract_info: DocumentAndContractInfo, - contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll, + contested_document_resource_vote_poll: ContestedDocumentResourceVotePollWithContractInfo, insert_without_check: bool, block_info: BlockInfo, apply: bool, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs index f3810ed3e9..5dd1d3d81b 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs @@ -9,7 +9,7 @@ use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use grovedb::TransactionArg; impl Drive { @@ -32,7 +32,7 @@ impl Drive { pub(crate) fn add_contested_document_for_contract_apply_and_add_to_operations( &self, document_and_contract_info: DocumentAndContractInfo, - contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll, + contested_document_resource_vote_poll: ContestedDocumentResourceVotePollWithContractInfo, insert_without_check: bool, block_info: &BlockInfo, document_is_unique_for_document_type_in_batch: bool, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/v0/mod.rs index 9d75179d01..7524419c6b 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/v0/mod.rs @@ -4,8 +4,8 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use dpp::version::PlatformVersion; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; @@ -16,7 +16,7 @@ impl Drive { pub(super) fn add_contested_document_for_contract_apply_and_add_to_operations_v0( &self, document_and_contract_info: DocumentAndContractInfo, - contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll, + contested_document_resource_vote_poll: ContestedDocumentResourceVotePollWithContractInfo, insert_without_check: bool, block_info: &BlockInfo, document_is_unique_for_document_type_in_batch: bool, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/mod.rs index 7b8c1badb3..67f534a710 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/mod.rs @@ -7,8 +7,8 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use dpp::version::PlatformVersion; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; @@ -18,7 +18,7 @@ impl Drive { pub(crate) fn add_contested_document_for_contract_operations( &self, document_and_contract_info: DocumentAndContractInfo, - contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll, + contested_document_resource_vote_poll: ContestedDocumentResourceVotePollWithContractInfo, insert_without_check: bool, block_info: &BlockInfo, previous_batch_operations: &mut Option<&mut Vec>, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs index 1956e72d2b..c56976b7d9 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs @@ -1,10 +1,10 @@ use crate::drive::object_size_info::DocumentAndContractInfo; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::voting::vote_polls::VotePoll; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; @@ -16,7 +16,7 @@ impl Drive { pub(super) fn add_contested_document_for_contract_operations_v0( &self, document_and_contract_info: DocumentAndContractInfo, - contested_document_resource_vote_poll: ContestedDocumentResourceVotePoll, + contested_document_resource_vote_poll: ContestedDocumentResourceVotePollWithContractInfo, insert_without_check: bool, block_info: &BlockInfo, previous_batch_operations: &mut Option<&mut Vec>, @@ -67,7 +67,9 @@ impl Drive { if !contest_already_existed { self.add_vote_poll_end_date_query_operations( document_and_contract_info.owned_document_info.owner_id, - VotePoll::ContestedDocumentResourceVotePoll(contested_document_resource_vote_poll), + VotePoll::ContestedDocumentResourceVotePoll( + contested_document_resource_vote_poll.into(), + ), end_date, block_info, estimated_costs_only_with_layer_info, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_vote_subtrees_for_non_identities_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_vote_subtrees_for_non_identities_operations/mod.rs index 229a0386d1..473652ee3f 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_vote_subtrees_for_non_identities_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_vote_subtrees_for_non_identities_operations/mod.rs @@ -2,7 +2,7 @@ mod v0; use crate::drive::flags::StorageFlags; -use crate::drive::object_size_info::{DocumentAndContractInfo, PathInfo}; +use crate::drive::object_size_info::PathInfo; use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_vote_subtrees_for_non_identities_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_vote_subtrees_for_non_identities_operations/v0/mod.rs index 43e279b08e..7760aa845c 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_vote_subtrees_for_non_identities_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_vote_subtrees_for_non_identities_operations/v0/mod.rs @@ -1,29 +1,18 @@ -use crate::drive::defaults::{ - CONTESTED_DOCUMENT_REFERENCE_SIZE, DEFAULT_HASH_SIZE_U8, STORAGE_FLAGS_SIZE, U8_SIZE_U32, - U8_SIZE_U8, -}; -use crate::drive::document::make_document_contested_reference; +use crate::drive::defaults::{DEFAULT_HASH_SIZE_U8, U8_SIZE_U32, U8_SIZE_U8}; use crate::drive::flags::StorageFlags; use crate::drive::grove_operations::BatchInsertTreeApplyType; -use crate::drive::object_size_info::DocumentInfo::{ - DocumentAndSerialization, DocumentEstimatedAverageSize, DocumentOwnedInfo, - DocumentRefAndSerialization, DocumentRefInfo, -}; use crate::drive::object_size_info::DriveKeyInfo::KeyRef; -use crate::drive::object_size_info::KeyElementInfo::{KeyElement, KeyUnknownElementSize}; -use crate::drive::object_size_info::{DocumentAndContractInfo, PathInfo, PathKeyElementInfo}; +use crate::drive::object_size_info::PathInfo; use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; -use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; use dpp::version::drive_versions::DriveVersion; -use grovedb::batch::key_info::KeyInfo; use grovedb::batch::KeyInfoPath; use grovedb::EstimatedLayerCount::{ApproximateElements, PotentiallyAtMaxElements}; use grovedb::EstimatedLayerSizes::{AllItems, Mix}; use grovedb::EstimatedSumTrees::AllSumTrees; -use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; +use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; impl Drive { diff --git a/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs index 2776810402..4b4665d867 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_masternode_vote/v0/mod.rs @@ -11,7 +11,7 @@ use crate::query::Query; use dpp::voting::votes::Vote; impl Drive { - /// Verifies the balance of an identity by their identity ID. + /// Verifies the masternode vote. /// /// `verify_subset_of_proof` is used to indicate if we want to verify a subset of a bigger proof. /// For example, if the proof can prove the balance and the revision, but here we are only interested diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs index 694d7c8f68..134f1106fb 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs @@ -6,8 +6,7 @@ use grovedb::{Element, GroveDb}; use crate::error::Error; use crate::drive::votes::paths::{ - RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8, RESOURCE_FINISHED_INFO_KEY_U8, - RESOURCE_LOCK_VOTE_TREE_KEY_U8, + RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8, RESOURCE_LOCK_VOTE_TREE_KEY_U8, RESOURCE_STORED_INFO_KEY_U8, }; use crate::error::drive::DriveError; use crate::query::vote_poll_vote_state_query::{ @@ -16,8 +15,9 @@ use crate::query::vote_poll_vote_state_query::{ }; use dpp::version::PlatformVersion; use dpp::voting::contender_structs::ContenderWithSerializedDocument; -use dpp::voting::vote_outcomes::finalized_contested_document_vote_poll_stored_info::FinalizedContestedDocumentVotePollStoredInfo; -use dpp::voting::vote_outcomes::finalized_contested_document_vote_poll_stored_info::FinalizedContestedDocumentVotePollStoredInfoV0Getters; +use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::{ + ContestedDocumentVotePollStoredInfo, ContestedDocumentVotePollStoredInfoV0Getters, +}; impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { /// Verifies a proof for a collection of documents. @@ -131,22 +131,44 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { } abstaining_vote_tally = Some(sum_tree_value as u32); } - Some(key) if key == &RESOURCE_FINISHED_INFO_KEY_U8 => { + Some(key) if key == &RESOURCE_STORED_INFO_KEY_U8 => { // The vote is actually over, let's deserialize the info - let finalized_contested_document_vote_poll_stored_info = FinalizedContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&vote_tally.into_item_bytes()?)?; - locked_vote_tally = Some( - finalized_contested_document_vote_poll_stored_info.locked_votes(), - ); - abstaining_vote_tally = Some( - finalized_contested_document_vote_poll_stored_info.abstain_votes(), - ); - winner = Some(( - *finalized_contested_document_vote_poll_stored_info.winner(), - *finalized_contested_document_vote_poll_stored_info - .finalization_block(), - )); - contenders = finalized_contested_document_vote_poll_stored_info - .contender_votes_in_vec_of_contender_with_serialized_document(); + let finalized_contested_document_vote_poll_stored_info = + ContestedDocumentVotePollStoredInfo::deserialize_from_bytes( + &vote_tally.into_item_bytes()?, + )?; + if finalized_contested_document_vote_poll_stored_info + .vote_poll_status() + .awarded_or_locked() + { + locked_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .last_locked_votes() + .ok_or(Error::Drive(DriveError::CorruptedDriveState( + "we should have last locked votes".to_string(), + )))?, + ); + abstaining_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .last_abstain_votes() + .ok_or(Error::Drive(DriveError::CorruptedDriveState( + "we should have last abstain votes".to_string(), + )))?, + ); + winner = Some(( + finalized_contested_document_vote_poll_stored_info.winner(), + finalized_contested_document_vote_poll_stored_info + .last_finalization_block() + .ok_or(Error::Drive(DriveError::CorruptedDriveState( + "we should have a last finalization block".to_string(), + )))?, + )); + contenders = finalized_contested_document_vote_poll_stored_info + .contender_votes_in_vec_of_contender_with_serialized_document() + .ok_or(Error::Drive(DriveError::CorruptedDriveState( + "we should have a last contender votes".to_string(), + )))?; + } } _ => { let sum_tree_value = vote_tally.into_sum_tree_value()?; @@ -247,22 +269,48 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { contenders.push(contender); } else { // The vote is actually over, let's deserialize the info - let finalized_contested_document_vote_poll_stored_info = FinalizedContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&serialized_item_info)?; - locked_vote_tally = Some( - finalized_contested_document_vote_poll_stored_info - .locked_votes(), - ); - abstaining_vote_tally = Some( - finalized_contested_document_vote_poll_stored_info - .abstain_votes(), - ); - winner = Some(( - *finalized_contested_document_vote_poll_stored_info - .winner(), - *finalized_contested_document_vote_poll_stored_info - .finalization_block(), - )); - contenders = finalized_contested_document_vote_poll_stored_info.contender_votes_in_vec_of_contender_with_serialized_document(); + let finalized_contested_document_vote_poll_stored_info = ContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&serialized_item_info)?; + if finalized_contested_document_vote_poll_stored_info + .vote_poll_status() + .awarded_or_locked() + { + locked_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .last_locked_votes() + .ok_or(Error::Drive( + DriveError::CorruptedDriveState( + "we should have last locked votes" + .to_string(), + ), + ))?, + ); + abstaining_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .last_abstain_votes() + .ok_or(Error::Drive( + DriveError::CorruptedDriveState( + "we should have last abstain votes" + .to_string(), + ), + ))?, + ); + winner = Some(( + finalized_contested_document_vote_poll_stored_info + .winner(), + finalized_contested_document_vote_poll_stored_info + .last_finalization_block() + .ok_or(Error::Drive( + DriveError::CorruptedDriveState( + "we should have a last finalization block" + .to_string(), + ), + ))?, + )); + contenders = finalized_contested_document_vote_poll_stored_info + .contender_votes_in_vec_of_contender_with_serialized_document().ok_or(Error::Drive(DriveError::CorruptedDriveState( + "we should have a last contender votes".to_string(), + )))?; + } } } _ => { @@ -328,22 +376,48 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { contenders.push(contender); } else { // The vote is actually over, let's deserialize the info - let finalized_contested_document_vote_poll_stored_info = FinalizedContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&serialized_item_info)?; - locked_vote_tally = Some( - finalized_contested_document_vote_poll_stored_info - .locked_votes(), - ); - abstaining_vote_tally = Some( - finalized_contested_document_vote_poll_stored_info - .abstain_votes(), - ); - winner = Some(( - *finalized_contested_document_vote_poll_stored_info - .winner(), - *finalized_contested_document_vote_poll_stored_info - .finalization_block(), - )); - contenders = finalized_contested_document_vote_poll_stored_info.contender_votes_in_vec_of_contender_with_serialized_document(); + let finalized_contested_document_vote_poll_stored_info = ContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&serialized_item_info)?; + if finalized_contested_document_vote_poll_stored_info + .vote_poll_status() + .awarded_or_locked() + { + locked_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .last_locked_votes() + .ok_or(Error::Drive( + DriveError::CorruptedDriveState( + "we should have last locked votes" + .to_string(), + ), + ))?, + ); + abstaining_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .last_abstain_votes() + .ok_or(Error::Drive( + DriveError::CorruptedDriveState( + "we should have last abstain votes" + .to_string(), + ), + ))?, + ); + winner = Some(( + finalized_contested_document_vote_poll_stored_info + .winner(), + finalized_contested_document_vote_poll_stored_info + .last_finalization_block() + .ok_or(Error::Drive( + DriveError::CorruptedDriveState( + "we should have a last finalization block" + .to_string(), + ), + ))?, + )); + contenders = finalized_contested_document_vote_poll_stored_info + .contender_votes_in_vec_of_contender_with_serialized_document().ok_or(Error::Drive(DriveError::CorruptedDriveState( + "we should have a last contender votes".to_string(), + )))?; + } } } _ => { diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_votes_proof/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_votes_proof/v0/mod.rs index f446d66b27..3d475fdad2 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_votes_proof/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_votes_proof/v0/mod.rs @@ -1,7 +1,7 @@ use crate::drive::verify::RootHash; use dpp::identifier::Identifier; use dpp::platform_value; -use grovedb::{Element, GroveDb}; +use grovedb::GroveDb; use crate::error::Error; diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_polls_end_date_query/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_polls_end_date_query/mod.rs index fb8e2ca916..a64cfbf893 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_vote_polls_end_date_query/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_polls_end_date_query/mod.rs @@ -9,7 +9,6 @@ use crate::error::Error; use crate::query::VotePollsByEndDateDriveQuery; use dpp::version::PlatformVersion; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::voting::vote_polls::VotePoll; impl VotePollsByEndDateDriveQuery { diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_contenders_operations/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_contenders_operations/mod.rs index bdcf77e248..b7fd4e2e11 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_contenders_operations/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_contenders_operations/mod.rs @@ -12,7 +12,6 @@ use dpp::identifier::Identifier; use dpp::prelude::TimestampMillis; use dpp::version::PlatformVersion; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use grovedb::TransactionArg; impl Drive { diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_contenders_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_contenders_operations/v0/mod.rs index 2646f841c1..26fad235ba 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_contenders_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_contenders_operations/v0/mod.rs @@ -1,5 +1,5 @@ use crate::drive::grove_operations::BatchDeleteApplyType; -use crate::drive::votes::paths::{VotePollPaths, VOTING_STORAGE_TREE_KEY}; +use crate::drive::votes::paths::VotePollPaths; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use crate::drive::votes::ResourceVoteChoiceToKeyTrait; use crate::drive::Drive; diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_end_date_query_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_end_date_query_operations/v0/mod.rs index 2cf1dac3df..8b0305811d 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_end_date_query_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_end_date_query_operations/v0/mod.rs @@ -1,7 +1,5 @@ use crate::drive::grove_operations::BatchDeleteUpTreeApplyType; -use crate::drive::votes::paths::{ - vote_contested_resource_end_date_queries_at_time_tree_path_vec, vote_end_date_queries_tree_path, -}; +use crate::drive::votes::paths::vote_contested_resource_end_date_queries_at_time_tree_path_vec; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use crate::drive::Drive; use crate::error::Error; diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/mod.rs index 6d8015fe04..e571e8d315 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/mod.rs @@ -12,7 +12,6 @@ use dpp::identifier::Identifier; use dpp::prelude::TimestampMillis; use dpp::version::PlatformVersion; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use grovedb::TransactionArg; impl Drive { diff --git a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/v0/mod.rs index 004ddb9e0e..eb968c2e59 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/remove_contested_resource_vote_poll_votes_operations/v0/mod.rs @@ -1,8 +1,5 @@ -use crate::drive::grove_operations::{BatchDeleteApplyType, BatchDeleteUpTreeApplyType}; -use crate::drive::votes::paths::{ - vote_contested_resource_end_date_queries_at_time_tree_path_vec, VotePollPaths, - VOTING_STORAGE_TREE_KEY, -}; +use crate::drive::grove_operations::BatchDeleteApplyType; +use crate::drive::votes::paths::{VotePollPaths, VOTING_STORAGE_TREE_KEY}; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use crate::drive::Drive; use crate::error::Error; @@ -10,8 +7,6 @@ use crate::fee::op::LowLevelDriveOperation; use dpp::identifier::Identifier; use dpp::identity::TimestampMillis; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; -use grovedb::batch::KeyInfoPath; use grovedb::TransactionArg; use platform_version::version::PlatformVersion; use std::collections::BTreeMap; diff --git a/packages/rs-drive/src/drive/votes/fetch/fetch_contested_document_vote_poll_stored_info/mod.rs b/packages/rs-drive/src/drive/votes/fetch/fetch_contested_document_vote_poll_stored_info/mod.rs new file mode 100644 index 0000000000..82b563be59 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/fetch/fetch_contested_document_vote_poll_stored_info/mod.rs @@ -0,0 +1,44 @@ +mod v0; + +use crate::drive::Drive; + +use crate::error::drive::DriveError; +use crate::error::Error; + +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use dpp::block::epoch::Epoch; +use dpp::fee::fee_result::FeeResult; +use dpp::version::PlatformVersion; +use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStoredInfo; +use grovedb::TransactionArg; + +impl Drive { + /// Fetches a contested resource contest start info. + pub fn fetch_contested_document_vote_poll_stored_info( + &self, + contested_document_resource_vote_poll_with_contract_info: &ContestedDocumentResourceVotePollWithContractInfo, + epoch: &Epoch, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(FeeResult, Option), Error> { + match platform_version + .drive + .methods + .vote + .fetch + .fetch_contested_document_vote_poll_stored_info + { + 0 => self.fetch_contested_document_vote_poll_stored_info_v0( + contested_document_resource_vote_poll_with_contract_info, + epoch, + transaction, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "fetch_contested_document_vote_poll_stored_info".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/votes/fetch/fetch_contested_document_vote_poll_stored_info/v0/mod.rs b/packages/rs-drive/src/drive/votes/fetch/fetch_contested_document_vote_poll_stored_info/v0/mod.rs new file mode 100644 index 0000000000..a84ea8e1d6 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/fetch/fetch_contested_document_vote_poll_stored_info/v0/mod.rs @@ -0,0 +1,49 @@ +use crate::drive::grove_operations::DirectQueryType; +use crate::drive::votes::paths::{VotePollPaths, RESOURCE_STORED_INFO_KEY_U8}; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use crate::drive::Drive; +use crate::error::Error; +use dpp::block::epoch::Epoch; +use dpp::fee::fee_result::FeeResult; +use dpp::serialization::PlatformDeserializable; +use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStoredInfo; +use grovedb::TransactionArg; +use platform_version::version::PlatformVersion; + +impl Drive { + /// Fetches the contested document vote poll stored info + pub(super) fn fetch_contested_document_vote_poll_stored_info_v0( + &self, + contested_document_resource_vote_poll_with_contract_info: &ContestedDocumentResourceVotePollWithContractInfo, + epoch: &Epoch, + transaction: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result<(FeeResult, Option), Error> { + let path = contested_document_resource_vote_poll_with_contract_info + .contenders_path(platform_version)?; + let mut cost_operations = vec![]; + let maybe_element = self.grove_get_raw( + path.as_slice().into(), + vec![RESOURCE_STORED_INFO_KEY_U8].as_slice(), + DirectQueryType::StatefulDirectQuery, + transaction, + &mut cost_operations, + &platform_version.drive, + )?; + let fee_result = Drive::calculate_fee( + None, + Some(cost_operations), + epoch, + self.config.epochs_per_era, + platform_version, + )?; + let Some(element) = maybe_element else { + return Ok((fee_result, None)); + }; + let contested_start_info_bytes = element.into_item_bytes()?; + let start_info = ContestedDocumentVotePollStoredInfo::deserialize_from_bytes( + &contested_start_info_bytes, + )?; + Ok((fee_result, Some(start_info))) + } +} diff --git a/packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/mod.rs b/packages/rs-drive/src/drive/votes/fetch/fetch_identities_voting_for_contenders/mod.rs similarity index 98% rename from packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/mod.rs rename to packages/rs-drive/src/drive/votes/fetch/fetch_identities_voting_for_contenders/mod.rs index a6d6c1ccd3..734a66c8fa 100644 --- a/packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/mod.rs +++ b/packages/rs-drive/src/drive/votes/fetch/fetch_identities_voting_for_contenders/mod.rs @@ -26,6 +26,7 @@ impl Drive { .drive .methods .vote + .fetch .fetch_identities_voting_for_contenders { 0 => self.fetch_identities_voting_for_contenders_v0( diff --git a/packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/v0/mod.rs b/packages/rs-drive/src/drive/votes/fetch/fetch_identities_voting_for_contenders/v0/mod.rs similarity index 97% rename from packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/v0/mod.rs rename to packages/rs-drive/src/drive/votes/fetch/fetch_identities_voting_for_contenders/v0/mod.rs index b4fd3352f6..ebebb9108b 100644 --- a/packages/rs-drive/src/drive/votes/fetch_identities_voting_for_contenders/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/fetch/fetch_identities_voting_for_contenders/v0/mod.rs @@ -23,7 +23,7 @@ impl Drive { transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result>, Error> { - let mut path = contested_document_resource_vote_poll_with_contract_info + let path = contested_document_resource_vote_poll_with_contract_info .contenders_path(platform_version)?; let mut query = Query::new_with_direction(true); diff --git a/packages/rs-drive/src/drive/votes/fetch/mod.rs b/packages/rs-drive/src/drive/votes/fetch/mod.rs new file mode 100644 index 0000000000..bccde52f4f --- /dev/null +++ b/packages/rs-drive/src/drive/votes/fetch/mod.rs @@ -0,0 +1,2 @@ +mod fetch_contested_document_vote_poll_stored_info; +mod fetch_identities_voting_for_contenders; diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index 4931593d07..c37a0350ab 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -1,10 +1,7 @@ use crate::drive::grove_operations::BatchInsertTreeApplyType; -use crate::drive::object_size_info::PathKeyElementInfo::{ - PathFixedSizeKeyRefElement, PathKeyElement, -}; +use crate::drive::object_size_info::PathKeyElementInfo::PathKeyElement; use crate::drive::object_size_info::PathKeyInfo; use crate::drive::votes::paths::{ - vote_contested_resource_identity_votes_tree_path, vote_contested_resource_identity_votes_tree_path_for_identity_vec, vote_contested_resource_identity_votes_tree_path_vec, VotePollPaths, }; diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/insert_record_of_finished_vote_poll/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/insert_stored_info_for_contested_resource_vote_poll/mod.rs similarity index 66% rename from packages/rs-drive/src/drive/votes/insert/contested_resource/insert_record_of_finished_vote_poll/mod.rs rename to packages/rs-drive/src/drive/votes/insert/contested_resource/insert_stored_info_for_contested_resource_vote_poll/mod.rs index 07a7524ab9..1b1bdb1307 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/insert_record_of_finished_vote_poll/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/insert_stored_info_for_contested_resource_vote_poll/mod.rs @@ -8,15 +8,15 @@ use crate::error::Error; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use crate::fee::op::LowLevelDriveOperation; use dpp::version::PlatformVersion; -use dpp::voting::vote_outcomes::finalized_contested_document_vote_poll_stored_info::FinalizedContestedDocumentVotePollStoredInfo; +use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStoredInfo; use grovedb::TransactionArg; impl Drive { /// Inserts a record of a finished vote poll that can later be queried - pub fn insert_record_of_finished_vote_poll( + pub fn insert_stored_info_for_contested_resource_vote_poll( &self, vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, - finalized_contested_document_vote_poll_stored_info: FinalizedContestedDocumentVotePollStoredInfo, + finalized_contested_document_vote_poll_stored_info: ContestedDocumentVotePollStoredInfo, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { @@ -25,16 +25,16 @@ impl Drive { .methods .vote .contested_resource_insert - .insert_record_of_finished_vote_poll + .insert_stored_info_for_contested_resource_vote_poll { - 0 => self.insert_record_of_finished_vote_poll_v0( + 0 => self.insert_stored_info_for_contested_resource_vote_poll_v0( vote_poll, finalized_contested_document_vote_poll_stored_info, transaction, platform_version, ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "insert_record_of_finished_vote_poll".to_string(), + method: "insert_stored_info_for_contested_resource_vote_poll".to_string(), known_versions: vec![0], received: version, })), @@ -42,10 +42,10 @@ impl Drive { } /// Returns the operations of inserting a record of a finished vote poll that can later be queried - pub fn insert_record_of_finished_vote_poll_operations( + pub fn insert_stored_info_for_contested_resource_vote_poll_operations( &self, vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, - finalized_contested_document_vote_poll_stored_info: FinalizedContestedDocumentVotePollStoredInfo, + finalized_contested_document_vote_poll_stored_info: ContestedDocumentVotePollStoredInfo, platform_version: &PlatformVersion, ) -> Result, Error> { match platform_version @@ -53,15 +53,16 @@ impl Drive { .methods .vote .contested_resource_insert - .insert_record_of_finished_vote_poll + .insert_stored_info_for_contested_resource_vote_poll { - 0 => self.insert_record_of_finished_vote_poll_operations_v0( + 0 => self.insert_stored_info_for_contested_resource_vote_poll_operations_v0( vote_poll, finalized_contested_document_vote_poll_stored_info, platform_version, ), version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "insert_record_of_finished_vote_poll_operations".to_string(), + method: "insert_stored_info_for_contested_resource_vote_poll_operations" + .to_string(), known_versions: vec![0], received: version, })), diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/insert_record_of_finished_vote_poll/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/insert_stored_info_for_contested_resource_vote_poll/v0/mod.rs similarity index 66% rename from packages/rs-drive/src/drive/votes/insert/contested_resource/insert_record_of_finished_vote_poll/v0/mod.rs rename to packages/rs-drive/src/drive/votes/insert/contested_resource/insert_stored_info_for_contested_resource_vote_poll/v0/mod.rs index b20d271c40..634d878957 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/insert_record_of_finished_vote_poll/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/insert_stored_info_for_contested_resource_vote_poll/v0/mod.rs @@ -1,27 +1,28 @@ use crate::drive::object_size_info::PathKeyElementInfo::PathKeyElement; -use crate::drive::votes::paths::{VotePollPaths, RESOURCE_FINISHED_INFO_KEY_U8}; +use crate::drive::votes::paths::{VotePollPaths, RESOURCE_STORED_INFO_KEY_U8}; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::serialization::PlatformSerializable; -use dpp::voting::vote_outcomes::finalized_contested_document_vote_poll_stored_info::FinalizedContestedDocumentVotePollStoredInfo; +use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStoredInfo; use grovedb::{Element, TransactionArg}; use platform_version::version::PlatformVersion; impl Drive { - pub(super) fn insert_record_of_finished_vote_poll_v0( + pub(super) fn insert_stored_info_for_contested_resource_vote_poll_v0( &self, vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, - finalized_contested_document_vote_poll_stored_info: FinalizedContestedDocumentVotePollStoredInfo, + finalized_contested_document_vote_poll_stored_info: ContestedDocumentVotePollStoredInfo, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result<(), Error> { - let batch_operations = self.insert_record_of_finished_vote_poll_operations_v0( - vote_poll, - finalized_contested_document_vote_poll_stored_info, - platform_version, - )?; + let batch_operations = self + .insert_stored_info_for_contested_resource_vote_poll_operations_v0( + vote_poll, + finalized_contested_document_vote_poll_stored_info, + platform_version, + )?; let mut drive_operations: Vec = vec![]; self.apply_batch_low_level_drive_operations( @@ -35,10 +36,10 @@ impl Drive { Ok(()) } - pub(super) fn insert_record_of_finished_vote_poll_operations_v0( + pub(super) fn insert_stored_info_for_contested_resource_vote_poll_operations_v0( &self, vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, - finalized_contested_document_vote_poll_stored_info: FinalizedContestedDocumentVotePollStoredInfo, + finalized_contested_document_vote_poll_stored_info: ContestedDocumentVotePollStoredInfo, platform_version: &PlatformVersion, ) -> Result, Error> { let mut drive_operations: Vec = vec![]; @@ -50,7 +51,7 @@ impl Drive { self.batch_insert::<0>( PathKeyElement(( vote_poll_root_path.clone(), - vec![RESOURCE_FINISHED_INFO_KEY_U8], + vec![RESOURCE_STORED_INFO_KEY_U8], Element::new_item(serialization), )), &mut drive_operations, diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/mod.rs index 6d6c632b53..810a208e76 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/mod.rs @@ -1,2 +1,2 @@ mod individual_vote; -mod insert_record_of_finished_vote_poll; +mod insert_stored_info_for_contested_resource_vote_poll; diff --git a/packages/rs-drive/src/drive/votes/mod.rs b/packages/rs-drive/src/drive/votes/mod.rs index 2a181053ea..ee635bcc26 100644 --- a/packages/rs-drive/src/drive/votes/mod.rs +++ b/packages/rs-drive/src/drive/votes/mod.rs @@ -23,8 +23,6 @@ pub mod paths; #[cfg(feature = "server")] mod setup; -#[cfg(feature = "server")] -mod fetch_identities_voting_for_contenders; #[cfg(any(feature = "server", feature = "verify"))] /// Resolve contested document resource vote poll module pub mod resolved; @@ -35,6 +33,9 @@ pub mod storage_form; /// Tree path storage form pub mod tree_path_storage_form; +#[cfg(feature = "server")] +mod fetch; + /// A trait to convert the vote to a tree path usable in grovedb pub trait TreePath { /// The tree path function diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index 3866819b21..8f2427c54f 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -9,7 +9,6 @@ use crate::error::Error; use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; use dpp::data_contract::document_type::IndexProperty; -use dpp::identifier::Identifier; use dpp::identity::TimestampMillis; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use platform_version::version::PlatformVersion; @@ -45,19 +44,19 @@ pub const IDENTITY_VOTES_TREE_KEY: char = 'i'; pub const RESOURCE_LOCK_VOTE_TREE_KEY: char = 'l'; /// In the active vote poll this will contain votes for abstaining on the vote for the contested resource -pub const RESOURCE_ABSTAIN_VOTE_TREE_KEY: char = 'a'; +pub const RESOURCE_ABSTAIN_VOTE_TREE_KEY: char = 'k'; /// In the active vote poll this will contain votes for locking the contested resource pub const RESOURCE_LOCK_VOTE_TREE_KEY_U8: u8 = 'l' as u8; /// In the active vote poll this will contain votes for abstaining on the vote for the contested resource -pub const RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8: u8 = 'a' as u8; +pub const RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8: u8 = 'k' as u8; /// The finished info -pub const RESOURCE_FINISHED_INFO_KEY: char = 'f'; +pub const RESOURCE_STORED_INFO_KEY: char = 'b'; /// The finished info -pub const RESOURCE_FINISHED_INFO_KEY_U8: u8 = 'f' as u8; +pub const RESOURCE_STORED_INFO_KEY_U8: u8 = 'b' as u8; /// The tree key for storage pub const VOTING_STORAGE_TREE_KEY: u8 = 1; diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs index 309040a50a..f3868b9f2c 100644 --- a/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/resolve.rs @@ -1,3 +1,4 @@ +use crate::drive::contract::DataContractFetchInfo; #[cfg(feature = "server")] use crate::drive::object_size_info::DataContractOwnedResolvedInfo; #[cfg(any(feature = "server", feature = "verify"))] @@ -95,6 +96,20 @@ pub trait ContestedDocumentResourceVotePollResolver { transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error>; + + /// Resolve owned into a struct that allows for a borrowed contract + #[cfg(any(feature = "verify", feature = "server"))] + fn resolve_with_provided_arc_contract_fetch_info( + &self, + data_contract: Arc, + ) -> Result; + + /// Resolve owned into a struct that allows for a borrowed contract + #[cfg(any(feature = "verify", feature = "server"))] + fn resolve_owned_with_provided_arc_contract_fetch_info( + self, + data_contract: Arc, + ) -> Result; } impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVotePoll { @@ -197,6 +212,64 @@ impl ContestedDocumentResourceVotePollResolver for ContestedDocumentResourceVote ) } + #[cfg(any(feature = "verify", feature = "server"))] + fn resolve_with_provided_arc_contract_fetch_info( + &self, + data_contract: Arc, + ) -> Result { + let ContestedDocumentResourceVotePoll { + contract_id, + document_type_name, + index_name, + index_values, + } = self; + + if contract_id != data_contract.contract.id_ref() { + return Err(Error::DataContract( + DataContractError::ProvidedContractMismatch(format!( + "data contract provided {} is not the one required {}", + data_contract.contract.id_ref(), + contract_id + )), + )); + } + Ok(ContestedDocumentResourceVotePollWithContractInfo { + contract: DataContractOwnedResolvedInfo::DataContractFetchInfo(data_contract), + document_type_name: document_type_name.clone(), + index_name: index_name.clone(), + index_values: index_values.clone(), + }) + } + + #[cfg(any(feature = "verify", feature = "server"))] + fn resolve_owned_with_provided_arc_contract_fetch_info( + self, + data_contract: Arc, + ) -> Result { + let ContestedDocumentResourceVotePoll { + contract_id, + document_type_name, + index_name, + index_values, + } = self; + + if contract_id != data_contract.contract.id_ref() { + return Err(Error::DataContract( + DataContractError::ProvidedContractMismatch(format!( + "data contract provided {} is not the one required {}", + data_contract.contract.id_ref(), + contract_id + )), + )); + } + Ok(ContestedDocumentResourceVotePollWithContractInfo { + contract: DataContractOwnedResolvedInfo::DataContractFetchInfo(data_contract), + document_type_name, + index_name, + index_values, + }) + } + #[cfg(any(feature = "verify", feature = "server"))] fn resolve_with_provided_borrowed_contract<'a>( &self, diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs index d34171fe0d..fb9bfcfdf8 100644 --- a/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs @@ -2,7 +2,6 @@ use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_ use derive_more::From; use dpp::identifier::Identifier; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use dpp::ProtocolError; use std::collections::BTreeMap; diff --git a/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs b/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs index f4fd57b974..86875c59ab 100644 --- a/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs +++ b/packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs @@ -188,11 +188,11 @@ impl ContestedDocumentVotePollVotesDriveQuery { | Err(Error::GroveDB(GroveError::PathNotFound(_))) | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok(vec![]), Err(e) => Err(e), - Ok((query_result_elements, skipped)) => { + Ok((query_result_elements, _skipped)) => { let voters = query_result_elements .to_keys() .into_iter() - .map(|voter_id| Identifier::try_from(voter_id)) + .map(Identifier::try_from) .collect::, platform_value::Error>>()?; Ok(voters) diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index 51ebdab457..b658e3c376 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -1,7 +1,6 @@ use crate::drive::votes::paths::{ - VotePollPaths, RESOURCE_ABSTAIN_VOTE_TREE_KEY, RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8, - RESOURCE_FINISHED_INFO_KEY, RESOURCE_FINISHED_INFO_KEY_U8, RESOURCE_LOCK_VOTE_TREE_KEY, - RESOURCE_LOCK_VOTE_TREE_KEY_U8, + VotePollPaths, RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8, RESOURCE_LOCK_VOTE_TREE_KEY_U8, + RESOURCE_STORED_INFO_KEY_U8, }; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfoAllowBorrowed; @@ -13,24 +12,18 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; #[cfg(feature = "server")] use crate::query::GroveError; -use dpp::bincode::{Decode, Encode}; #[cfg(feature = "server")] use dpp::block::block_info::BlockInfo; -use dpp::data_contract::document_type::DocumentTypeRef; use dpp::data_contract::DataContract; -use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0; -use dpp::document::Document; use dpp::identifier::Identifier; use dpp::serialization::PlatformDeserializable; use dpp::voting::contender_structs::{ ContenderWithSerializedDocument, FinalizedContenderWithSerializedDocument, - FinalizedResourceVoteChoicesWithVoterInfo, }; -use dpp::voting::vote_outcomes::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; -use dpp::voting::vote_outcomes::finalized_contested_document_vote_poll_stored_info::{ - FinalizedContestedDocumentVotePollStoredInfo, - FinalizedContestedDocumentVotePollStoredInfoV0Getters, +use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::{ + ContestedDocumentVotePollStoredInfo, ContestedDocumentVotePollStoredInfoV0Getters, }; +use dpp::voting::vote_info_storage::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; #[cfg(feature = "server")] use grovedb::query_result_type::{QueryResultElements, QueryResultType}; @@ -526,24 +519,50 @@ impl ContestedDocumentVotePollDriveQuery { } abstaining_vote_tally = Some(sum_tree_value as u32); } - Some(key) if key == &RESOURCE_FINISHED_INFO_KEY_U8 => { + Some(key) if key == &RESOURCE_STORED_INFO_KEY_U8 => { // The vote is actually over, let's deserialize the info - let finalized_contested_document_vote_poll_stored_info = FinalizedContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&vote_tally.into_item_bytes()?)?; - locked_vote_tally = Some( - finalized_contested_document_vote_poll_stored_info - .locked_votes(), - ); - abstaining_vote_tally = Some( - finalized_contested_document_vote_poll_stored_info - .abstain_votes(), - ); - winner = Some(( - *finalized_contested_document_vote_poll_stored_info - .winner(), - *finalized_contested_document_vote_poll_stored_info - .finalization_block(), - )); - contenders = finalized_contested_document_vote_poll_stored_info.contender_votes_in_vec_of_contender_with_serialized_document(); + let finalized_contested_document_vote_poll_stored_info = ContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&vote_tally.into_item_bytes()?)?; + if finalized_contested_document_vote_poll_stored_info + .vote_poll_status() + .awarded_or_locked() + { + locked_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .last_locked_votes() + .ok_or(Error::Drive( + DriveError::CorruptedDriveState( + "we should have last locked votes" + .to_string(), + ), + ))?, + ); + abstaining_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .last_abstain_votes() + .ok_or(Error::Drive( + DriveError::CorruptedDriveState( + "we should have last abstain votes" + .to_string(), + ), + ))?, + ); + winner = Some(( + finalized_contested_document_vote_poll_stored_info + .winner(), + finalized_contested_document_vote_poll_stored_info + .last_finalization_block() + .ok_or(Error::Drive( + DriveError::CorruptedDriveState( + "we should have a last finalization block" + .to_string(), + ), + ))?, + )); + contenders = finalized_contested_document_vote_poll_stored_info + .contender_votes_in_vec_of_contender_with_serialized_document().ok_or(Error::Drive(DriveError::CorruptedDriveState( + "we should have a last contender votes".to_string(), + )))?; + } } _ => { @@ -647,22 +666,35 @@ impl ContestedDocumentVotePollDriveQuery { contenders.push(contender); } else { // The vote is actually over, let's deserialize the info - let finalized_contested_document_vote_poll_stored_info = FinalizedContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&serialized_item_info)?; - locked_vote_tally = Some( - finalized_contested_document_vote_poll_stored_info - .locked_votes(), - ); - abstaining_vote_tally = Some( - finalized_contested_document_vote_poll_stored_info - .abstain_votes(), - ); - winner = Some(( - *finalized_contested_document_vote_poll_stored_info - .winner(), - *finalized_contested_document_vote_poll_stored_info - .finalization_block(), - )); - contenders = finalized_contested_document_vote_poll_stored_info.contender_votes_in_vec_of_contender_with_serialized_document(); + let finalized_contested_document_vote_poll_stored_info = ContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&serialized_item_info)?; + if finalized_contested_document_vote_poll_stored_info + .vote_poll_status() + .awarded_or_locked() + { + locked_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .last_locked_votes() + .ok_or(Error::Drive(DriveError::CorruptedDriveState( + "we should have last locked votes".to_string(), + )))?, + ); + abstaining_vote_tally = + Some(finalized_contested_document_vote_poll_stored_info + .last_abstain_votes().ok_or(Error::Drive(DriveError::CorruptedDriveState( + "we should have last abstain votes".to_string(), + )))?); + winner = Some(( + finalized_contested_document_vote_poll_stored_info.winner(), + finalized_contested_document_vote_poll_stored_info + .last_finalization_block().ok_or(Error::Drive(DriveError::CorruptedDriveState( + "we should have a last finalization block".to_string(), + )))?, + )); + contenders = finalized_contested_document_vote_poll_stored_info + .contender_votes_in_vec_of_contender_with_serialized_document().ok_or(Error::Drive(DriveError::CorruptedDriveState( + "we should have a last contender votes".to_string(), + )))?; + } } } _ => { @@ -728,22 +760,35 @@ impl ContestedDocumentVotePollDriveQuery { contenders.push(contender); } else { // The vote is actually over, let's deserialize the info - let finalized_contested_document_vote_poll_stored_info = FinalizedContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&serialized_item_info)?; - locked_vote_tally = Some( - finalized_contested_document_vote_poll_stored_info - .locked_votes(), - ); - abstaining_vote_tally = Some( - finalized_contested_document_vote_poll_stored_info - .abstain_votes(), - ); - winner = Some(( - *finalized_contested_document_vote_poll_stored_info - .winner(), - *finalized_contested_document_vote_poll_stored_info - .finalization_block(), - )); - contenders = finalized_contested_document_vote_poll_stored_info.contender_votes_in_vec_of_contender_with_serialized_document(); + let finalized_contested_document_vote_poll_stored_info = ContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&serialized_item_info)?; + if finalized_contested_document_vote_poll_stored_info + .vote_poll_status() + .awarded_or_locked() + { + locked_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .last_locked_votes() + .ok_or(Error::Drive(DriveError::CorruptedDriveState( + "we should have last locked votes".to_string(), + )))?, + ); + abstaining_vote_tally = + Some(finalized_contested_document_vote_poll_stored_info + .last_abstain_votes().ok_or(Error::Drive(DriveError::CorruptedDriveState( + "we should have last abstain votes".to_string(), + )))?); + winner = Some(( + finalized_contested_document_vote_poll_stored_info.winner(), + finalized_contested_document_vote_poll_stored_info + .last_finalization_block().ok_or(Error::Drive(DriveError::CorruptedDriveState( + "we should have a last finalization block".to_string(), + )))?, + )); + contenders = finalized_contested_document_vote_poll_stored_info + .contender_votes_in_vec_of_contender_with_serialized_document().ok_or(Error::Drive(DriveError::CorruptedDriveState( + "we should have a last contender votes".to_string(), + )))?; + } } } _ => { diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs index 373002c101..26f2fa2b7d 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs @@ -16,7 +16,7 @@ use dpp::ProtocolError; pub use v0::*; use crate::state_transition_action::document::documents_batch::document_transition::document_base_transition_action::{DocumentBaseTransitionAction}; use dpp::version::PlatformVersion; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; /// document create transition action #[derive(Debug, Clone, From)] @@ -64,13 +64,15 @@ impl DocumentCreateTransitionActionAccessorsV0 for DocumentCreateTransitionActio fn take_prefunded_voting_balance( &mut self, - ) -> Option<(ContestedDocumentResourceVotePoll, Credits)> { + ) -> Option<(ContestedDocumentResourceVotePollWithContractInfo, Credits)> { match self { DocumentCreateTransitionAction::V0(v0) => v0.prefunded_voting_balance.take(), } } - fn prefunded_voting_balance(&self) -> &Option<(ContestedDocumentResourceVotePoll, Credits)> { + fn prefunded_voting_balance( + &self, + ) -> &Option<(ContestedDocumentResourceVotePollWithContractInfo, Credits)> { match self { DocumentCreateTransitionAction::V0(v0) => &v0.prefunded_voting_balance, } diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/transformer.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/transformer.rs index 6933d82685..8ab406d5a7 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/transformer.rs @@ -5,6 +5,7 @@ use std::sync::Arc; use dpp::ProtocolError; use dpp::state_transition::documents_batch_transition::document_create_transition::DocumentCreateTransition; use crate::drive::contract::DataContractFetchInfo; +use crate::error::Error; use crate::state_transition_action::document::documents_batch::document_transition::document_create_transition_action::{DocumentCreateTransitionAction, DocumentCreateTransitionActionV0}; impl DocumentCreateTransitionAction { @@ -13,7 +14,7 @@ impl DocumentCreateTransitionAction { value: DocumentCreateTransition, block_info: &BlockInfo, get_data_contract: impl Fn(Identifier) -> Result, ProtocolError>, - ) -> Result { + ) -> Result { match value { DocumentCreateTransition::V0(v0) => Ok(DocumentCreateTransitionActionV0::try_from_document_create_transition_with_contract_lookup(v0, block_info, get_data_contract)?.into()), } @@ -24,7 +25,7 @@ impl DocumentCreateTransitionAction { value: &DocumentCreateTransition, block_info: &BlockInfo, get_data_contract: impl Fn(Identifier) -> Result, ProtocolError>, - ) -> Result { + ) -> Result { match value { DocumentCreateTransition::V0(v0) => Ok(DocumentCreateTransitionActionV0::try_from_borrowed_document_create_transition_with_contract_lookup(v0, block_info, get_data_contract)?.into()), } diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs index c1f48a169c..900b0a2286 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs @@ -20,8 +20,8 @@ use dpp::fee::Credits; use crate::state_transition_action::document::documents_batch::document_transition::document_base_transition_action::{DocumentBaseTransitionAction, DocumentBaseTransitionActionV0}; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use dpp::version::PlatformVersion; -use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; /// document create transition action v0 #[derive(Debug, Clone)] @@ -34,7 +34,8 @@ pub struct DocumentCreateTransitionActionV0 { pub data: BTreeMap, /// Pre funded balance (for unique index conflict resolution voting - the identity will put money /// aside that will be used by voters to vote) - pub prefunded_voting_balance: Option<(ContestedDocumentResourceVotePoll, Credits)>, + pub prefunded_voting_balance: + Option<(ContestedDocumentResourceVotePollWithContractInfo, Credits)>, } /// document create transition action accessors v0 @@ -55,11 +56,13 @@ pub trait DocumentCreateTransitionActionAccessorsV0 { /// Take the prefunded voting balance vec (and replace it with an empty vec). fn take_prefunded_voting_balance( &mut self, - ) -> Option<(ContestedDocumentResourceVotePoll, Credits)>; + ) -> Option<(ContestedDocumentResourceVotePollWithContractInfo, Credits)>; /// pre funded balance (for unique index conflict resolution voting - the identity will put money /// aside that will be used by voters to vote) - fn prefunded_voting_balance(&self) -> &Option<(ContestedDocumentResourceVotePoll, Credits)>; + fn prefunded_voting_balance( + &self, + ) -> &Option<(ContestedDocumentResourceVotePollWithContractInfo, Credits)>; } /// documents from create transition v0 diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs index ead12549d3..4fcf638190 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs @@ -7,6 +7,8 @@ use dpp::ProtocolError; use dpp::state_transition::documents_batch_transition::document_create_transition::v0::DocumentCreateTransitionV0; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; use crate::drive::contract::DataContractFetchInfo; +use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; +use crate::error::Error; use crate::state_transition_action::document::documents_batch::document_transition::document_base_transition_action::{DocumentBaseTransitionAction, DocumentBaseTransitionActionAccessorsV0}; use crate::state_transition_action::document::documents_batch::document_transition::document_create_transition_action::DocumentCreateTransitionActionV0; @@ -16,7 +18,7 @@ impl DocumentCreateTransitionActionV0 { value: DocumentCreateTransitionV0, block_info: &BlockInfo, get_data_contract: impl Fn(Identifier) -> Result, ProtocolError>, - ) -> Result { + ) -> Result { let DocumentCreateTransitionV0 { base, data, @@ -50,7 +52,12 @@ impl DocumentCreateTransitionActionV0 { index_values, }; - Ok::<_, ProtocolError>((vote_poll, credits)) + let resolved_vote_poll = vote_poll + .resolve_owned_with_provided_arc_contract_fetch_info( + base.data_contract_fetch_info(), + )?; + + Ok::<_, Error>((resolved_vote_poll, credits)) }) .transpose()?; @@ -67,7 +74,7 @@ impl DocumentCreateTransitionActionV0 { value: &DocumentCreateTransitionV0, block_info: &BlockInfo, get_data_contract: impl Fn(Identifier) -> Result, ProtocolError>, - ) -> Result { + ) -> Result { let DocumentCreateTransitionV0 { base, data, @@ -103,7 +110,12 @@ impl DocumentCreateTransitionActionV0 { index_values, }; - Ok::<_, ProtocolError>((vote_poll, *credits)) + let resolved_vote_poll = vote_poll + .resolve_owned_with_provided_arc_contract_fetch_info( + base.data_contract_fetch_info(), + )?; + + Ok::<_, Error>((resolved_vote_poll, *credits)) }) .transpose()?; diff --git a/packages/rs-drive/src/state_transition_action/mod.rs b/packages/rs-drive/src/state_transition_action/mod.rs index 824d39fdb9..4e6b2e552a 100644 --- a/packages/rs-drive/src/state_transition_action/mod.rs +++ b/packages/rs-drive/src/state_transition_action/mod.rs @@ -86,7 +86,7 @@ impl StateTransitionAction { StateTransitionAction::PartiallyUseAssetLockAction(action) => { action.user_fee_increase() } - StateTransitionAction::MasternodeVoteAction(action) => { + StateTransitionAction::MasternodeVoteAction(_) => { UserFeeIncrease::default() // 0 (or none) } } diff --git a/packages/rs-platform-version/src/version/dpp_versions.rs b/packages/rs-platform-version/src/version/dpp_versions.rs index 53e707e070..0452b1fd76 100644 --- a/packages/rs-platform-version/src/version/dpp_versions.rs +++ b/packages/rs-platform-version/src/version/dpp_versions.rs @@ -64,6 +64,7 @@ pub struct DPPValidationVersions { pub json_schema_validator: JsonSchemaValidatorVersions, pub data_contract: DataContractValidationVersions, pub document_type: DocumentTypeValidationVersions, + pub voting: VotingValidationVersions, } #[derive(Clone, Debug, Default)] @@ -76,6 +77,12 @@ pub struct DataContractValidationVersions { pub validate_property_definition: FeatureVersion, } +#[derive(Clone, Debug, Default)] +pub struct VotingValidationVersions { + /// How long do we allow other contenders to join a contest after the first contender + pub allow_other_contenders_time_ms: u64, +} + #[derive(Clone, Debug, Default)] pub struct DocumentTypeValidationVersions { pub validate_update: FeatureVersion, @@ -228,7 +235,7 @@ pub struct IdentityVersions { #[derive(Clone, Debug, Default)] pub struct VotingVersions { pub default_vote_poll_time_duration_ms: u64, - pub finalized_contested_document_vote_poll_stored_info_version: FeatureVersion, + pub contested_document_vote_poll_stored_info_version: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 0e4389a5f8..303021435c 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -270,7 +270,13 @@ pub struct DriveVoteMethodVersions { pub cleanup: DriveVoteCleanupMethodVersions, pub setup: DriveVoteSetupMethodVersions, pub storage_form: DriveVoteStorageFormMethodVersions, + pub fetch: DriveVoteFetchMethodVersions, +} + +#[derive(Clone, Debug, Default)] +pub struct DriveVoteFetchMethodVersions { pub fetch_identities_voting_for_contenders: FeatureVersion, + pub fetch_contested_document_vote_poll_stored_info: FeatureVersion, } #[derive(Clone, Debug, Default)] @@ -302,7 +308,7 @@ pub struct DriveVoteInsertMethodVersions { #[derive(Clone, Debug, Default)] pub struct DriveVoteContestedResourceInsertMethodVersions { pub register_contested_resource_identity_vote: FeatureVersion, - pub insert_record_of_finished_vote_poll: FeatureVersion, + pub insert_stored_info_for_contested_resource_vote_poll: FeatureVersion, pub register_identity_vote: FeatureVersion, pub add_vote_poll_end_date_query_operations: FeatureVersion, } diff --git a/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/mod.rs b/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/mod.rs index 37009a7acc..280202ef35 100644 --- a/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/mod.rs +++ b/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/mod.rs @@ -3,6 +3,8 @@ pub mod v1; pub struct VoteResolutionFundFees { /// This is the amount that will be deducted from an identity and used to pay for voting pub contested_document_vote_resolution_fund_required_amount: u64, + /// This is the amount that will be deducted from an identity and used to pay for voting if we are currently locked + pub contested_document_vote_resolution_unlock_fund_required_amount: u64, /// This is the amount that a single vote will cost pub contested_document_single_vote_cost: u64, } diff --git a/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs b/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs index afb8230a89..4275b122c5 100644 --- a/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs +++ b/packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs @@ -2,5 +2,6 @@ use crate::version::fee::vote_resolution_fund_fees::VoteResolutionFundFees; pub const VOTE_RESOLUTION_FUND_FEES_VERSION1: VoteResolutionFundFees = VoteResolutionFundFees { contested_document_vote_resolution_fund_required_amount: 20000000000, // 0.2 Dash + contested_document_vote_resolution_unlock_fund_required_amount: 400000000000, // 4 Dash contested_document_single_vote_cost: 10000000, // 0.0001 Dash }; diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 986ce979e0..61da6e7962 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -10,7 +10,7 @@ use crate::version::dpp_versions::{ IdentityVersions, JsonSchemaValidatorVersions, PublicKeyInCreationMethodVersions, RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, - VotingVersions, + VotingValidationVersions, VotingVersions, }; use crate::version::drive_abci_versions::{ DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, @@ -70,8 +70,9 @@ use crate::version::drive_versions::{ DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVerifyVoteMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, - DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, - DriveVoteMethodVersions, DriveVoteSetupMethodVersions, DriveVoteStorageFormMethodVersions, + DriveVoteContestedResourceInsertMethodVersions, DriveVoteFetchMethodVersions, + DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions, + DriveVoteStorageFormMethodVersions, }; use crate::version::fee::v1::FEE_VERSION1; use crate::version::mocks::TEST_PROTOCOL_VERSION_SHIFT_BYTES; @@ -231,7 +232,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { }, contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { register_contested_resource_identity_vote: 0, - insert_record_of_finished_vote_poll: 0, + insert_stored_info_for_contested_resource_vote_poll: 0, register_identity_vote: 0, add_vote_poll_end_date_query_operations: 0, }, @@ -250,7 +251,10 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { storage_form: DriveVoteStorageFormMethodVersions { resolve_with_contract: 0, }, - fetch_identities_voting_for_contenders: 0, + fetch: DriveVoteFetchMethodVersions { + fetch_identities_voting_for_contenders: 0, + fetch_contested_document_vote_poll_stored_info: 0, + }, }, contract: DriveContractMethodVersions { prove: DriveContractProveMethodVersions { @@ -961,6 +965,9 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { validate_property_definition: 0, }, document_type: DocumentTypeValidationVersions { validate_update: 0 }, + voting: VotingValidationVersions { + allow_other_contenders_time_ms: 604_800_000, // 1 week in ms + }, }, state_transition_serialization_versions: StateTransitionSerializationVersions { identity_public_key_in_creation: FeatureVersionBounds { @@ -1184,7 +1191,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { }, voting_versions: VotingVersions { default_vote_poll_time_duration_ms: 1_209_600_000, //2 weeks - finalized_contested_document_vote_poll_stored_info_version: 0, + contested_document_vote_poll_stored_info_version: 0, }, asset_lock_versions: AssetLockVersions { reduced_asset_lock_value: FeatureVersionBounds { diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 22857b4029..59257dc119 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -10,7 +10,7 @@ use crate::version::dpp_versions::{ IdentityVersions, JsonSchemaValidatorVersions, PublicKeyInCreationMethodVersions, RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, - VotingVersions, + VotingValidationVersions, VotingVersions, }; use crate::version::drive_abci_versions::{ DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, @@ -70,8 +70,9 @@ use crate::version::drive_versions::{ DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVerifyVoteMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, - DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, - DriveVoteMethodVersions, DriveVoteSetupMethodVersions, DriveVoteStorageFormMethodVersions, + DriveVoteContestedResourceInsertMethodVersions, DriveVoteFetchMethodVersions, + DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions, + DriveVoteStorageFormMethodVersions, }; use crate::version::fee::v1::FEE_VERSION1; use crate::version::mocks::TEST_PROTOCOL_VERSION_SHIFT_BYTES; @@ -239,7 +240,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { }, contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { register_contested_resource_identity_vote: 0, - insert_record_of_finished_vote_poll: 0, + insert_stored_info_for_contested_resource_vote_poll: 0, register_identity_vote: 0, add_vote_poll_end_date_query_operations: 0, }, @@ -258,7 +259,10 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { storage_form: DriveVoteStorageFormMethodVersions { resolve_with_contract: 0, }, - fetch_identities_voting_for_contenders: 0, + fetch: DriveVoteFetchMethodVersions { + fetch_identities_voting_for_contenders: 0, + fetch_contested_document_vote_poll_stored_info: 0, + }, }, contract: DriveContractMethodVersions { prove: DriveContractProveMethodVersions { @@ -961,6 +965,9 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { validate_property_definition: 0, }, document_type: DocumentTypeValidationVersions { validate_update: 0 }, + voting: VotingValidationVersions { + allow_other_contenders_time_ms: 604_800_000, // 1 week in ms + }, }, state_transition_serialization_versions: StateTransitionSerializationVersions { identity_public_key_in_creation: FeatureVersionBounds { @@ -1184,7 +1191,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { }, voting_versions: VotingVersions { default_vote_poll_time_duration_ms: 1_209_600_000, //2 weeks - finalized_contested_document_vote_poll_stored_info_version: 0, + contested_document_vote_poll_stored_info_version: 0, }, asset_lock_versions: AssetLockVersions { reduced_asset_lock_value: FeatureVersionBounds { diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index c82d399d94..f707a76425 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -10,7 +10,7 @@ use crate::version::dpp_versions::{ IdentityVersions, JsonSchemaValidatorVersions, PublicKeyInCreationMethodVersions, RecursiveSchemaValidatorVersions, StateTransitionConversionVersions, StateTransitionMethodVersions, StateTransitionSerializationVersions, StateTransitionVersions, - VotingVersions, + VotingValidationVersions, VotingVersions, }; use crate::version::drive_abci_versions::{ DriveAbciAssetLockValidationVersions, DriveAbciBlockEndMethodVersions, @@ -70,8 +70,9 @@ use crate::version::drive_versions::{ DriveVerifyMethodVersions, DriveVerifySingleDocumentMethodVersions, DriveVerifyStateTransitionMethodVersions, DriveVerifySystemMethodVersions, DriveVerifyVoteMethodVersions, DriveVersion, DriveVoteCleanupMethodVersions, - DriveVoteContestedResourceInsertMethodVersions, DriveVoteInsertMethodVersions, - DriveVoteMethodVersions, DriveVoteSetupMethodVersions, DriveVoteStorageFormMethodVersions, + DriveVoteContestedResourceInsertMethodVersions, DriveVoteFetchMethodVersions, + DriveVoteInsertMethodVersions, DriveVoteMethodVersions, DriveVoteSetupMethodVersions, + DriveVoteStorageFormMethodVersions, }; use crate::version::fee::v1::FEE_VERSION1; use crate::version::protocol_version::{FeatureVersionBounds, PlatformVersion}; @@ -230,7 +231,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { }, contested_resource_insert: DriveVoteContestedResourceInsertMethodVersions { register_contested_resource_identity_vote: 0, - insert_record_of_finished_vote_poll: 0, + insert_stored_info_for_contested_resource_vote_poll: 0, register_identity_vote: 0, add_vote_poll_end_date_query_operations: 0, }, @@ -249,7 +250,10 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { storage_form: DriveVoteStorageFormMethodVersions { resolve_with_contract: 0, }, - fetch_identities_voting_for_contenders: 0, + fetch: DriveVoteFetchMethodVersions { + fetch_identities_voting_for_contenders: 0, + fetch_contested_document_vote_poll_stored_info: 0, + }, }, contract: DriveContractMethodVersions { prove: DriveContractProveMethodVersions { @@ -960,6 +964,9 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { validate_property_definition: 0, }, document_type: DocumentTypeValidationVersions { validate_update: 0 }, + voting: VotingValidationVersions { + allow_other_contenders_time_ms: 604_800_000, // 1 week in ms + }, }, state_transition_serialization_versions: StateTransitionSerializationVersions { identity_public_key_in_creation: FeatureVersionBounds { @@ -1183,7 +1190,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { }, voting_versions: VotingVersions { default_vote_poll_time_duration_ms: 1_209_600_000, //2 weeks - finalized_contested_document_vote_poll_stored_info_version: 0, + contested_document_vote_poll_stored_info_version: 0, }, asset_lock_versions: AssetLockVersions { reduced_asset_lock_value: FeatureVersionBounds { From df9f373aae7bd415aebf7468612d18986e2c1385 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 9 Jun 2024 17:06:57 +0300 Subject: [PATCH 126/135] more work --- .../state_v0/mod.rs | 28 ++--- .../data_triggers/triggers/dashpay/v0/mod.rs | 12 +- .../data_triggers/triggers/dpns/v0/mod.rs | 6 +- .../documents_batch/transformer/v0/mod.rs | 28 ++++- .../drive/batch/drive_op_batch/document.rs | 5 + .../document/document_create_transition.rs | 3 + .../add_contested_document/mod.rs | 4 +- .../add_contested_document/v0/mod.rs | 8 +- .../mod.rs | 3 + .../v0/mod.rs | 3 + .../mod.rs | 3 + .../v0/mod.rs | 4 + .../mod.rs | 3 + .../v0/mod.rs | 12 ++ .../v0/mod.rs | 2 +- .../document_create_transition_action/mod.rs | 25 ++++ .../transformer.rs | 24 +++- .../v0/mod.rs | 17 +++ .../v0/transformer.rs | 108 +++++++++++++++--- 19 files changed, 235 insertions(+), 63 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_create_transition_action/state_v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_create_transition_action/state_v0/mod.rs index 3c2ee12a91..2f5b186b77 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_create_transition_action/state_v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/action_validation/document_create_transition_action/state_v0/mod.rs @@ -16,8 +16,7 @@ use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::{C use drive::error::drive::DriveError; use drive::query::TransactionArg; use crate::error::Error; -use crate::execution::types::execution_operation::ValidationOperation; -use crate::execution::types::state_transition_execution_context::{StateTransitionExecutionContext, StateTransitionExecutionContextMethodsV0}; +use crate::execution::types::state_transition_execution_context::{StateTransitionExecutionContext}; use crate::execution::validation::state_transition::documents_batch::state::v0::fetch_documents::fetch_document_with_id; use crate::platform_types::platform::PlatformStateRef; @@ -38,7 +37,7 @@ impl DocumentCreateTransitionActionStateValidationV0 for DocumentCreateTransitio platform: &PlatformStateRef, owner_id: Identifier, block_info: &BlockInfo, - execution_context: &mut StateTransitionExecutionContext, + _execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { @@ -98,18 +97,7 @@ impl DocumentCreateTransitionActionStateValidationV0 for DocumentCreateTransitio if let Some((contested_document_resource_vote_poll, credits)) = self.prefunded_voting_balance() { - let (fee_result, maybe_stored_info) = platform - .drive - .fetch_contested_document_vote_poll_stored_info( - contested_document_resource_vote_poll, - &block_info.epoch, - transaction, - platform_version, - )?; - execution_context - .add_operation(ValidationOperation::PrecalculatedOperation(fee_result)); - - if let Some(stored_info) = maybe_stored_info { + if let Some(stored_info) = self.current_store_contest_info() { // We have previous stored info match stored_info.vote_poll_status() { ContestedDocumentVotePollStatus::NotStarted => { @@ -128,10 +116,10 @@ impl DocumentCreateTransitionActionStateValidationV0 for DocumentCreateTransitio Ok(SimpleConsensusValidationResult::new_with_error( ConsensusError::StateError(StateError::DocumentContestCurrentlyLockedError( DocumentContestCurrentlyLockedError::new( - contested_document_resource_vote_poll.into(), - stored_info, - platform_version.fee_version.vote_resolution_fund_fees.contested_document_vote_resolution_unlock_fund_required_amount, - ))), + contested_document_resource_vote_poll.into(), + stored_info.clone(), + platform_version.fee_version.vote_resolution_fund_fees.contested_document_vote_resolution_unlock_fund_required_amount, + ))), )) } ContestedDocumentVotePollStatus::Started(start_block) => { @@ -143,7 +131,7 @@ impl DocumentCreateTransitionActionStateValidationV0 for DocumentCreateTransitio Ok(SimpleConsensusValidationResult::new_with_error(ConsensusError::StateError(StateError::DocumentContestNotJoinableError( DocumentContestNotJoinableError::new( contested_document_resource_vote_poll.into(), - stored_info, + stored_info.clone(), start_block.time_ms, block_info.time_ms, join_time_allowed, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/data_triggers/triggers/dashpay/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/data_triggers/triggers/dashpay/v0/mod.rs index 3a70730e38..a8126e6269 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/data_triggers/triggers/dashpay/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/data_triggers/triggers/dashpay/v0/mod.rs @@ -224,9 +224,9 @@ mod test { }; let result = create_contact_request_data_trigger( - &DocumentCreateTransitionAction::from_document_borrowed_create_transition_with_contract_lookup(document_create_transition, &BlockInfo::default(), |_identifier| { + &DocumentCreateTransitionAction::from_document_borrowed_create_transition_with_contract_lookup(&platform.drive, None, document_create_transition, &BlockInfo::default(), |_identifier| { Ok(Arc::new(DataContractFetchInfo::dashpay_contract_fixture(protocol_version))) - }).expect("expected to create action").into(), + }, platform_version).expect("expected to create action").0.into(), &data_trigger_context, platform_version, ) @@ -335,9 +335,9 @@ mod test { let _dashpay_identity_id = data_trigger_context.owner_id.to_owned(); let result = create_contact_request_data_trigger( - &DocumentCreateTransitionAction::from_document_borrowed_create_transition_with_contract_lookup(document_create_transition, &BlockInfo::default(), |_identifier| { + &DocumentCreateTransitionAction::from_document_borrowed_create_transition_with_contract_lookup(&platform.drive, None, document_create_transition, &BlockInfo::default(), |_identifier| { Ok(Arc::new(DataContractFetchInfo::dashpay_contract_fixture(protocol_version))) - }).expect("expected to create action").into(), + }, platform_version).expect("expected to create action").0.into(), &data_trigger_context, platform_version, ) @@ -441,9 +441,9 @@ mod test { let _dashpay_identity_id = data_trigger_context.owner_id.to_owned(); let result = create_contact_request_data_trigger( - &DocumentCreateTransitionAction::from_document_borrowed_create_transition_with_contract_lookup(document_create_transition, &BlockInfo::default(), |_identifier| { + &DocumentCreateTransitionAction::from_document_borrowed_create_transition_with_contract_lookup(&platform.drive, None, document_create_transition, &BlockInfo::default(), |_identifier| { Ok(Arc::new(DataContractFetchInfo::dashpay_contract_fixture(protocol_version))) - }).expect("expected to create action").into(), + }, platform_version).expect("expected to create action").0.into(), &data_trigger_context, platform_version, ) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/data_triggers/triggers/dpns/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/data_triggers/triggers/dpns/v0/mod.rs index eb46dd4e7a..c72a30237b 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/data_triggers/triggers/dpns/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/data_triggers/triggers/dpns/v0/mod.rs @@ -501,10 +501,10 @@ mod test { }; let result = create_domain_data_trigger_v0( - &DocumentCreateTransitionAction::from_document_borrowed_create_transition_with_contract_lookup( - document_create_transition, &BlockInfo::default(), |_identifier| { + &DocumentCreateTransitionAction::from_document_borrowed_create_transition_with_contract_lookup(&platform.drive, None, + document_create_transition, &BlockInfo::default(), |_identifier| { Ok(Arc::new(DataContractFetchInfo::dpns_contract_fixture(platform_version.protocol_version))) - }).expect("expected to create action").into(), + }, platform_version).expect("expected to create action").0.into(), &data_trigger_context, platform_version, ) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/transformer/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/transformer/v0/mod.rs index a191567e56..4113953476 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/transformer/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/transformer/v0/mod.rs @@ -46,11 +46,13 @@ use dpp::state_transition::documents_batch_transition::document_transition::docu use dpp::state_transition::documents_batch_transition::document_transition::document_transfer_transition::v0::v0_methods::DocumentTransferTransitionV0Methods; use dpp::state_transition::documents_batch_transition::document_transition::document_update_price_transition::v0::v0_methods::DocumentUpdatePriceTransitionV0Methods; use drive::drive::contract::DataContractFetchInfo; +use drive::drive::Drive; use drive::state_transition_action::document::documents_batch::document_transition::document_purchase_transition_action::DocumentPurchaseTransitionAction; use drive::state_transition_action::document::documents_batch::document_transition::document_transfer_transition_action::DocumentTransferTransitionAction; use drive::state_transition_action::document::documents_batch::document_transition::document_update_price_transition_action::DocumentUpdatePriceTransitionAction; use drive::state_transition_action::system::bump_identity_data_contract_nonce_action::BumpIdentityDataContractNonceAction; -use crate::execution::types::state_transition_execution_context::StateTransitionExecutionContext; +use crate::execution::types::execution_operation::ValidationOperation; +use crate::execution::types::state_transition_execution_context::{StateTransitionExecutionContext, StateTransitionExecutionContextMethodsV0}; pub(in crate::execution::validation::state_transition::state_transitions::documents_batch) trait DocumentsBatchTransitionTransformerV0 { @@ -84,18 +86,22 @@ trait DocumentsBatchTransitionInternalTransformerV0 { document_type_name: &str, owner_id: Identifier, document_transitions: &[&DocumentTransition], - _execution_context: &mut StateTransitionExecutionContext, + execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result>, Error>; /// The data contract can be of multiple difference versions fn transform_transition_v0( + drive: &Drive, + transaction: TransactionArg, full_validation: bool, block_info: &BlockInfo, data_contract_fetch_info: Arc, transition: &DocumentTransition, replaced_documents: &[Document], owner_id: Identifier, + execution_context: &mut StateTransitionExecutionContext, + platform_version: &PlatformVersion, ) -> Result, Error>; fn find_replaced_document_v0<'a>( document_transition: &'a DocumentTransition, @@ -254,7 +260,7 @@ impl DocumentsBatchTransitionInternalTransformerV0 for DocumentsBatchTransition document_type_name: &str, owner_id: Identifier, document_transitions: &[&DocumentTransition], - _execution_context: &mut StateTransitionExecutionContext, + execution_context: &mut StateTransitionExecutionContext, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result>, Error> { @@ -320,12 +326,16 @@ impl DocumentsBatchTransitionInternalTransformerV0 for DocumentsBatchTransition .map(|transition| { // we validate every transition in this document type Self::transform_transition_v0( + &platform.drive, + transaction, validate_against_state, block_info, data_contract_fetch_info.clone(), transition, &replaced_documents, owner_id, + execution_context, + platform_version, ) }) .collect::>, Error>>( @@ -346,21 +356,29 @@ impl DocumentsBatchTransitionInternalTransformerV0 for DocumentsBatchTransition /// The data contract can be of multiple difference versions fn transform_transition_v0<'a>( + drive: &Drive, + transaction: TransactionArg, validate_against_state: bool, block_info: &BlockInfo, data_contract_fetch_info: Arc, transition: &DocumentTransition, replaced_documents: &[Document], owner_id: Identifier, + execution_context: &mut StateTransitionExecutionContext, + platform_version: &PlatformVersion, ) -> Result, Error> { match transition { DocumentTransition::Create(document_create_transition) => { let result = ConsensusValidationResult::::new(); - let document_create_action = DocumentCreateTransitionAction::from_document_borrowed_create_transition_with_contract_lookup( + let (document_create_action, fee_result) = DocumentCreateTransitionAction::from_document_borrowed_create_transition_with_contract_lookup( + drive, transaction, document_create_transition, block_info, |_identifier| { Ok(data_contract_fetch_info.clone()) - })?; + }, platform_version)?; + + execution_context + .add_operation(ValidationOperation::PrecalculatedOperation(fee_result)); if result.is_valid() { Ok(DocumentTransitionAction::CreateAction(document_create_action).into()) diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/document.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/document.rs index 695cb76e25..d000dca686 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/document.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/document.rs @@ -18,6 +18,7 @@ use dpp::system_data_contracts::withdrawals_contract::v1::document_types::withdr use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use dpp::version::PlatformVersion; +use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStoredInfo; use dpp::ProtocolError; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; @@ -77,6 +78,8 @@ pub enum DocumentOperationType<'a> { document_type_info: DocumentTypeInfo<'a>, /// Should we insert without verifying first that the document doesn't already exist insert_without_check: bool, + /// Should we also insert the vote poll stored info + also_insert_vote_poll_stored_info: Option, }, /// Updates a document and returns the associated fee. UpdateDocument { @@ -160,6 +163,7 @@ impl DriveLowLevelOperationConverter for DocumentOperationType<'_> { contract_info, document_type_info, insert_without_check, + also_insert_vote_poll_stored_info, } => { let mut drive_operations: Vec = vec![]; let contract_resolved_info = contract_info.resolve( @@ -182,6 +186,7 @@ impl DriveLowLevelOperationConverter for DocumentOperationType<'_> { contested_document_resource_vote_poll, insert_without_check, block_info, + also_insert_vote_poll_stored_info, &mut None, estimated_costs_only_with_layer_info, transaction, diff --git a/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs b/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs index f0a86b2cfd..cfdb190263 100644 --- a/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs +++ b/packages/rs-drive/src/drive/batch/transitions/document/document_create_transition.rs @@ -35,6 +35,8 @@ impl DriveHighLevelDocumentOperationConverter for DocumentCreateTransitionAction let maybe_prefunded_voting_balance = self.take_prefunded_voting_balance(); + let also_insert_vote_poll_stored_info = self.take_should_store_contest_info(); + let document = Document::try_from_owned_create_transition_action(self, owner_id, platform_version)?; @@ -78,6 +80,7 @@ impl DriveHighLevelDocumentOperationConverter for DocumentCreateTransitionAction contract_info: DataContractFetchInfo(contract_fetch_info), document_type_info: DocumentTypeInfo::DocumentTypeName(document_type_name), insert_without_check: false, //todo: consider setting to true + also_insert_vote_poll_stored_info, }, )); } else { diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs index 7322d5ce85..52e21782b4 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/mod.rs @@ -35,7 +35,7 @@ impl Drive { owned_document_info: OwnedDocumentInfo, contested_document_resource_vote_poll: ContestedDocumentResourceVotePollWithContractInfo, insert_without_check: bool, - also_insert_vote_poll_stored_start_info: Option, + also_insert_vote_poll_stored_info: Option, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, @@ -52,7 +52,7 @@ impl Drive { owned_document_info, contested_document_resource_vote_poll, insert_without_check, - also_insert_vote_poll_stored_start_info, + also_insert_vote_poll_stored_info, block_info, apply, transaction, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/v0/mod.rs index 18fcb3ee9a..c1ed51f720 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document/v0/mod.rs @@ -56,13 +56,6 @@ impl Drive { document_type, }; let mut drive_operations: Vec = vec![]; - if let Some(vote_poll_stored_start_info) = also_insert_vote_poll_stored_info { - self.insert_stored_info_for_contested_resource_vote_poll_operations( - &contested_document_resource_vote_poll, - vote_poll_stored_start_info, - platform_version, - )?; - } self.add_contested_document_for_contract_apply_and_add_to_operations( document_and_contract_info, contested_document_resource_vote_poll, @@ -70,6 +63,7 @@ impl Drive { block_info, true, apply, + also_insert_vote_poll_stored_info, transaction, &mut drive_operations, platform_version, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/mod.rs index 3e1f8095ba..218524609f 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/mod.rs @@ -11,6 +11,7 @@ use dpp::fee::fee_result::FeeResult; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use dpp::version::PlatformVersion; +use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStoredInfo; use grovedb::TransactionArg; impl Drive { @@ -34,6 +35,7 @@ impl Drive { insert_without_check: bool, block_info: BlockInfo, apply: bool, + also_insert_vote_poll_stored_info: Option, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { @@ -50,6 +52,7 @@ impl Drive { insert_without_check, block_info, apply, + also_insert_vote_poll_stored_info, transaction, platform_version, ), diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/v0/mod.rs index 785bb7a51c..2de89935b6 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/v0/mod.rs @@ -8,6 +8,7 @@ use dpp::fee::fee_result::FeeResult; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use dpp::version::PlatformVersion; +use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStoredInfo; use grovedb::TransactionArg; impl Drive { @@ -20,6 +21,7 @@ impl Drive { insert_without_check: bool, block_info: BlockInfo, apply: bool, + also_insert_vote_poll_stored_info: Option, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { @@ -31,6 +33,7 @@ impl Drive { &block_info, true, apply, + also_insert_vote_poll_stored_info, transaction, &mut drive_operations, platform_version, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs index 5dd1d3d81b..38b15771b5 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/mod.rs @@ -10,6 +10,7 @@ use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStoredInfo; use grovedb::TransactionArg; impl Drive { @@ -37,6 +38,7 @@ impl Drive { block_info: &BlockInfo, document_is_unique_for_document_type_in_batch: bool, stateful: bool, + also_insert_vote_poll_stored_info: Option, transaction: TransactionArg, drive_operations: &mut Vec, platform_version: &PlatformVersion, @@ -55,6 +57,7 @@ impl Drive { block_info, document_is_unique_for_document_type_in_batch, stateful, + also_insert_vote_poll_stored_info, transaction, drive_operations, platform_version, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/v0/mod.rs index 7524419c6b..9b0b84c418 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_apply_and_add_to_operations/v0/mod.rs @@ -6,6 +6,7 @@ use dpp::block::block_info::BlockInfo; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use dpp::version::PlatformVersion; +use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStoredInfo; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; @@ -21,6 +22,7 @@ impl Drive { block_info: &BlockInfo, document_is_unique_for_document_type_in_batch: bool, stateful: bool, + also_insert_vote_poll_stored_info: Option, transaction: TransactionArg, drive_operations: &mut Vec, platform_version: &PlatformVersion, @@ -36,6 +38,7 @@ impl Drive { contested_document_resource_vote_poll, insert_without_check, block_info, + also_insert_vote_poll_stored_info, &mut None, &mut estimated_costs_only_with_layer_info, transaction, @@ -54,6 +57,7 @@ impl Drive { contested_document_resource_vote_poll, insert_without_check, block_info, + also_insert_vote_poll_stored_info, &mut Some(drive_operations), &mut estimated_costs_only_with_layer_info, transaction, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/mod.rs index 67f534a710..2830df1a2c 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/mod.rs @@ -9,6 +9,7 @@ use dpp::block::block_info::BlockInfo; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use dpp::version::PlatformVersion; +use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStoredInfo; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; @@ -21,6 +22,7 @@ impl Drive { contested_document_resource_vote_poll: ContestedDocumentResourceVotePollWithContractInfo, insert_without_check: bool, block_info: &BlockInfo, + also_insert_vote_poll_stored_info: Option, previous_batch_operations: &mut Option<&mut Vec>, estimated_costs_only_with_layer_info: &mut Option< HashMap, @@ -40,6 +42,7 @@ impl Drive { contested_document_resource_vote_poll, insert_without_check, block_info, + also_insert_vote_poll_stored_info, previous_batch_operations, estimated_costs_only_with_layer_info, transaction, diff --git a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs index c56976b7d9..c26caa1062 100644 --- a/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs +++ b/packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract_operations/v0/mod.rs @@ -5,6 +5,7 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; +use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStoredInfo; use dpp::voting::vote_polls::VotePoll; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; @@ -19,6 +20,7 @@ impl Drive { contested_document_resource_vote_poll: ContestedDocumentResourceVotePollWithContractInfo, insert_without_check: bool, block_info: &BlockInfo, + also_insert_vote_poll_stored_info: Option, previous_batch_operations: &mut Option<&mut Vec>, estimated_costs_only_with_layer_info: &mut Option< HashMap, @@ -65,6 +67,16 @@ impl Drive { )?; if !contest_already_existed { + if let Some(vote_poll_stored_start_info) = also_insert_vote_poll_stored_info { + let mut operations = self + .insert_stored_info_for_contested_resource_vote_poll_operations( + &contested_document_resource_vote_poll, + vote_poll_stored_start_info, + platform_version, + )?; + batch_operations.append(&mut operations); + } + self.add_vote_poll_end_date_query_operations( document_and_contract_info.owned_document_info.owner_id, VotePoll::ContestedDocumentResourceVotePoll( diff --git a/packages/rs-drive/src/drive/votes/fetch/fetch_contested_document_vote_poll_stored_info/v0/mod.rs b/packages/rs-drive/src/drive/votes/fetch/fetch_contested_document_vote_poll_stored_info/v0/mod.rs index a84ea8e1d6..0746bd39aa 100644 --- a/packages/rs-drive/src/drive/votes/fetch/fetch_contested_document_vote_poll_stored_info/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/fetch/fetch_contested_document_vote_poll_stored_info/v0/mod.rs @@ -22,7 +22,7 @@ impl Drive { let path = contested_document_resource_vote_poll_with_contract_info .contenders_path(platform_version)?; let mut cost_operations = vec![]; - let maybe_element = self.grove_get_raw( + let maybe_element = self.grove_get_raw_optional( path.as_slice().into(), vec![RESOURCE_STORED_INFO_KEY_U8].as_slice(), DirectQueryType::StatefulDirectQuery, diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs index 26f2fa2b7d..352444f830 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/mod.rs @@ -16,6 +16,7 @@ use dpp::ProtocolError; pub use v0::*; use crate::state_transition_action::document::documents_batch::document_transition::document_base_transition_action::{DocumentBaseTransitionAction}; use dpp::version::PlatformVersion; +use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStoredInfo; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; /// document create transition action @@ -77,6 +78,30 @@ impl DocumentCreateTransitionActionAccessorsV0 for DocumentCreateTransitionActio DocumentCreateTransitionAction::V0(v0) => &v0.prefunded_voting_balance, } } + + fn should_store_contest_info(&self) -> &Option { + match self { + DocumentCreateTransitionAction::V0(v0) => &v0.should_store_contest_info, + } + } + + fn take_should_store_contest_info(&mut self) -> Option { + match self { + DocumentCreateTransitionAction::V0(v0) => v0.should_store_contest_info.take(), + } + } + + fn current_store_contest_info(&self) -> &Option { + match self { + DocumentCreateTransitionAction::V0(v0) => &v0.current_store_contest_info, + } + } + + fn take_current_store_contest_info(&mut self) -> Option { + match self { + DocumentCreateTransitionAction::V0(v0) => v0.current_store_contest_info.take(), + } + } } /// document from create transition diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/transformer.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/transformer.rs index 8ab406d5a7..50d8b830af 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/transformer.rs @@ -1,33 +1,49 @@ use dpp::block::block_info::BlockInfo; +use dpp::fee::fee_result::FeeResult; use dpp::platform_value::Identifier; +use grovedb::TransactionArg; use std::sync::Arc; use dpp::ProtocolError; use dpp::state_transition::documents_batch_transition::document_create_transition::DocumentCreateTransition; +use platform_version::version::PlatformVersion; use crate::drive::contract::DataContractFetchInfo; +use crate::drive::Drive; use crate::error::Error; use crate::state_transition_action::document::documents_batch::document_transition::document_create_transition_action::{DocumentCreateTransitionAction, DocumentCreateTransitionActionV0}; impl DocumentCreateTransitionAction { /// from_document_create_transition_with_contract_lookup pub fn from_document_create_transition_with_contract_lookup( + drive: &Drive, + transaction: TransactionArg, value: DocumentCreateTransition, block_info: &BlockInfo, get_data_contract: impl Fn(Identifier) -> Result, ProtocolError>, - ) -> Result { + platform_version: &PlatformVersion, + ) -> Result<(Self, FeeResult), Error> { match value { - DocumentCreateTransition::V0(v0) => Ok(DocumentCreateTransitionActionV0::try_from_document_create_transition_with_contract_lookup(v0, block_info, get_data_contract)?.into()), + DocumentCreateTransition::V0(v0) => { + let (v0, fee) = DocumentCreateTransitionActionV0::try_from_document_create_transition_with_contract_lookup(drive, transaction, v0, block_info, get_data_contract, platform_version)?; + Ok((v0.into(), fee)) + } } } /// from_document_borrowed_create_transition_with_contract_lookup pub fn from_document_borrowed_create_transition_with_contract_lookup( + drive: &Drive, + transaction: TransactionArg, value: &DocumentCreateTransition, block_info: &BlockInfo, get_data_contract: impl Fn(Identifier) -> Result, ProtocolError>, - ) -> Result { + platform_version: &PlatformVersion, + ) -> Result<(Self, FeeResult), Error> { match value { - DocumentCreateTransition::V0(v0) => Ok(DocumentCreateTransitionActionV0::try_from_borrowed_document_create_transition_with_contract_lookup(v0, block_info, get_data_contract)?.into()), + DocumentCreateTransition::V0(v0) => { + let (v0, fee) = DocumentCreateTransitionActionV0::try_from_borrowed_document_create_transition_with_contract_lookup(drive, transaction, v0, block_info, get_data_contract, platform_version)?; + Ok((v0.into(), fee)) + } } } } diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs index 900b0a2286..10ffaaebb9 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/mod.rs @@ -22,6 +22,7 @@ use crate::state_transition_action::document::documents_batch::document_transiti use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use dpp::version::PlatformVersion; +use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStoredInfo; /// document create transition action v0 #[derive(Debug, Clone)] @@ -36,6 +37,10 @@ pub struct DocumentCreateTransitionActionV0 { /// aside that will be used by voters to vote) pub prefunded_voting_balance: Option<(ContestedDocumentResourceVotePollWithContractInfo, Credits)>, + /// We store contest info only in the case of a new contested document that creates a new contest + pub current_store_contest_info: Option, + /// We store contest info only in the case of a new contested document that creates a new contest + pub should_store_contest_info: Option, } /// document create transition action accessors v0 @@ -63,6 +68,18 @@ pub trait DocumentCreateTransitionActionAccessorsV0 { fn prefunded_voting_balance( &self, ) -> &Option<(ContestedDocumentResourceVotePollWithContractInfo, Credits)>; + + /// Get the should store contest info (if it should be stored) + fn should_store_contest_info(&self) -> &Option; + + /// Take the should store contest info (if it should be stored) and replace it with None. + fn take_should_store_contest_info(&mut self) -> Option; + + /// Get the current store contest info (if it should be stored) + fn current_store_contest_info(&self) -> &Option; + + /// Take the current store contest info (if it should be stored) and replace it with None. + fn take_current_store_contest_info(&mut self) -> Option; } /// documents from create transition v0 diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs index 4fcf638190..2fdaf99c31 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs @@ -1,12 +1,17 @@ use dpp::block::block_info::BlockInfo; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; +use dpp::fee::fee_result::FeeResult; use dpp::platform_value::Identifier; +use grovedb::TransactionArg; use std::sync::Arc; use dpp::ProtocolError; use dpp::state_transition::documents_batch_transition::document_create_transition::v0::DocumentCreateTransitionV0; +use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStoredInfo; use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll; +use platform_version::version::PlatformVersion; use crate::drive::contract::DataContractFetchInfo; +use crate::drive::Drive; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; use crate::error::Error; use crate::state_transition_action::document::documents_batch::document_transition::document_base_transition_action::{DocumentBaseTransitionAction, DocumentBaseTransitionActionAccessorsV0}; @@ -15,10 +20,13 @@ use crate::state_transition_action::document::documents_batch::document_transiti impl DocumentCreateTransitionActionV0 { /// try from document create transition with contract lookup pub fn try_from_document_create_transition_with_contract_lookup( + drive: &Drive, + transaction: TransactionArg, value: DocumentCreateTransitionV0, block_info: &BlockInfo, get_data_contract: impl Fn(Identifier) -> Result, ProtocolError>, - ) -> Result { + platform_version: &PlatformVersion, + ) -> Result<(Self, FeeResult), Error> { let DocumentCreateTransitionV0 { base, data, @@ -61,20 +69,57 @@ impl DocumentCreateTransitionActionV0 { }) .transpose()?; - Ok(DocumentCreateTransitionActionV0 { - base, - block_info: *block_info, - data, - prefunded_voting_balance: prefunded_voting_balances_by_vote_poll, - }) + let mut fee_result = FeeResult::default(); + + let (current_store_contest_info, should_store_contest_info) = + if let Some((contested_document_resource_vote_poll, _)) = + &prefunded_voting_balances_by_vote_poll + { + let (fetch_fee_result, maybe_current_store_contest_info) = drive + .fetch_contested_document_vote_poll_stored_info( + contested_document_resource_vote_poll, + &block_info.epoch, + transaction, + platform_version, + )?; + + fee_result = fetch_fee_result; + let should_store_contest_info = if maybe_current_store_contest_info.is_none() { + // We are starting a new contest + Some(ContestedDocumentVotePollStoredInfo::new( + *block_info, + platform_version, + )?) + } else { + None + }; + (maybe_current_store_contest_info, should_store_contest_info) + } else { + (None, None) + }; + + Ok(( + DocumentCreateTransitionActionV0 { + base, + block_info: *block_info, + data, + prefunded_voting_balance: prefunded_voting_balances_by_vote_poll, + current_store_contest_info, + should_store_contest_info, + }, + fee_result, + )) } /// try from borrowed document create transition with contract lookup pub fn try_from_borrowed_document_create_transition_with_contract_lookup( + drive: &Drive, + transaction: TransactionArg, value: &DocumentCreateTransitionV0, block_info: &BlockInfo, get_data_contract: impl Fn(Identifier) -> Result, ProtocolError>, - ) -> Result { + platform_version: &PlatformVersion, + ) -> Result<(Self, FeeResult), Error> { let DocumentCreateTransitionV0 { base, data, @@ -119,12 +164,45 @@ impl DocumentCreateTransitionActionV0 { }) .transpose()?; - Ok(DocumentCreateTransitionActionV0 { - base, - block_info: *block_info, - //todo: get rid of clone - data: data.clone(), - prefunded_voting_balance: prefunded_voting_balances_by_vote_poll, - }) + let mut fee_result = FeeResult::default(); + + let (current_store_contest_info, should_store_contest_info) = + if let Some((contested_document_resource_vote_poll, _)) = + &prefunded_voting_balances_by_vote_poll + { + let (fetch_fee_result, maybe_current_store_contest_info) = drive + .fetch_contested_document_vote_poll_stored_info( + contested_document_resource_vote_poll, + &block_info.epoch, + transaction, + platform_version, + )?; + + fee_result = fetch_fee_result; + let should_store_contest_info = if maybe_current_store_contest_info.is_none() { + // We are starting a new contest + Some(ContestedDocumentVotePollStoredInfo::new( + *block_info, + platform_version, + )?) + } else { + None + }; + (maybe_current_store_contest_info, should_store_contest_info) + } else { + (None, None) + }; + + Ok(( + DocumentCreateTransitionActionV0 { + base, + block_info: *block_info, + data: data.clone(), + prefunded_voting_balance: prefunded_voting_balances_by_vote_poll, + current_store_contest_info, + should_store_contest_info, + }, + fee_result, + )) } } From a6e107d245a9a2b382f653e3fd2f79925df0eea2 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 9 Jun 2024 19:26:35 +0300 Subject: [PATCH 127/135] things working --- .../protos/platform/v0/platform.proto | 3 +- .../v0/mod.rs | 1 - .../state_transitions/documents_batch/mod.rs | 3 - .../state_transitions/masternode_vote/mod.rs | 12 - .../state_transition/state_transitions/mod.rs | 8 - .../contested_resource_vote_state/v0/mod.rs | 2 - .../v0/mod.rs | 271 +++++----------- .../v0/mod.rs | 4 +- packages/rs-drive/src/drive/votes/paths.rs | 6 +- .../src/query/vote_poll_vote_state_query.rs | 290 ++++++------------ 10 files changed, 182 insertions(+), 418 deletions(-) diff --git a/packages/dapi-grpc/protos/platform/v0/platform.proto b/packages/dapi-grpc/protos/platform/v0/platform.proto index 577eed1e8b..3665ad2f70 100644 --- a/packages/dapi-grpc/protos/platform/v0/platform.proto +++ b/packages/dapi-grpc/protos/platform/v0/platform.proto @@ -747,8 +747,7 @@ message GetContestedResourceVoteStateRequest { bool allow_include_locked_and_abstaining_vote_tally = 6; optional StartAtIdentifierInfo start_at_identifier_info = 7; optional uint32 count = 8; - bool order_ascending = 9; - bool prove = 10; + bool prove = 9; } oneof version { diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/v0/mod.rs index a0d337dcee..f3f2219223 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/tally_votes_for_contested_document_resource_vote_poll/v0/mod.rs @@ -34,7 +34,6 @@ where .maximum_contenders_to_consider, ), start_at: None, - order_ascending: true, allow_include_locked_and_abstaining_vote_tally: true, }; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs index 5fbd6d2f04..255d50993f 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs @@ -649,7 +649,6 @@ mod tests { allow_include_locked_and_abstaining_vote_tally: false, start_at_identifier_info: None, count: None, - order_ascending: true, prove: false, }, )), @@ -733,7 +732,6 @@ mod tests { allow_include_locked_and_abstaining_vote_tally: false, start_at_identifier_info: None, count: None, - order_ascending: true, prove: true, }, )), @@ -772,7 +770,6 @@ mod tests { offset: None, limit: None, start_at: None, - order_ascending: true, allow_include_locked_and_abstaining_vote_tally: true, }; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index e35f8c3bbb..42fbb76c08 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -413,7 +413,6 @@ mod tests { "quantum", None, true, - true, None, ResultType::DocumentsAndVoteTally, platform_version, @@ -484,7 +483,6 @@ mod tests { "quantum", None, true, - true, None, ResultType::DocumentsAndVoteTally, platform_version, @@ -551,7 +549,6 @@ mod tests { "quantum", None, true, - true, None, ResultType::DocumentsAndVoteTally, platform_version, @@ -587,7 +584,6 @@ mod tests { &dpns_contract, "quantum", None, - true, false, None, ResultType::DocumentsAndVoteTally, @@ -655,7 +651,6 @@ mod tests { "quantum", None, true, - true, None, ResultType::DocumentsAndVoteTally, platform_version, @@ -691,7 +686,6 @@ mod tests { &dpns_contract, "quantum", None, - true, false, None, ResultType::DocumentsAndVoteTally, @@ -3420,7 +3414,6 @@ mod tests { "quantum", None, true, - true, None, ResultType::DocumentsAndVoteTally, platform_version, @@ -3496,7 +3489,6 @@ mod tests { "quantum", None, true, - true, None, ResultType::DocumentsAndVoteTally, platform_version, @@ -3547,7 +3539,6 @@ mod tests { "quantum", None, true, - true, None, ResultType::DocumentsAndVoteTally, platform_version, @@ -3625,7 +3616,6 @@ mod tests { "quantum", None, true, - true, None, ResultType::DocumentsAndVoteTally, platform_version, @@ -3700,7 +3690,6 @@ mod tests { "quantum", None, true, - true, None, ResultType::DocumentsAndVoteTally, platform_version, @@ -3751,7 +3740,6 @@ mod tests { "quantum", None, true, - true, None, ResultType::DocumentsAndVoteTally, platform_version, 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 08946fd7f9..fb430c4e71 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 @@ -739,7 +739,6 @@ mod tests { allow_include_locked_and_abstaining_vote_tally: true, start_at_identifier_info: None, count: None, - order_ascending: true, prove: false, }, )), @@ -821,7 +820,6 @@ mod tests { allow_include_locked_and_abstaining_vote_tally: true, start_at_identifier_info: None, count: None, - order_ascending: true, prove: true, }, )), @@ -860,7 +858,6 @@ mod tests { offset: None, limit: None, start_at: None, - order_ascending: true, allow_include_locked_and_abstaining_vote_tally: true, }; @@ -1036,7 +1033,6 @@ mod tests { dpns_contract: &DataContract, name: &str, count: Option, - order_ascending: bool, allow_include_locked_and_abstaining_vote_tally: bool, start_at_identifier_info: Option< get_contested_resource_vote_state_request_v0::StartAtIdentifierInfo, @@ -1081,7 +1077,6 @@ mod tests { allow_include_locked_and_abstaining_vote_tally, start_at_identifier_info, count, - order_ascending, prove: false, }, )), @@ -1137,7 +1132,6 @@ mod tests { dpns_contract: &DataContract, name: &str, count: Option, - order_ascending: bool, allow_include_locked_and_abstaining_vote_tally: bool, start_at_identifier_info: Option< get_contested_resource_vote_state_request_v0::StartAtIdentifierInfo, @@ -1182,7 +1176,6 @@ mod tests { allow_include_locked_and_abstaining_vote_tally, start_at_identifier_info, count, - order_ascending, prove: true, }, )), @@ -1224,7 +1217,6 @@ mod tests { offset: None, limit: count.map(|a| a as u16), start_at: None, - order_ascending, allow_include_locked_and_abstaining_vote_tally, }; diff --git a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs index 8407dfc699..3b80d60343 100644 --- a/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/voting/contested_resource_vote_state/v0/mod.rs @@ -35,7 +35,6 @@ impl Platform { allow_include_locked_and_abstaining_vote_tally, start_at_identifier_info, count, - order_ascending, prove, }: GetContestedResourceVoteStateRequestV0, platform_state: &PlatformState, @@ -147,7 +146,6 @@ impl Platform { )) }) .transpose()?, - order_ascending, allow_include_locked_and_abstaining_vote_tally, }; diff --git a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs index 134f1106fb..6ace93596c 100644 --- a/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs +++ b/packages/rs-drive/src/drive/verify/voting/verify_vote_poll_vote_state_proof/v0/mod.rs @@ -205,43 +205,89 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { let mut abstaining_vote_tally: Option = None; let mut winner = None; - if self.order_ascending { - // Handle ascending order - while let Some((path, _, element)) = elements_iter.next() { - let Some(element) = element else { - continue; - }; - let Some(identity_bytes) = path.last() else { - return Err(Error::Drive(DriveError::CorruptedDriveState( - "the path must have a last element".to_string(), - ))); - }; + // Handle ascending order + while let Some((path, first_key, element)) = elements_iter.next() { + let Some(element) = element else { + continue; + }; + let Some(identity_bytes) = path.last() else { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "the path must have a last element".to_string(), + ))); + }; - match element { - Element::SumTree(_, sum_tree_value, _) => { - if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { - return Err(Error::Drive(DriveError::CorruptedDriveState(format!( + match element { + Element::SumTree(_, sum_tree_value, _) => { + if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!( "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", sum_tree_value )))); - } + } - match identity_bytes.get(0) { - Some(key) if key == &RESOURCE_LOCK_VOTE_TREE_KEY_U8 => { - locked_vote_tally = Some(sum_tree_value as u32); - } - Some(key) if key == &RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8 => { - abstaining_vote_tally = Some(sum_tree_value as u32); - } - _ => { - return Err(Error::Drive(DriveError::CorruptedDriveState( - "unexpected key for sum tree value in verification" - .to_string(), - ))); - } + match identity_bytes.get(0) { + Some(key) if key == &RESOURCE_LOCK_VOTE_TREE_KEY_U8 => { + locked_vote_tally = Some(sum_tree_value as u32); + } + Some(key) if key == &RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8 => { + abstaining_vote_tally = Some(sum_tree_value as u32); + } + _ => { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "unexpected key for sum tree value in verification" + .to_string(), + ))); } } - Element::Item(serialized_item_info, _) => { + } + Element::Item(serialized_item_info, _) => { + if first_key.len() == 1 + && first_key.first() == Some(&RESOURCE_STORED_INFO_KEY_U8) + { + // this is the stored info, let's check to see if the vote is over + let finalized_contested_document_vote_poll_stored_info = + ContestedDocumentVotePollStoredInfo::deserialize_from_bytes( + &serialized_item_info, + )?; + if finalized_contested_document_vote_poll_stored_info + .vote_poll_status() + .awarded_or_locked() + { + locked_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .last_locked_votes() + .ok_or(Error::Drive( + DriveError::CorruptedDriveState( + "we should have last locked votes".to_string(), + ), + ))?, + ); + abstaining_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .last_abstain_votes() + .ok_or(Error::Drive( + DriveError::CorruptedDriveState( + "we should have last abstain votes".to_string(), + ), + ))?, + ); + winner = Some(( + finalized_contested_document_vote_poll_stored_info.winner(), + finalized_contested_document_vote_poll_stored_info + .last_finalization_block() + .ok_or(Error::Drive( + DriveError::CorruptedDriveState( + "we should have a last finalization block" + .to_string(), + ), + ))?, + )); + contenders = finalized_contested_document_vote_poll_stored_info + .contender_votes_in_vec_of_contender_with_serialized_document().ok_or(Error::Drive(DriveError::CorruptedDriveState( + "we should have a last contender votes".to_string(), + )))?; + } + } else { // We should find a sum tree paired with this document if let Some(( path_tally, @@ -250,14 +296,14 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { )) = elements_iter.next() { if path != path_tally { - return Err(Error::Drive(DriveError::CorruptedDriveState("the two results in a chunk when requesting documents and vote tally should both have the same path".to_string()))); + return Err(Error::Drive(DriveError::CorruptedDriveState("the two results in a chunk when requesting documents and vote tally should both have the same path when in item verifying vote vote state proof".to_string()))); } if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { return Err(Error::Drive(DriveError::CorruptedDriveState(format!( - "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", - sum_tree_value - )))); + "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", + sum_tree_value + )))); } let identity_id = Identifier::from_bytes(identity_bytes)?; @@ -268,163 +314,16 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { }; contenders.push(contender); } else { - // The vote is actually over, let's deserialize the info - let finalized_contested_document_vote_poll_stored_info = ContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&serialized_item_info)?; - if finalized_contested_document_vote_poll_stored_info - .vote_poll_status() - .awarded_or_locked() - { - locked_vote_tally = Some( - finalized_contested_document_vote_poll_stored_info - .last_locked_votes() - .ok_or(Error::Drive( - DriveError::CorruptedDriveState( - "we should have last locked votes" - .to_string(), - ), - ))?, - ); - abstaining_vote_tally = Some( - finalized_contested_document_vote_poll_stored_info - .last_abstain_votes() - .ok_or(Error::Drive( - DriveError::CorruptedDriveState( - "we should have last abstain votes" - .to_string(), - ), - ))?, - ); - winner = Some(( - finalized_contested_document_vote_poll_stored_info - .winner(), - finalized_contested_document_vote_poll_stored_info - .last_finalization_block() - .ok_or(Error::Drive( - DriveError::CorruptedDriveState( - "we should have a last finalization block" - .to_string(), - ), - ))?, - )); - contenders = finalized_contested_document_vote_poll_stored_info - .contender_votes_in_vec_of_contender_with_serialized_document().ok_or(Error::Drive(DriveError::CorruptedDriveState( - "we should have a last contender votes".to_string(), - )))?; - } + return Err(Error::Drive(DriveError::CorruptedDriveState( + "we should have a sum item after a normal item".to_string(), + ))); } } - _ => { - return Err(Error::Drive(DriveError::CorruptedDriveState( - "unexpected element type in result".to_string(), - ))); - } } - } - } else { - // Handle descending order - let mut prev_element: Option<(Vec>, i64, Element)> = None; - - while let Some((path, _, element)) = elements_iter.next() { - let Some(element) = element else { - continue; - }; - let Some(identity_bytes) = path.last() else { + _ => { return Err(Error::Drive(DriveError::CorruptedDriveState( - "the path must have a last element".to_string(), + "unexpected element type in result".to_string(), ))); - }; - - match element { - Element::SumTree(_, sum_tree_value, _) => { - if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { - return Err(Error::Drive(DriveError::CorruptedDriveState(format!( - "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", - sum_tree_value - )))); - } - - match identity_bytes.get(0) { - Some(key) if key == &RESOURCE_LOCK_VOTE_TREE_KEY_U8 => { - locked_vote_tally = Some(sum_tree_value as u32); - } - Some(key) if key == &RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8 => { - abstaining_vote_tally = Some(sum_tree_value as u32); - } - _ => { - prev_element = - Some((path.clone(), sum_tree_value, element)); - } - } - } - Element::Item(serialized_item_info, _) => { - if let Some(( - prev_path, - sum_tree_value, - Element::SumTree(_, _, _), - )) = prev_element.take() - { - if prev_path != path { - return Err(Error::Drive(DriveError::CorruptedDriveState("the two results in a chunk when requesting documents and vote tally should both have the same path".to_string()))); - } - - let identity_id = Identifier::from_bytes(identity_bytes)?; - let contender = ContenderWithSerializedDocument { - identity_id, - serialized_document: Some(serialized_item_info), - vote_tally: Some(sum_tree_value as u32), - }; - contenders.push(contender); - } else { - // The vote is actually over, let's deserialize the info - let finalized_contested_document_vote_poll_stored_info = ContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&serialized_item_info)?; - if finalized_contested_document_vote_poll_stored_info - .vote_poll_status() - .awarded_or_locked() - { - locked_vote_tally = Some( - finalized_contested_document_vote_poll_stored_info - .last_locked_votes() - .ok_or(Error::Drive( - DriveError::CorruptedDriveState( - "we should have last locked votes" - .to_string(), - ), - ))?, - ); - abstaining_vote_tally = Some( - finalized_contested_document_vote_poll_stored_info - .last_abstain_votes() - .ok_or(Error::Drive( - DriveError::CorruptedDriveState( - "we should have last abstain votes" - .to_string(), - ), - ))?, - ); - winner = Some(( - finalized_contested_document_vote_poll_stored_info - .winner(), - finalized_contested_document_vote_poll_stored_info - .last_finalization_block() - .ok_or(Error::Drive( - DriveError::CorruptedDriveState( - "we should have a last finalization block" - .to_string(), - ), - ))?, - )); - contenders = finalized_contested_document_vote_poll_stored_info - .contender_votes_in_vec_of_contender_with_serialized_document().ok_or(Error::Drive(DriveError::CorruptedDriveState( - "we should have a last contender votes".to_string(), - )))?; - } - } - } - _ => { - return Err(Error::Drive(DriveError::CorruptedDriveState( - "unexpected element type in result".to_string(), - ))); - } } } } diff --git a/packages/rs-drive/src/drive/votes/fetch/fetch_identities_voting_for_contenders/v0/mod.rs b/packages/rs-drive/src/drive/votes/fetch/fetch_identities_voting_for_contenders/v0/mod.rs index ebebb9108b..cfccd890c1 100644 --- a/packages/rs-drive/src/drive/votes/fetch/fetch_identities_voting_for_contenders/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/fetch/fetch_identities_voting_for_contenders/v0/mod.rs @@ -1,6 +1,6 @@ use crate::drive::votes::paths::{ VotePollPaths, RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8, RESOURCE_LOCK_VOTE_TREE_KEY_U8, - VOTING_STORAGE_TREE_KEY, + RESOURCE_STORED_INFO_KEY_U8, VOTING_STORAGE_TREE_KEY, }; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use crate::drive::Drive; @@ -42,7 +42,7 @@ impl Drive { ]); } } else if also_fetch_abstaining_and_locked_votes { - query.insert_all() + query.insert_range_after(vec![RESOURCE_STORED_INFO_KEY_U8]..) } else { query.insert_range_after(vec![RESOURCE_LOCK_VOTE_TREE_KEY_U8]..) } diff --git a/packages/rs-drive/src/drive/votes/paths.rs b/packages/rs-drive/src/drive/votes/paths.rs index 8f2427c54f..00243691fc 100644 --- a/packages/rs-drive/src/drive/votes/paths.rs +++ b/packages/rs-drive/src/drive/votes/paths.rs @@ -47,16 +47,16 @@ pub const RESOURCE_LOCK_VOTE_TREE_KEY: char = 'l'; pub const RESOURCE_ABSTAIN_VOTE_TREE_KEY: char = 'k'; /// In the active vote poll this will contain votes for locking the contested resource -pub const RESOURCE_LOCK_VOTE_TREE_KEY_U8: u8 = 'l' as u8; +pub const RESOURCE_LOCK_VOTE_TREE_KEY_U8: u8 = b'l'; /// In the active vote poll this will contain votes for abstaining on the vote for the contested resource -pub const RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8: u8 = 'k' as u8; +pub const RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8: u8 = b'k'; /// The finished info pub const RESOURCE_STORED_INFO_KEY: char = 'b'; /// The finished info -pub const RESOURCE_STORED_INFO_KEY_U8: u8 = 'b' as u8; +pub const RESOURCE_STORED_INFO_KEY_U8: u8 = b'b'; //62 /// The tree key for storage pub const VOTING_STORAGE_TREE_KEY: u8 = 1; diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index b658e3c376..e8d09f599c 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -102,8 +102,6 @@ pub struct ContestedDocumentVotePollDriveQuery { pub limit: Option, /// Start at identity id pub start_at: Option<([u8; 32], bool)>, - /// Ascending - pub order_ascending: bool, /// Include locked and abstaining vote tally /// This is not automatic, it will just be at the beginning if the order is ascending /// If the order is descending, we will get a value if we finish the query @@ -213,7 +211,6 @@ impl ContestedDocumentVotePollDriveQuery { offset, limit, start_at, - order_ascending, allow_include_locked_and_abstaining_vote_tally, } = self; Ok(ResolvedContestedDocumentVotePollDriveQuery { @@ -222,7 +219,6 @@ impl ContestedDocumentVotePollDriveQuery { offset: *offset, limit: *limit, start_at: *start_at, - order_ascending: *order_ascending, allow_include_locked_and_abstaining_vote_tally: *allow_include_locked_and_abstaining_vote_tally, }) @@ -240,7 +236,6 @@ impl ContestedDocumentVotePollDriveQuery { offset, limit, start_at, - order_ascending, allow_include_locked_and_abstaining_vote_tally, } = self; Ok(ResolvedContestedDocumentVotePollDriveQuery { @@ -250,7 +245,6 @@ impl ContestedDocumentVotePollDriveQuery { offset: *offset, limit: *limit, start_at: *start_at, - order_ascending: *order_ascending, allow_include_locked_and_abstaining_vote_tally: *allow_include_locked_and_abstaining_vote_tally, }) @@ -268,7 +262,6 @@ impl ContestedDocumentVotePollDriveQuery { offset, limit, start_at, - order_ascending, allow_include_locked_and_abstaining_vote_tally, } = self; Ok(ResolvedContestedDocumentVotePollDriveQuery { @@ -277,7 +270,6 @@ impl ContestedDocumentVotePollDriveQuery { offset: *offset, limit: *limit, start_at: *start_at, - order_ascending: *order_ascending, allow_include_locked_and_abstaining_vote_tally: *allow_include_locked_and_abstaining_vote_tally, }) @@ -424,7 +416,6 @@ impl ContestedDocumentVotePollDriveQuery { ) -> Result { let resolved = self.resolve(drive, transaction, platform_version)?; let path_query = resolved.construct_path_query(platform_version)?; - let order_ascending = resolved.order_ascending; let query_result = drive.grove_get_path_query( &path_query, transaction, @@ -598,62 +589,100 @@ impl ContestedDocumentVotePollDriveQuery { let mut abstaining_vote_tally: Option = None; let mut winner = None; - if order_ascending { - // Handle ascending order - while let Some((path, _, element)) = elements_iter.next() { - let Some(identity_bytes) = path.last() else { - return Err(Error::Drive(DriveError::CorruptedDriveState( - "the path must have a last element".to_string(), - ))); - }; + // Handle ascending order + while let Some((path, first_key, element)) = elements_iter.next() { + let Some(identity_bytes) = path.last() else { + return Err(Error::Drive(DriveError::CorruptedDriveState( + "the path must have a last element".to_string(), + ))); + }; - match element { - Element::SumTree(_, sum_tree_value, _) => { - if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { - return Err(Error::Drive(DriveError::CorruptedDriveState(format!( + match element { + Element::SumTree(_, sum_tree_value, _) => { + if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { + return Err(Error::Drive(DriveError::CorruptedDriveState(format!( "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", sum_tree_value )))); - } + } - match identity_bytes.get(0) { - Some(key) if key == &RESOURCE_LOCK_VOTE_TREE_KEY_U8 => { - locked_vote_tally = Some(sum_tree_value as u32); - } - Some(key) - if key == &RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8 => - { - abstaining_vote_tally = Some(sum_tree_value as u32); - } - _ => { - return Err(Error::Drive( - DriveError::CorruptedDriveState( - "unexpected key for sum tree value" - .to_string(), - ), - )); - } + match identity_bytes.get(0) { + Some(key) if key == &RESOURCE_LOCK_VOTE_TREE_KEY_U8 => { + locked_vote_tally = Some(sum_tree_value as u32); + } + Some(key) if key == &RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8 => { + abstaining_vote_tally = Some(sum_tree_value as u32); + } + _ => { + return Err(Error::Drive( + DriveError::CorruptedDriveState( + "unexpected key for sum tree value".to_string(), + ), + )); } } - Element::Item(serialized_item_info, _) => { + } + Element::Item(serialized_item_info, _) => { + if first_key.len() == 1 + && first_key.first() == Some(&RESOURCE_STORED_INFO_KEY_U8) + { + // this is the stored info, let's check to see if the vote is over + let finalized_contested_document_vote_poll_stored_info = ContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&serialized_item_info)?; + if finalized_contested_document_vote_poll_stored_info + .vote_poll_status() + .awarded_or_locked() + { + locked_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .last_locked_votes() + .ok_or(Error::Drive( + DriveError::CorruptedDriveState( + "we should have last locked votes" + .to_string(), + ), + ))?, + ); + abstaining_vote_tally = Some( + finalized_contested_document_vote_poll_stored_info + .last_abstain_votes() + .ok_or(Error::Drive( + DriveError::CorruptedDriveState( + "we should have last abstain votes" + .to_string(), + ), + ))?, + ); + winner = Some(( + finalized_contested_document_vote_poll_stored_info.winner(), + finalized_contested_document_vote_poll_stored_info + .last_finalization_block().ok_or(Error::Drive(DriveError::CorruptedDriveState( + "we should have a last finalization block".to_string(), + )))?, + )); + contenders = finalized_contested_document_vote_poll_stored_info + .contender_votes_in_vec_of_contender_with_serialized_document().ok_or(Error::Drive(DriveError::CorruptedDriveState( + "we should have a last contender votes".to_string(), + )))?; + } + } else { // We should find a sum tree paired with this document if let Some(( path_tally, - _, + second_key, Element::SumTree(_, sum_tree_value, _), )) = elements_iter.next() { if path != path_tally { - return Err(Error::Drive(DriveError::CorruptedDriveState("the two results in a chunk when requesting documents and vote tally should both have the same path".to_string()))); + return Err(Error::Drive(DriveError::CorruptedDriveState(format!("the two results in a chunk when requesting documents and vote tally should both have the same path asc, got {}:{}, and {}:{}", path.iter().map(hex::encode).collect::>().join("/"), hex::encode(first_key), path_tally.iter().map(hex::encode).collect::>().join("/"), hex::encode(second_key))))); } if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { return Err(Error::Drive(DriveError::CorruptedDriveState(format!( - "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", - sum_tree_value - )))); + "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", + sum_tree_value + )))); } let identity_id = @@ -665,137 +694,19 @@ impl ContestedDocumentVotePollDriveQuery { }; contenders.push(contender); } else { - // The vote is actually over, let's deserialize the info - let finalized_contested_document_vote_poll_stored_info = ContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&serialized_item_info)?; - if finalized_contested_document_vote_poll_stored_info - .vote_poll_status() - .awarded_or_locked() - { - locked_vote_tally = Some( - finalized_contested_document_vote_poll_stored_info - .last_locked_votes() - .ok_or(Error::Drive(DriveError::CorruptedDriveState( - "we should have last locked votes".to_string(), - )))?, - ); - abstaining_vote_tally = - Some(finalized_contested_document_vote_poll_stored_info - .last_abstain_votes().ok_or(Error::Drive(DriveError::CorruptedDriveState( - "we should have last abstain votes".to_string(), - )))?); - winner = Some(( - finalized_contested_document_vote_poll_stored_info.winner(), - finalized_contested_document_vote_poll_stored_info - .last_finalization_block().ok_or(Error::Drive(DriveError::CorruptedDriveState( - "we should have a last finalization block".to_string(), - )))?, - )); - contenders = finalized_contested_document_vote_poll_stored_info - .contender_votes_in_vec_of_contender_with_serialized_document().ok_or(Error::Drive(DriveError::CorruptedDriveState( - "we should have a last contender votes".to_string(), - )))?; - } + return Err(Error::Drive( + DriveError::CorruptedDriveState( + "we should have a sum item after a normal item" + .to_string(), + ), + )); } } - _ => { - return Err(Error::Drive(DriveError::CorruptedDriveState( - "unexpected element type in result".to_string(), - ))); - } } - } - } else { - // Handle descending order - let mut prev_element: Option<(Vec>, i64, Element)> = None; - - while let Some((path, _, element)) = elements_iter.next() { - let Some(identity_bytes) = path.last() else { + _ => { return Err(Error::Drive(DriveError::CorruptedDriveState( - "the path must have a last element".to_string(), + "unexpected element type in result".to_string(), ))); - }; - - match element { - Element::SumTree(_, sum_tree_value, _) => { - if sum_tree_value < 0 || sum_tree_value > u32::MAX as i64 { - return Err(Error::Drive(DriveError::CorruptedDriveState(format!( - "sum tree value for vote tally must be between 0 and u32::Max, received {} from state", - sum_tree_value - )))); - } - - match identity_bytes.get(0) { - Some(key) if key == &RESOURCE_LOCK_VOTE_TREE_KEY_U8 => { - locked_vote_tally = Some(sum_tree_value as u32); - } - Some(key) - if key == &RESOURCE_ABSTAIN_VOTE_TREE_KEY_U8 => - { - abstaining_vote_tally = Some(sum_tree_value as u32); - } - _ => { - prev_element = - Some((path.clone(), sum_tree_value, element)); - } - } - } - Element::Item(serialized_item_info, _) => { - if let Some(( - prev_path, - sum_tree_value, - Element::SumTree(_, _, _), - )) = prev_element.take() - { - if prev_path != path { - return Err(Error::Drive(DriveError::CorruptedDriveState("the two results in a chunk when requesting documents and vote tally should both have the same path".to_string()))); - } - - let identity_id = - Identifier::from_bytes(identity_bytes)?; - let contender = ContenderWithSerializedDocument { - identity_id, - serialized_document: Some(serialized_item_info), - vote_tally: Some(sum_tree_value as u32), - }; - contenders.push(contender); - } else { - // The vote is actually over, let's deserialize the info - let finalized_contested_document_vote_poll_stored_info = ContestedDocumentVotePollStoredInfo::deserialize_from_bytes(&serialized_item_info)?; - if finalized_contested_document_vote_poll_stored_info - .vote_poll_status() - .awarded_or_locked() - { - locked_vote_tally = Some( - finalized_contested_document_vote_poll_stored_info - .last_locked_votes() - .ok_or(Error::Drive(DriveError::CorruptedDriveState( - "we should have last locked votes".to_string(), - )))?, - ); - abstaining_vote_tally = - Some(finalized_contested_document_vote_poll_stored_info - .last_abstain_votes().ok_or(Error::Drive(DriveError::CorruptedDriveState( - "we should have last abstain votes".to_string(), - )))?); - winner = Some(( - finalized_contested_document_vote_poll_stored_info.winner(), - finalized_contested_document_vote_poll_stored_info - .last_finalization_block().ok_or(Error::Drive(DriveError::CorruptedDriveState( - "we should have a last finalization block".to_string(), - )))?, - )); - contenders = finalized_contested_document_vote_poll_stored_info - .contender_votes_in_vec_of_contender_with_serialized_document().ok_or(Error::Drive(DriveError::CorruptedDriveState( - "we should have a last contender votes".to_string(), - )))?; - } - } - } - _ => { - return Err(Error::Drive(DriveError::CorruptedDriveState( - "unexpected element type in result".to_string(), - ))); - } } } } @@ -862,8 +773,6 @@ pub struct ResolvedContestedDocumentVotePollDriveQuery<'a> { pub limit: Option, /// Start at identity id, the bool is if it is also included pub start_at: Option<([u8; 32], bool)>, - /// Ascending - pub order_ascending: bool, /// Include locked and abstaining vote tally pub allow_include_locked_and_abstaining_vote_tally: bool, } @@ -876,7 +785,7 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { ) -> Result { let path = self.vote_poll.contenders_path(platform_version)?; - let mut query = Query::new_with_direction(self.order_ascending); + let mut query = Query::new(); let allow_include_locked_and_abstaining_vote_tally = self .allow_include_locked_and_abstaining_vote_tally @@ -893,31 +802,9 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { } Some((starts_at_key_bytes, start_at_included)) => { let starts_at_key = starts_at_key_bytes.to_vec(); - match self.order_ascending { - true => match start_at_included { - true => query.insert_range_from(starts_at_key..), - false => query.insert_range_after(starts_at_key..), - }, - false => match start_at_included { - true => { - if allow_include_locked_and_abstaining_vote_tally { - query.insert_range_to_inclusive(..=starts_at_key) - } else { - query.insert_range_after_to_inclusive( - vec![RESOURCE_LOCK_VOTE_TREE_KEY_U8]..=starts_at_key, - ) - } - } - false => { - if allow_include_locked_and_abstaining_vote_tally { - query.insert_range_to(..starts_at_key) - } else { - query.insert_range_after_to( - vec![RESOURCE_LOCK_VOTE_TREE_KEY_U8]..starts_at_key, - ) - } - } - }, + match start_at_included { + true => query.insert_range_from(starts_at_key..), + false => query.insert_range_after(starts_at_key..), } } } @@ -947,6 +834,11 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> { Some(vec![vec![1]]), None, ); + query.add_conditional_subquery( + QueryItem::Key(vec![RESOURCE_STORED_INFO_KEY_U8]), + None, + None, + ); } Ok(PathQuery { From 2f681b7c6a944bbfddc2484e9dae8fe72eb95814 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 9 Jun 2024 20:16:04 +0300 Subject: [PATCH 128/135] validation done --- packages/rs-dpp/src/errors/consensus/codes.rs | 2 + .../src/errors/consensus/state/state_error.rs | 8 ++ .../src/errors/consensus/state/voting/mod.rs | 2 + ...ote_poll_not_available_for_voting_error.rs | 39 +++++++ .../state/voting/vote_poll_not_found_error.rs | 37 +++++++ packages/rs-dpp/src/voting/vote_polls/mod.rs | 11 ++ .../src/execution/check_tx/v0/mod.rs | 2 +- .../create_genesis_state/v0/mod.rs | 4 +- .../voting/keep_record_of_vote_poll/v0/mod.rs | 2 +- .../state_transitions/documents_batch/mod.rs | 91 ++++++++++++++- .../state_transitions/masternode_vote/mod.rs | 6 +- .../masternode_vote/state/v0/mod.rs | 104 +++++++++++------- .../masternode_vote/structure/v0/mod.rs | 2 - .../transform_into_action/mod.rs | 1 + .../transform_into_action/v0/mod.rs | 60 ++++++++++ .../state_transition/state_transitions/mod.rs | 2 +- .../tests/strategy_tests/voting_tests.rs | 3 - .../mod.rs | 10 +- .../v0/mod.rs | 29 +++-- .../drive/votes/resolved/vote_polls/mod.rs | 13 +++ .../v0/transformer.rs | 13 ++- .../src/errors/consensus/consensus_error.rs | 16 +++ 22 files changed, 389 insertions(+), 68 deletions(-) create mode 100644 packages/rs-dpp/src/errors/consensus/state/voting/vote_poll_not_available_for_voting_error.rs create mode 100644 packages/rs-dpp/src/errors/consensus/state/voting/vote_poll_not_found_error.rs create mode 100644 packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/mod.rs create mode 100644 packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/v0/mod.rs diff --git a/packages/rs-dpp/src/errors/consensus/codes.rs b/packages/rs-dpp/src/errors/consensus/codes.rs index 56693456a1..01a23877fd 100644 --- a/packages/rs-dpp/src/errors/consensus/codes.rs +++ b/packages/rs-dpp/src/errors/consensus/codes.rs @@ -227,6 +227,8 @@ impl ErrorWithCode for StateError { // Voting Errors: 40300-40399 Self::MasternodeNotFoundError(_) => 40300, + Self::VotePollNotFoundError(_) => 40301, + Self::VotePollNotAvailableForVotingError(_) => 40302, // Prefunded specialized balances Errors: 40400-40499 Self::PrefundedSpecializedBalanceInsufficientError(_) => 40400, diff --git a/packages/rs-dpp/src/errors/consensus/state/state_error.rs b/packages/rs-dpp/src/errors/consensus/state/state_error.rs index 001b772085..09b792e9f0 100644 --- a/packages/rs-dpp/src/errors/consensus/state/state_error.rs +++ b/packages/rs-dpp/src/errors/consensus/state/state_error.rs @@ -38,6 +38,8 @@ use crate::consensus::state::identity::invalid_identity_contract_nonce_error::In use crate::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_insufficient_error::PrefundedSpecializedBalanceInsufficientError; use crate::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_not_found_error::PrefundedSpecializedBalanceNotFoundError; use crate::consensus::state::voting::masternode_not_found_error::MasternodeNotFoundError; +use crate::consensus::state::voting::vote_poll_not_available_for_voting_error::VotePollNotAvailableForVotingError; +use crate::consensus::state::voting::vote_poll_not_found_error::VotePollNotFoundError; use super::document::document_timestamps_are_equal_error::DocumentTimestampsAreEqualError; @@ -153,6 +155,12 @@ pub enum StateError { #[error(transparent)] MasternodeNotFoundError(MasternodeNotFoundError), + + #[error(transparent)] + VotePollNotFoundError(VotePollNotFoundError), + + #[error(transparent)] + VotePollNotAvailableForVotingError(VotePollNotAvailableForVotingError), } impl From for ConsensusError { diff --git a/packages/rs-dpp/src/errors/consensus/state/voting/mod.rs b/packages/rs-dpp/src/errors/consensus/state/voting/mod.rs index fc8ba5f1d3..f595c790dc 100644 --- a/packages/rs-dpp/src/errors/consensus/state/voting/mod.rs +++ b/packages/rs-dpp/src/errors/consensus/state/voting/mod.rs @@ -1 +1,3 @@ pub mod masternode_not_found_error; +pub mod vote_poll_not_available_for_voting_error; +pub mod vote_poll_not_found_error; diff --git a/packages/rs-dpp/src/errors/consensus/state/voting/vote_poll_not_available_for_voting_error.rs b/packages/rs-dpp/src/errors/consensus/state/voting/vote_poll_not_available_for_voting_error.rs new file mode 100644 index 0000000000..26341b31d4 --- /dev/null +++ b/packages/rs-dpp/src/errors/consensus/state/voting/vote_poll_not_available_for_voting_error.rs @@ -0,0 +1,39 @@ +use crate::consensus::state::state_error::StateError; +use crate::consensus::ConsensusError; +use crate::errors::ProtocolError; +use crate::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStatus; +use crate::voting::vote_polls::VotePoll; +use bincode::{Decode, Encode}; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +use thiserror::Error; + +#[derive( + Error, Debug, Clone, PartialEq, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] +#[error("VotePoll {vote_poll} not available for voting: {status}")] +#[platform_serialize(unversioned)] +pub struct VotePollNotAvailableForVotingError { + /* + + DO NOT CHANGE ORDER OF FIELDS WITHOUT INTRODUCING OF NEW VERSION + + */ + vote_poll: VotePoll, + status: ContestedDocumentVotePollStatus, +} + +impl VotePollNotAvailableForVotingError { + pub fn new(vote_poll: VotePoll, status: ContestedDocumentVotePollStatus) -> Self { + Self { vote_poll, status } + } + + pub fn vote_poll(&self) -> &VotePoll { + &self.vote_poll + } +} + +impl From for ConsensusError { + fn from(err: VotePollNotAvailableForVotingError) -> Self { + Self::StateError(StateError::VotePollNotAvailableForVotingError(err)) + } +} diff --git a/packages/rs-dpp/src/errors/consensus/state/voting/vote_poll_not_found_error.rs b/packages/rs-dpp/src/errors/consensus/state/voting/vote_poll_not_found_error.rs new file mode 100644 index 0000000000..77a6c62bdd --- /dev/null +++ b/packages/rs-dpp/src/errors/consensus/state/voting/vote_poll_not_found_error.rs @@ -0,0 +1,37 @@ +use crate::consensus::state::state_error::StateError; +use crate::consensus::ConsensusError; +use crate::errors::ProtocolError; +use crate::voting::vote_polls::VotePoll; +use bincode::{Decode, Encode}; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +use thiserror::Error; + +#[derive( + Error, Debug, Clone, PartialEq, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] +#[error("VotePoll {vote_poll} not found")] +#[platform_serialize(unversioned)] +pub struct VotePollNotFoundError { + /* + + DO NOT CHANGE ORDER OF FIELDS WITHOUT INTRODUCING OF NEW VERSION + + */ + vote_poll: VotePoll, +} + +impl VotePollNotFoundError { + pub fn new(vote_poll: VotePoll) -> Self { + Self { vote_poll } + } + + pub fn vote_poll(&self) -> &VotePoll { + &self.vote_poll + } +} + +impl From for ConsensusError { + fn from(err: VotePollNotFoundError) -> Self { + Self::StateError(StateError::VotePollNotFoundError(err)) + } +} diff --git a/packages/rs-dpp/src/voting/vote_polls/mod.rs b/packages/rs-dpp/src/voting/vote_polls/mod.rs index d05bcb344d..9186451e68 100644 --- a/packages/rs-dpp/src/voting/vote_polls/mod.rs +++ b/packages/rs-dpp/src/voting/vote_polls/mod.rs @@ -6,6 +6,7 @@ use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; use platform_value::Identifier; #[cfg(feature = "vote-serde-conversion")] use serde::{Deserialize, Serialize}; +use std::fmt; pub mod contested_document_resource_vote_poll; @@ -21,6 +22,16 @@ pub enum VotePoll { ContestedDocumentResourceVotePoll(ContestedDocumentResourceVotePoll), } +impl fmt::Display for VotePoll { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + VotePoll::ContestedDocumentResourceVotePoll(poll) => { + write!(f, "ContestedDocumentResourceVotePoll({})", poll) + } + } + } +} + impl Default for VotePoll { fn default() -> Self { ContestedDocumentResourceVotePoll::default().into() diff --git a/packages/rs-drive-abci/src/execution/check_tx/v0/mod.rs b/packages/rs-drive-abci/src/execution/check_tx/v0/mod.rs index e6fa1e13e8..878959b43d 100644 --- a/packages/rs-drive-abci/src/execution/check_tx/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/check_tx/v0/mod.rs @@ -1118,7 +1118,7 @@ mod tests { assert_eq!( update_processing_result.aggregated_fees().processing_fee, - 7125710 + 7140160 ); let check_result = platform diff --git a/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs index 1cfabd0a77..164cccc45a 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/v0/mod.rs @@ -287,8 +287,8 @@ mod tests { assert_eq!( root_hash, [ - 240, 136, 118, 187, 50, 89, 9, 222, 55, 136, 185, 144, 40, 137, 74, 135, 132, - 142, 233, 191, 242, 65, 51, 153, 97, 74, 223, 91, 161, 40, 131, 60 + 157, 162, 165, 114, 176, 1, 91, 184, 245, 168, 243, 235, 34, 240, 248, 117, 16, + 237, 204, 66, 41, 68, 228, 15, 95, 48, 153, 67, 128, 112, 42, 225 ] ) } diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs index ab8931d2f6..2e1cbd0eb9 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/keep_record_of_vote_poll/v0/mod.rs @@ -40,7 +40,7 @@ where .drive .fetch_contested_document_vote_poll_stored_info( vote_poll, - &block_info.epoch, + None, transaction, platform_version, )? diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs index 255d50993f..2a1b29b377 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs @@ -818,7 +818,7 @@ mod tests { } #[test] - fn test_that_a_contested_vote_can_not_be_added_to_after_a_week() { + fn test_that_a_contested_document_can_not_be_added_to_after_a_week() { let platform_version = PlatformVersion::latest(); let mut platform = TestPlatformBuilder::new() .build_with_mock_rpc() @@ -865,15 +865,98 @@ mod tests { let platform_state = platform.state.load(); - let contender_4 = add_contender_to_dpns_name_contest( + // We expect this to fail + + let _contender_4 = add_contender_to_dpns_name_contest( + &mut platform, + &platform_state, + 9, + "quantum", + Some("Document Contest for vote_poll ContestedDocumentResourceVotePoll { contract_id: GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec, document_type_name: domain, index_name: parentNameAndLabel, index_values: [string dash, string quantum] } is not joinable V0(ContestedDocumentVotePollStoredInfoV0 { finalized_events: [], vote_poll_status: Started(BlockInfo { time_ms: 3000, height: 0, core_height: 0, epoch: 0 }), locked_count: 0 }), it started 3000 and it is now 1000003000, and you can only join for 604800000"), // this should fail, as we are over a week + platform_version, + ); + } + + #[test] + fn test_that_a_contested_document_can_not_be_added_if_we_are_locked() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + perform_votes_multi( + &mut platform, + dpns_contract.as_ref(), + vec![ + (TowardsIdentity(contender_1.id()), 3), + (TowardsIdentity(contender_2.id()), 5), + (ResourceVoteChoice::Abstain, 10), + (ResourceVoteChoice::Lock, 50), + ], + "quantum", + 10, + platform_version, + ); + + fast_forward_to_block(&platform, 200_000_000, 900); //less than a week + + let platform_state = platform.state.load(); + + let contender_3 = add_contender_to_dpns_name_contest( + &mut platform, + &platform_state, + 4, + "quantum", + None, // this should succeed, as we are under a week + platform_version, + ); + + fast_forward_to_block(&platform, 2_000_000_000, 900); //more than two weeks + + let transaction = platform.drive.grove.start_transaction(); + + platform + .check_for_ended_vote_polls( + &BlockInfo { + time_ms: 2_000_000_000, + height: 900, + core_height: 42, + epoch: Default::default(), + }, + Some(&transaction), + platform_version, + ) + .expect("expected to check for ended vote polls"); + + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit transaction"); + + let platform_state = platform.state.load(); + + // We expect this to fail + + let _contender_4 = add_contender_to_dpns_name_contest( &mut platform, &platform_state, 9, "quantum", - Some(""), // this should fail, as we are over a week + Some("Document Contest for vote_poll ContestedDocumentResourceVotePoll { contract_id: GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec, document_type_name: domain, index_name: parentNameAndLabel, index_values: [string dash, string quantum] } is currently already locked V0(ContestedDocumentVotePollStoredInfoV0 { finalized_events: [ContestedDocumentVotePollStoredInfoVoteEventV0 { resource_vote_choices: [FinalizedResourceVoteChoicesWithVoterInfo { resource_vote_choice: TowardsIdentity(BjNejy4r9QAvLHpQ9Yq6yRMgNymeGZ46d48fJxJbMrfW), voters: [2oGomAQc47V9h3mkpyHUPbF74gT2AmoYKg1oSb94Rbwm, 4iroeiNBeBYZetCt21kW7FGyczE8WqoqzZ48YAHwyV7R, Cdf8V4KGHHd395x5xPJPPrzTKwmp5MqbuszSE2iMzzeP] }, FinalizedResourceVoteChoicesWithVoterInfo { resource_vote_choice: TowardsIdentity(Fv8S6kTbNrRqKC7PR7XcRUoPR59bxNhhggg5mRaNN6ow), voters: [4MK8GWEWX1PturUqjZJefdE4WGrUqz1UQZnbK17ENkeA, 5gRudU7b4n8LYkNvhZomv6FtMrP7gvaTvRrHKfaTS22K, AfzQBrdwzDuTVdXrMWqQyVvXRWqPMDVjA76hViuGLh6W, E75wdFZB22P1uW1wJBJGPgXZuZKLotK7YmbH5wUk5msH, G3ZfS2v39x6FuLGnnJ1RNQyy4zn4Wb64KiGAjqj39wUu] }, FinalizedResourceVoteChoicesWithVoterInfo { resource_vote_choice: Abstain, voters: [F1oA8iAoyJ8dgCAi2GSPqcNhp9xEuAqhP47yXBDw5QR, 2YSjsJUp74MJpm12rdn8wyPR5MY3c322pV8E8siw989u, 5Ur8tDxJnatfUd9gcVFDde7ptHydujZzJLNTxa6aMYYy, 93Gsg14oT9K4FLYmC7N26uS4g5b7JcM1GwGEDeJCCBPJ, 96eX4PTjbXRuGHuMzwXdptWFtHcboXbtevk51Jd73pP7, AE9xm2mbemDeMxPUzyt35Agq1axRxggVfV4DRLAZp7Qt, FbLyu5d7JxEsvSsujj7Wopg57Wrvz9HH3UULCusKpBnF, GsubMWb3LH1skUJrcxTmZ7wus1habJcbpb8su8yBVqFY, H9UrL7aWaxDmXhqeGMJy7LrGdT2wWb45mc7kQYsoqwuf, Hv88mzPZVKq2fnjoUqK56vjzkcmqRHpWE1ME4z1MXDrw] }, FinalizedResourceVoteChoicesWithVoterInfo { resource_vote_choice: Lock, voters: [14MaZELpiqw9Ar1TgG967tPwDxm1Vmykf4RJkV9CSBvp, CriqrFqi178KnT2cgay5MCkf5pkh1hasNNspivkCX5n, 27RfG8uGpyKbqqnr4hBCM1raUGPpr4gG3iuzkfSBBYvw, 2BjX2J4T1FEtoFeCbXTqgbsaT9Y46VgprBjp57XYKTm5, 2Hkzj9tQvRM33eGuJGrSYamtcovpUbHbKcgnej8Uyu9o, 2UYVEKeR3hW4ychcn9hFyVqjb6imNJWNoAw7o2TVLmeT, 2eUjgMPhXJWJinxriaWJEQuY8QkZwGptJfw1jPhHe1kA, 3aDY49u9bPuCAruPuXPQcyYDmz5CkCxTLogwTbpTQhK8, 3fQrmN4PWhthUFnCFTaJqbT2PPGf7MytAyik4eY1DP8V, 3swdruXXX2oCVthuqCLcs3jiyyjikZ6mHfTyDbhhYFpr, 4HD2RaqYUeu2qne29SgSg1q7QNsCat3TKsgJN3M7mwjs, 4wJ9S1nn6eUiqeMPrJweMw26MSWqdsfXc2K4V4exo8MJ, 4wbuSyhfH52D8ohXEqDMj2SCqxyYyw6EBJjXGrbD7gaX, 52vMgLeUNShUvr2uwsN7nTZaRK33vSQ8bVBQ7h82p82Z, 5Bcb3RxXu4BgSj8CYTp33ChLmy2YiffGf2r2t31Mxcdv, 5SM9jqscqFq4yjncNAcD66xhYGBe7MWMeNEC5CGvFMSR, 5U28rCCGU9jfetcLikGY96cSfnsDFAw71aKatv7D8RNY, 5ge8VEzRMApREH6nYHTJ9kKoZ4gNATF4gwMkKiPNFn2X, 5pYptJYBSw4g5ud2W9XsVJiGL3SEERsHUDLymy7yagkH, 64X9GjPPC9wqqv2mu35pCJbSHEWzTcjTQMSAj84LZGby, 6tUa6r1Rqcrw6BKdgSjqw6P5cLwwsdEasrx25xJ1jyGy, 75GYjACNwsaVhwj3MSEowTB1riZHMycZro8mMEgFLZ4z, 7bnNhHqWpLNeKk1APwe9vBHMrhQzZuiJJuHuTY5Rvpso, 7r7gnAiZunVLjtSd5ky4yvPpnWTFYbJuQAapg8kDCeNK, 86TUE89xNkBDcmshXRD198xjAvMmKecvHbwo6i83AmqA, 8RLTSr4inUHuJ9xZmKnCErv7M5M7aFLQFZ6JVMkHAbVc, 8ihqg1AbpNZ8pFfJVjaqscVkBwXGMFMe9UogPwtMCU65, 8vuWmPZtDdmwFCAez4yxc9hNtSUhcUUJTunMPUBYsKZg, 97iYr4cirPdG176kqa5nvJWT9tsnqxHmENfRnZUgM6SC, 99nKfYZL4spsTe9p9pPNhc1JWv9yq4CbPPMPm87a5sgn, 9FqjzdpGCZmRsW3C6WJWov3PTB5pQmMRfmESSAm5aDy6, 9ZsrkfAmzpbJRuPDEoCuixBNe8FZKi7myCuqbaSJD9gr, 9tLuR56o8SHPeym9Uw6pX2JAeG4G24BwWsAF56XDvguZ, A37G3cY3tU3rDg3Dj7Q3PPXbkGK1W2T2cfgcWfTxvpfY, B7qxTW7779iDRqjC2af9mHtbendJCjMCnVeu1xSjyH6i, BFB4YYTJHYULZyNBtAfCGE81dP56GbG9T24DsSYwZNGh, BXeNfZYNC4oetTPULzpvdUUAaXLMruZbuu8drekYhV2p, BYAqFxCVwMKrw5YAQMCFQGiAF2v3YhKRm2EdGfgkYN9G, CGKeK3AfdZUxXF3qH9zxp5MR7Z4WvDVqMrU5wjMKqT5C, DJemF3kCXuHQSPi7y57CrT2D3yAraCCb6PFKvjnJgPMm, DoQuTLKPHzaAgAoxRqmqrm2Qy9bfdPr3adPeypkhGrGA, EK8Yb6TZoH4aKoMtkzBXtnckf5WB2RVTVgNXYf1y1e2R, EYhibyc33dQYHs1DLuzXc32Q462H1M5QEm3HhTVpLUJf, EcouVEjKx9189HuZeAK1RwSxFtctENFMHbdnqb6A9sJk, Ezkr9YEzLV6zsXesusbyk77aF342nCXMt3KaV5E7iJvi, GZvYVr4hQk3bp65bgqkZPGLHxFku2g1TNeJeGxerF57d, GorCxh81wFUGqR4uMhSoMVG2CBFgCQpGHgMQyaKjyfMA, HLa9WaCbh4xPfeP93okaXVvQyTuAqPETvMmFFdQcES69, HRPPEX4mdoZAMkg6NLJUgDzN4pSTpiDXEAGcR5JBdiXX, HWBvY9zHMvpDoSktSBvPJPNBs2RwS5y5YUSEbLWeetZn] }], start_block: BlockInfo { time_ms: 3000, height: 0, core_height: 0, epoch: 0 }, finalization_block: BlockInfo { time_ms: 2000000000, height: 900, core_height: 42, epoch: 0 }, winner: Locked }], vote_poll_status: Locked, locked_count: 1 }), unlocking is possible by paying 400000000000 credits"), // this should fail, as it is locked platform_version, ); - //todo() this should fail! } #[test] diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 42fbb76c08..96ad8623b2 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -2,6 +2,7 @@ mod balance; mod nonce; mod state; mod structure; +mod transform_into_action; use dpp::block::block_info::BlockInfo; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; @@ -18,6 +19,7 @@ use crate::platform_types::platform::PlatformRef; use crate::rpc::core::CoreRPCLike; use crate::execution::validation::state_transition::masternode_vote::state::v0::MasternodeVoteStateTransitionStateValidationV0; +use crate::execution::validation::state_transition::masternode_vote::transform_into_action::v0::MasternodeVoteStateTransitionTransformIntoActionValidationV0; use crate::execution::validation::state_transition::processor::v0::StateTransitionStateValidationV0; use crate::execution::validation::state_transition::transformer::StateTransitionActionTransformerV0; use crate::execution::validation::state_transition::ValidationMode; @@ -41,7 +43,9 @@ impl StateTransitionActionTransformerV0 for MasternodeVoteTransition { .masternode_vote_state_transition .transform_into_action { - 0 => self.transform_into_action_v0(platform, tx, platform_version), + 0 => self + .transform_into_action_v0(platform, tx, platform_version) + .map(|result| result.map(|action| action.into())), version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { method: "masternode votes state transition: transform_into_action".to_string(), known_versions: vec![0], diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs index 4fc31c387f..685a329965 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs @@ -1,7 +1,11 @@ use crate::error::Error; use crate::platform_types::platform::PlatformRef; use dashcore_rpc::dashcore_rpc_json::MasternodeType; +use dpp::consensus::state::state_error::StateError; use dpp::consensus::state::voting::masternode_not_found_error::MasternodeNotFoundError; +use dpp::consensus::state::voting::vote_poll_not_available_for_voting_error::VotePollNotAvailableForVotingError; +use dpp::consensus::state::voting::vote_poll_not_found_error::VotePollNotFoundError; +use dpp::consensus::ConsensusError; use dpp::dashcore::hashes::Hash; use dpp::dashcore::ProTxHash; @@ -10,8 +14,17 @@ use dpp::state_transition::masternode_vote_transition::accessors::MasternodeVote use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; use drive::state_transition_action::identity::masternode_vote::MasternodeVoteTransitionAction; +use crate::execution::validation::state_transition::masternode_vote::transform_into_action::v0::MasternodeVoteStateTransitionTransformIntoActionValidationV0; use crate::platform_types::platform_state::v0::PlatformStateV0Methods; use dpp::version::PlatformVersion; +use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::{ + ContestedDocumentVotePollStatus, ContestedDocumentVotePollStoredInfo, + ContestedDocumentVotePollStoredInfoV0Getters, +}; +use drive::drive::votes::resolved::vote_polls::ResolvedVotePoll; +use drive::drive::votes::resolved::votes::resolved_resource_vote::accessors::v0::ResolvedResourceVoteGettersV0; +use drive::drive::votes::resolved::votes::resolved_resource_vote::ResolvedResourceVote; +use drive::drive::votes::resolved::votes::ResolvedVote; use drive::grovedb::TransactionArg; use drive::state_transition_action::StateTransitionAction; @@ -23,13 +36,6 @@ pub(in crate::execution::validation::state_transition::state_transitions::master tx: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error>; - - fn transform_into_action_v0( - &self, - platform: &PlatformRef, - tx: TransactionArg, - platform_version: &PlatformVersion, - ) -> Result, Error>; } impl MasternodeVoteStateTransitionStateValidationV0 for MasternodeVoteTransition { @@ -39,39 +45,61 @@ impl MasternodeVoteStateTransitionStateValidationV0 for MasternodeVoteTransition tx: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { - self.transform_into_action_v0(platform, tx, platform_version) - } + let result = self.transform_into_action_v0(platform, tx, platform_version)?; - fn transform_into_action_v0( - &self, - platform: &PlatformRef, - tx: TransactionArg, - platform_version: &PlatformVersion, - ) -> Result, Error> { - let Some(masternode) = platform - .state - .full_masternode_list() - .get(&ProTxHash::from_byte_array(self.pro_tx_hash().to_buffer())) - else { - return Ok(ConsensusValidationResult::new_with_error( - MasternodeNotFoundError::new(self.pro_tx_hash()).into(), - )); - }; + if !result.is_valid() { + return Ok(ConsensusValidationResult::new_with_errors(result.errors)); + } - let strength = match masternode.node_type { - MasternodeType::Regular => 1, - MasternodeType::Evo => 4, - }; + let action = result.into_data()?; - Ok(ConsensusValidationResult::new_with_data( - MasternodeVoteTransitionAction::transform_from_transition( - self, - strength, - platform.drive, - tx, - platform_version, - )? - .into(), - )) + // We need to make sure that the vote poll exists and is in started state + match action.vote_ref() { + ResolvedVote::ResolvedResourceVote(resource_vote) => { + let vote_poll = resource_vote.vote_poll(); + match vote_poll { + ResolvedVotePoll::ContestedDocumentResourceVotePollWithContractInfo( + contested_document_resource_vote_poll, + ) => { + let Some(stored_info) = platform + .drive + .fetch_contested_document_vote_poll_stored_info( + contested_document_resource_vote_poll, + None, + tx, + platform_version, + )? + .1 + else { + return Ok(ConsensusValidationResult::new_with_error( + ConsensusError::StateError(StateError::VotePollNotFoundError( + VotePollNotFoundError::new(vote_poll.into()), + )), + )); + }; + let vote_poll_status = stored_info.vote_poll_status(); + match &vote_poll_status { + ContestedDocumentVotePollStatus::NotStarted + | ContestedDocumentVotePollStatus::Awarded(_) + | ContestedDocumentVotePollStatus::Locked => { + Ok(ConsensusValidationResult::new_with_error( + ConsensusError::StateError( + StateError::VotePollNotAvailableForVotingError( + VotePollNotAvailableForVotingError::new( + vote_poll.into(), + vote_poll_status, + ), + ), + ), + )) + } + ContestedDocumentVotePollStatus::Started(_) => { + Ok(ConsensusValidationResult::new_with_data(action.into())) + } + } + } + } + } + } } } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/structure/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/structure/v0/mod.rs index 429a72393a..f8073c437d 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/structure/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/structure/v0/mod.rs @@ -3,8 +3,6 @@ use crate::error::Error; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; use dpp::validation::SimpleConsensusValidationResult; -const MIN_TRANSFER_AMOUNT: u64 = 1000; - pub(in crate::execution::validation::state_transition::state_transitions::masternode_vote) trait MasternodeVoteStateTransitionStructureValidationV0 { fn validate_base_structure_v0(&self) -> Result; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/mod.rs new file mode 100644 index 0000000000..9a1925de7f --- /dev/null +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/mod.rs @@ -0,0 +1 @@ +pub(crate) mod v0; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/v0/mod.rs new file mode 100644 index 0000000000..95e7eb312f --- /dev/null +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/v0/mod.rs @@ -0,0 +1,60 @@ +use crate::error::Error; +use crate::platform_types::platform::PlatformRef; +use dashcore_rpc::dashcore_rpc_json::MasternodeType; +use dpp::consensus::state::voting::masternode_not_found_error::MasternodeNotFoundError; +use dpp::dashcore::hashes::Hash; +use dpp::dashcore::ProTxHash; + +use dpp::prelude::ConsensusValidationResult; +use dpp::state_transition::masternode_vote_transition::accessors::MasternodeVoteTransitionAccessorsV0; +use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; +use drive::state_transition_action::identity::masternode_vote::MasternodeVoteTransitionAction; + +use crate::platform_types::platform_state::v0::PlatformStateV0Methods; +use dpp::version::PlatformVersion; +use drive::grovedb::TransactionArg; +use drive::state_transition_action::StateTransitionAction; + +pub(in crate::execution::validation::state_transition::state_transitions::masternode_vote) trait MasternodeVoteStateTransitionTransformIntoActionValidationV0 +{ + fn transform_into_action_v0( + &self, + platform: &PlatformRef, + tx: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error>; +} + +impl MasternodeVoteStateTransitionTransformIntoActionValidationV0 for MasternodeVoteTransition { + fn transform_into_action_v0( + &self, + platform: &PlatformRef, + tx: TransactionArg, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let Some(masternode) = platform + .state + .full_masternode_list() + .get(&ProTxHash::from_byte_array(self.pro_tx_hash().to_buffer())) + else { + return Ok(ConsensusValidationResult::new_with_error( + MasternodeNotFoundError::new(self.pro_tx_hash()).into(), + )); + }; + + let strength = match masternode.node_type { + MasternodeType::Regular => 1, + MasternodeType::Evo => 4, + }; + + Ok(ConsensusValidationResult::new_with_data( + MasternodeVoteTransitionAction::transform_from_transition( + self, + strength, + platform.drive, + tx, + platform_version, + )?, + )) + } +} 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 fb430c4e71..191f8ab875 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 @@ -693,7 +693,7 @@ mod tests { }; assert_eq!(consensus_error.to_string(), expected_err); } else { - assert_eq!(processing_result.valid_count(), 2); + assert_eq!(processing_result.valid_count(), 1); } identity_1 } diff --git a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs index 70346e2c98..996416e39e 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/voting_tests.rs @@ -243,7 +243,6 @@ mod tests { allow_include_locked_and_abstaining_vote_tally: true, start_at_identifier_info: None, count: None, - order_ascending: true, prove: false, }, )), @@ -307,7 +306,6 @@ mod tests { allow_include_locked_and_abstaining_vote_tally: true, start_at_identifier_info: None, count: None, - order_ascending: true, prove: true, }, )), @@ -346,7 +344,6 @@ mod tests { offset: None, limit: None, start_at: None, - order_ascending: true, allow_include_locked_and_abstaining_vote_tally: true, }; diff --git a/packages/rs-drive/src/drive/votes/fetch/fetch_contested_document_vote_poll_stored_info/mod.rs b/packages/rs-drive/src/drive/votes/fetch/fetch_contested_document_vote_poll_stored_info/mod.rs index 82b563be59..aca035f38e 100644 --- a/packages/rs-drive/src/drive/votes/fetch/fetch_contested_document_vote_poll_stored_info/mod.rs +++ b/packages/rs-drive/src/drive/votes/fetch/fetch_contested_document_vote_poll_stored_info/mod.rs @@ -17,10 +17,16 @@ impl Drive { pub fn fetch_contested_document_vote_poll_stored_info( &self, contested_document_resource_vote_poll_with_contract_info: &ContestedDocumentResourceVotePollWithContractInfo, - epoch: &Epoch, + epoch: Option<&Epoch>, transaction: TransactionArg, platform_version: &PlatformVersion, - ) -> Result<(FeeResult, Option), Error> { + ) -> Result< + ( + Option, + Option, + ), + Error, + > { match platform_version .drive .methods diff --git a/packages/rs-drive/src/drive/votes/fetch/fetch_contested_document_vote_poll_stored_info/v0/mod.rs b/packages/rs-drive/src/drive/votes/fetch/fetch_contested_document_vote_poll_stored_info/v0/mod.rs index 0746bd39aa..c04338c048 100644 --- a/packages/rs-drive/src/drive/votes/fetch/fetch_contested_document_vote_poll_stored_info/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/fetch/fetch_contested_document_vote_poll_stored_info/v0/mod.rs @@ -15,10 +15,16 @@ impl Drive { pub(super) fn fetch_contested_document_vote_poll_stored_info_v0( &self, contested_document_resource_vote_poll_with_contract_info: &ContestedDocumentResourceVotePollWithContractInfo, - epoch: &Epoch, + epoch: Option<&Epoch>, transaction: TransactionArg, platform_version: &PlatformVersion, - ) -> Result<(FeeResult, Option), Error> { + ) -> Result< + ( + Option, + Option, + ), + Error, + > { let path = contested_document_resource_vote_poll_with_contract_info .contenders_path(platform_version)?; let mut cost_operations = vec![]; @@ -30,13 +36,18 @@ impl Drive { &mut cost_operations, &platform_version.drive, )?; - let fee_result = Drive::calculate_fee( - None, - Some(cost_operations), - epoch, - self.config.epochs_per_era, - platform_version, - )?; + + let fee_result = epoch + .map(|epoch| { + Drive::calculate_fee( + None, + Some(cost_operations), + epoch, + self.config.epochs_per_era, + platform_version, + ) + }) + .transpose()?; let Some(element) = maybe_element else { return Ok((fee_result, None)); }; diff --git a/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs b/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs index fb9bfcfdf8..643af76e8a 100644 --- a/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs +++ b/packages/rs-drive/src/drive/votes/resolved/vote_polls/mod.rs @@ -2,6 +2,7 @@ use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_ use derive_more::From; use dpp::identifier::Identifier; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use dpp::voting::vote_polls::VotePoll; use dpp::ProtocolError; use std::collections::BTreeMap; @@ -21,6 +22,18 @@ pub enum ResolvedVotePoll { ), } +impl From<&ResolvedVotePoll> for VotePoll { + fn from(value: &ResolvedVotePoll) -> Self { + match value { + ResolvedVotePoll::ContestedDocumentResourceVotePollWithContractInfo( + contested_document_resource_vote_poll, + ) => VotePoll::ContestedDocumentResourceVotePoll( + contested_document_resource_vote_poll.into(), + ), + } + } +} + /// Represents a resolved vote poll in the system that also contains votes. #[derive(Debug, Clone, PartialEq, From)] pub enum ResolvedVotePollWithVotes { diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs index 2fdaf99c31..2c2aea87be 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/document_transition/document_create_transition_action/v0/transformer.rs @@ -13,6 +13,7 @@ use platform_version::version::PlatformVersion; use crate::drive::contract::DataContractFetchInfo; use crate::drive::Drive; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::resolve::ContestedDocumentResourceVotePollResolver; +use crate::error::drive::DriveError; use crate::error::Error; use crate::state_transition_action::document::documents_batch::document_transition::document_base_transition_action::{DocumentBaseTransitionAction, DocumentBaseTransitionActionAccessorsV0}; use crate::state_transition_action::document::documents_batch::document_transition::document_create_transition_action::DocumentCreateTransitionActionV0; @@ -78,12 +79,14 @@ impl DocumentCreateTransitionActionV0 { let (fetch_fee_result, maybe_current_store_contest_info) = drive .fetch_contested_document_vote_poll_stored_info( contested_document_resource_vote_poll, - &block_info.epoch, + Some(&block_info.epoch), transaction, platform_version, )?; - fee_result = fetch_fee_result; + fee_result = fetch_fee_result.ok_or(Error::Drive( + DriveError::CorruptedCodeExecution("expected fee result"), + ))?; let should_store_contest_info = if maybe_current_store_contest_info.is_none() { // We are starting a new contest Some(ContestedDocumentVotePollStoredInfo::new( @@ -173,12 +176,14 @@ impl DocumentCreateTransitionActionV0 { let (fetch_fee_result, maybe_current_store_contest_info) = drive .fetch_contested_document_vote_poll_stored_info( contested_document_resource_vote_poll, - &block_info.epoch, + Some(&block_info.epoch), transaction, platform_version, )?; - fee_result = fetch_fee_result; + fee_result = fetch_fee_result.ok_or(Error::Drive( + DriveError::CorruptedCodeExecution("expected fee result"), + ))?; let should_store_contest_info = if maybe_current_store_contest_info.is_none() { // We are starting a new contest Some(ContestedDocumentVotePollStoredInfo::new( diff --git a/packages/wasm-dpp/src/errors/consensus/consensus_error.rs b/packages/wasm-dpp/src/errors/consensus/consensus_error.rs index 3948b67ec6..5204f9e0f8 100644 --- a/packages/wasm-dpp/src/errors/consensus/consensus_error.rs +++ b/packages/wasm-dpp/src/errors/consensus/consensus_error.rs @@ -66,6 +66,8 @@ use dpp::consensus::basic::document::{DocumentCreationNotAllowedError, MaxDocume use dpp::consensus::basic::identity::{DataContractBoundsNotPresentError, DisablingKeyIdAlsoBeingAddedInSameTransitionError, InvalidIdentityCreditWithdrawalTransitionAmountError, InvalidIdentityUpdateTransitionDisableKeysError, InvalidIdentityUpdateTransitionEmptyError, TooManyMasterPublicKeyError}; use dpp::consensus::basic::overflow_error::OverflowError; use dpp::consensus::state::data_contract::document_type_update_error::DocumentTypeUpdateError; +use dpp::consensus::state::document::document_contest_currently_locked_error::DocumentContestCurrentlyLockedError; +use dpp::consensus::state::document::document_contest_not_joinable_error::DocumentContestNotJoinableError; use dpp::consensus::state::document::document_incorrect_purchase_price_error::DocumentIncorrectPurchasePriceError; use dpp::consensus::state::document::document_not_for_sale_error::DocumentNotForSaleError; use dpp::consensus::state::identity::identity_public_key_already_exists_for_unique_contract_bounds_error::IdentityPublicKeyAlreadyExistsForUniqueContractBoundsError; @@ -73,6 +75,8 @@ use dpp::consensus::state::identity::master_public_key_update_error::MasterPubli use dpp::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_insufficient_error::PrefundedSpecializedBalanceInsufficientError; use dpp::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_not_found_error::PrefundedSpecializedBalanceNotFoundError; use dpp::consensus::state::voting::masternode_not_found_error::MasternodeNotFoundError; +use dpp::consensus::state::voting::vote_poll_not_available_for_voting_error::VotePollNotAvailableForVotingError; +use dpp::consensus::state::voting::vote_poll_not_found_error::VotePollNotFoundError; use crate::errors::consensus::basic::data_contract::{ DataContractErrorWasm, DataContractHaveNewUniqueIndexErrorWasm, @@ -253,6 +257,18 @@ pub fn from_state_error(state_error: &StateError) -> JsValue { StateError::MasternodeNotFoundError(e) => { generic_consensus_error!(MasternodeNotFoundError, e).into() } + StateError::DocumentContestCurrentlyLockedError(e) => { + generic_consensus_error!(DocumentContestCurrentlyLockedError, e).into() + } + StateError::DocumentContestNotJoinableError(e) => { + generic_consensus_error!(DocumentContestNotJoinableError, e).into() + } + StateError::VotePollNotFoundError(e) => { + generic_consensus_error!(VotePollNotFoundError, e).into() + } + StateError::VotePollNotAvailableForVotingError(e) => { + generic_consensus_error!(VotePollNotAvailableForVotingError, e).into() + } } } From 20635e1c2d5860c1f38f35045c348ae83a8a556b Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 10 Jun 2024 20:54:31 +0300 Subject: [PATCH 129/135] changing votes is validated now --- packages/rs-dpp/src/errors/consensus/codes.rs | 2 + .../src/errors/consensus/state/state_error.rs | 8 ++ .../masternode_vote_already_present_error.rs | 46 +++++++ .../voting/masternode_voted_too_many_times.rs | 42 ++++++ .../src/errors/consensus/state/voting/mod.rs | 2 + .../state_transitions/masternode_vote/mod.rs | 124 ++++++++++++++++++ .../masternode_vote/state/v0/mod.rs | 52 ++++++-- .../state_transition/state_transitions/mod.rs | 14 +- .../mod.rs | 45 +++++++ .../v0/mod.rs | 64 +++++++++ .../rs-drive/src/drive/votes/fetch/mod.rs | 1 + .../src/version/drive_versions.rs | 1 + .../src/version/mocks/v2_test.rs | 1 + .../src/version/mocks/v3_test.rs | 1 + .../rs-platform-version/src/version/v1.rs | 1 + 15 files changed, 393 insertions(+), 11 deletions(-) create mode 100644 packages/rs-dpp/src/errors/consensus/state/voting/masternode_vote_already_present_error.rs create mode 100644 packages/rs-dpp/src/errors/consensus/state/voting/masternode_voted_too_many_times.rs create mode 100644 packages/rs-drive/src/drive/votes/fetch/fetch_identity_contested_resource_vote/mod.rs create mode 100644 packages/rs-drive/src/drive/votes/fetch/fetch_identity_contested_resource_vote/v0/mod.rs diff --git a/packages/rs-dpp/src/errors/consensus/codes.rs b/packages/rs-dpp/src/errors/consensus/codes.rs index 01a23877fd..73b069f79c 100644 --- a/packages/rs-dpp/src/errors/consensus/codes.rs +++ b/packages/rs-dpp/src/errors/consensus/codes.rs @@ -229,6 +229,8 @@ impl ErrorWithCode for StateError { Self::MasternodeNotFoundError(_) => 40300, Self::VotePollNotFoundError(_) => 40301, Self::VotePollNotAvailableForVotingError(_) => 40302, + Self::MasternodeVotedTooManyTimesError(_) => 40303, + Self::MasternodeVoteAlreadyPresentError(_) => 40304, // Prefunded specialized balances Errors: 40400-40499 Self::PrefundedSpecializedBalanceInsufficientError(_) => 40400, diff --git a/packages/rs-dpp/src/errors/consensus/state/state_error.rs b/packages/rs-dpp/src/errors/consensus/state/state_error.rs index 09b792e9f0..4bee280e26 100644 --- a/packages/rs-dpp/src/errors/consensus/state/state_error.rs +++ b/packages/rs-dpp/src/errors/consensus/state/state_error.rs @@ -38,6 +38,8 @@ use crate::consensus::state::identity::invalid_identity_contract_nonce_error::In use crate::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_insufficient_error::PrefundedSpecializedBalanceInsufficientError; use crate::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_not_found_error::PrefundedSpecializedBalanceNotFoundError; use crate::consensus::state::voting::masternode_not_found_error::MasternodeNotFoundError; +use crate::consensus::state::voting::masternode_vote_already_present_error::MasternodeVoteAlreadyPresentError; +use crate::consensus::state::voting::masternode_voted_too_many_times::MasternodeVotedTooManyTimesError; use crate::consensus::state::voting::vote_poll_not_available_for_voting_error::VotePollNotAvailableForVotingError; use crate::consensus::state::voting::vote_poll_not_found_error::VotePollNotFoundError; @@ -161,6 +163,12 @@ pub enum StateError { #[error(transparent)] VotePollNotAvailableForVotingError(VotePollNotAvailableForVotingError), + + #[error(transparent)] + MasternodeVotedTooManyTimesError(MasternodeVotedTooManyTimesError), + + #[error(transparent)] + MasternodeVoteAlreadyPresentError(MasternodeVoteAlreadyPresentError), } impl From for ConsensusError { diff --git a/packages/rs-dpp/src/errors/consensus/state/voting/masternode_vote_already_present_error.rs b/packages/rs-dpp/src/errors/consensus/state/voting/masternode_vote_already_present_error.rs new file mode 100644 index 0000000000..7526eba217 --- /dev/null +++ b/packages/rs-dpp/src/errors/consensus/state/voting/masternode_vote_already_present_error.rs @@ -0,0 +1,46 @@ +use crate::consensus::state::state_error::StateError; +use crate::consensus::ConsensusError; +use crate::errors::ProtocolError; +use crate::voting::vote_polls::VotePoll; +use bincode::{Decode, Encode}; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +use platform_value::Identifier; +use thiserror::Error; + +#[derive( + Error, Debug, Clone, PartialEq, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] +#[error("Masternode vote is already present for masternode {pro_tx_hash} voting for {vote_poll}")] +#[platform_serialize(unversioned)] +pub struct MasternodeVoteAlreadyPresentError { + /* + + DO NOT CHANGE ORDER OF FIELDS WITHOUT INTRODUCING OF NEW VERSION + + */ + pro_tx_hash: Identifier, + vote_poll: VotePoll, +} + +impl MasternodeVoteAlreadyPresentError { + pub fn new(pro_tx_hash: Identifier, vote_poll: VotePoll) -> Self { + Self { + pro_tx_hash, + vote_poll, + } + } + + pub fn pro_tx_hash(&self) -> Identifier { + self.pro_tx_hash + } + + pub fn vote_poll(&self) -> &VotePoll { + &self.vote_poll + } +} + +impl From for ConsensusError { + fn from(err: MasternodeVoteAlreadyPresentError) -> Self { + Self::StateError(StateError::MasternodeVoteAlreadyPresentError(err)) + } +} diff --git a/packages/rs-dpp/src/errors/consensus/state/voting/masternode_voted_too_many_times.rs b/packages/rs-dpp/src/errors/consensus/state/voting/masternode_voted_too_many_times.rs new file mode 100644 index 0000000000..e787691fb2 --- /dev/null +++ b/packages/rs-dpp/src/errors/consensus/state/voting/masternode_voted_too_many_times.rs @@ -0,0 +1,42 @@ +use crate::consensus::state::state_error::StateError; +use crate::consensus::ConsensusError; +use crate::errors::ProtocolError; +use bincode::{Decode, Encode}; +use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; +use platform_value::Identifier; +use thiserror::Error; + +#[derive( + Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, +)] +#[error("Masternode with id: {pro_tx_hash} voted {times_voted}, which is too many times")] +#[platform_serialize(unversioned)] +pub struct MasternodeVotedTooManyTimesError { + /* + + DO NOT CHANGE ORDER OF FIELDS WITHOUT INTRODUCING OF NEW VERSION + + */ + pro_tx_hash: Identifier, + + times_voted: u16, +} + +impl MasternodeVotedTooManyTimesError { + pub fn new(pro_tx_hash: Identifier, times_voted: u16) -> Self { + Self { + pro_tx_hash, + times_voted, + } + } + + pub fn pro_tx_hash(&self) -> Identifier { + self.pro_tx_hash + } +} + +impl From for ConsensusError { + fn from(err: MasternodeVotedTooManyTimesError) -> Self { + Self::StateError(StateError::MasternodeVotedTooManyTimesError(err)) + } +} diff --git a/packages/rs-dpp/src/errors/consensus/state/voting/mod.rs b/packages/rs-dpp/src/errors/consensus/state/voting/mod.rs index f595c790dc..dcf121e847 100644 --- a/packages/rs-dpp/src/errors/consensus/state/voting/mod.rs +++ b/packages/rs-dpp/src/errors/consensus/state/voting/mod.rs @@ -1,3 +1,5 @@ pub mod masternode_not_found_error; +pub mod masternode_vote_already_present_error; +pub mod masternode_voted_too_many_times; pub mod vote_poll_not_available_for_voting_error; pub mod vote_poll_not_found_error; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 96ad8623b2..c99dc9b755 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -407,6 +407,7 @@ mod tests { masternode_1.id(), &voting_key_1, 1, + None, platform_version, ); @@ -477,6 +478,7 @@ mod tests { masternode_1.id(), &voting_key_1, 1, + None, platform_version, ); @@ -957,6 +959,7 @@ mod tests { masternode.id(), &voting_key, 1, + None, platform_version, ); } @@ -977,6 +980,7 @@ mod tests { masternode.id(), &voting_key, 1, + None, platform_version, ); } @@ -997,6 +1001,7 @@ mod tests { masternode.id(), &voting_key, 1, + None, platform_version, ); } @@ -1078,6 +1083,7 @@ mod tests { masternode.id(), &voting_key, 1, + None, platform_version, ); } @@ -1113,6 +1119,7 @@ mod tests { masternode.id(), &voting_key, 1, + None, platform_version, ); } @@ -1195,6 +1202,7 @@ mod tests { masternode.id(), &voting_key, 1, + None, platform_version, ); } @@ -1215,6 +1223,7 @@ mod tests { masternode.id(), &voting_key, 1, + None, platform_version, ); } @@ -1235,6 +1244,7 @@ mod tests { masternode.id(), &voting_key, 1, + None, platform_version, ); } @@ -1507,6 +1517,7 @@ mod tests { masternode.id(), &voting_key, 1, + None, platform_version, ); @@ -1522,6 +1533,7 @@ mod tests { masternode.id(), &voting_key, 2, + None, platform_version, ); @@ -1537,6 +1549,7 @@ mod tests { masternode.id(), &voting_key, 3, + None, platform_version, ); @@ -1666,6 +1679,7 @@ mod tests { masternode.id(), &voting_key, 1, + None, platform_version, ); @@ -1681,6 +1695,7 @@ mod tests { masternode.id(), &voting_key, 2, + None, platform_version, ); @@ -1696,6 +1711,7 @@ mod tests { masternode.id(), &voting_key, 3, + None, platform_version, ); @@ -3223,6 +3239,7 @@ mod tests { masternode.id(), &voting_key, 1, + None, platform_version, ); } @@ -3253,6 +3270,7 @@ mod tests { masternode.id(), &voting_key, 1, + None, platform_version, ); } @@ -3329,6 +3347,7 @@ mod tests { masternode.id(), &voting_key, 1, + None, platform_version, ); } @@ -3359,6 +3378,7 @@ mod tests { masternode.id(), &voting_key, 1, + None, platform_version, ); } @@ -3778,5 +3798,109 @@ mod tests { } } } + mod changing_vote { + use super::*; + #[test] + fn test_masternode_vote_again_same_vote_should_return_error() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + let (masternode, signer, voting_key) = + setup_masternode_identity(&mut platform, 10, platform_version); + + let platform_state = platform.state.load(); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + TowardsIdentity(contender_1.id()), + "quantum", + &signer, + masternode.id(), + &voting_key, + 1, + None, + platform_version, + ); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + TowardsIdentity(contender_1.id()), + "quantum", + &signer, + masternode.id(), + &voting_key, + 2, + Some("Masternode vote is already present for masternode 4iroeiNBeBYZetCt21kW7FGyczE8WqoqzZ48YAHwyV7R voting for ContestedDocumentResourceVotePoll(ContestedDocumentResourceVotePoll { contract_id: GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec, document_type_name: domain, index_name: parentNameAndLabel, index_values: [string dash, string quantum] })"), + platform_version, + ); + } + + #[test] + fn test_masternode_vote_again_different_choice() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + let (masternode, signer, voting_key) = + setup_masternode_identity(&mut platform, 10, platform_version); + + let platform_state = platform.state.load(); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + TowardsIdentity(contender_1.id()), + "quantum", + &signer, + masternode.id(), + &voting_key, + 1, + None, + platform_version, + ); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + TowardsIdentity(contender_2.id()), + "quantum", + &signer, + masternode.id(), + &voting_key, + 2, + None, + platform_version, + ); + } + } } } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs index 685a329965..cc5294adef 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs @@ -1,29 +1,25 @@ use crate::error::Error; use crate::platform_types::platform::PlatformRef; -use dashcore_rpc::dashcore_rpc_json::MasternodeType; use dpp::consensus::state::state_error::StateError; -use dpp::consensus::state::voting::masternode_not_found_error::MasternodeNotFoundError; +use dpp::consensus::state::voting::masternode_vote_already_present_error::MasternodeVoteAlreadyPresentError; use dpp::consensus::state::voting::vote_poll_not_available_for_voting_error::VotePollNotAvailableForVotingError; use dpp::consensus::state::voting::vote_poll_not_found_error::VotePollNotFoundError; use dpp::consensus::ConsensusError; -use dpp::dashcore::hashes::Hash; -use dpp::dashcore::ProTxHash; use dpp::prelude::ConsensusValidationResult; use dpp::state_transition::masternode_vote_transition::accessors::MasternodeVoteTransitionAccessorsV0; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; -use drive::state_transition_action::identity::masternode_vote::MasternodeVoteTransitionAction; use crate::execution::validation::state_transition::masternode_vote::transform_into_action::v0::MasternodeVoteStateTransitionTransformIntoActionValidationV0; -use crate::platform_types::platform_state::v0::PlatformStateV0Methods; use dpp::version::PlatformVersion; use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::{ - ContestedDocumentVotePollStatus, ContestedDocumentVotePollStoredInfo, - ContestedDocumentVotePollStoredInfoV0Getters, + ContestedDocumentVotePollStatus, ContestedDocumentVotePollStoredInfoV0Getters, }; +use dpp::voting::vote_polls::VotePoll; +use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; +use dpp::voting::votes::Vote; use drive::drive::votes::resolved::vote_polls::ResolvedVotePoll; use drive::drive::votes::resolved::votes::resolved_resource_vote::accessors::v0::ResolvedResourceVoteGettersV0; -use drive::drive::votes::resolved::votes::resolved_resource_vote::ResolvedResourceVote; use drive::drive::votes::resolved::votes::ResolvedVote; use drive::grovedb::TransactionArg; use drive::state_transition_action::StateTransitionAction; @@ -45,6 +41,44 @@ impl MasternodeVoteStateTransitionStateValidationV0 for MasternodeVoteTransition tx: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { + // Before we transform into action we want to make sure that we have not yet voted + + match self.vote() { + Vote::ResourceVote(resource_vote) => { + match resource_vote.vote_poll() { + VotePoll::ContestedDocumentResourceVotePoll(vote_poll) => { + let vote_id = vote_poll.unique_id()?; + let maybe_existing_resource_vote_choice = + platform.drive.fetch_identity_contested_resource_vote( + self.pro_tx_hash(), + vote_id, + tx, + &mut vec![], + platform_version, + )?; + if let Some(existing_resource_vote_choice) = + maybe_existing_resource_vote_choice + { + if existing_resource_vote_choice == resource_vote.resource_vote_choice() + { + // We are submitting a vote for something we already have + return Ok(ConsensusValidationResult::new_with_error( + ConsensusError::StateError( + StateError::MasternodeVoteAlreadyPresentError( + MasternodeVoteAlreadyPresentError::new( + self.pro_tx_hash(), + resource_vote.vote_poll().clone(), + ), + ), + ), + )); + } + } + } + } + } + } + let result = self.transform_into_action_v0(platform, tx, platform_version)?; if !result.is_valid() { 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 191f8ab875..562757ee75 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 @@ -108,7 +108,7 @@ mod tests { use crate::platform_types::platform_state::PlatformState; use crate::platform_types::platform_state::v0::PlatformStateV0Methods; use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult; - use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult::SuccessfulExecution; + use crate::platform_types::state_transitions_processing_result::StateTransitionExecutionResult::{SuccessfulExecution, UnpaidConsensusError}; pub(in crate::execution::validation::state_transition::state_transitions) fn setup_identity( platform: &mut TempPlatform, @@ -916,6 +916,7 @@ mod tests { masternode_id: Identifier, voting_key: &IdentityPublicKey, nonce: IdentityNonce, + expect_error: Option<&str>, platform_version: &PlatformVersion, ) { // Let's vote for contender 1 @@ -971,7 +972,15 @@ mod tests { .expect("expected to commit transaction"); let execution_result = processing_result.into_execution_results().remove(0); - assert_matches!(execution_result, SuccessfulExecution(..)); + if let Some(error_msg) = expect_error { + assert_matches!(execution_result, UnpaidConsensusError(..)); + let UnpaidConsensusError(consensus_error) = execution_result else { + panic!() + }; + assert_eq!(consensus_error.to_string(), error_msg) + } else { + assert_matches!(execution_result, SuccessfulExecution(..)); + } } pub(in crate::execution::validation::state_transition::state_transitions) fn perform_votes( @@ -999,6 +1008,7 @@ mod tests { masternode.id(), &voting_key, 1, + None, platform_version, ); } diff --git a/packages/rs-drive/src/drive/votes/fetch/fetch_identity_contested_resource_vote/mod.rs b/packages/rs-drive/src/drive/votes/fetch/fetch_identity_contested_resource_vote/mod.rs new file mode 100644 index 0000000000..8e45905256 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/fetch/fetch_identity_contested_resource_vote/mod.rs @@ -0,0 +1,45 @@ +mod v0; + +use crate::drive::Drive; + +use crate::error::drive::DriveError; +use crate::error::Error; + +use crate::fee::op::LowLevelDriveOperation; +use dpp::platform_value::Identifier; +use dpp::version::PlatformVersion; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use grovedb::TransactionArg; + +impl Drive { + /// Fetches a specific identity vote. + pub fn fetch_identity_contested_resource_vote( + &self, + masternode_pro_tx_hash: Identifier, + vote_id: Identifier, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result, Error> { + match platform_version + .drive + .methods + .vote + .fetch + .fetch_identity_contested_resource_vote + { + 0 => self.fetch_identity_contested_resource_vote_v0( + masternode_pro_tx_hash, + vote_id, + transaction, + drive_operations, + platform_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "fetch_identity_contested_resource_vote".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/drive/votes/fetch/fetch_identity_contested_resource_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/fetch/fetch_identity_contested_resource_vote/v0/mod.rs new file mode 100644 index 0000000000..35c4b39087 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/fetch/fetch_identity_contested_resource_vote/v0/mod.rs @@ -0,0 +1,64 @@ +use crate::drive::grove_operations::DirectQueryType; +use crate::drive::votes::paths::vote_contested_resource_identity_votes_tree_path_for_identity; +use crate::drive::votes::storage_form::contested_document_resource_storage_form::ContestedDocumentResourceVoteStorageForm; +use crate::drive::votes::tree_path_storage_form::TreePathStorageForm; +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fee::op::LowLevelDriveOperation; +use dpp::identifier::Identifier; +use dpp::prelude::DataContract; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; +use grovedb::reference_path::ReferencePathType; +use grovedb::TransactionArg; +use platform_version::version::PlatformVersion; + +impl Drive { + /// Fetches the identities voting for contenders. + pub fn fetch_identity_contested_resource_vote_v0( + &self, + masternode_pro_tx_hash: Identifier, + vote_id: Identifier, + transaction: TransactionArg, + drive_operations: &mut Vec, + platform_version: &PlatformVersion, + ) -> Result, Error> { + let path = vote_contested_resource_identity_votes_tree_path_for_identity( + masternode_pro_tx_hash.as_bytes(), + ); + + let optional_element = self.grove_get_raw_optional( + (&path).into(), + vote_id.as_slice(), + DirectQueryType::StatefulDirectQuery, + transaction, + drive_operations, + &platform_version.drive, + )?; + + optional_element + .map(|element| { + let serialized_reference = element.into_item_bytes()?; + let bincode_config = bincode::config::standard() + .with_big_endian() + .with_no_limit(); + let reference: ReferencePathType = + bincode::decode_from_slice(&serialized_reference, bincode_config) + .map_err(|e| { + Error::Drive(DriveError::CorruptedSerialization(format!( + "serialization of reference {} is corrupted: {}", + hex::encode(serialized_reference), + e + ))) + })? + .0; + let absolute_path = + reference.absolute_path(path.as_slice(), Some(vote_id.as_slice()))?; + let vote_storage_form = + ContestedDocumentResourceVoteStorageForm::try_from_tree_path(absolute_path)?; + Ok(vote_storage_form.resource_vote_choice) + }) + .transpose() + } +} diff --git a/packages/rs-drive/src/drive/votes/fetch/mod.rs b/packages/rs-drive/src/drive/votes/fetch/mod.rs index bccde52f4f..74748b04f0 100644 --- a/packages/rs-drive/src/drive/votes/fetch/mod.rs +++ b/packages/rs-drive/src/drive/votes/fetch/mod.rs @@ -1,2 +1,3 @@ mod fetch_contested_document_vote_poll_stored_info; mod fetch_identities_voting_for_contenders; +mod fetch_identity_contested_resource_vote; diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 303021435c..33d5380ab8 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -277,6 +277,7 @@ pub struct DriveVoteMethodVersions { pub struct DriveVoteFetchMethodVersions { pub fetch_identities_voting_for_contenders: FeatureVersion, pub fetch_contested_document_vote_poll_stored_info: FeatureVersion, + pub fetch_identity_contested_resource_vote: FeatureVersion, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 61da6e7962..77f732ddb0 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -254,6 +254,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { fetch: DriveVoteFetchMethodVersions { fetch_identities_voting_for_contenders: 0, fetch_contested_document_vote_poll_stored_info: 0, + fetch_identity_contested_resource_vote: 0, }, }, contract: DriveContractMethodVersions { diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 59257dc119..3d2c627557 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -262,6 +262,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { fetch: DriveVoteFetchMethodVersions { fetch_identities_voting_for_contenders: 0, fetch_contested_document_vote_poll_stored_info: 0, + fetch_identity_contested_resource_vote: 0, }, }, contract: DriveContractMethodVersions { diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index f707a76425..e8b802c25e 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -253,6 +253,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { fetch: DriveVoteFetchMethodVersions { fetch_identities_voting_for_contenders: 0, fetch_contested_document_vote_poll_stored_info: 0, + fetch_identity_contested_resource_vote: 0, }, }, contract: DriveContractMethodVersions { From a22119440f6ba666ca46d64eeb6c829235c0603d Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 10 Jun 2024 21:11:06 +0300 Subject: [PATCH 130/135] last home stretch --- .../state_transitions/masternode_vote/mod.rs | 124 ++++++++++++++++++ .../masternode_vote/state/v0/mod.rs | 38 ------ .../transform_into_action/v0/mod.rs | 49 ++++++- .../identity/masternode_vote/mod.rs | 10 ++ .../identity/masternode_vote/transformer.rs | 5 + .../identity/masternode_vote/v0/mod.rs | 3 + .../masternode_vote/v0/transformer.rs | 5 + 7 files changed, 195 insertions(+), 39 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index c99dc9b755..72a3c3ef1d 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -3800,6 +3800,7 @@ mod tests { } mod changing_vote { use super::*; + use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice::Abstain; #[test] fn test_masternode_vote_again_same_vote_should_return_error() { let platform_version = PlatformVersion::latest(); @@ -3900,6 +3901,129 @@ mod tests { None, platform_version, ); + + let (contenders, abstaining, locking, finished_vote_info) = get_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); + + assert_eq!(finished_vote_info, None); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + assert_ne!(first_contender.document, second_contender.document); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(0)); + + assert_eq!(second_contender.vote_tally, Some(1)); + } + + #[test] + fn test_masternode_vote_again_different_choice_too_many_times() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + let (masternode, signer, voting_key) = + setup_masternode_identity(&mut platform, 10, platform_version); + + let platform_state = platform.state.load(); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + TowardsIdentity(contender_1.id()), + "quantum", + &signer, + masternode.id(), + &voting_key, + 1, + None, + platform_version, + ); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + TowardsIdentity(contender_2.id()), + "quantum", + &signer, + masternode.id(), + &voting_key, + 2, + None, + platform_version, + ); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + Lock, + "quantum", + &signer, + masternode.id(), + &voting_key, + 3, + None, + platform_version, + ); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + Abstain, + "quantum", + &signer, + masternode.id(), + &voting_key, + 4, + None, + platform_version, + ); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + TowardsIdentity(contender_1.id()), + "quantum", + &signer, + masternode.id(), + &voting_key, + 5, + Some(""), + platform_version, + ); } } } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs index cc5294adef..f36a818f56 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs @@ -41,44 +41,6 @@ impl MasternodeVoteStateTransitionStateValidationV0 for MasternodeVoteTransition tx: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { - // Before we transform into action we want to make sure that we have not yet voted - - match self.vote() { - Vote::ResourceVote(resource_vote) => { - match resource_vote.vote_poll() { - VotePoll::ContestedDocumentResourceVotePoll(vote_poll) => { - let vote_id = vote_poll.unique_id()?; - let maybe_existing_resource_vote_choice = - platform.drive.fetch_identity_contested_resource_vote( - self.pro_tx_hash(), - vote_id, - tx, - &mut vec![], - platform_version, - )?; - if let Some(existing_resource_vote_choice) = - maybe_existing_resource_vote_choice - { - if existing_resource_vote_choice == resource_vote.resource_vote_choice() - { - // We are submitting a vote for something we already have - return Ok(ConsensusValidationResult::new_with_error( - ConsensusError::StateError( - StateError::MasternodeVoteAlreadyPresentError( - MasternodeVoteAlreadyPresentError::new( - self.pro_tx_hash(), - resource_vote.vote_poll().clone(), - ), - ), - ), - )); - } - } - } - } - } - } - let result = self.transform_into_action_v0(platform, tx, platform_version)?; if !result.is_valid() { diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/v0/mod.rs index 95e7eb312f..cdd8e2157f 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/v0/mod.rs @@ -1,7 +1,10 @@ use crate::error::Error; use crate::platform_types::platform::PlatformRef; use dashcore_rpc::dashcore_rpc_json::MasternodeType; +use dpp::consensus::state::state_error::StateError; use dpp::consensus::state::voting::masternode_not_found_error::MasternodeNotFoundError; +use dpp::consensus::state::voting::masternode_vote_already_present_error::MasternodeVoteAlreadyPresentError; +use dpp::consensus::ConsensusError; use dpp::dashcore::hashes::Hash; use dpp::dashcore::ProTxHash; @@ -12,8 +15,10 @@ use drive::state_transition_action::identity::masternode_vote::MasternodeVoteTra use crate::platform_types::platform_state::v0::PlatformStateV0Methods; use dpp::version::PlatformVersion; +use dpp::voting::vote_polls::VotePoll; +use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; +use dpp::voting::votes::Vote; use drive::grovedb::TransactionArg; -use drive::state_transition_action::StateTransitionAction; pub(in crate::execution::validation::state_transition::state_transitions::masternode_vote) trait MasternodeVoteStateTransitionTransformIntoActionValidationV0 { @@ -32,6 +37,47 @@ impl MasternodeVoteStateTransitionTransformIntoActionValidationV0 for Masternode tx: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { + let mut previous_resource_vote_choice_to_remove = None; + // Before we transform into action we want to make sure that we have not yet voted + match self.vote() { + Vote::ResourceVote(resource_vote) => { + match resource_vote.vote_poll() { + VotePoll::ContestedDocumentResourceVotePoll(vote_poll) => { + let vote_id = vote_poll.unique_id()?; + let maybe_existing_resource_vote_choice = + platform.drive.fetch_identity_contested_resource_vote( + self.pro_tx_hash(), + vote_id, + tx, + &mut vec![], + platform_version, + )?; + if let Some(existing_resource_vote_choice) = + maybe_existing_resource_vote_choice + { + if existing_resource_vote_choice == resource_vote.resource_vote_choice() + { + // We are submitting a vote for something we already have + return Ok(ConsensusValidationResult::new_with_error( + ConsensusError::StateError( + StateError::MasternodeVoteAlreadyPresentError( + MasternodeVoteAlreadyPresentError::new( + self.pro_tx_hash(), + resource_vote.vote_poll().clone(), + ), + ), + ), + )); + } else { + previous_resource_vote_choice_to_remove = + Some(existing_resource_vote_choice); + } + } + } + } + } + } + let Some(masternode) = platform .state .full_masternode_list() @@ -51,6 +97,7 @@ impl MasternodeVoteStateTransitionTransformIntoActionValidationV0 for Masternode MasternodeVoteTransitionAction::transform_from_transition( self, strength, + previous_resource_vote_choice_to_remove, platform.drive, tx, platform_version, diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs index 848ddcb175..780e700746 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs @@ -8,6 +8,7 @@ use crate::state_transition_action::identity::masternode_vote::v0::MasternodeVot use derive_more::From; use dpp::platform_value::Identifier; use dpp::prelude::IdentityNonce; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; /// action #[derive(Debug, Clone, From)] @@ -51,4 +52,13 @@ impl MasternodeVoteTransitionAction { MasternodeVoteTransitionAction::V0(transition) => transition.vote_strength, } } + + /// The previous resource vote choice that needs to be removed + pub fn previous_resource_vote_choice_to_remove(&self) -> Option { + match self { + MasternodeVoteTransitionAction::V0(transition) => { + transition.previous_resource_vote_choice_to_remove + } + } + } } diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs index 61d9733d77..e7150bd4fd 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs @@ -3,6 +3,7 @@ use crate::error::Error; use crate::state_transition_action::identity::masternode_vote::v0::MasternodeVoteTransitionActionV0; use crate::state_transition_action::identity::masternode_vote::MasternodeVoteTransitionAction; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use grovedb::TransactionArg; use platform_version::version::PlatformVersion; @@ -23,6 +24,7 @@ impl MasternodeVoteTransitionAction { pub fn transform_from_owned_transition( value: MasternodeVoteTransition, masternode_strength: u8, + previous_resource_vote_choice_to_remove: Option, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -32,6 +34,7 @@ impl MasternodeVoteTransitionAction { MasternodeVoteTransitionActionV0::transform_from_owned_transition( v0, masternode_strength, + previous_resource_vote_choice_to_remove, drive, transaction, platform_version, @@ -57,6 +60,7 @@ impl MasternodeVoteTransitionAction { pub fn transform_from_transition( value: &MasternodeVoteTransition, masternode_strength: u8, + previous_resource_vote_choice_to_remove: Option, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -66,6 +70,7 @@ impl MasternodeVoteTransitionAction { Ok(MasternodeVoteTransitionActionV0::transform_from_transition( v0, masternode_strength, + previous_resource_vote_choice_to_remove, drive, transaction, platform_version, diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs index 5cba194606..91f380a161 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs @@ -3,6 +3,7 @@ mod transformer; use crate::drive::votes::resolved::votes::ResolvedVote; use dpp::platform_value::Identifier; use dpp::prelude::IdentityNonce; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; /// action v0 #[derive(Debug, Clone)] @@ -13,6 +14,8 @@ pub struct MasternodeVoteTransitionActionV0 { pub vote_strength: u8, /// the resource votes pub vote: ResolvedVote, + /// vote choice to remove + pub previous_resource_vote_choice_to_remove: Option, /// nonce pub nonce: IdentityNonce, } diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs index dcdb99b372..3245511925 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs @@ -3,6 +3,7 @@ use crate::drive::Drive; use crate::error::Error; use crate::state_transition_action::identity::masternode_vote::v0::MasternodeVoteTransitionActionV0; use dpp::state_transition::state_transitions::identity::masternode_vote_transition::v0::MasternodeVoteTransitionV0; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use grovedb::TransactionArg; use platform_version::version::PlatformVersion; @@ -10,6 +11,7 @@ impl MasternodeVoteTransitionActionV0 { pub(crate) fn transform_from_owned_transition( value: MasternodeVoteTransitionV0, masternode_strength: u8, + previous_resource_vote_choice_to_remove: Option, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -25,6 +27,7 @@ impl MasternodeVoteTransitionActionV0 { pro_tx_hash, vote_strength: masternode_strength, vote: resolved_vote, + previous_resource_vote_choice_to_remove, nonce, }) } @@ -32,6 +35,7 @@ impl MasternodeVoteTransitionActionV0 { pub(crate) fn transform_from_transition( value: &MasternodeVoteTransitionV0, masternode_strength: u8, + previous_resource_vote_choice_to_remove: Option, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -47,6 +51,7 @@ impl MasternodeVoteTransitionActionV0 { pro_tx_hash: *pro_tx_hash, vote_strength: masternode_strength, vote: resolved_vote, + previous_resource_vote_choice_to_remove, nonce: *nonce, }) } From a8ac4d2b3597d7ef5b494a472a10fcdf2f743cdb Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Mon, 10 Jun 2024 22:01:49 +0300 Subject: [PATCH 131/135] old vote is removed when new vote is added --- .../drive/batch/drive_op_batch/identity.rs | 5 ++++ .../identity/masternode_vote_transition.rs | 5 +++- .../mod.rs | 4 +++ .../v0/mod.rs | 26 ++++++++++++++++++- .../insert/register_identity_vote/mod.rs | 5 ++++ .../insert/register_identity_vote/v0/mod.rs | 5 ++++ .../identity/masternode_vote/mod.rs | 13 ++++++++-- 7 files changed, 59 insertions(+), 4 deletions(-) diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs index c7d8992711..99c7a0219d 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs @@ -9,6 +9,7 @@ use dpp::prelude::{IdentityNonce, Revision}; use crate::drive::identity::update::methods::merge_identity_nonce::MergeIdentityContractNonceResultToResult; use crate::drive::votes::resolved::votes::ResolvedVote; use dpp::version::PlatformVersion; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use std::collections::HashMap; @@ -83,6 +84,8 @@ pub enum IdentityOperationType { strength: u8, /// Contested Vote type vote: ResolvedVote, + /// Remove previous contested resource vote choice + previous_resource_vote_choice_to_remove: Option, }, /// Updates an identities nonce for a specific contract. UpdateIdentityNonce { @@ -195,10 +198,12 @@ impl DriveLowLevelOperationConverter for IdentityOperationType { voter_pro_tx_hash, strength, vote, + previous_resource_vote_choice_to_remove, } => drive.register_identity_vote_operations( voter_pro_tx_hash, strength, vote, + previous_resource_vote_choice_to_remove, block_info, estimated_costs_only_with_layer_info, transaction, diff --git a/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs b/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs index ed7c78279f..7615ab8806 100644 --- a/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs +++ b/packages/rs-drive/src/drive/batch/transitions/identity/masternode_vote_transition.rs @@ -13,13 +13,15 @@ use dpp::ProtocolError; impl DriveHighLevelOperationConverter for MasternodeVoteTransitionAction { fn into_high_level_drive_operations<'a>( - self, + mut self, _epoch: &Epoch, platform_version: &PlatformVersion, ) -> Result>, Error> { let pro_tx_hash = self.pro_tx_hash(); let nonce = self.nonce(); let strength = self.vote_strength(); + let previous_resource_vote_choice_to_remove = + self.take_previous_resource_vote_choice_to_remove(); let vote = self.vote_owned(); let prefunded_specialized_balance_id = vote.specialized_balance_id()?.ok_or(Error::Protocol(ProtocolError::VoteError("vote does not have a specialized balance from where it can use to pay for processing (this should have been caught during validation)".to_string())))?; @@ -32,6 +34,7 @@ impl DriveHighLevelOperationConverter for MasternodeVoteTransitionAction { voter_pro_tx_hash: pro_tx_hash.to_buffer(), strength, vote, + previous_resource_vote_choice_to_remove, }), // Casting a vote has a fixed cost PrefundedSpecializedBalanceOperation( diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs index 58c5fe0ca3..02036289b8 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs @@ -49,6 +49,7 @@ impl Drive { strength: u8, vote_poll: ContestedDocumentResourceVotePollWithContractInfo, vote_choice: ResourceVoteChoice, + previous_resource_vote_choice_to_remove: Option, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, @@ -66,6 +67,7 @@ impl Drive { strength, vote_poll, vote_choice, + previous_resource_vote_choice_to_remove, block_info, apply, transaction, @@ -111,6 +113,7 @@ impl Drive { strength: u8, vote_poll: ContestedDocumentResourceVotePollWithContractInfo, vote_choice: ResourceVoteChoice, + previous_resource_vote_choice_to_remove: Option, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< HashMap, @@ -130,6 +133,7 @@ impl Drive { strength, vote_poll, vote_choice, + previous_resource_vote_choice_to_remove, block_info, estimated_costs_only_with_layer_info, transaction, diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index c37a0350ab..d59cbee9ce 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -1,4 +1,4 @@ -use crate::drive::grove_operations::BatchInsertTreeApplyType; +use crate::drive::grove_operations::{BatchDeleteApplyType, BatchInsertTreeApplyType}; use crate::drive::object_size_info::PathKeyElementInfo::PathKeyElement; use crate::drive::object_size_info::PathKeyInfo; use crate::drive::votes::paths::{ @@ -26,6 +26,7 @@ impl Drive { strength: u8, vote_poll: ContestedDocumentResourceVotePollWithContractInfo, vote_choice: ResourceVoteChoice, + previous_resource_vote_choice_to_remove: Option, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, @@ -42,6 +43,7 @@ impl Drive { strength, vote_poll, vote_choice, + previous_resource_vote_choice_to_remove, block_info, &mut estimated_costs_only_with_layer_info, transaction, @@ -73,6 +75,7 @@ impl Drive { strength: u8, vote_poll: ContestedDocumentResourceVotePollWithContractInfo, vote_choice: ResourceVoteChoice, + previous_resource_vote_choice_to_remove: Option, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< HashMap, @@ -100,6 +103,26 @@ impl Drive { &platform_version.drive, )?; + if let Some(previous_resource_vote_choice_to_remove) = + previous_resource_vote_choice_to_remove + { + let previous_voting_path = vote_poll.contender_voting_path( + &previous_resource_vote_choice_to_remove, + platform_version, + )?; + + self.batch_delete( + previous_voting_path.as_slice().into(), + voter_pro_tx_hash.as_slice(), + BatchDeleteApplyType::StatefulBatchDelete { + is_known_to_be_subtree_with_sum: Some((false, true)), + }, + transaction, + &mut drive_operations, + &platform_version.drive, + )?; + } + let votes_identities_path = vote_contested_resource_identity_votes_tree_path_vec(); self.batch_insert_empty_tree_if_not_exists( @@ -132,6 +155,7 @@ impl Drive { e ))) })?; + self.batch_insert::<0>( PathKeyElement(( path, diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs index e5b8c8139f..d0915e08e6 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs @@ -13,6 +13,7 @@ use crate::drive::votes::resolved::votes::ResolvedVote; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use grovedb::{EstimatedLayerInformation, TransactionArg}; impl Drive { @@ -45,6 +46,7 @@ impl Drive { voter_pro_tx_hash: [u8; 32], strength: u8, vote: ResolvedVote, + previous_resource_vote_choice_to_remove: Option, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, @@ -61,6 +63,7 @@ impl Drive { voter_pro_tx_hash, strength, vote, + previous_resource_vote_choice_to_remove, block_info, apply, transaction, @@ -104,6 +107,7 @@ impl Drive { voter_pro_tx_hash: [u8; 32], strength: u8, vote: ResolvedVote, + previous_resource_vote_choice_to_remove: Option, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< HashMap, @@ -122,6 +126,7 @@ impl Drive { voter_pro_tx_hash, strength, vote, + previous_resource_vote_choice_to_remove, block_info, estimated_costs_only_with_layer_info, transaction, diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs index d9e99c2b79..ab29e6a65c 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs @@ -6,6 +6,7 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; +use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use grovedb::batch::KeyInfoPath; use grovedb::{EstimatedLayerInformation, TransactionArg}; use platform_version::version::PlatformVersion; @@ -17,6 +18,7 @@ impl Drive { voter_pro_tx_hash: [u8; 32], strength: u8, vote: ResolvedVote, + previous_resource_vote_choice_to_remove: Option, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, @@ -33,6 +35,7 @@ impl Drive { strength, contested_document_resource_vote_poll, vote_choice, + previous_resource_vote_choice_to_remove, block_info, apply, transaction, @@ -48,6 +51,7 @@ impl Drive { voter_pro_tx_hash: [u8; 32], strength: u8, vote: ResolvedVote, + previous_resource_vote_choice_to_remove: Option, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< HashMap, @@ -66,6 +70,7 @@ impl Drive { strength, contested_document_resource_vote_poll, vote_choice, + previous_resource_vote_choice_to_remove, block_info, estimated_costs_only_with_layer_info, transaction, diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs index 780e700746..64e0563f01 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs @@ -54,10 +54,19 @@ impl MasternodeVoteTransitionAction { } /// The previous resource vote choice that needs to be removed - pub fn previous_resource_vote_choice_to_remove(&self) -> Option { + pub fn take_previous_resource_vote_choice_to_remove(&mut self) -> Option { match self { MasternodeVoteTransitionAction::V0(transition) => { - transition.previous_resource_vote_choice_to_remove + transition.previous_resource_vote_choice_to_remove.take() + } + } + } + + /// The previous resource vote choice that needs to be removed + pub fn previous_resource_vote_choice_to_remove(&self) -> &Option { + match self { + MasternodeVoteTransitionAction::V0(transition) => { + &transition.previous_resource_vote_choice_to_remove } } } From e35f963eaa89edbdb47e9da9ac40977afac98aa5 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 11 Jun 2024 00:32:33 +0300 Subject: [PATCH 132/135] more validation --- .../voting/masternode_voted_too_many_times.rs | 19 ++++++++++--- .../state_transitions/masternode_vote/mod.rs | 16 ++++++++++- .../transform_into_action/v0/mod.rs | 28 +++++++++++++++++-- .../drive/batch/drive_op_batch/identity.rs | 3 +- .../mod.rs | 3 +- .../v0/mod.rs | 16 +++++++---- .../mod.rs | 5 ++-- .../v0/mod.rs | 22 +++++++++++---- .../insert/register_identity_vote/mod.rs | 5 ++-- .../insert/register_identity_vote/v0/mod.rs | 5 ++-- .../mod.rs | 12 ++++++++ .../mod.rs | 1 + .../src/drive/votes/storage_form/mod.rs | 3 ++ ..._resource_votes_given_by_identity_query.rs | 8 ++++-- .../identity/masternode_vote/mod.rs | 12 ++++++-- .../identity/masternode_vote/transformer.rs | 8 ++++-- .../identity/masternode_vote/v0/mod.rs | 5 +++- .../masternode_vote/v0/transformer.rs | 8 ++++-- .../src/version/dpp_versions.rs | 2 ++ .../src/version/mocks/v2_test.rs | 1 + .../src/version/mocks/v3_test.rs | 1 + .../rs-platform-version/src/version/v1.rs | 1 + 22 files changed, 146 insertions(+), 38 deletions(-) create mode 100644 packages/rs-drive/src/drive/votes/storage_form/contested_document_resource_reference_storage_form/mod.rs diff --git a/packages/rs-dpp/src/errors/consensus/state/voting/masternode_voted_too_many_times.rs b/packages/rs-dpp/src/errors/consensus/state/voting/masternode_voted_too_many_times.rs index e787691fb2..d1b167320a 100644 --- a/packages/rs-dpp/src/errors/consensus/state/voting/masternode_voted_too_many_times.rs +++ b/packages/rs-dpp/src/errors/consensus/state/voting/masternode_voted_too_many_times.rs @@ -9,7 +9,7 @@ use thiserror::Error; #[derive( Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, )] -#[error("Masternode with id: {pro_tx_hash} voted {times_voted}, which is too many times")] +#[error("Masternode with id: {pro_tx_hash} already voted {times_already_voted} times and is trying to vote again, they can only vote {max_times_allowed} times")] #[platform_serialize(unversioned)] pub struct MasternodeVotedTooManyTimesError { /* @@ -19,20 +19,31 @@ pub struct MasternodeVotedTooManyTimesError { */ pro_tx_hash: Identifier, - times_voted: u16, + times_already_voted: u16, + + max_times_allowed: u16, } impl MasternodeVotedTooManyTimesError { - pub fn new(pro_tx_hash: Identifier, times_voted: u16) -> Self { + pub fn new(pro_tx_hash: Identifier, times_already_voted: u16, max_times_allowed: u16) -> Self { Self { pro_tx_hash, - times_voted, + times_already_voted, + max_times_allowed, } } pub fn pro_tx_hash(&self) -> Identifier { self.pro_tx_hash } + + pub fn times_already_voted(&self) -> u16 { + self.times_already_voted + } + + pub fn max_times_allowed(&self) -> u16 { + self.max_times_allowed + } } impl From for ConsensusError { diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 72a3c3ef1d..5e532f1566 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -4021,7 +4021,21 @@ mod tests { masternode.id(), &voting_key, 5, - Some(""), + None, + platform_version, + ); + + perform_vote( + &mut platform, + &platform_state, + dpns_contract.as_ref(), + TowardsIdentity(contender_2.id()), + "quantum", + &signer, + masternode.id(), + &voting_key, + 6, + Some("Masternode with id: 4iroeiNBeBYZetCt21kW7FGyczE8WqoqzZ48YAHwyV7R already voted 5 times and is trying to vote again, they can only vote 5 times"), platform_version, ); } diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/v0/mod.rs index cdd8e2157f..d5dcb1aa63 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/v0/mod.rs @@ -4,6 +4,7 @@ use dashcore_rpc::dashcore_rpc_json::MasternodeType; use dpp::consensus::state::state_error::StateError; use dpp::consensus::state::voting::masternode_not_found_error::MasternodeNotFoundError; use dpp::consensus::state::voting::masternode_vote_already_present_error::MasternodeVoteAlreadyPresentError; +use dpp::consensus::state::voting::masternode_voted_too_many_times::MasternodeVotedTooManyTimesError; use dpp::consensus::ConsensusError; use dpp::dashcore::hashes::Hash; use dpp::dashcore::ProTxHash; @@ -52,7 +53,7 @@ impl MasternodeVoteStateTransitionTransformIntoActionValidationV0 for Masternode &mut vec![], platform_version, )?; - if let Some(existing_resource_vote_choice) = + if let Some((existing_resource_vote_choice, previous_vote_count)) = maybe_existing_resource_vote_choice { if existing_resource_vote_choice == resource_vote.resource_vote_choice() @@ -68,9 +69,32 @@ impl MasternodeVoteStateTransitionTransformIntoActionValidationV0 for Masternode ), ), )); + } else if previous_vote_count + >= platform_version + .dpp + .validation + .voting + .votes_allowed_per_masternode + { + // We are submitting a vote for something we already have + return Ok(ConsensusValidationResult::new_with_error( + ConsensusError::StateError( + StateError::MasternodeVotedTooManyTimesError( + MasternodeVotedTooManyTimesError::new( + self.pro_tx_hash(), + previous_vote_count, + platform_version + .dpp + .validation + .voting + .votes_allowed_per_masternode, + ), + ), + ), + )); } else { previous_resource_vote_choice_to_remove = - Some(existing_resource_vote_choice); + Some((existing_resource_vote_choice, previous_vote_count)); } } } diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs index 99c7a0219d..c5909539b5 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs @@ -8,6 +8,7 @@ use dpp::prelude::{IdentityNonce, Revision}; use crate::drive::identity::update::methods::merge_identity_nonce::MergeIdentityContractNonceResultToResult; use crate::drive::votes::resolved::votes::ResolvedVote; +use crate::state_transition_action::identity::masternode_vote::v0::PreviousVoteCount; use dpp::version::PlatformVersion; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use grovedb::batch::KeyInfoPath; @@ -85,7 +86,7 @@ pub enum IdentityOperationType { /// Contested Vote type vote: ResolvedVote, /// Remove previous contested resource vote choice - previous_resource_vote_choice_to_remove: Option, + previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, }, /// Updates an identities nonce for a specific contract. UpdateIdentityNonce { diff --git a/packages/rs-drive/src/drive/votes/fetch/fetch_identity_contested_resource_vote/mod.rs b/packages/rs-drive/src/drive/votes/fetch/fetch_identity_contested_resource_vote/mod.rs index 8e45905256..71f0999f3a 100644 --- a/packages/rs-drive/src/drive/votes/fetch/fetch_identity_contested_resource_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/fetch/fetch_identity_contested_resource_vote/mod.rs @@ -6,6 +6,7 @@ use crate::error::drive::DriveError; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; +use crate::state_transition_action::identity::masternode_vote::v0::PreviousVoteCount; use dpp::platform_value::Identifier; use dpp::version::PlatformVersion; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; @@ -20,7 +21,7 @@ impl Drive { transaction: TransactionArg, drive_operations: &mut Vec, platform_version: &PlatformVersion, - ) -> Result, Error> { + ) -> Result, Error> { match platform_version .drive .methods diff --git a/packages/rs-drive/src/drive/votes/fetch/fetch_identity_contested_resource_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/fetch/fetch_identity_contested_resource_vote/v0/mod.rs index 35c4b39087..8fd9278fa6 100644 --- a/packages/rs-drive/src/drive/votes/fetch/fetch_identity_contested_resource_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/fetch/fetch_identity_contested_resource_vote/v0/mod.rs @@ -1,11 +1,13 @@ use crate::drive::grove_operations::DirectQueryType; use crate::drive::votes::paths::vote_contested_resource_identity_votes_tree_path_for_identity; +use crate::drive::votes::storage_form::contested_document_resource_reference_storage_form::ContestedDocumentResourceVoteReferenceStorageForm; use crate::drive::votes::storage_form::contested_document_resource_storage_form::ContestedDocumentResourceVoteStorageForm; use crate::drive::votes::tree_path_storage_form::TreePathStorageForm; use crate::drive::Drive; use crate::error::drive::DriveError; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; +use crate::state_transition_action::identity::masternode_vote::v0::PreviousVoteCount; use dpp::identifier::Identifier; use dpp::prelude::DataContract; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; @@ -23,7 +25,7 @@ impl Drive { transaction: TransactionArg, drive_operations: &mut Vec, platform_version: &PlatformVersion, - ) -> Result, Error> { + ) -> Result, Error> { let path = vote_contested_resource_identity_votes_tree_path_for_identity( masternode_pro_tx_hash.as_bytes(), ); @@ -43,7 +45,7 @@ impl Drive { let bincode_config = bincode::config::standard() .with_big_endian() .with_no_limit(); - let reference: ReferencePathType = + let reference: ContestedDocumentResourceVoteReferenceStorageForm = bincode::decode_from_slice(&serialized_reference, bincode_config) .map_err(|e| { Error::Drive(DriveError::CorruptedSerialization(format!( @@ -53,11 +55,15 @@ impl Drive { ))) })? .0; - let absolute_path = - reference.absolute_path(path.as_slice(), Some(vote_id.as_slice()))?; + let absolute_path = reference + .reference_path_type + .absolute_path(path.as_slice(), Some(vote_id.as_slice()))?; let vote_storage_form = ContestedDocumentResourceVoteStorageForm::try_from_tree_path(absolute_path)?; - Ok(vote_storage_form.resource_vote_choice) + Ok(( + vote_storage_form.resource_vote_choice, + reference.identity_vote_times, + )) }) .transpose() } diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs index 02036289b8..fcfbd18fda 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs @@ -11,6 +11,7 @@ use dpp::fee::fee_result::FeeResult; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; use crate::fee::op::LowLevelDriveOperation; +use crate::state_transition_action::identity::masternode_vote::v0::PreviousVoteCount; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; @@ -49,7 +50,7 @@ impl Drive { strength: u8, vote_poll: ContestedDocumentResourceVotePollWithContractInfo, vote_choice: ResourceVoteChoice, - previous_resource_vote_choice_to_remove: Option, + previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, @@ -113,7 +114,7 @@ impl Drive { strength: u8, vote_poll: ContestedDocumentResourceVotePollWithContractInfo, vote_choice: ResourceVoteChoice, - previous_resource_vote_choice_to_remove: Option, + previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< HashMap, diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index d59cbee9ce..209ab3ee09 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -6,9 +6,12 @@ use crate::drive::votes::paths::{ vote_contested_resource_identity_votes_tree_path_vec, VotePollPaths, }; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; +use crate::drive::votes::storage_form; +use crate::drive::votes::storage_form::contested_document_resource_reference_storage_form::ContestedDocumentResourceVoteReferenceStorageForm; use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; +use crate::state_transition_action::identity::masternode_vote::v0::PreviousVoteCount; use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; @@ -26,7 +29,7 @@ impl Drive { strength: u8, vote_poll: ContestedDocumentResourceVotePollWithContractInfo, vote_choice: ResourceVoteChoice, - previous_resource_vote_choice_to_remove: Option, + previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, @@ -75,7 +78,7 @@ impl Drive { strength: u8, vote_poll: ContestedDocumentResourceVotePollWithContractInfo, vote_choice: ResourceVoteChoice, - previous_resource_vote_choice_to_remove: Option, + previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< HashMap, @@ -103,7 +106,9 @@ impl Drive { &platform_version.drive, )?; - if let Some(previous_resource_vote_choice_to_remove) = + let mut identity_vote_times = 1; + + if let Some((previous_resource_vote_choice_to_remove, previous_vote_count)) = previous_resource_vote_choice_to_remove { let previous_voting_path = vote_poll.contender_voting_path( @@ -121,6 +126,8 @@ impl Drive { &mut drive_operations, &platform_version.drive, )?; + + identity_vote_times += previous_vote_count; } let votes_identities_path = vote_contested_resource_identity_votes_tree_path_vec(); @@ -144,12 +151,17 @@ impl Drive { voting_path.remove(0); // we remove the top (root tree vote key) voting_path.remove(0); // contested resource - let reference = + let reference_path_type = ReferencePathType::UpstreamRootHeightWithParentPathAdditionReference(2, voting_path); let config = bincode::config::standard() .with_big_endian() .with_no_limit(); - let encoded_reference = bincode::encode_to_vec(reference, config).map_err(|e| { + + let storage_form = ContestedDocumentResourceVoteReferenceStorageForm { + reference_path_type, + identity_vote_times, + }; + let encoded_reference = bincode::encode_to_vec(storage_form, config).map_err(|e| { Error::Protocol(ProtocolError::CorruptedSerialization(format!( "can not encode reference: {}", e diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs index d0915e08e6..f173d12f8e 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs @@ -11,6 +11,7 @@ use dpp::fee::fee_result::FeeResult; use crate::drive::votes::resolved::votes::ResolvedVote; use crate::fee::op::LowLevelDriveOperation; +use crate::state_transition_action::identity::masternode_vote::v0::PreviousVoteCount; use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; @@ -46,7 +47,7 @@ impl Drive { voter_pro_tx_hash: [u8; 32], strength: u8, vote: ResolvedVote, - previous_resource_vote_choice_to_remove: Option, + previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, @@ -107,7 +108,7 @@ impl Drive { voter_pro_tx_hash: [u8; 32], strength: u8, vote: ResolvedVote, - previous_resource_vote_choice_to_remove: Option, + previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< HashMap, diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs index ab29e6a65c..20b44f6105 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs @@ -4,6 +4,7 @@ use crate::drive::votes::resolved::votes::ResolvedVote; use crate::drive::Drive; use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; +use crate::state_transition_action::identity::masternode_vote::v0::PreviousVoteCount; use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; @@ -18,7 +19,7 @@ impl Drive { voter_pro_tx_hash: [u8; 32], strength: u8, vote: ResolvedVote, - previous_resource_vote_choice_to_remove: Option, + previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, block_info: &BlockInfo, apply: bool, transaction: TransactionArg, @@ -51,7 +52,7 @@ impl Drive { voter_pro_tx_hash: [u8; 32], strength: u8, vote: ResolvedVote, - previous_resource_vote_choice_to_remove: Option, + previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, block_info: &BlockInfo, estimated_costs_only_with_layer_info: &mut Option< HashMap, diff --git a/packages/rs-drive/src/drive/votes/storage_form/contested_document_resource_reference_storage_form/mod.rs b/packages/rs-drive/src/drive/votes/storage_form/contested_document_resource_reference_storage_form/mod.rs new file mode 100644 index 0000000000..7a84734a78 --- /dev/null +++ b/packages/rs-drive/src/drive/votes/storage_form/contested_document_resource_reference_storage_form/mod.rs @@ -0,0 +1,12 @@ +use bincode::{Decode, Encode}; +use grovedb::reference_path::ReferencePathType; + +/// Represents the storage form of a reference. +#[derive(Debug, Clone, PartialEq, Encode, Decode)] +pub struct ContestedDocumentResourceVoteReferenceStorageForm { + /// The reference + pub reference_path_type: ReferencePathType, + + /// The amount of times the identity has voted + pub identity_vote_times: u16, +} diff --git a/packages/rs-drive/src/drive/votes/storage_form/contested_document_resource_storage_form/mod.rs b/packages/rs-drive/src/drive/votes/storage_form/contested_document_resource_storage_form/mod.rs index 167f88fd00..9654e7a5e5 100644 --- a/packages/rs-drive/src/drive/votes/storage_form/contested_document_resource_storage_form/mod.rs +++ b/packages/rs-drive/src/drive/votes/storage_form/contested_document_resource_storage_form/mod.rs @@ -65,6 +65,7 @@ impl ContestedDocumentResourceVoteStorageForm { document_type_name, index_values, resource_vote_choice, + .. } = self; let document_type = data_contract.document_type_for_name(document_type_name.as_str())?; diff --git a/packages/rs-drive/src/drive/votes/storage_form/mod.rs b/packages/rs-drive/src/drive/votes/storage_form/mod.rs index cffe63448f..a797ee8c5b 100644 --- a/packages/rs-drive/src/drive/votes/storage_form/mod.rs +++ b/packages/rs-drive/src/drive/votes/storage_form/mod.rs @@ -3,3 +3,6 @@ pub mod contested_document_resource_storage_form; /// Module for handling the storage form of votes. pub mod vote_storage_form; + +/// Module for handling the storage form of the reference of the contested document resources. +pub mod contested_document_resource_reference_storage_form; diff --git a/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs b/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs index b13c527293..f398c5153e 100644 --- a/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs +++ b/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs @@ -1,4 +1,5 @@ use crate::drive::votes::paths::vote_contested_resource_identity_votes_tree_path_for_identity_vec; +use crate::drive::votes::storage_form::contested_document_resource_reference_storage_form::ContestedDocumentResourceVoteReferenceStorageForm; use crate::drive::votes::storage_form::contested_document_resource_storage_form::ContestedDocumentResourceVoteStorageForm; use crate::drive::votes::tree_path_storage_form::TreePathStorageForm; #[cfg(feature = "server")] @@ -154,7 +155,7 @@ impl ContestedResourceVotesGivenByIdentityQuery { let bincode_config = bincode::config::standard() .with_big_endian() .with_no_limit(); - let reference: ReferencePathType = + let reference: ContestedDocumentResourceVoteReferenceStorageForm = bincode::decode_from_slice(&serialized_reference, bincode_config) .map_err(|e| { Error::Drive(DriveError::CorruptedSerialization(format!( @@ -164,8 +165,9 @@ impl ContestedResourceVotesGivenByIdentityQuery { ))) })? .0; - let absolute_path = - reference.absolute_path(path.as_slice(), Some(key.as_slice()))?; + let absolute_path = reference + .reference_path_type + .absolute_path(path.as_slice(), Some(key.as_slice()))?; let vote_id = Identifier::from_vec(key)?; Ok(( vote_id, diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs index 64e0563f01..f5dc84a8de 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/mod.rs @@ -4,7 +4,9 @@ pub mod transformer; pub mod v0; use crate::drive::votes::resolved::votes::ResolvedVote; -use crate::state_transition_action::identity::masternode_vote::v0::MasternodeVoteTransitionActionV0; +use crate::state_transition_action::identity::masternode_vote::v0::{ + MasternodeVoteTransitionActionV0, PreviousVoteCount, +}; use derive_more::From; use dpp::platform_value::Identifier; use dpp::prelude::IdentityNonce; @@ -54,7 +56,9 @@ impl MasternodeVoteTransitionAction { } /// The previous resource vote choice that needs to be removed - pub fn take_previous_resource_vote_choice_to_remove(&mut self) -> Option { + pub fn take_previous_resource_vote_choice_to_remove( + &mut self, + ) -> Option<(ResourceVoteChoice, PreviousVoteCount)> { match self { MasternodeVoteTransitionAction::V0(transition) => { transition.previous_resource_vote_choice_to_remove.take() @@ -63,7 +67,9 @@ impl MasternodeVoteTransitionAction { } /// The previous resource vote choice that needs to be removed - pub fn previous_resource_vote_choice_to_remove(&self) -> &Option { + pub fn previous_resource_vote_choice_to_remove( + &self, + ) -> &Option<(ResourceVoteChoice, PreviousVoteCount)> { match self { MasternodeVoteTransitionAction::V0(transition) => { &transition.previous_resource_vote_choice_to_remove diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs index e7150bd4fd..c9c702fab0 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/transformer.rs @@ -1,6 +1,8 @@ use crate::drive::Drive; use crate::error::Error; -use crate::state_transition_action::identity::masternode_vote::v0::MasternodeVoteTransitionActionV0; +use crate::state_transition_action::identity::masternode_vote::v0::{ + MasternodeVoteTransitionActionV0, PreviousVoteCount, +}; use crate::state_transition_action::identity::masternode_vote::MasternodeVoteTransitionAction; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; @@ -24,7 +26,7 @@ impl MasternodeVoteTransitionAction { pub fn transform_from_owned_transition( value: MasternodeVoteTransition, masternode_strength: u8, - previous_resource_vote_choice_to_remove: Option, + previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -60,7 +62,7 @@ impl MasternodeVoteTransitionAction { pub fn transform_from_transition( value: &MasternodeVoteTransition, masternode_strength: u8, - previous_resource_vote_choice_to_remove: Option, + previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion, diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs index 91f380a161..414700a417 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/mod.rs @@ -5,6 +5,9 @@ use dpp::platform_value::Identifier; use dpp::prelude::IdentityNonce; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; +/// The previous vote count +pub type PreviousVoteCount = u16; + /// action v0 #[derive(Debug, Clone)] pub struct MasternodeVoteTransitionActionV0 { @@ -15,7 +18,7 @@ pub struct MasternodeVoteTransitionActionV0 { /// the resource votes pub vote: ResolvedVote, /// vote choice to remove - pub previous_resource_vote_choice_to_remove: Option, + pub previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, /// nonce pub nonce: IdentityNonce, } diff --git a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs index 3245511925..9966ba6c0f 100644 --- a/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/identity/masternode_vote/v0/transformer.rs @@ -1,7 +1,9 @@ use crate::drive::votes::resolved::votes::resolve::VoteResolver; use crate::drive::Drive; use crate::error::Error; -use crate::state_transition_action::identity::masternode_vote::v0::MasternodeVoteTransitionActionV0; +use crate::state_transition_action::identity::masternode_vote::v0::{ + MasternodeVoteTransitionActionV0, PreviousVoteCount, +}; use dpp::state_transition::state_transitions::identity::masternode_vote_transition::v0::MasternodeVoteTransitionV0; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use grovedb::TransactionArg; @@ -11,7 +13,7 @@ impl MasternodeVoteTransitionActionV0 { pub(crate) fn transform_from_owned_transition( value: MasternodeVoteTransitionV0, masternode_strength: u8, - previous_resource_vote_choice_to_remove: Option, + previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion, @@ -35,7 +37,7 @@ impl MasternodeVoteTransitionActionV0 { pub(crate) fn transform_from_transition( value: &MasternodeVoteTransitionV0, masternode_strength: u8, - previous_resource_vote_choice_to_remove: Option, + previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, drive: &Drive, transaction: TransactionArg, platform_version: &PlatformVersion, diff --git a/packages/rs-platform-version/src/version/dpp_versions.rs b/packages/rs-platform-version/src/version/dpp_versions.rs index 0452b1fd76..a1fa69bb9d 100644 --- a/packages/rs-platform-version/src/version/dpp_versions.rs +++ b/packages/rs-platform-version/src/version/dpp_versions.rs @@ -81,6 +81,8 @@ pub struct DataContractValidationVersions { pub struct VotingValidationVersions { /// How long do we allow other contenders to join a contest after the first contender pub allow_other_contenders_time_ms: u64, + /// How many votes do we allow from the same masternode? + pub votes_allowed_per_masternode: u16, } #[derive(Clone, Debug, Default)] diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index 77f732ddb0..ec107d6221 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -968,6 +968,7 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { document_type: DocumentTypeValidationVersions { validate_update: 0 }, voting: VotingValidationVersions { allow_other_contenders_time_ms: 604_800_000, // 1 week in ms + votes_allowed_per_masternode: 5, }, }, state_transition_serialization_versions: StateTransitionSerializationVersions { diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 3d2c627557..1669b0cb36 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -968,6 +968,7 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { document_type: DocumentTypeValidationVersions { validate_update: 0 }, voting: VotingValidationVersions { allow_other_contenders_time_ms: 604_800_000, // 1 week in ms + votes_allowed_per_masternode: 5, }, }, state_transition_serialization_versions: StateTransitionSerializationVersions { diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index e8b802c25e..c8f203c314 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -967,6 +967,7 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { document_type: DocumentTypeValidationVersions { validate_update: 0 }, voting: VotingValidationVersions { allow_other_contenders_time_ms: 604_800_000, // 1 week in ms + votes_allowed_per_masternode: 5, }, }, state_transition_serialization_versions: StateTransitionSerializationVersions { From eba991a7c54f2f5c110499d8df68e0eda099bc47 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 11 Jun 2024 09:13:26 +0300 Subject: [PATCH 133/135] cleanup --- .../check_for_ended_vote_polls/v0/mod.rs | 7 +-- .../voting/lock_contested_resource/mod.rs | 43 ------------------- .../voting/lock_contested_resource/v0/mod.rs | 33 -------------- .../execution/platform_events/voting/mod.rs | 1 - .../check_tx_verification/v0/mod.rs | 1 + .../state_transitions/documents_batch/mod.rs | 10 ++++- .../state_transitions/masternode_vote/mod.rs | 24 +++++------ .../masternode_vote/state/v0/mod.rs | 5 --- .../drive/batch/drive_op_batch/identity.rs | 22 +++++----- .../src/drive/batch/drive_op_batch/mod.rs | 1 - .../src/drive/batch/drive_op_batch/voting.rs | 18 -------- .../mod.rs | 39 ----------------- .../v0/mod.rs | 21 --------- .../rs-drive/src/drive/votes/cleanup/mod.rs | 2 - .../v0/mod.rs | 3 -- .../mod.rs | 12 +----- .../v0/mod.rs | 20 +-------- .../insert/register_identity_vote/mod.rs | 12 +----- .../insert/register_identity_vote/v0/mod.rs | 12 +----- ..._resource_votes_given_by_identity_query.rs | 1 - .../document/documents_batch/mod.rs | 2 +- .../src/version/drive_abci_versions.rs | 1 - .../src/version/drive_versions.rs | 1 - .../src/version/mocks/v2_test.rs | 2 - .../src/version/mocks/v3_test.rs | 2 - .../rs-platform-version/src/version/v1.rs | 2 - 26 files changed, 40 insertions(+), 257 deletions(-) delete mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/lock_contested_resource/mod.rs delete mode 100644 packages/rs-drive-abci/src/execution/platform_events/voting/lock_contested_resource/v0/mod.rs delete mode 100644 packages/rs-drive/src/drive/batch/drive_op_batch/voting.rs delete mode 100644 packages/rs-drive/src/drive/votes/cleanup/add_lock_for_contested_document_resource_vote_poll/mod.rs delete mode 100644 packages/rs-drive/src/drive/votes/cleanup/add_lock_for_contested_document_resource_vote_poll/v0/mod.rs diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs index ab49d06f83..d8f5398f3b 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/check_for_ended_vote_polls/v0/mod.rs @@ -139,12 +139,7 @@ where // let's check to make sure the lock votes didn't win it // if the lock is tied with the top contender the top contender gets it if result.locked_vote_tally > top_contender.final_vote_tally { - self.lock_contested_resource( - block_info, - &resolved_contested_document_resource_vote_poll, - transaction, - platform_version, - )?; + // the record will show it's locked ContestedDocumentVotePollWinnerInfo::Locked } else { let contender_id = top_contender.identity_id; diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/lock_contested_resource/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/lock_contested_resource/mod.rs deleted file mode 100644 index 42207f2157..0000000000 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/lock_contested_resource/mod.rs +++ /dev/null @@ -1,43 +0,0 @@ -use crate::error::execution::ExecutionError; -use crate::error::Error; -use crate::platform_types::platform::Platform; -use crate::rpc::core::CoreRPCLike; -use dpp::block::block_info::BlockInfo; -use dpp::version::PlatformVersion; -use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; -use drive::grovedb::TransactionArg; - -mod v0; - -impl Platform -where - C: CoreRPCLike, -{ - /// Keeps a record of the vote poll after it has finished - pub(in crate::execution) fn lock_contested_resource( - &self, - block_info: &BlockInfo, - vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, - transaction: TransactionArg, - platform_version: &PlatformVersion, - ) -> Result<(), Error> { - match platform_version - .drive_abci - .methods - .voting - .lock_contested_resource - { - 0 => self.lock_contested_resource_v0( - block_info, - vote_poll, - transaction, - platform_version, - ), - version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { - method: "lock_contested_resource".to_string(), - known_versions: vec![0], - received: version, - })), - } - } -} diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/lock_contested_resource/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/lock_contested_resource/v0/mod.rs deleted file mode 100644 index 2bb073daa6..0000000000 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/lock_contested_resource/v0/mod.rs +++ /dev/null @@ -1,33 +0,0 @@ -use crate::error::Error; -use crate::platform_types::platform::Platform; -use crate::rpc::core::CoreRPCLike; -use dpp::block::block_info::BlockInfo; -use dpp::version::PlatformVersion; -use drive::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; -use drive::grovedb::TransactionArg; - -impl Platform -where - C: CoreRPCLike, -{ - /// Locks a contested resource after the lock vote wins - #[inline(always)] - pub(super) fn lock_contested_resource_v0( - &self, - block_info: &BlockInfo, - vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, - transaction: TransactionArg, - platform_version: &PlatformVersion, - ) -> Result<(), Error> { - // We need to lock the vote_poll - - self.drive - .add_lock_for_contested_document_resource_vote_poll( - vote_poll, - transaction, - platform_version, - )?; - - Ok(()) - } -} diff --git a/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs index 99bb77f91c..0ef9c09528 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs @@ -4,5 +4,4 @@ mod clean_up_after_contested_resources_vote_polls_end; mod clean_up_after_vote_polls_end; mod delay_vote_poll; mod keep_record_of_vote_poll; -mod lock_contested_resource; mod tally_votes_for_contested_document_resource_vote_poll; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/check_tx_verification/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/check_tx_verification/v0/mod.rs index f3ce164f57..b48464fd3c 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/check_tx_verification/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/check_tx_verification/v0/mod.rs @@ -29,6 +29,7 @@ pub(super) fn state_transition_to_execution_event_for_check_tx_v0<'a, C: CoreRPC let mut state_transition_execution_context = StateTransitionExecutionContext::default_for_platform_version(platform_version)?; + #[allow(unreachable_patterns)] match check_tx_level { CheckTxLevel::FirstTimeCheck => { // Only identity top up and identity create do not have nonces validation diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs index 2a1b29b377..3b70780e5c 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/mod.rs @@ -681,6 +681,12 @@ mod tests { panic!("expected contenders") }; + assert_eq!(abstain_vote_tally, None); + + assert_eq!(lock_vote_tally, None); + + assert_eq!(finished_vote_info, None); + assert_eq!(contenders.len(), 2); let first_contender = contenders.first().unwrap(); @@ -852,7 +858,7 @@ mod tests { let platform_state = platform.state.load(); - let contender_3 = add_contender_to_dpns_name_contest( + let _contender_3 = add_contender_to_dpns_name_contest( &mut platform, &platform_state, 4, @@ -912,7 +918,7 @@ mod tests { let platform_state = platform.state.load(); - let contender_3 = add_contender_to_dpns_name_contest( + let _contender_3 = add_contender_to_dpns_name_contest( &mut platform, &platform_state, 4, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 5e532f1566..4c88340cb4 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -285,7 +285,7 @@ mod tests { let platform_state = platform.state.load(); - let (identity_1, identity_2, dpns_contract) = create_dpns_name_contest( + let (_identity_1, _identity_2, _dpns_contract) = create_dpns_name_contest( &mut platform, &platform_state, 7, @@ -293,7 +293,7 @@ mod tests { platform_version, ); - let (identity_3, identity_4, dpns_contract) = create_dpns_name_contest( + let (_identity_3, _identity_4, dpns_contract) = create_dpns_name_contest( &mut platform, &platform_state, 8, @@ -1473,7 +1473,7 @@ mod tests { let platform_state = platform.state.load(); - let (contender_1_quantum, contender_2_quantum, dpns_contract) = + let (contender_1_quantum, _contender_2_quantum, _dpns_contract) = create_dpns_name_contest( &mut platform, &platform_state, @@ -1482,7 +1482,7 @@ mod tests { platform_version, ); - let (contender_1_cooldog, contender_2_cooldog, dpns_contract) = + let (_contender_1_cooldog, contender_2_cooldog, _dpns_contract) = create_dpns_name_contest( &mut platform, &platform_state, @@ -1491,7 +1491,7 @@ mod tests { platform_version, ); - let (contender_1_superman, contender_2_superman, dpns_contract) = + let (_contender_1_superman, _contender_2_superman, dpns_contract) = create_dpns_name_contest( &mut platform, &platform_state, @@ -1635,7 +1635,7 @@ mod tests { let platform_state = platform.state.load(); - let (contender_1_quantum, contender_2_quantum, dpns_contract) = + let (contender_1_quantum, _contender_2_quantum, _dpns_contract) = create_dpns_name_contest( &mut platform, &platform_state, @@ -1644,7 +1644,7 @@ mod tests { platform_version, ); - let (contender_1_cooldog, contender_2_cooldog, dpns_contract) = + let (_contender_1_cooldog, contender_2_cooldog, _dpns_contract) = create_dpns_name_contest( &mut platform, &platform_state, @@ -1653,7 +1653,7 @@ mod tests { platform_version, ); - let (contender_1_superman, contender_2_superman, dpns_contract) = + let (_contender_1_superman, _contender_2_superman, dpns_contract) = create_dpns_name_contest( &mut platform, &platform_state, @@ -3205,7 +3205,7 @@ mod tests { assert_eq!(start_balance, dash_to_credits!(0.4)); - let (contender_3, contender_4, _) = create_dpns_name_contest( + let (_contender_3, _contender_4, _) = create_dpns_name_contest( &mut platform, &platform_state, 9, @@ -3313,7 +3313,7 @@ mod tests { assert_eq!(start_balance, dash_to_credits!(0.4)); - let (contender_3, contender_4, _) = create_dpns_name_contest( + let (_contender_3, _contender_4, _) = create_dpns_name_contest( &mut platform, &platform_state, 9, @@ -3810,7 +3810,7 @@ mod tests { let platform_state = platform.state.load(); - let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + let (contender_1, _contender_2, dpns_contract) = create_dpns_name_contest( &mut platform, &platform_state, 7, @@ -3902,7 +3902,7 @@ mod tests { platform_version, ); - let (contenders, abstaining, locking, finished_vote_info) = get_vote_states( + let (contenders, _abstaining, _locking, finished_vote_info) = get_vote_states( &platform, &platform_state, &dpns_contract, diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs index f36a818f56..81c6587bd8 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs @@ -1,13 +1,11 @@ use crate::error::Error; use crate::platform_types::platform::PlatformRef; use dpp::consensus::state::state_error::StateError; -use dpp::consensus::state::voting::masternode_vote_already_present_error::MasternodeVoteAlreadyPresentError; use dpp::consensus::state::voting::vote_poll_not_available_for_voting_error::VotePollNotAvailableForVotingError; use dpp::consensus::state::voting::vote_poll_not_found_error::VotePollNotFoundError; use dpp::consensus::ConsensusError; use dpp::prelude::ConsensusValidationResult; -use dpp::state_transition::masternode_vote_transition::accessors::MasternodeVoteTransitionAccessorsV0; use dpp::state_transition::masternode_vote_transition::MasternodeVoteTransition; use crate::execution::validation::state_transition::masternode_vote::transform_into_action::v0::MasternodeVoteStateTransitionTransformIntoActionValidationV0; @@ -15,9 +13,6 @@ use dpp::version::PlatformVersion; use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::{ ContestedDocumentVotePollStatus, ContestedDocumentVotePollStoredInfoV0Getters, }; -use dpp::voting::vote_polls::VotePoll; -use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; -use dpp::voting::votes::Vote; use drive::drive::votes::resolved::vote_polls::ResolvedVotePoll; use drive::drive::votes::resolved::votes::resolved_resource_vote::accessors::v0::ResolvedResourceVoteGettersV0; use drive::drive::votes::resolved::votes::ResolvedVote; diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs index c5909539b5..74dda5ba04 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/identity.rs @@ -200,16 +200,18 @@ impl DriveLowLevelOperationConverter for IdentityOperationType { strength, vote, previous_resource_vote_choice_to_remove, - } => drive.register_identity_vote_operations( - voter_pro_tx_hash, - strength, - vote, - previous_resource_vote_choice_to_remove, - block_info, - estimated_costs_only_with_layer_info, - transaction, - platform_version, - ), + } => { + // No need to have estimated_costs_only_with_layer_info and block_info here + // This is because voting is a special operation with a fixed cost + drive.register_identity_vote_operations( + voter_pro_tx_hash, + strength, + vote, + previous_resource_vote_choice_to_remove, + transaction, + platform_version, + ) + } IdentityOperationType::UpdateIdentityContractNonce { identity_id, contract_id, diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/mod.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/mod.rs index e8a9b98d3e..cb8754ddec 100644 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/mod.rs +++ b/packages/rs-drive/src/drive/batch/drive_op_batch/mod.rs @@ -5,7 +5,6 @@ mod finalize_task; mod identity; mod prefunded_specialized_balance; mod system; -mod voting; mod withdrawals; use crate::drive::batch::GroveDbOpBatch; diff --git a/packages/rs-drive/src/drive/batch/drive_op_batch/voting.rs b/packages/rs-drive/src/drive/batch/drive_op_batch/voting.rs deleted file mode 100644 index 92f9f53086..0000000000 --- a/packages/rs-drive/src/drive/batch/drive_op_batch/voting.rs +++ /dev/null @@ -1,18 +0,0 @@ -use dpp::identifier::Identifier; -use dpp::identity::TimestampMillis; - -use dpp::voting::vote_polls::VotePoll; - -/// Voting based Operations -#[derive(Clone, Debug)] -pub enum VotingOperationType { - /// Adds a vote poll to the state. - AddVotePoll { - /// The creator of the vote poll - creator_identity_id: Option, - /// The vote poll - vote_poll: VotePoll, - /// The end date of the vote poll - end_date: TimestampMillis, - }, -} diff --git a/packages/rs-drive/src/drive/votes/cleanup/add_lock_for_contested_document_resource_vote_poll/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/add_lock_for_contested_document_resource_vote_poll/mod.rs deleted file mode 100644 index 8c1889f4df..0000000000 --- a/packages/rs-drive/src/drive/votes/cleanup/add_lock_for_contested_document_resource_vote_poll/mod.rs +++ /dev/null @@ -1,39 +0,0 @@ -mod v0; - -use crate::drive::Drive; - -use crate::error::drive::DriveError; -use crate::error::Error; - -use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; -use dpp::version::PlatformVersion; -use grovedb::TransactionArg; - -impl Drive { - /// Adding a lock to a vote poll disables voting for the vote poll - pub fn add_lock_for_contested_document_resource_vote_poll( - &self, - vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, - transaction: TransactionArg, - platform_version: &PlatformVersion, - ) -> Result<(), Error> { - match platform_version - .drive - .methods - .vote - .cleanup - .add_lock_for_contested_document_resource_vote_poll - { - 0 => self.add_lock_for_contested_document_resource_vote_poll_v0( - vote_poll, - transaction, - platform_version, - ), - version => Err(Error::Drive(DriveError::UnknownVersionMismatch { - method: "add_lock_for_contested_document_resource_vote_poll".to_string(), - known_versions: vec![0], - received: version, - })), - } - } -} diff --git a/packages/rs-drive/src/drive/votes/cleanup/add_lock_for_contested_document_resource_vote_poll/v0/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/add_lock_for_contested_document_resource_vote_poll/v0/mod.rs deleted file mode 100644 index 63745b5a83..0000000000 --- a/packages/rs-drive/src/drive/votes/cleanup/add_lock_for_contested_document_resource_vote_poll/v0/mod.rs +++ /dev/null @@ -1,21 +0,0 @@ -use crate::drive::votes::paths::VotePollPaths; -use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; -use crate::drive::Drive; -use crate::error::Error; -use grovedb::TransactionArg; -use platform_version::version::PlatformVersion; - -impl Drive { - /// We remove vote_choices for an identity when that identity is somehow disabled. Currently there is - /// no way to "disable" identities except for masternodes being removed from the list - pub(super) fn add_lock_for_contested_document_resource_vote_poll_v0( - &self, - vote_poll: &ContestedDocumentResourceVotePollWithContractInfo, - transaction: TransactionArg, - platform_version: &PlatformVersion, - ) -> Result<(), Error> { - let path = vote_poll.contenders_path(platform_version)?; - - Ok(()) - } -} diff --git a/packages/rs-drive/src/drive/votes/cleanup/mod.rs b/packages/rs-drive/src/drive/votes/cleanup/mod.rs index 6527b13667..6eeba294ef 100644 --- a/packages/rs-drive/src/drive/votes/cleanup/mod.rs +++ b/packages/rs-drive/src/drive/votes/cleanup/mod.rs @@ -1,6 +1,4 @@ mod remove_all_votes_given_by_identity; - -mod add_lock_for_contested_document_resource_vote_poll; mod remove_contested_resource_vote_poll_contenders_operations; mod remove_contested_resource_vote_poll_documents_operations; mod remove_contested_resource_vote_poll_end_date_query_operations; diff --git a/packages/rs-drive/src/drive/votes/fetch/fetch_identity_contested_resource_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/fetch/fetch_identity_contested_resource_vote/v0/mod.rs index 8fd9278fa6..75f89c6a2b 100644 --- a/packages/rs-drive/src/drive/votes/fetch/fetch_identity_contested_resource_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/fetch/fetch_identity_contested_resource_vote/v0/mod.rs @@ -9,10 +9,7 @@ use crate::error::Error; use crate::fee::op::LowLevelDriveOperation; use crate::state_transition_action::identity::masternode_vote::v0::PreviousVoteCount; use dpp::identifier::Identifier; -use dpp::prelude::DataContract; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use dpp::voting::votes::resource_vote::accessors::v0::ResourceVoteGettersV0; -use grovedb::reference_path::ReferencePathType; use grovedb::TransactionArg; use platform_version::version::PlatformVersion; diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs index fcfbd18fda..dc7902f823 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/mod.rs @@ -1,8 +1,6 @@ mod v0; use crate::drive::Drive; -use grovedb::batch::KeyInfoPath; -use std::collections::HashMap; use crate::error::drive::DriveError; use crate::error::Error; @@ -15,7 +13,7 @@ use crate::state_transition_action::identity::masternode_vote::v0::PreviousVoteC use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use grovedb::{EstimatedLayerInformation, TransactionArg}; +use grovedb::TransactionArg; impl Drive { /// Registers a vote for a contested resource based on the voter's identifier, @@ -52,7 +50,6 @@ impl Drive { vote_choice: ResourceVoteChoice, previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, block_info: &BlockInfo, - apply: bool, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { @@ -70,7 +67,6 @@ impl Drive { vote_choice, previous_resource_vote_choice_to_remove, block_info, - apply, transaction, platform_version, ), @@ -115,10 +111,6 @@ impl Drive { vote_poll: ContestedDocumentResourceVotePollWithContractInfo, vote_choice: ResourceVoteChoice, previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, - block_info: &BlockInfo, - estimated_costs_only_with_layer_info: &mut Option< - HashMap, - >, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { @@ -135,8 +127,6 @@ impl Drive { vote_poll, vote_choice, previous_resource_vote_choice_to_remove, - block_info, - estimated_costs_only_with_layer_info, transaction, platform_version, ), diff --git a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs index 209ab3ee09..e8f556e907 100644 --- a/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/contested_resource/individual_vote/register_contested_resource_identity_vote/v0/mod.rs @@ -6,7 +6,6 @@ use crate::drive::votes::paths::{ vote_contested_resource_identity_votes_tree_path_vec, VotePollPaths, }; use crate::drive::votes::resolved::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePollWithContractInfo; -use crate::drive::votes::storage_form; use crate::drive::votes::storage_form::contested_document_resource_reference_storage_form::ContestedDocumentResourceVoteReferenceStorageForm; use crate::drive::Drive; use crate::error::Error; @@ -16,11 +15,9 @@ use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; use dpp::{bincode, ProtocolError}; -use grovedb::batch::KeyInfoPath; use grovedb::reference_path::ReferencePathType; -use grovedb::{Element, EstimatedLayerInformation, TransactionArg}; +use grovedb::{Element, TransactionArg}; use platform_version::version::PlatformVersion; -use std::collections::HashMap; impl Drive { pub(super) fn register_contested_resource_identity_vote_v0( @@ -31,31 +28,22 @@ impl Drive { vote_choice: ResourceVoteChoice, previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, block_info: &BlockInfo, - apply: bool, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { - let mut estimated_costs_only_with_layer_info = if apply { - None::> - } else { - Some(HashMap::new()) - }; - let batch_operations = self.register_contested_resource_identity_vote_operations_v0( voter_pro_tx_hash, strength, vote_poll, vote_choice, previous_resource_vote_choice_to_remove, - block_info, - &mut estimated_costs_only_with_layer_info, transaction, platform_version, )?; let mut drive_operations: Vec = vec![]; self.apply_batch_low_level_drive_operations( - estimated_costs_only_with_layer_info, + None, transaction, batch_operations, &mut drive_operations, @@ -79,10 +67,6 @@ impl Drive { vote_poll: ContestedDocumentResourceVotePollWithContractInfo, vote_choice: ResourceVoteChoice, previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, - block_info: &BlockInfo, - estimated_costs_only_with_layer_info: &mut Option< - HashMap, - >, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs index f173d12f8e..0db85e0f01 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs @@ -1,8 +1,6 @@ mod v0; use crate::drive::Drive; -use grovedb::batch::KeyInfoPath; -use std::collections::HashMap; use crate::error::drive::DriveError; use crate::error::Error; @@ -15,7 +13,7 @@ use crate::state_transition_action::identity::masternode_vote::v0::PreviousVoteC use dpp::block::block_info::BlockInfo; use dpp::version::PlatformVersion; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use grovedb::{EstimatedLayerInformation, TransactionArg}; +use grovedb::TransactionArg; impl Drive { /// Registers a vote associated with a specific identity using the given voter's ProRegTx hash. @@ -49,7 +47,6 @@ impl Drive { vote: ResolvedVote, previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, block_info: &BlockInfo, - apply: bool, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { @@ -66,7 +63,6 @@ impl Drive { vote, previous_resource_vote_choice_to_remove, block_info, - apply, transaction, platform_version, ), @@ -109,10 +105,6 @@ impl Drive { strength: u8, vote: ResolvedVote, previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, - block_info: &BlockInfo, - estimated_costs_only_with_layer_info: &mut Option< - HashMap, - >, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { @@ -128,8 +120,6 @@ impl Drive { strength, vote, previous_resource_vote_choice_to_remove, - block_info, - estimated_costs_only_with_layer_info, transaction, platform_version, ), diff --git a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs index 20b44f6105..ef23a9d000 100644 --- a/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs +++ b/packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs @@ -8,10 +8,8 @@ use crate::state_transition_action::identity::masternode_vote::v0::PreviousVoteC use dpp::block::block_info::BlockInfo; use dpp::fee::fee_result::FeeResult; use dpp::voting::vote_choices::resource_vote_choice::ResourceVoteChoice; -use grovedb::batch::KeyInfoPath; -use grovedb::{EstimatedLayerInformation, TransactionArg}; +use grovedb::TransactionArg; use platform_version::version::PlatformVersion; -use std::collections::HashMap; impl Drive { pub(super) fn register_identity_vote_v0( @@ -21,7 +19,6 @@ impl Drive { vote: ResolvedVote, previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, block_info: &BlockInfo, - apply: bool, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result { @@ -38,7 +35,6 @@ impl Drive { vote_choice, previous_resource_vote_choice_to_remove, block_info, - apply, transaction, platform_version, ), @@ -53,10 +49,6 @@ impl Drive { strength: u8, vote: ResolvedVote, previous_resource_vote_choice_to_remove: Option<(ResourceVoteChoice, PreviousVoteCount)>, - block_info: &BlockInfo, - estimated_costs_only_with_layer_info: &mut Option< - HashMap, - >, transaction: TransactionArg, platform_version: &PlatformVersion, ) -> Result, Error> { @@ -72,8 +64,6 @@ impl Drive { contested_document_resource_vote_poll, vote_choice, previous_resource_vote_choice_to_remove, - block_info, - estimated_costs_only_with_layer_info, transaction, platform_version, ), diff --git a/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs b/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs index f398c5153e..8abbc067f4 100644 --- a/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs +++ b/packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs @@ -17,7 +17,6 @@ use dpp::block::block_info::BlockInfo; use dpp::identifier::Identifier; #[cfg(feature = "server")] use grovedb::query_result_type::{QueryResultElements, QueryResultType}; -use grovedb::reference_path::ReferencePathType; #[cfg(feature = "server")] use grovedb::TransactionArg; use grovedb::{PathQuery, SizedQuery}; diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/mod.rs index 1f918e396d..9d5891f0d1 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/mod.rs @@ -89,7 +89,7 @@ impl DocumentsBatchTransitionAction { } /// The sum of all conflicting index collateral voting funds for all document create transitions in the batch - fn all_conflicting_index_collateral_voting_funds( + pub fn all_conflicting_index_collateral_voting_funds( &self, ) -> Result, ProtocolError> { match self { diff --git a/packages/rs-platform-version/src/version/drive_abci_versions.rs b/packages/rs-platform-version/src/version/drive_abci_versions.rs index 4243734740..445aa84ca0 100644 --- a/packages/rs-platform-version/src/version/drive_abci_versions.rs +++ b/packages/rs-platform-version/src/version/drive_abci_versions.rs @@ -306,7 +306,6 @@ pub struct DriveAbciVotingMethodVersions { pub check_for_ended_vote_polls: FeatureVersion, pub tally_votes_for_contested_document_resource_vote_poll: FeatureVersion, pub award_document_to_winner: FeatureVersion, - pub lock_contested_resource: FeatureVersion, pub delay_vote_poll: FeatureVersion, } diff --git a/packages/rs-platform-version/src/version/drive_versions.rs b/packages/rs-platform-version/src/version/drive_versions.rs index 33d5380ab8..c4d9e81258 100644 --- a/packages/rs-platform-version/src/version/drive_versions.rs +++ b/packages/rs-platform-version/src/version/drive_versions.rs @@ -292,7 +292,6 @@ pub struct DriveVoteSetupMethodVersions { #[derive(Clone, Debug, Default)] pub struct DriveVoteCleanupMethodVersions { - pub add_lock_for_contested_document_resource_vote_poll: FeatureVersion, pub remove_all_votes_given_by_identity: FeatureVersion, pub remove_specific_votes_given_by_identity: FeatureVersion, pub remove_contested_resource_vote_poll_end_date_query_operations: FeatureVersion, diff --git a/packages/rs-platform-version/src/version/mocks/v2_test.rs b/packages/rs-platform-version/src/version/mocks/v2_test.rs index ec107d6221..e93de4b9f7 100644 --- a/packages/rs-platform-version/src/version/mocks/v2_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v2_test.rs @@ -237,7 +237,6 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { add_vote_poll_end_date_query_operations: 0, }, cleanup: DriveVoteCleanupMethodVersions { - add_lock_for_contested_document_resource_vote_poll: 0, remove_all_votes_given_by_identity: 0, remove_specific_votes_given_by_identity: 0, remove_contested_resource_vote_poll_end_date_query_operations: 0, @@ -653,7 +652,6 @@ pub const TEST_PLATFORM_V2: PlatformVersion = PlatformVersion { check_for_ended_vote_polls: 0, tally_votes_for_contested_document_resource_vote_poll: 0, award_document_to_winner: 0, - lock_contested_resource: 0, delay_vote_poll: 0, }, state_transition_processing: DriveAbciStateTransitionProcessingMethodVersions { diff --git a/packages/rs-platform-version/src/version/mocks/v3_test.rs b/packages/rs-platform-version/src/version/mocks/v3_test.rs index 1669b0cb36..885d6f5ebe 100644 --- a/packages/rs-platform-version/src/version/mocks/v3_test.rs +++ b/packages/rs-platform-version/src/version/mocks/v3_test.rs @@ -245,7 +245,6 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { add_vote_poll_end_date_query_operations: 0, }, cleanup: DriveVoteCleanupMethodVersions { - add_lock_for_contested_document_resource_vote_poll: 0, remove_all_votes_given_by_identity: 0, remove_specific_votes_given_by_identity: 0, remove_contested_resource_vote_poll_end_date_query_operations: 0, @@ -653,7 +652,6 @@ pub const TEST_PLATFORM_V3: PlatformVersion = PlatformVersion { check_for_ended_vote_polls: 0, tally_votes_for_contested_document_resource_vote_poll: 0, award_document_to_winner: 0, - lock_contested_resource: 0, delay_vote_poll: 0, }, state_transition_processing: DriveAbciStateTransitionProcessingMethodVersions { diff --git a/packages/rs-platform-version/src/version/v1.rs b/packages/rs-platform-version/src/version/v1.rs index c8f203c314..67a4cb8d5d 100644 --- a/packages/rs-platform-version/src/version/v1.rs +++ b/packages/rs-platform-version/src/version/v1.rs @@ -236,7 +236,6 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { add_vote_poll_end_date_query_operations: 0, }, cleanup: DriveVoteCleanupMethodVersions { - add_lock_for_contested_document_resource_vote_poll: 0, remove_all_votes_given_by_identity: 0, remove_specific_votes_given_by_identity: 0, remove_contested_resource_vote_poll_end_date_query_operations: 0, @@ -652,7 +651,6 @@ pub const PLATFORM_V1: PlatformVersion = PlatformVersion { check_for_ended_vote_polls: 0, tally_votes_for_contested_document_resource_vote_poll: 0, award_document_to_winner: 0, - lock_contested_resource: 0, delay_vote_poll: 0, }, state_transition_processing: DriveAbciStateTransitionProcessingMethodVersions { From a5c306505908c2340ce265787760479053b49c24 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 11 Jun 2024 11:11:28 +0300 Subject: [PATCH 134/135] another fix --- .../state_transitions/masternode_vote/mod.rs | 807 ++++++++++++++++++ .../src/query/vote_poll_vote_state_query.rs | 4 +- 2 files changed, 810 insertions(+), 1 deletion(-) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index 4c88340cb4..ed65f462ea 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -3600,6 +3600,813 @@ mod tests { } } + #[test] + fn test_document_distribution_abstain_very_high() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + perform_votes_multi( + &mut platform, + dpns_contract.as_ref(), + vec![ + (TowardsIdentity(contender_1.id()), 50), + (TowardsIdentity(contender_2.id()), 5), + (ResourceVoteChoice::Abstain, 60), + (ResourceVoteChoice::Lock, 3), + ], + "quantum", + 10, + platform_version, + ); + + let platform_state = platform.state.load(); + + let (contenders, abstaining, locking, finished_vote_info) = get_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); + + assert_eq!(finished_vote_info, None); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + assert_ne!(first_contender.document, second_contender.document); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(50)); + + assert_eq!(second_contender.vote_tally, Some(5)); + + assert_eq!(abstaining, Some(60)); + + assert_eq!(locking, Some(3)); + + let mut platform_state = (**platform_state).clone(); + + let block_info = BlockInfo { + time_ms: 1_209_900_000, //2 weeks and 300s + height: 10000, + core_height: 42, + epoch: Default::default(), + }; + + platform_state.set_last_committed_block_info(Some( + ExtendedBlockInfoV0 { + basic_info: block_info, + app_hash: platform.drive.grove.root_hash(None).unwrap().unwrap(), + quorum_hash: [0u8; 32], + block_id_hash: [0u8; 32], + signature: [0u8; 96], + round: 0, + } + .into(), + )); + + platform.state.store(Arc::new(platform_state)); + + let platform_state = platform.state.load(); + + let transaction = platform.drive.grove.start_transaction(); + + platform + .check_for_ended_vote_polls(&block_info, Some(&transaction), platform_version) + .expect("expected to check for ended vote polls"); + + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit transaction"); + + // At this point the document should have been awarded to contender 1. + + { + let (contenders, abstaining, locking, finished_vote_info) = get_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); + + assert_eq!( + finished_vote_info, + Some(FinishedVoteInfo { + finished_vote_outcome: + finished_vote_info::FinishedVoteOutcome::TowardsIdentity as i32, + won_by_identity_id: Some(contender_1.id().to_vec()), + finished_at_block_height: 10000, + finished_at_core_block_height: 42, + finished_at_block_time_ms: 1209900000, + finished_at_epoch: 0 + }) + ); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + assert_eq!(first_contender.document, None); + + assert_eq!(second_contender.document, None); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(50)); + + assert_eq!(second_contender.vote_tally, Some(5)); + + assert_eq!(abstaining, Some(60)); + + assert_eq!(locking, Some(3)); + } + + { + let (contenders, abstaining, locking, finished_vote_info) = + get_proved_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); + + assert_eq!( + finished_vote_info, + Some(( + ContestedDocumentVotePollWinnerInfo::WonByIdentity(contender_1.id()), + block_info + )) + ); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + assert_eq!(first_contender.document, None); + + assert_eq!(second_contender.document, None); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(50)); + + assert_eq!(second_contender.vote_tally, Some(5)); + + assert_eq!(abstaining, Some(60)); + + assert_eq!(locking, Some(3)); + } + } + + #[test] + fn test_document_distribution_low_votes() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + perform_votes_multi( + &mut platform, + dpns_contract.as_ref(), + vec![ + (TowardsIdentity(contender_1.id()), 1), + (TowardsIdentity(contender_2.id()), 1), + (ResourceVoteChoice::Abstain, 1), + (ResourceVoteChoice::Lock, 1), + ], + "quantum", + 10, + platform_version, + ); + + let platform_state = platform.state.load(); + + let (contenders, abstaining, locking, finished_vote_info) = get_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); + + assert_eq!(finished_vote_info, None); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + assert_ne!(first_contender.document, second_contender.document); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(1)); + + assert_eq!(second_contender.vote_tally, Some(1)); + + assert_eq!(abstaining, Some(1)); + + assert_eq!(locking, Some(1)); + + let mut platform_state = (**platform_state).clone(); + + let block_info = BlockInfo { + time_ms: 1_209_900_000, //2 weeks and 300s + height: 10000, + core_height: 42, + epoch: Default::default(), + }; + + platform_state.set_last_committed_block_info(Some( + ExtendedBlockInfoV0 { + basic_info: block_info, + app_hash: platform.drive.grove.root_hash(None).unwrap().unwrap(), + quorum_hash: [0u8; 32], + block_id_hash: [0u8; 32], + signature: [0u8; 96], + round: 0, + } + .into(), + )); + + platform.state.store(Arc::new(platform_state)); + + let platform_state = platform.state.load(); + + let transaction = platform.drive.grove.start_transaction(); + + platform + .check_for_ended_vote_polls(&block_info, Some(&transaction), platform_version) + .expect("expected to check for ended vote polls"); + + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit transaction"); + + // At this point the document should have been awarded to contender 1. + + { + let (contenders, abstaining, locking, finished_vote_info) = get_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); + + assert_eq!( + finished_vote_info, + Some(FinishedVoteInfo { + finished_vote_outcome: + finished_vote_info::FinishedVoteOutcome::TowardsIdentity as i32, + won_by_identity_id: Some(contender_1.id().to_vec()), + finished_at_block_height: 10000, + finished_at_core_block_height: 42, + finished_at_block_time_ms: 1209900000, + finished_at_epoch: 0 + }) + ); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + assert_eq!(first_contender.document, None); + + assert_eq!(second_contender.document, None); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(1)); + + assert_eq!(second_contender.vote_tally, Some(1)); + + assert_eq!(abstaining, Some(1)); + + assert_eq!(locking, Some(1)); + } + + { + let (contenders, abstaining, locking, finished_vote_info) = + get_proved_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); + + assert_eq!( + finished_vote_info, + Some(( + ContestedDocumentVotePollWinnerInfo::WonByIdentity(contender_1.id()), + block_info + )) + ); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + assert_eq!(first_contender.document, None); + + assert_eq!(second_contender.document, None); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(1)); + + assert_eq!(second_contender.vote_tally, Some(1)); + + assert_eq!(abstaining, Some(1)); + + assert_eq!(locking, Some(1)); + } + } + + #[test] + fn test_document_distribution_single_vote() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + perform_votes_multi( + &mut platform, + dpns_contract.as_ref(), + vec![ + (TowardsIdentity(contender_1.id()), 1), + (TowardsIdentity(contender_2.id()), 1), + ], + "quantum", + 10, + platform_version, + ); + + let platform_state = platform.state.load(); + + let (contenders, abstaining, locking, finished_vote_info) = get_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); + + assert_eq!(finished_vote_info, None); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + assert_ne!(first_contender.document, second_contender.document); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(1)); + + assert_eq!(second_contender.vote_tally, Some(0)); + + assert_eq!(abstaining, Some(0)); + + assert_eq!(locking, Some(0)); + + let mut platform_state = (**platform_state).clone(); + + let block_info = BlockInfo { + time_ms: 1_209_900_000, //2 weeks and 300s + height: 10000, + core_height: 42, + epoch: Default::default(), + }; + + platform_state.set_last_committed_block_info(Some( + ExtendedBlockInfoV0 { + basic_info: block_info, + app_hash: platform.drive.grove.root_hash(None).unwrap().unwrap(), + quorum_hash: [0u8; 32], + block_id_hash: [0u8; 32], + signature: [0u8; 96], + round: 0, + } + .into(), + )); + + platform.state.store(Arc::new(platform_state)); + + let platform_state = platform.state.load(); + + let transaction = platform.drive.grove.start_transaction(); + + platform + .check_for_ended_vote_polls(&block_info, Some(&transaction), platform_version) + .expect("expected to check for ended vote polls"); + + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit transaction"); + + // At this point the document should have been awarded to contender 1. + + { + let (contenders, abstaining, locking, finished_vote_info) = get_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); + + assert_eq!( + finished_vote_info, + Some(FinishedVoteInfo { + finished_vote_outcome: + finished_vote_info::FinishedVoteOutcome::TowardsIdentity as i32, + won_by_identity_id: Some(contender_1.id().to_vec()), + finished_at_block_height: 10000, + finished_at_core_block_height: 42, + finished_at_block_time_ms: 1209900000, + finished_at_epoch: 0 + }) + ); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + assert_eq!(first_contender.document, None); + + assert_eq!(second_contender.document, None); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(1)); + + assert_eq!(second_contender.vote_tally, Some(0)); + + assert_eq!(abstaining, Some(0)); + + assert_eq!(locking, Some(0)); + } + + { + let (contenders, abstaining, locking, finished_vote_info) = + get_proved_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); + + assert_eq!( + finished_vote_info, + Some(( + ContestedDocumentVotePollWinnerInfo::WonByIdentity(contender_1.id()), + block_info + )) + ); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + assert_eq!(first_contender.document, None); + + assert_eq!(second_contender.document, None); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(1)); + + assert_eq!(second_contender.vote_tally, Some(0)); + + assert_eq!(abstaining, Some(0)); + + assert_eq!(locking, Some(0)); + } + } + + #[test] + fn test_document_distribution_no_votes() { + let platform_version = PlatformVersion::latest(); + let mut platform = TestPlatformBuilder::new() + .build_with_mock_rpc() + .set_genesis_state(); + + let platform_state = platform.state.load(); + + let (contender_1, contender_2, dpns_contract) = create_dpns_name_contest( + &mut platform, + &platform_state, + 7, + "quantum", + platform_version, + ); + + let platform_state = platform.state.load(); + + let (contenders, abstaining, locking, finished_vote_info) = get_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); + + assert_eq!(finished_vote_info, None); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + assert_ne!(first_contender.document, second_contender.document); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(0)); + + assert_eq!(second_contender.vote_tally, Some(0)); + + assert_eq!(abstaining, Some(0)); + + assert_eq!(locking, Some(0)); + + perform_votes_multi( + &mut platform, + dpns_contract.as_ref(), + vec![ + (TowardsIdentity(contender_1.id()), 1), + (TowardsIdentity(contender_2.id()), 5), + (ResourceVoteChoice::Abstain, 60), + (ResourceVoteChoice::Lock, 3), + ], + "quantum", + 10, + platform_version, + ); + + + let mut platform_state = (**platform_state).clone(); + + let block_info = BlockInfo { + time_ms: 1_209_900_000, //2 weeks and 300s + height: 10000, + core_height: 42, + epoch: Default::default(), + }; + + platform_state.set_last_committed_block_info(Some( + ExtendedBlockInfoV0 { + basic_info: block_info, + app_hash: platform.drive.grove.root_hash(None).unwrap().unwrap(), + quorum_hash: [0u8; 32], + block_id_hash: [0u8; 32], + signature: [0u8; 96], + round: 0, + } + .into(), + )); + + platform.state.store(Arc::new(platform_state)); + + let platform_state = platform.state.load(); + + let transaction = platform.drive.grove.start_transaction(); + + platform + .check_for_ended_vote_polls(&block_info, Some(&transaction), platform_version) + .expect("expected to check for ended vote polls"); + + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit transaction"); + + // At this point the document should have been awarded to contender 1. + + { + let (contenders, abstaining, locking, finished_vote_info) = get_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + false, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); + + assert_eq!( + finished_vote_info, + Some(FinishedVoteInfo { + finished_vote_outcome: + finished_vote_info::FinishedVoteOutcome::TowardsIdentity as i32, + won_by_identity_id: Some(contender_1.id().to_vec()), + finished_at_block_height: 10000, + finished_at_core_block_height: 42, + finished_at_block_time_ms: 1209900000, + finished_at_epoch: 0 + }) + ); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + assert_eq!(first_contender.document, None); + + assert_eq!(second_contender.document, None); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(0)); + + assert_eq!(second_contender.vote_tally, Some(0)); + + assert_eq!(abstaining, Some(0)); + + assert_eq!(locking, Some(0)); + } + + { + let (contenders, abstaining, locking, finished_vote_info) = + get_proved_vote_states( + &platform, + &platform_state, + &dpns_contract, + "quantum", + None, + true, + None, + ResultType::DocumentsAndVoteTally, + platform_version, + ); + + assert_eq!( + finished_vote_info, + Some(( + ContestedDocumentVotePollWinnerInfo::WonByIdentity(contender_1.id()), + block_info + )) + ); + + assert_eq!(contenders.len(), 2); + + let first_contender = contenders.first().unwrap(); + + let second_contender = contenders.last().unwrap(); + + assert_eq!(first_contender.document, None); + + assert_eq!(second_contender.document, None); + + assert_eq!(first_contender.identity_id, contender_1.id()); + + assert_eq!(second_contender.identity_id, contender_2.id()); + + assert_eq!(first_contender.vote_tally, Some(0)); + + assert_eq!(second_contender.vote_tally, Some(0)); + + assert_eq!(abstaining, Some(0)); + + assert_eq!(locking, Some(0)); + } + } + #[test] fn test_document_locking() { let platform_version = PlatformVersion::latest(); diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index e8d09f599c..778e58871f 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -429,7 +429,9 @@ impl ContestedDocumentVotePollDriveQuery { | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => { Ok(ContestedDocumentVotePollDriveQueryExecutionResult::default()) } - Err(e) => Err(e), + Err(e) => { + Err(e) + }, Ok((query_result_elements, skipped)) => { match self.result_type { ContestedDocumentVotePollDriveQueryResultType::IdentityIdsOnly => { From 3ddd0e4caf891387913c274fd39afd805937081f Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Tue, 11 Jun 2024 11:22:57 +0300 Subject: [PATCH 135/135] wasm-dpp --- .../state_transitions/masternode_vote/mod.rs | 19 +++++++++---------- .../src/query/vote_poll_vote_state_query.rs | 4 +--- .../src/errors/consensus/consensus_error.rs | 8 ++++++++ 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs index ed65f462ea..a217861b44 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs @@ -3685,7 +3685,7 @@ mod tests { signature: [0u8; 96], round: 0, } - .into(), + .into(), )); platform.state.store(Arc::new(platform_state)); @@ -3724,7 +3724,7 @@ mod tests { finished_vote_info, Some(FinishedVoteInfo { finished_vote_outcome: - finished_vote_info::FinishedVoteOutcome::TowardsIdentity as i32, + finished_vote_info::FinishedVoteOutcome::TowardsIdentity as i32, won_by_identity_id: Some(contender_1.id().to_vec()), finished_at_block_height: 10000, finished_at_core_block_height: 42, @@ -3887,7 +3887,7 @@ mod tests { signature: [0u8; 96], round: 0, } - .into(), + .into(), )); platform.state.store(Arc::new(platform_state)); @@ -3926,7 +3926,7 @@ mod tests { finished_vote_info, Some(FinishedVoteInfo { finished_vote_outcome: - finished_vote_info::FinishedVoteOutcome::TowardsIdentity as i32, + finished_vote_info::FinishedVoteOutcome::TowardsIdentity as i32, won_by_identity_id: Some(contender_1.id().to_vec()), finished_at_block_height: 10000, finished_at_core_block_height: 42, @@ -4087,7 +4087,7 @@ mod tests { signature: [0u8; 96], round: 0, } - .into(), + .into(), )); platform.state.store(Arc::new(platform_state)); @@ -4126,7 +4126,7 @@ mod tests { finished_vote_info, Some(FinishedVoteInfo { finished_vote_outcome: - finished_vote_info::FinishedVoteOutcome::TowardsIdentity as i32, + finished_vote_info::FinishedVoteOutcome::TowardsIdentity as i32, won_by_identity_id: Some(contender_1.id().to_vec()), finished_at_block_height: 10000, finished_at_core_block_height: 42, @@ -4220,7 +4220,7 @@ mod tests { "quantum", platform_version, ); - + let platform_state = platform.state.load(); let (contenders, abstaining, locking, finished_vote_info) = get_vote_states( @@ -4271,7 +4271,6 @@ mod tests { platform_version, ); - let mut platform_state = (**platform_state).clone(); let block_info = BlockInfo { @@ -4290,7 +4289,7 @@ mod tests { signature: [0u8; 96], round: 0, } - .into(), + .into(), )); platform.state.store(Arc::new(platform_state)); @@ -4329,7 +4328,7 @@ mod tests { finished_vote_info, Some(FinishedVoteInfo { finished_vote_outcome: - finished_vote_info::FinishedVoteOutcome::TowardsIdentity as i32, + finished_vote_info::FinishedVoteOutcome::TowardsIdentity as i32, won_by_identity_id: Some(contender_1.id().to_vec()), finished_at_block_height: 10000, finished_at_core_block_height: 42, diff --git a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs index 778e58871f..e8d09f599c 100644 --- a/packages/rs-drive/src/query/vote_poll_vote_state_query.rs +++ b/packages/rs-drive/src/query/vote_poll_vote_state_query.rs @@ -429,9 +429,7 @@ impl ContestedDocumentVotePollDriveQuery { | Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => { Ok(ContestedDocumentVotePollDriveQueryExecutionResult::default()) } - Err(e) => { - Err(e) - }, + Err(e) => Err(e), Ok((query_result_elements, skipped)) => { match self.result_type { ContestedDocumentVotePollDriveQueryResultType::IdentityIdsOnly => { diff --git a/packages/wasm-dpp/src/errors/consensus/consensus_error.rs b/packages/wasm-dpp/src/errors/consensus/consensus_error.rs index 5204f9e0f8..043916dda2 100644 --- a/packages/wasm-dpp/src/errors/consensus/consensus_error.rs +++ b/packages/wasm-dpp/src/errors/consensus/consensus_error.rs @@ -75,6 +75,8 @@ use dpp::consensus::state::identity::master_public_key_update_error::MasterPubli use dpp::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_insufficient_error::PrefundedSpecializedBalanceInsufficientError; use dpp::consensus::state::prefunded_specialized_balances::prefunded_specialized_balance_not_found_error::PrefundedSpecializedBalanceNotFoundError; use dpp::consensus::state::voting::masternode_not_found_error::MasternodeNotFoundError; +use dpp::consensus::state::voting::masternode_vote_already_present_error::MasternodeVoteAlreadyPresentError; +use dpp::consensus::state::voting::masternode_voted_too_many_times::MasternodeVotedTooManyTimesError; use dpp::consensus::state::voting::vote_poll_not_available_for_voting_error::VotePollNotAvailableForVotingError; use dpp::consensus::state::voting::vote_poll_not_found_error::VotePollNotFoundError; @@ -269,6 +271,12 @@ pub fn from_state_error(state_error: &StateError) -> JsValue { StateError::VotePollNotAvailableForVotingError(e) => { generic_consensus_error!(VotePollNotAvailableForVotingError, e).into() } + StateError::MasternodeVotedTooManyTimesError(e) => { + generic_consensus_error!(MasternodeVotedTooManyTimesError, e).into() + } + StateError::MasternodeVoteAlreadyPresentError(e) => { + generic_consensus_error!(MasternodeVoteAlreadyPresentError, e).into() + } } }